Skip to content

Commit 34815d3

Browse files
committed
Upgraded Rubocop to 0.21.0.
1 parent cd38e43 commit 34815d3

File tree

6 files changed

+95
-103
lines changed

6 files changed

+95
-103
lines changed

.rubocop.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
Excludes:
2+
Exclude:
33
- vendor/**
44

55
LineLength:
@@ -23,15 +23,6 @@ Encoding:
2323
# no need to always specify encoding
2424
Enabled: false
2525

26-
HashMethods:
27-
# key? instead of has_key?
28-
# value? instead of has_value?
29-
Enabled: false
30-
31-
StringLiterals:
32-
# use single or double-quoted strings, as you please
33-
Enabled: false
34-
3526
Void:
3627
# == operator used in void context in specs
3728
Enabled: false
@@ -67,3 +58,6 @@ WordArray:
6758
CyclomaticComplexity:
6859
Enabled: false
6960

61+
FileName:
62+
# allow grape-entity.rb for a require
63+
Enabled: false

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ group :development, :test do
1313
gem 'rspec'
1414
gem 'rack-test', "~> 0.6.2", :require => "rack/test"
1515
gem 'github-markup'
16-
gem 'rubocop', '~> 0.16.0'
16+
gem 'rubocop', '0.21.0'
1717
end
1818

1919
platforms :rbx do

grape-entity.gemspec

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
$:.push File.expand_path("../lib", __FILE__)
2-
require "grape_entity/version"
1+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
2+
require 'grape_entity/version'
33

44
Gem::Specification.new do |s|
5-
s.name = "grape-entity"
5+
s.name = 'grape-entity'
66
s.version = GrapeEntity::VERSION
77
s.platform = Gem::Platform::RUBY
8-
s.authors = ["Michael Bleigh"]
9-
s.email = ["[email protected]"]
10-
s.homepage = "https://github.com/intridea/grape-entity"
11-
s.summary = %q{A simple facade for managing the relationship between your model and API.}
12-
s.description = %q{Extracted from Grape, A Ruby framework for rapid API development with great conventions.}
13-
s.license = "MIT"
8+
s.authors = ['Michael Bleigh']
9+
s.email = ['[email protected]']
10+
s.homepage = 'https://github.com/intridea/grape-entity'
11+
s.summary = %q(A simple facade for managing the relationship between your model and API.)
12+
s.description = %q(Extracted from Grape, A Ruby framework for rapid API development with great conventions.)
13+
s.license = 'MIT'
1414

15-
s.rubyforge_project = "grape-entity"
15+
s.rubyforge_project = 'grape-entity'
1616

1717
s.add_runtime_dependency 'activesupport'
1818
s.add_runtime_dependency 'multi_json', '>= 1.3.2'
19-
19+
2020
s.add_development_dependency 'rake'
2121
s.add_development_dependency 'maruku'
2222
s.add_development_dependency 'yard'
@@ -25,6 +25,6 @@ Gem::Specification.new do |s|
2525

2626
s.files = `git ls-files`.split("\n")
2727
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
28-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
29-
s.require_paths = ["lib"]
28+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
29+
s.require_paths = ['lib']
3030
end

lib/grape_entity.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
require "active_support/core_ext"
2-
require "grape_entity/version"
3-
require "grape_entity/entity"
1+
require 'active_support'
2+
require 'active_support/core_ext'
3+
require 'grape_entity/version'
4+
require 'grape_entity/entity'

lib/grape_entity/entity.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ def self.expose(*args, &block)
127127
options = merge_options(args.last.is_a?(Hash) ? args.pop : {})
128128

129129
if args.size > 1
130-
raise ArgumentError, "You may not use the :as option on multi-attribute exposures." if options[:as]
131-
raise ArgumentError, "You may not use block-setting on multi-attribute exposures." if block_given?
130+
raise ArgumentError, 'You may not use the :as option on multi-attribute exposures.' if options[:as]
131+
raise ArgumentError, 'You may not use block-setting on multi-attribute exposures.' if block_given?
132132
end
133133

134-
raise ArgumentError, "You may not use block-setting when also using format_with" if block_given? && options[:format_with].respond_to?(:call)
134+
raise ArgumentError, 'You may not use block-setting when also using format_with' if block_given? && options[:format_with].respond_to?(:call)
135135

136136
options[:proc] = block if block_given? && block.parameters.any?
137137

@@ -247,7 +247,7 @@ def self.documentation
247247
# end
248248
#
249249
def self.format_with(name, &block)
250-
raise ArgumentError, "You must pass a block for formatters" unless block_given?
250+
raise ArgumentError, 'You must pass a block for formatters' unless block_given?
251251
formatters[name.to_sym] = block
252252
end
253253

@@ -328,7 +328,7 @@ def self.represent(objects, options = {})
328328
inner = inner.serializable_hash if options[:serializable]
329329
end
330330

331-
root_element = if options.has_key?(:root)
331+
root_element = if options.key?(:root)
332332
options[:root]
333333
else
334334
objects.respond_to?(:to_ary) ? @collection_root : @root
@@ -346,7 +346,7 @@ def exposures
346346
end
347347

348348
def valid_exposures
349-
exposures.reject { |a, options| options[:nested] }.select do |attribute, exposure_options|
349+
exposures.reject { |_, options| options[:nested] }.select do |attribute, exposure_options|
350350
valid_exposure?(attribute, exposure_options)
351351
end
352352
end
@@ -469,7 +469,7 @@ def delegate_attribute(attribute)
469469
def valid_exposure?(attribute, exposure_options)
470470
nested_exposures = self.class.nested_exposures_for(attribute)
471471
(nested_exposures.any? && nested_exposures.all? { |a, o| valid_exposure?(a, o) }) || \
472-
exposure_options.has_key?(:proc) || \
472+
exposure_options.key?(:proc) || \
473473
!exposure_options[:safe] || \
474474
object.respond_to?(self.class.name_for(attribute))
475475
end
@@ -500,8 +500,6 @@ def conditions_met?(exposure_options, options)
500500
true
501501
end
502502

503-
private
504-
505503
# All supported options.
506504
OPTIONS = [
507505
:as, :if, :unless, :using, :with, :proc, :documentation, :format_with, :safe, :if_extras, :unless_extras
@@ -544,7 +542,7 @@ def self.valid_options(options)
544542
raise ArgumentError, "#{key.inspect} is not a valid option." unless OPTIONS.include?(key)
545543
end
546544

547-
options[:using] = options.delete(:with) if options.has_key?(:with)
545+
options[:using] = options.delete(:with) if options.key?(:with)
548546
options
549547
end
550548
end

0 commit comments

Comments
 (0)