Bump up Rubocop to 0.24.1
This commit is contained in:
parent
529be67f4c
commit
8f512086fe
2
Rakefile
2
Rakefile
|
@ -10,6 +10,6 @@ RSpec::Core::RakeTask.new do |spec|
|
|||
end
|
||||
|
||||
require 'rubocop/rake_task'
|
||||
Rubocop::RakeTask.new(:rubocop)
|
||||
RuboCop::RakeTask.new(:rubocop)
|
||||
|
||||
task default: [:rubocop, :spec]
|
||||
|
|
|
@ -16,7 +16,7 @@ module Hashie
|
|||
def deep_fetch(*args, &block)
|
||||
args.reduce(self) do |obj, arg|
|
||||
begin
|
||||
arg = Integer(arg) if obj.kind_of? Array
|
||||
arg = Integer(arg) if obj.is_a? Array
|
||||
obj.fetch(arg)
|
||||
rescue ArgumentError, IndexError, NoMethodError => e
|
||||
break block.call(arg) if block
|
||||
|
|
|
@ -31,9 +31,8 @@ module Hashie
|
|||
module IgnoreUndeclared
|
||||
def initialize_attributes(attributes)
|
||||
attributes.each_pair do |att, value|
|
||||
if self.class.property?(att) || (self.class.respond_to?(:translations) && self.class.translations.include?(att.to_sym))
|
||||
self[att] = value
|
||||
end
|
||||
next unless self.class.property?(att) || (self.class.respond_to?(:translations) && self.class.translations.include?(att.to_sym))
|
||||
self[att] = value
|
||||
end if attributes
|
||||
end
|
||||
|
||||
|
|
|
@ -78,14 +78,13 @@ module Hashie
|
|||
# see if any of the regexps match the string
|
||||
@regexes.each do |regex|
|
||||
match = regex.match(query)
|
||||
if match
|
||||
@regex_counts[regex] += 1
|
||||
value = @hash[regex]
|
||||
if value.respond_to? :call
|
||||
yield value.call(match)
|
||||
else
|
||||
yield value
|
||||
end
|
||||
next unless match
|
||||
@regex_counts[regex] += 1
|
||||
value = @hash[regex]
|
||||
if value.respond_to? :call
|
||||
yield value.call(match)
|
||||
else
|
||||
yield value
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,10 +109,9 @@ module Hashie
|
|||
private
|
||||
|
||||
def optimize_if_necessary!
|
||||
if (@lookups += 1) >= @optimize_every
|
||||
@regexes = @regex_counts.sort_by { |_, count| -count }.map { |regex, _| regex }
|
||||
@lookups = 0
|
||||
end
|
||||
return unless (@lookups += 1) >= @optimize_every
|
||||
@regexes = @regex_counts.sort_by { |_, count| -count }.map { |regex, _| regex }
|
||||
@lookups = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ describe Hashie::Rash do
|
|||
1 => 'awesome',
|
||||
1..1000 => 'rangey',
|
||||
/(bcd)/ => proc { |m| m[1] }
|
||||
# /.+/ => "EVERYTHING"
|
||||
# /.+/ => "EVERYTHING"
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue