Skip to content

Commit

Permalink
Merge pull request #1531 from LeFnord/master
Browse files Browse the repository at this point in the history
updates gem dependencies
  • Loading branch information
dblock committed Dec 4, 2016
2 parents dc5e4b0 + a4364f2 commit 152fa40
Show file tree
Hide file tree
Showing 29 changed files with 179 additions and 85 deletions.
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ AllCops:
- bin/**/*

inherit_from: .rubocop_todo.yml

Style/Documentation:
Enabled: false

Style/MultilineIfModifier:
Enabled: false

Style/RaiseArgs:
Enabled: false
35 changes: 18 additions & 17 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-09-28 13:52:41 +0200 using RuboCop version 0.39.0.
# on 2016-12-01 19:41:18 +0100 using RuboCop version 0.46.0.
# 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
# versions of RuboCop, may require this file to be generated again.

# Offense count: 41
# Offense count: 3
# this must be removed for preparation of ruby 2.4
Lint/UnifiedInteger:
Exclude:
- 'lib/grape/dsl/inside_route.rb'
- 'spec/grape/validations/validators/allow_blank_spec.rb'

# Offense count: 44
Metrics/AbcSize:
Max: 44

Expand All @@ -19,36 +26,30 @@ Metrics/BlockNesting:
Metrics/ClassLength:
Max: 279

# Offense count: 28
# Offense count: 26
Metrics/CyclomaticComplexity:
Max: 14

# Offense count: 955
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# Offense count: 964
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 215

# Offense count: 52
# Offense count: 55
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 33

# Offense count: 8
# Offense count: 9
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 212

# Offense count: 18
# Offense count: 17
Metrics/PerceivedComplexity:
Max: 14

# Offense count: 114
Style/Documentation:
Enabled: false

# Offense count: 16
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: compact, exploded
Style/RaiseArgs:
Enabled: false
Style/MethodMissing:
Exclude:
- 'lib/grape/router/attribute_translator.rb'
26 changes: 17 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,32 @@ sudo: false

