mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
Move ToStdout to /app/lib folder and include it in app.rb
This commit is contained in:
parent
217f009fa3
commit
1d5c46e6a0
6 changed files with 13 additions and 16 deletions
|
@ -1,7 +1,5 @@
|
||||||
module ToStdout
|
class ToStdout
|
||||||
extend ActiveSupport::Concern
|
def self.msg(message)
|
||||||
|
|
||||||
def to_stdout(message)
|
|
||||||
time = Time.zone.now.utc
|
time = Time.zone.now.utc
|
||||||
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
|
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
|
||||||
end
|
end
|
|
@ -39,12 +39,12 @@ module Concerns
|
||||||
|
|
||||||
def release
|
def release
|
||||||
if release_to_auction
|
if release_to_auction
|
||||||
to_stdout 'Destroying domain'
|
ToStdout.msg 'Destroying domain'
|
||||||
destroy!
|
destroy!
|
||||||
to_stdout "Checking if domain_name is auctionable: #{domain_name.auctionable?}"
|
ToStdout.msg "Checking if domain_name is auctionable: #{domain_name.auctionable?}"
|
||||||
domain_name.sell_at_auction if domain_name.auctionable?
|
domain_name.sell_at_auction if domain_name.auctionable?
|
||||||
|
|
||||||
to_stdout 'Sending registrar notification'
|
ToStdout.msg 'Sending registrar notification'
|
||||||
registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}",
|
registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}",
|
||||||
attached_obj_id: id,
|
attached_obj_id: id,
|
||||||
attached_obj_type: self.class)
|
attached_obj_type: self.class)
|
||||||
|
|
|
@ -2,7 +2,6 @@ module DNS
|
||||||
# Namespace is needed, because a class with the same name is defined by `domain_name` gem,
|
# Namespace is needed, because a class with the same name is defined by `domain_name` gem,
|
||||||
# a dependency of `actionmailer`,
|
# a dependency of `actionmailer`,
|
||||||
class DomainName
|
class DomainName
|
||||||
include ToStdout
|
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
@name = name
|
@name = name
|
||||||
end
|
end
|
||||||
|
@ -37,7 +36,7 @@ module DNS
|
||||||
auction = Auction.new
|
auction = Auction.new
|
||||||
auction.domain = name
|
auction.domain = name
|
||||||
auction.start
|
auction.start
|
||||||
to_stdout "Created the auction: #{auction.inspect}"
|
ToStdout.msg "Created the auction: #{auction.inspect}"
|
||||||
update_whois_from_auction(auction)
|
update_whois_from_auction(auction)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,7 +101,7 @@ module DNS
|
||||||
whois_record = Whois::Record.find_or_create_by!(name: name) do |record|
|
whois_record = Whois::Record.find_or_create_by!(name: name) do |record|
|
||||||
record.json = {}
|
record.json = {}
|
||||||
end
|
end
|
||||||
to_stdout "Starting to update WHOIS record #{whois_record.inspect}\n\n"\
|
ToStdout.msg "Starting to update WHOIS record #{whois_record.inspect}\n\n"\
|
||||||
"from auction #{auction.inspect}"
|
"from auction #{auction.inspect}"
|
||||||
whois_record.update_from_auction(auction)
|
whois_record.update_from_auction(auction)
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,6 @@ class Domain < ApplicationRecord
|
||||||
include Concerns::Domain::RegistryLockable
|
include Concerns::Domain::RegistryLockable
|
||||||
include Concerns::Domain::Releasable
|
include Concerns::Domain::Releasable
|
||||||
include Concerns::Domain::Disputable
|
include Concerns::Domain::Disputable
|
||||||
include ToStdout
|
|
||||||
|
|
||||||
attr_accessor :roles
|
attr_accessor :roles
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
module Whois
|
module Whois
|
||||||
class Record < Whois::Server
|
class Record < Whois::Server
|
||||||
include ToStdout
|
|
||||||
self.table_name = 'whois_records'
|
self.table_name = 'whois_records'
|
||||||
|
|
||||||
def self.disclaimer
|
def self.disclaimer
|
||||||
|
@ -13,16 +12,16 @@ module Whois
|
||||||
update!(json: { name: auction.domain,
|
update!(json: { name: auction.domain,
|
||||||
status: ['AtAuction'],
|
status: ['AtAuction'],
|
||||||
disclaimer: self.class.disclaimer })
|
disclaimer: self.class.disclaimer })
|
||||||
to_stdout "Updated from auction WHOIS record #{inspect}"
|
ToStdout.msg "Updated from auction WHOIS record #{inspect}"
|
||||||
elsif auction.no_bids?
|
elsif auction.no_bids?
|
||||||
to_stdout "Destroying WHOIS record #{inspect}"
|
ToStdout.msg "Destroying WHOIS record #{inspect}"
|
||||||
destroy!
|
destroy!
|
||||||
elsif auction.awaiting_payment? || auction.payment_received?
|
elsif auction.awaiting_payment? || auction.payment_received?
|
||||||
update!(json: { name: auction.domain,
|
update!(json: { name: auction.domain,
|
||||||
status: ['PendingRegistration'],
|
status: ['PendingRegistration'],
|
||||||
disclaimer: self.class.disclaimer,
|
disclaimer: self.class.disclaimer,
|
||||||
registration_deadline: auction.whois_deadline })
|
registration_deadline: auction.whois_deadline })
|
||||||
to_stdout "Updated from auction WHOIS record #{inspect}"
|
ToStdout.msg "Updated from auction WHOIS record #{inspect}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/AbcSize
|
# rubocop:enable Metrics/AbcSize
|
||||||
|
|
|
@ -36,8 +36,10 @@ module DomainNameRegistry
|
||||||
|
|
||||||
# Autoload all model subdirs
|
# Autoload all model subdirs
|
||||||
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
|
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
|
||||||
|
config.autoload_paths += Dir[Rails.root.join('app', 'lib', '**/')]
|
||||||
config.autoload_paths += Dir[Rails.root.join('app', 'interactions', '**/')]
|
config.autoload_paths += Dir[Rails.root.join('app', 'interactions', '**/')]
|
||||||
config.eager_load_paths << config.root.join('lib', 'validators')
|
config.eager_load_paths << config.root.join('lib', 'validators')
|
||||||
|
config.eager_load_paths << config.root.join('app', 'lib')
|
||||||
config.watchable_dirs['lib'] = %i[rb]
|
config.watchable_dirs['lib'] = %i[rb]
|
||||||
|
|
||||||
config.active_record.schema_format = :sql
|
config.active_record.schema_format = :sql
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue