Merge pull request #859 from internetee/remove-lib-from-autoload-path

Remove `lib` folder from autoload path
This commit is contained in:
Timo Võhmar 2018-06-14 13:20:22 +03:00 committed by GitHub
commit 2828f8ca72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 57 additions and 58 deletions

View file

@ -1,5 +1,4 @@
class EppController < ApplicationController
include Iptable
layout false
protect_from_forgery with: :null_session
skip_before_action :verify_authenticity_token
@ -359,12 +358,6 @@ class EppController < ApplicationController
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/PerceivedComplexity
def iptables_counter_update
return if ENV['iptables_counter_enabled'].blank? && ENV['iptables_counter_enabled'] != 'true'
return if current_user.blank?
counter_update(current_user.registrar_code, ENV['iptables_server_ip'])
end
def resource
name = self.class.to_s.sub("Epp::","").sub("Controller","").underscore.singularize
instance_variable_get("@#{name}")
@ -407,4 +400,26 @@ class EppController < ApplicationController
timeout = 5.minutes
epp_session.updated_at < (Time.zone.now - timeout)
end
def iptables_counter_update
return if ENV['iptables_counter_enabled'].blank? && ENV['iptables_counter_enabled'] != 'true'
return if current_user.blank?
counter_update(current_user.registrar_code, ENV['iptables_server_ip'])
end
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,18 +1,15 @@
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 })
quick_options = options_for_select(quick_list, selected: selected)
# no double select
selected = quick_list.map(&:second).include?(selected) ? '' : selected
selected = quick_list.map(&:second).include?(selected) ? '' : selected
all_options = options_for_select([['---', '---']] + all_sorted_truncated,
{ selected: selected, disabled: ['---'] })
all_options = options_for_select([['---', '---']] + all_sorted_truncated,
selected: selected, disabled: ['---'])
quick_options + all_options
end
@ -21,12 +18,12 @@ class SortedCountry
def quick_list
@quick_list ||=
[
['Estonia', 'EE'],
['Finland', 'FI'],
['Latvia', 'LV'],
['Lithuania', 'LT'],
%w[Estonia' EE],
%w[Finland FI],
%w[Latvia LV],
%w[Lithuania LT],
['Russian Federation', 'RU'],
['Sweden', 'SE'],
%w[Sweden SE],
['United States', 'US']
]
end

View file

@ -40,8 +40,8 @@ module DomainNameRegistry
# Autoload all model subdirs
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
config.autoload_paths << Rails.root.join('lib')
config.eager_load_paths << config.root.join('lib', 'validators')
config.watchable_dirs['lib'] = %i[rb]
# Add the fonts path
config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts')

View file

@ -1,3 +1,5 @@
require 'devise_custom_failure'
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|

View file

@ -0,0 +1,4 @@
require 'core_ext/array'
require 'gem_ext/builder'
require 'gem_ext/i18n'
require 'gem_ext/paper_trail'

View file

@ -1 +0,0 @@
Dir[File.join(Rails.root, 'lib', 'ext', '*.rb')].each { |x| require x }

View file

@ -1,4 +1,4 @@
require 'epp_constraint'
require_dependency 'epp_constraint'
Rails.application.routes.draw do
namespace(:epp, defaults: { format: :xml }) do

View file

@ -668,7 +668,6 @@
<text text-anchor="start" x="-72.5" y="-60.8" font-family="Times,serif" font-size="14.00">generate_svtrid</text>
<text text-anchor="start" x="-72.5" y="-45.8" font-family="Times,serif" font-size="14.00">handle_errors</text>
<text text-anchor="start" x="-72.5" y="-30.8" font-family="Times,serif" font-size="14.00">has_attribute</text>
<text text-anchor="start" x="-72.5" y="-15.8" font-family="Times,serif" font-size="14.00">iptables_counter_update</text>
<text text-anchor="start" x="-72.5" y="-0.8" font-family="Times,serif" font-size="14.00">latin_only</text>
<text text-anchor="start" x="-72.5" y="14.2" font-family="Times,serif" font-size="14.00">mutually_exclusive</text>
<text text-anchor="start" x="-72.5" y="29.2" font-family="Times,serif" font-size="14.00">optional</text>

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Before After
Before After

View file

@ -1,5 +1,5 @@
class Array
def include_any? *args
def include_any?(*args)
(self & args).any?
end
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

View file

@ -1,5 +1,5 @@
# 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
# 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

View file

@ -8,7 +8,7 @@ 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"
elsif File.basename($PROGRAM_NAME) == 'rake'
# rake username does not work when spring enabled
PaperTrail.whodunnit = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
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