Skip to content

adds ruby 2.5, drops ruby 2.2 support #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ AllCops:

inherit_from: .rubocop_todo.yml

Style/FileName:
Gemspec/RequiredRubyVersion:
Enabled: false

Naming/FileName:
Exclude:
- 'Gemfile'
- 'Rakefile'
Expand Down
33 changes: 23 additions & 10 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-04-05 10:30:29 +0700 using RuboCop version 0.48.1.
# on 2018-01-11 18:20:10 +0100 using RuboCop version 0.52.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -18,23 +18,17 @@ Metrics/AbcSize:
# Offense count: 35
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 1499
Max: 1489

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 208
Max: 210

# Offense count: 3
# Offense count: 2
Metrics/CyclomaticComplexity:
Max: 11

# Offense count: 238
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 146

# Offense count: 7
# Configuration parameters: CountComments.
Metrics/MethodLength:
Expand All @@ -43,3 +37,22 @@ Metrics/MethodLength:
# Offense count: 2
Metrics/PerceivedComplexity:
Max: 13

# Offense count: 1
Style/EvalWithLocation:
Exclude:
- 'lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to, define_method
Style/SymbolProc:
Exclude:
- 'spec/grape_entity/entity_spec.rb'

# Offense count: 250
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 146
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ after_success:
- bundle exec danger

rvm:
- 2.4.2
- 2.3.5
- 2.5.0
- 2.4.3

matrix:
fast_finish: true

include:
- rvm: 2.2.8
- rvm: 2.3.6
- rvm: ruby-head
- rvm: jruby-9.1.10.0
- rvm: jruby-head
- rvm: rbx-2

allow_failures:
- rvm: 2.2.8
- rvm: 2.3.6
- rvm: ruby-head
- rvm: jruby-9.1.10.0
- rvm: jruby-head
- rvm: rbx-2
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### Features

* [#287](https://github.com/ruby-grape/grape-entity/pull/287): Adds ruby 2.5, drops ruby 2.2 support - [@LeFnord](https://github.com/LeFnord).
* [#277](https://github.com/ruby-grape/grape-entity/pull/277): Provide grape::entity::options#dig - [@kachick](https://github.com/kachick).
* [#265](https://github.com/ruby-grape/grape-entity/pull/265): Adds ability to provide a proc to as: - [@james2m](https://github.com/james2m).
* [#264](https://github.com/ruby-grape/grape-entity/pull/264): Adds Rubocop config and todo list - [@james2m](https://github.com/james2m).
Expand All @@ -12,7 +13,7 @@

#### Fixes

* [#288](https://github.com/ruby-grape/grape-entity/pull/288) Fix wrong argument exception when &:block passed to the expose method - [@DmitryTsepelev](https://github.com/DmitryTsepelev)
* [#288](https://github.com/ruby-grape/grape-entity/pull/288) Fix wrong argument exception when &:block passed to the expose method - [@DmitryTsepelev](https://github.com/DmitryTsepelev).

* Your contribution here.

Expand Down
5 changes: 3 additions & 2 deletions grape-entity.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ Gem::Specification.new do |s|
s.description = 'Extracted from Grape, A Ruby framework for rapid API development with great conventions.'
s.license = 'MIT'

s.required_ruby_version = '>= 2.2'
s.required_ruby_version = '>= 2.3'

s.rubyforge_project = 'grape-entity'

s.add_runtime_dependency 'activesupport', '>= 4.0.0'
s.add_runtime_dependency 'activesupport', '>=4.0'
# FIXME: remove dependecy
s.add_runtime_dependency 'multi_json', '>= 1.3.2'

s.add_development_dependency 'bundler'
Expand Down
5 changes: 2 additions & 3 deletions lib/grape_entity/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def self.expose(*args, &block)
@nesting_stack.pop
end
end
# rubocop:enable Style/Next
end

# Returns exposures that have been declared for this Entity on the top level.
Expand Down Expand Up @@ -255,9 +256,7 @@ def self.with_options(options)
# #docmentation, any exposure without a documentation key will be ignored.
def self.documentation
@documentation ||= root_exposures.each_with_object({}) do |exposure, memo|
if exposure.documentation && !exposure.documentation.empty?
memo[exposure.key] = exposure.documentation
end
memo[exposure.key] = exposure.documentation if exposure.documentation && !exposure.documentation.empty?
end
end

Expand Down
8 changes: 2 additions & 6 deletions lib/grape_entity/exposure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,15 @@ def self.new(attribute, options)

def self.compile_conditions(options)
if_conditions = []
unless options[:if_extras].nil?
if_conditions.concat(options[:if_extras])
end
if_conditions.concat(options[:if_extras]) unless options[:if_extras].nil?
if_conditions << options[:if] unless options[:if].nil?

if_conditions.map! do |cond|
Condition.new_if cond
end

unless_conditions = []
unless options[:unless_extras].nil?
unless_conditions.concat(options[:unless_extras])
end
unless_conditions.concat(options[:unless_extras]) unless options[:unless_extras].nil?
unless_conditions << options[:unless] unless options[:unless].nil?

unless_conditions.map! do |cond|
Expand Down
4 changes: 3 additions & 1 deletion spec/grape_entity/entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
end

it 'makes sure that :format_with as a proc cannot be used with a block' do
expect { subject.expose :name, format_with: proc {} {} }.to raise_error ArgumentError
# rubocop:disable Style/BlockDelimiters
expect { subject.expose :name, format_with: proc {} do p 'hi' end }.to raise_error ArgumentError
# rubocop:enable Style/BlockDelimiters
end

it 'makes sure unknown options are not silently ignored' do
Expand Down