Merge branch 'master' into registry-790

# Conflicts:
#	app/models/domain_cron.rb
#	lib/tasks/dev.rake
This commit is contained in:
Artur Beljajev 2018-06-18 16:27:56 +03:00
commit 5b821f4074
77 changed files with 278 additions and 496 deletions

5
lib/core_ext/array.rb Normal file
View file

@ -0,0 +1,5 @@
class Array
def include_any?(*args)
(self & args).any?
end
end

View file

@ -1,14 +0,0 @@
require 'builder'
class Builder::XmlMarkup
def epp_head
self.instruct!
epp(
'xmlns' => 'https://epp.tld.ee/schema/epp-ee-1.0.xsd',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'lib/schemas/epp-ee-1.0.xsd'
) do
yield
end
end
end

14
lib/gem_ext/builder.rb Normal file
View file

@ -0,0 +1,14 @@
module Builder
class XmlMarkup
def epp_head
instruct!
epp(
'xmlns' => 'https://epp.tld.ee/schema/epp-ee-1.0.xsd',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'lib/schemas/epp-ee-1.0.xsd'
) do
yield
end
end
end
end

11
lib/gem_ext/i18n.rb Normal file
View file

@ -0,0 +1,11 @@
# Don't raise error when nil
# http://stackoverflow.com/questions/9467034/rails-i18n-how-to-handle-case-of-a-nil-date-being-passed-ie-lnil
module I18n
class << self
alias_method :original_localize, :localize
def localize(object, options = {})
object.present? ? original_localize(object, options) : ''
end
end
end

View file

@ -0,0 +1,23 @@
# the following line is required for PaperTrail >= 4.0.0 with Rails
PaperTrail::Rails::Engine.eager_load!
PaperTrail::Version.module_eval do
self.abstract_class = true
end
# Store console and rake changes in versions
if defined?(::Rails::Console) || File.basename($PROGRAM_NAME).split(' ').first == 'spring'
PaperTrail.whodunnit = "console-#{`whoami`.strip}"
elsif File.basename($PROGRAM_NAME) == 'rake'
# rake username does not work when spring enabled
PaperTrail.whodunnit = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
end
class PaperSession
class << self
attr_writer :session
def session
@session ||= Time.zone.now.to_s(:db)
end
end
end

View file

@ -1,17 +0,0 @@
module Iptable
def counter_update(registrar_code, ip)
counter_proc = "/proc/net/xt_recent/#{registrar_code}"
begin
File.open(counter_proc, 'a') do |f|
f.puts "+#{ip}"
end
rescue Errno::ENOENT => e
logger.error "IPTABLES COUNTER UPDATE: cannot open #{counter_proc}: #{e}"
rescue Errno::EACCES => e
logger.error "IPTABLES COUNTER UPDATE: no permission #{counter_proc}: #{e}"
rescue IOError => e
logger.error "IPTABLES COUNTER UPDATE: cannot write #{ip} to #{counter_proc}: #{e}"
end
end
end

View file

@ -1,43 +0,0 @@
require 'countries'
require 'action_view'
class SortedCountry
class << self
include ActionView::Helpers
def all_options(selected = nil)
quick_options = options_for_select(quick_list, { selected: selected })
# no double select
selected = quick_list.map(&:second).include?(selected) ? '' : selected
all_options = options_for_select([['---', '---']] + all_sorted_truncated,
{ selected: selected, disabled: ['---'] })
quick_options + all_options
end
private
def quick_list
@quick_list ||=
[
['Estonia', 'EE'],
['Finland', 'FI'],
['Latvia', 'LV'],
['Lithuania', 'LT'],
['Russian Federation', 'RU'],
['Sweden', 'SE'],
['United States', 'US']
]
end
def all_sorted
@all_sorted ||= Country.all.sort_by(&:name)
end
def all_sorted_truncated
@all_sorted_truncated ||=
all_sorted.map { |country| [country.name.truncate(26), country.alpha2] }
end
end
end

View file

@ -1,5 +1,3 @@
# rubocop: disable Style/SymbolProc
# rubocop: disable Performance/Detect
namespace :import do
# README
#
@ -360,7 +358,6 @@ namespace :import do
legacy_contact_id
)
# rubocop: disable Lint/UselessAssignment
domain_status_columns = %w(
description
value
@ -368,7 +365,6 @@ namespace :import do
updator_str
legacy_domain_id
)
# rubocop: enable Lint/UselessAssignment
nameserver_columns = %w(
hostname
@ -786,5 +782,3 @@ def parse_zone_ns_data(domain, zone)
end
[ns_records.strip, a_records.strip, a4_records.strip]
end
# rubocop: enable Performance/Detect
# rubocop: enable Style/SymbolProc