Upgrade grape to 1.0

Main feature was the deprication of the Hashie stuff, so the access by
calling keys as method is gone now.
This commit is contained in:
Zeger-Jan van de Weg 2017-08-16 18:06:59 +02:00
parent 374cdda3c0
commit dc8e1676cd
No known key found for this signature in database
GPG key ID: 65F6A8D64A88ABAC
8 changed files with 23 additions and 21 deletions

View file

@ -16,7 +16,7 @@ gem 'mysql2', '~> 0.4.5', group: :mysql
gem 'pg', '~> 0.18.2', group: :postgres gem 'pg', '~> 0.18.2', group: :postgres
gem 'rugged', '~> 0.26.0' gem 'rugged', '~> 0.26.0'
gem 'grape-route-helpers', '~> 2.0.0' gem 'grape-route-helpers', '~> 2.1.0'
gem 'faraday', '~> 0.12' gem 'faraday', '~> 0.12'
@ -76,7 +76,7 @@ gem 'gollum-rugged_adapter', '~> 0.4.4', require: false
gem 'github-linguist', '~> 4.7.0', require: 'linguist' gem 'github-linguist', '~> 4.7.0', require: 'linguist'
# API # API
gem 'grape', '~> 0.19.2' gem 'grape', '~> 1.0'
gem 'grape-entity', '~> 0.6.0' gem 'grape-entity', '~> 0.6.0'
gem 'rack-cors', '~> 0.4.0', require: 'rack/cors' gem 'rack-cors', '~> 0.4.0', require: 'rack/cors'

View file

@ -342,12 +342,9 @@ GEM
signet (~> 0.7) signet (~> 0.7)
gpgme (2.0.13) gpgme (2.0.13)
mini_portile2 (~> 2.1) mini_portile2 (~> 2.1)
grape (0.19.2) grape (1.0.0)
activesupport activesupport
builder builder
hashie (>= 2.1.0)
multi_json (>= 1.3.2)
multi_xml (>= 0.5.2)
mustermann-grape (~> 1.0.0) mustermann-grape (~> 1.0.0)
rack (>= 1.3.0) rack (>= 1.3.0)
rack-accept rack-accept
@ -355,9 +352,9 @@ GEM
grape-entity (0.6.0) grape-entity (0.6.0)
activesupport activesupport
multi_json (>= 1.3.2) multi_json (>= 1.3.2)
grape-route-helpers (2.0.0) grape-route-helpers (2.1.0)
activesupport activesupport
grape (~> 0.16, >= 0.16.0) grape (>= 0.16.0)
rake rake
grpc (1.4.0) grpc (1.4.0)
google-protobuf (~> 3.1) google-protobuf (~> 3.1)
@ -375,7 +372,7 @@ GEM
thor thor
tilt tilt
hashdiff (0.3.4) hashdiff (0.3.4)
hashie (3.5.5) hashie (3.5.6)
hashie-forbidden_attributes (0.1.1) hashie-forbidden_attributes (0.1.1)
hashie (>= 3.0) hashie (>= 3.0)
health_check (2.6.0) health_check (2.6.0)
@ -1035,9 +1032,9 @@ DEPENDENCIES
gon (~> 6.1.0) gon (~> 6.1.0)
google-api-client (~> 0.8.6) google-api-client (~> 0.8.6)
gpgme gpgme
grape (~> 0.19.2) grape (~> 1.0)
grape-entity (~> 0.6.0) grape-entity (~> 0.6.0)
grape-route-helpers (~> 2.0.0) grape-route-helpers (~> 2.1.0)
haml_lint (~> 0.26.0) haml_lint (~> 0.26.0)
hamlit (~> 2.6.1) hamlit (~> 2.6.1)
hashie-forbidden_attributes hashie-forbidden_attributes

View file

@ -0,0 +1,5 @@
---
title: Upgrade grape to 1.0
merge_request:
author:
type: other

View file

@ -290,7 +290,7 @@ module API
def uploaded_file(field, uploads_path) def uploaded_file(field, uploads_path)
if params[field] if params[field]
bad_request!("#{field} is not a file") unless params[field].respond_to?(:filename) bad_request!("#{field} is not a file") unless params[field][:filename]
return params[field] return params[field]
end end

View file

@ -16,9 +16,9 @@ module API
case scope case scope
when String when String
[scope] [scope]
when Hashie::Mash when ::Hash
scope.values scope.values
when Hashie::Array when ::Array
scope scope
else else
['unknown'] ['unknown']

View file

@ -57,7 +57,7 @@ module API
end end
get "templates/licenses" do get "templates/licenses" do
options = { options = {
featured: declared(params).popular.present? ? true : nil featured: declared(params)[:popular].present? ? true : nil
} }
licences = ::Kaminari.paginate_array(Licensee::License.all(options)) licences = ::Kaminari.paginate_array(Licensee::License.all(options))
present paginate(licences), with: Entities::RepoLicense present paginate(licences), with: Entities::RepoLicense
@ -71,7 +71,7 @@ module API
requires :name, type: String, desc: 'The name of the template' requires :name, type: String, desc: 'The name of the template'
end end
get "templates/licenses/:name", requirements: { name: /[\w\.-]+/ } do get "templates/licenses/:name", requirements: { name: /[\w\.-]+/ } do
not_found!('License') unless Licensee::License.find(declared(params).name) not_found!('License') unless Licensee::License.find(declared(params)[:name])
template = parsed_license_template template = parsed_license_template
@ -102,7 +102,7 @@ module API
requires :name, type: String, desc: 'The name of the template' requires :name, type: String, desc: 'The name of the template'
end end
get "templates/#{template_type}/:name" do get "templates/#{template_type}/:name" do
new_template = klass.find(declared(params).name) new_template = klass.find(declared(params)[:name])
render_response(template_type, new_template) render_response(template_type, new_template)
end end

View file

@ -16,7 +16,7 @@ module API
coerce_with: ->(scope) { coerce_with: ->(scope) {
if scope.is_a?(String) if scope.is_a?(String)
[scope] [scope]
elsif scope.is_a?(Hashie::Mash) elsif scope.is_a?(::Hash)
scope.values scope.values
else else
['unknown'] ['unknown']

View file

@ -59,7 +59,7 @@ module API
end end
get route do get route do
options = { options = {
featured: declared(params).popular.present? ? true : nil featured: declared(params)[:popular].present? ? true : nil
} }
present Licensee::License.all(options), with: ::API::Entities::RepoLicense present Licensee::License.all(options), with: ::API::Entities::RepoLicense
end end
@ -76,7 +76,7 @@ module API
requires :name, type: String, desc: 'The name of the template' requires :name, type: String, desc: 'The name of the template'
end end
get route, requirements: { name: /[\w\.-]+/ } do get route, requirements: { name: /[\w\.-]+/ } do
not_found!('License') unless Licensee::License.find(declared(params).name) not_found!('License') unless Licensee::License.find(declared(params)[:name])
template = parsed_license_template template = parsed_license_template
@ -111,7 +111,7 @@ module API
requires :name, type: String, desc: 'The name of the template' requires :name, type: String, desc: 'The name of the template'
end end
get route do get route do
new_template = klass.find(declared(params).name) new_template = klass.find(declared(params)[:name])
render_response(template_type, new_template) render_response(template_type, new_template)
end end