summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter M. Goldstein <peter.m.goldstein@gmail.com>2014-07-06 14:56:20 -0700
committerPeter M. Goldstein <peter.m.goldstein@gmail.com>2014-07-06 14:56:20 -0700
commit8f512086fe8cb009fd553bcbc4652ed11cd3ced1 (patch)
tree3f90c6c6322fe4af0f106c437606554622de8c4c
parent529be67f4cab88ee928b1a0eaac695e5312ba691 (diff)
downloadhashie-8f512086fe8cb009fd553bcbc4652ed11cd3ced1.tar.gz
Bump up Rubocop to 0.24.1
-rw-r--r--Gemfile2
-rw-r--r--Rakefile2
-rw-r--r--lib/hashie/extensions/deep_fetch.rb2
-rw-r--r--lib/hashie/extensions/ignore_undeclared.rb5
-rw-r--r--lib/hashie/rash.rb22
-rw-r--r--spec/hashie/rash_spec.rb2
6 files changed, 16 insertions, 19 deletions
diff --git a/Gemfile b/Gemfile
index e1676e6..586eb58 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,4 +8,4 @@ end
gemspec
-gem 'rubocop', '0.21.0'
+gem 'rubocop', '0.24.1'
diff --git a/Rakefile b/Rakefile
index 853bc35..0601612 100644
--- a/Rakefile
+++ b/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]
diff --git a/lib/hashie/extensions/deep_fetch.rb b/lib/hashie/extensions/deep_fetch.rb
index a441934..9149f0d 100644
--- a/lib/hashie/extensions/deep_fetch.rb
+++ b/lib/hashie/extensions/deep_fetch.rb
@@ -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
diff --git a/lib/hashie/extensions/ignore_undeclared.rb b/lib/hashie/extensions/ignore_undeclared.rb
index 13e2909..e16e0a4 100644
--- a/lib/hashie/extensions/ignore_undeclared.rb
+++ b/lib/hashie/extensions/ignore_undeclared.rb
@@ -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
diff --git a/lib/hashie/rash.rb b/lib/hashie/rash.rb
index d2d766a..abbff8e 100644
--- a/lib/hashie/rash.rb
+++ b/lib/hashie/rash.rb
@@ -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
diff --git a/spec/hashie/rash_spec.rb b/spec/hashie/rash_spec.rb
index c69c7d1..20b2652 100644
--- a/spec/hashie/rash_spec.rb
+++ b/spec/hashie/rash_spec.rb
@@ -10,7 +10,7 @@ describe Hashie::Rash do
1 => 'awesome',
1..1000 => 'rangey',
/(bcd)/ => proc { |m| m[1] }
- # /.+/ => "EVERYTHING"
+ # /.+/ => "EVERYTHING"
)
end