From ce52e6e097b4e8b0991ae9d7762d300914b5dba8 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 7 Apr 2015 17:02:47 +0300 Subject: [PATCH] depp now rubocop ready --- vendor/gems/depp/Rakefile | 4 -- .../depp/application_controller.rb | 2 +- vendor/gems/depp/app/models/depp/contact.rb | 40 ++++++++----------- vendor/gems/depp/bin/rails | 3 +- vendor/gems/depp/depp.gemspec | 2 +- vendor/gems/depp/lib/depp/sorted_country.rb | 4 +- 6 files changed, 23 insertions(+), 32 deletions(-) diff --git a/vendor/gems/depp/Rakefile b/vendor/gems/depp/Rakefile index f35deb1c8..64fdcb6f0 100644 --- a/vendor/gems/depp/Rakefile +++ b/vendor/gems/depp/Rakefile @@ -17,11 +17,8 @@ end APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) load 'rails/tasks/engine.rake' - load 'rails/tasks/statistics.rake' - - Bundler::GemHelper.install_tasks require 'rake/testtask' @@ -33,5 +30,4 @@ Rake::TestTask.new(:test) do |t| t.verbose = false end - task default: :test diff --git a/vendor/gems/depp/app/controllers/depp/application_controller.rb b/vendor/gems/depp/app/controllers/depp/application_controller.rb index cd0211a62..ff59a5342 100644 --- a/vendor/gems/depp/app/controllers/depp/application_controller.rb +++ b/vendor/gems/depp/app/controllers/depp/application_controller.rb @@ -10,7 +10,7 @@ module Depp helper_method :depp_current_user - rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |exception| + rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |_exception| redirect_to login_url, alert: t(:no_connection_to_registry) end diff --git a/vendor/gems/depp/app/models/depp/contact.rb b/vendor/gems/depp/app/models/depp/contact.rb index ebfac40f1..c6a9cf902 100644 --- a/vendor/gems/depp/app/models/depp/contact.rb +++ b/vendor/gems/depp/app/models/depp/contact.rb @@ -11,12 +11,15 @@ module Depp DISCLOSURE_TYPES = [DISABLED, '1', '0'] TYPES = %w( bic priv birthday ) SELECTION_TYPES = [ - [ 'Business code', 'bic' ], - [ 'Personal identification code', 'priv' ], - [ 'Birthday', 'birthday' ] + ['Business code', 'bic'], + ['Personal identification code', 'priv'], + ['Birthday', 'birthday'] ] class << self + attr_reader :epp_xml, :user + + # rubocop: disable Metrics/MethodLength def new_from_params(params) new( id: params[:code], @@ -36,9 +39,10 @@ module Depp city: params[:city], zip: params[:zip], state: params[:state], - country_code: params[:country_code], + country_code: params[:country_code] ) end + # rubocop: enable Metrics/MethodLength def find_by_id(id) data = info_xml(id) @@ -77,14 +81,6 @@ module Depp @epp_xml = EppXml::Contact.new(cl_trid_prefix: user.tag) end - def epp_xml - @epp_xml - end - - def user - @user - end - def info_xml(id, password = nil) xml = epp_xml.info( id: { value: id }, @@ -140,7 +136,7 @@ module Depp end end - def initialize(attributes={}) + def initialize(attributes = {}) super self.country_code = 'EE' if country_code.blank? self.ident_type = 'bic' if ident_type.blank? @@ -172,6 +168,7 @@ module Depp handle_errors(data) end + # rubocop: disable Metrics/MethodLength def update_attributes(params) self.ident_country_code = params[:ident_country_code] self.ident_type = params[:ident_type] @@ -215,6 +212,7 @@ module Depp data = Depp::Contact.user.request(update_xml) handle_errors(data) end + # rubocop: enable Metrics/MethodLength def delete delete_xml = Contact.epp_xml.delete( @@ -275,17 +273,13 @@ module Depp def handle_errors(data) data.css('result').each do |x| success_codes = %(1000, 1300, 1301) + next if success_codes.include?(x['code']) - unless success_codes.include?(x['code']) - message = "#{x.css('msg').text} #{x.css('value').text}" - - attr = message.split('[').last.strip.sub(']','') if message.include?('[') - - attr = :base if attr.nil? - attr = 'phone' if attr == 'voice' - - errors.add(attr, message) - end + message = "#{x.css('msg').text} #{x.css('value').text}" + attr = message.split('[').last.strip.sub(']', '') if message.include?('[') + attr = :base if attr.nil? + attr = 'phone' if attr == 'voice' + errors.add(attr, message) end errors.blank? end diff --git a/vendor/gems/depp/bin/rails b/vendor/gems/depp/bin/rails index 7d1fe1124..613b3076a 100755 --- a/vendor/gems/depp/bin/rails +++ b/vendor/gems/depp/bin/rails @@ -1,5 +1,6 @@ #!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. +# This command will automatically be run +# when you run "rails" with Rails 4 gems installed from the root of your application. ENGINE_ROOT = File.expand_path('../..', __FILE__) ENGINE_PATH = File.expand_path('../../lib/depp/engine', __FILE__) diff --git a/vendor/gems/depp/depp.gemspec b/vendor/gems/depp/depp.gemspec index bbb0aaa06..3b59cc979 100644 --- a/vendor/gems/depp/depp.gemspec +++ b/vendor/gems/depp/depp.gemspec @@ -1,4 +1,4 @@ -$:.push File.expand_path("../lib", __FILE__) +$LOAD_PATH.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "depp/version" diff --git a/vendor/gems/depp/lib/depp/sorted_country.rb b/vendor/gems/depp/lib/depp/sorted_country.rb index 5b452b236..114213681 100644 --- a/vendor/gems/depp/lib/depp/sorted_country.rb +++ b/vendor/gems/depp/lib/depp/sorted_country.rb @@ -6,10 +6,10 @@ class SortedCountry include ActionView::Helpers def all_options(selected = nil) - quick_options = options_for_select(quick_list + [['---','']], selected) + quick_options = options_for_select(quick_list + [['---', '']], selected) # no double select - selected = quick_list.map{ |c| c.second }.include?(selected) ? '' : selected + selected = quick_list.map(&:second).include?(selected) ? '' : selected all_options = options_for_select(all_sorted_truncated, selected) quick_options + all_options