matrix:
include:
- rvm: 2.3.1
- rvm: 2.3.3
script:
- bundle exec danger
- rvm: 2.3.1
- rvm: 2.3.3
gemfile: Gemfile
- rvm: 2.3.1
- rvm: 2.3.3
gemfile: gemfiles/rack_edge.gemfile
- rvm: 2.3.3
gemfile: gemfiles/rack_1.5.2.gemfile
- rvm: 2.3.3
gemfile: gemfiles/rails_edge.gemfile
- rvm: 2.3.3
gemfile: gemfiles/rails_5.gemfile
- rvm: 2.3.1
- rvm: 2.2.6
gemfile: Gemfile
- rvm: 2.2.6
gemfile: gemfiles/rack_1.5.2.gemfile
- rvm: 2.3.0
- rvm: 2.2.5
- rvm: 2.1.10
- rvm: 2.2.6
gemfile: gemfiles/rails_5.gemfile
- rvm: 2.2.6
gemfile: gemfiles/rails_4.gemfile
- rvm: 2.1.10
- rvm: 2.2.6
gemfile: gemfiles/rails_3.gemfile
- rvm: rbx-2
- rvm: ruby-head
- rvm: jruby-head
- rvm: rbx-2
allow_failures:
- rvm: ruby-head
- rvm: jruby-head
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Next Release
* [#1512](https://github.com/ruby-grape/grape/pull/1512): Fix: deeply nested parameters are included within `#declared(params)` - [@krbs](https://github.com/krbs).
* [#1510](https://github.com/ruby-grape/grape/pull/1510): Fix: inconsistent validation for multiple parameters - [@dgasper](https://github.com/dgasper).
* [#1526](https://github.com/ruby-grape/grape/pull/1526): Reduce warnings caused by instance variables not initialized - [@cpetschnig](https://github.com/cpetschnig).
* [#1531](https://github.com/ruby-grape/grape/pull/1531): Updates gem dependencies - [@LeFnord](https://github.com/LeFnord).


0.18.0 (10/7/2016)
==================
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gemspec
group :development, :test do
gem 'bundler'
gem 'rake'
gem 'rubocop', '0.39.0'
gem 'rubocop', '~> 0.45'
end

group :development do
Expand All @@ -21,12 +21,12 @@ group :development do
end

group :test do
gem 'grape-entity', '0.5.0'
gem 'grape-entity', '~> 0.6'
gem 'maruku'
gem 'rack-test'
gem 'rspec', '~> 3.0'
gem 'cookiejar'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'mime-types', '< 3.0'
gem 'mime-types', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
34 changes: 34 additions & 0 deletions gemfiles/rack_edge.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file was generated by Appraisal

source 'https://rubygems.org'

gem 'rack', github: 'rack/rack'

group :development, :test do
gem 'bundler'
gem 'rake'
gem 'rubocop', '~> 0.45.0'
end

group :development do
gem 'guard'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'yard'
gem 'appraisal'
gem 'benchmark-ips'
gem 'redcarpet'
end

group :test do
gem 'grape-entity', '~> 0.6'
gem 'maruku'
gem 'rack-test'
gem 'rspec', '~> 3.0'
gem 'cookiejar'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'mime-types', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end

gemspec path: '../'
2 changes: 1 addition & 1 deletion gemfiles/rails_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gem 'rails', '5.0.0'
group :development, :test do
gem 'bundler'
gem 'rake'
gem 'rubocop', '0.39.0'
gem 'rubocop', '0.45.0'
end

group :development do
Expand Down
34 changes: 34 additions & 0 deletions gemfiles/rails_edge.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file was generated by Appraisal

source 'https://rubygems.org'

gem 'rails', github: 'rails/rails'

group :development, :test do
gem 'bundler'
gem 'rake'
gem 'rubocop', '~> 0.45.0'
end

group :development do
gem 'guard'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'yard'
gem 'appraisal'
gem 'benchmark-ips'
gem 'redcarpet'
end

group :test do
gem 'grape-entity', '~> 0.6'
gem 'maruku'
gem 'rack-test'
gem 'rspec', '~> 3.0'
gem 'cookiejar'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'mime-types', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end

gemspec path: '../'
1 change: 1 addition & 0 deletions lib/grape/dsl/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def helpers(new_mod = nil, &block)
mod = new_mod || Module.new
define_boolean_in_mod(mod)
inject_api_helpers_to_mod(mod) if new_mod

inject_api_helpers_to_mod(mod) do
mod.class_eval(&block)
end if block_given?
Expand Down
4 changes: 2 additions & 2 deletions lib/grape/dsl/parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def all_or_none_of(*attrs)
# @yield a parameter definition DSL
def given(*attrs, &block)
attrs.each do |attr|
attr_ = attr.is_a?(Hash) ? attr.keys[0] : attr
raise Grape::Exceptions::UnknownParameter.new(attr_) unless declared_param?(attr_)
proxy_attr = attr.is_a?(Hash) ? attr.keys[0] : attr
raise Grape::Exceptions::UnknownParameter.new(proxy_attr) unless declared_param?(proxy_attr)
end
new_lateral_scope(dependent_on: attrs, &block)
end
Expand Down
5 changes: 2 additions & 3 deletions lib/grape/dsl/request_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ def rescue_from(*args, &block)
end
handler ||= extract_with(options)

case
when args.include?(:all)
if args.include?(:all)
namespace_inheritable(:rescue_all, true)
namespace_inheritable :all_rescue_handler, handler
when args.include?(:grape_exceptions)
elsif args.include?(:grape_exceptions)
namespace_inheritable(:rescue_all, true)
namespace_inheritable(:rescue_grape_exceptions, true)
else
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,15 @@ def reset_endpoints!
# @option options [Regexp] You may supply a regular expression that the declared parameter must meet.
def route_param(param, options = {}, &block)
options = options.dup

options[:requirements] = {
param.to_sym => options[:requirements]
} if options[:requirements].is_a?(Regexp)

Grape::Validations::ParamsScope.new(api: self) do
requires param, type: options[:type]
end if options.key?(:type)

namespace(":#{param}", options, &block)
end

Expand Down
1 change: 1 addition & 0 deletions lib/grape/error_formatter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def present(message, env)
# env['api.endpoint'].route does not work when the error occurs within a middleware
# the Endpoint does not have a valid env at this moment
http_codes = env[Grape::Env::GRAPE_ROUTING_ARGS][:route_info].http_codes || []

found_code = http_codes.find do |http_code|
(http_code[0].to_i == env[Grape::Env::API_ENDPOINT].status) && http_code[2].respond_to?(:represent)
end if env[Grape::Env::API_ENDPOINT].request
Expand Down
6 changes: 2 additions & 4 deletions lib/grape/middleware/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ def call!(env)

# @abstract
# Called before the application is called in the middleware lifecycle.
def before
end
def before; end

# @abstract
# Called after the application is called in the middleware lifecycle.
# @return [Response, nil] a Rack SPEC response or nil to call the application afterwards.
def after
end
def after; end

def response
return @app_response if @app_response.is_a?(Rack::Response)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/middleware/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def rescuable_by_grape?(klass)
end

def exec_handler(e, &handler)
if handler.lambda? && handler.arity == 0
if handler.lambda? && handler.arity.zero?
instance_exec(&handler)
else
instance_exec(e, &handler)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/middleware/versioner/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def default_options
def before
path = env[Grape::Http::Headers::PATH_INFO].dup

if prefix && path.index(prefix) == 0
if prefix && path.index(prefix).zero?
path.sub!(prefix, '')
path = Grape::Router.normalize_path(path)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def transaction(env)
return response if response && !(cascade = cascade?(response))
end

(!cascade && neighbor) ? call_with_allow_headers(env, neighbor.allow_header, neighbor.endpoint) : nil
!cascade && neighbor ? call_with_allow_headers(env, neighbor.allow_header, neighbor.endpoint) : nil
end

def process_route(route, env)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/router/attribute_translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def to_h
def method_missing(m, *args)
if m[-1] == '='
@attributes[m[0..-1]] = *args
else
elsif m[-1] != '='
@attributes[m]
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/router/pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ def build_path(pattern, anchor: false, suffix: nil, **_options)
pattern << '/' unless pattern.end_with?('/')
pattern << '*path'
end

pattern = pattern.split('/').tap do |parts|
parts[parts.length - 1] = '?' + parts.last
end.join('/') if pattern.end_with?('*path')

pattern + suffix.to_s
end

Expand Down
4 changes: 4 additions & 0 deletions lib/grape/router/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def method_missing(method_id, *arguments)
end
end

def respond_to_missing?(method_id, _)
ROUTE_ATTRIBUTE_REGEXP.match(method_id.to_s)
end

[
:prefix,
:version,
Expand Down
Loading

0 comments on commit 152fa40

Please sign in to comment.