depp now rubocop ready

This commit is contained in:
Priit Tark 2015-04-07 17:02:47 +03:00
parent c0b6604ba9
commit ce52e6e097
6 changed files with 23 additions and 32 deletions

View file

@ -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

View file

@ -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

View file

@ -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,18 +273,14 @@ 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 = message.split('[').last.strip.sub(']', '') if message.include?('[')
attr = :base if attr.nil?
attr = 'phone' if attr == 'voice'
errors.add(attr, message)
end
end
errors.blank?
end
end

View file

@ -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__)

View file

@ -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"

View file

@ -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