introspective_grape 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a3c90f61cd6c0cfcc681b4c4c37f1b888bfe7fd
4
- data.tar.gz: 26e6dcb9a96899eaaf5c298d9ffe7c48e6d43ea4
3
+ metadata.gz: daa5779c5e6121c36862f5c3158c1b8d5cf5ebdd
4
+ data.tar.gz: d48b10b855364975e10bb605ef4a005cd9231dac
5
5
  SHA512:
6
- metadata.gz: a11bec2f1cde26753b08898c14ba54339f6a984be48f1eea1090c4f585146d2db4c35980481852f02b4f1c1a78090a7ff0da25238dd4b27da76281c1ae0e9080
7
- data.tar.gz: d1e1a33bbab8952ca376c1ebc52a9c55c379405698c2479af8898500ff924437578fedb37b1743dc3494674fa5fc6b81d8486d7dfbbcb2637515afe05c2e51e2
6
+ metadata.gz: b96dcd7acfecfbc9e84b05560f878bbbbab5eecf7c2deb5072551449ccb64dea6c5171585782ebf5274915c71bc95288984d9cf496979cd864466f78d326dfd1
7
+ data.tar.gz: 9d73edaf90c44038289bae9dd5f8391519830f9646cbef922d4a0a28a9b0d425c1b29cf6ca2a685eddc0ce0c10eef4f941fec39963b09d6d0e9f6e56e9c4742f
@@ -1,77 +1,53 @@
1
1
  language: ruby
2
2
  before_install:
3
- - gem install bundler
3
+ - gem install bundler -v 1.17.3
4
4
  install: bundle install --jobs=1 --retry=1
5
5
  script:
6
6
  - bundle install
7
7
  - bundle exec rspec
8
8
 
9
9
  rvm:
10
- - 2.0.0
11
- - 2.1.0
12
- - 2.2.0
13
- - 2.2.6
14
- - 2.3.0
10
+ # - 2.0.0
11
+ # - 2.1.0
12
+ - 2.2.2
13
+ - 2.3.1
15
14
  - 2.4.0
16
15
  - ruby-head
17
16
  - jruby-head
18
17
  gemfile:
19
18
  # - gemfiles/Gemfile.rails.3.2.22
20
19
  # - gemfiles/Gemfile.rails.4.1.13
21
- - gemfiles/Gemfile.rails.4.2.7.1
22
- - gemfiles/Gemfile.rails.4.2.7.1.new.swagger
23
- - gemfiles/Gemfile.rails.4.2.8
20
+ # - gemfiles/Gemfile.rails.4.2.7.1
21
+ # - gemfiles/Gemfile.rails.4.2.7.1.new.swagger
22
+ # - gemfiles/Gemfile.rails.4.2.8
23
+ # - gemfiles/Gemfile.rails.5.0.0
24
24
  - gemfiles/Gemfile.rails.5.0.1
25
+ - gemfiles/Gemfile.rails.5.1.0
26
+ - gemfiles/Gemfile.rails.5.2.0
25
27
  - gemfiles/Gemfile.rails.master
28
+ - gemfiles/Gemfile.6.0.0.beta
26
29
 
27
30
  matrix:
28
31
  exclude:
29
32
  # We'll have to back up to grape-swagger 0.11 for earlier rubies.
30
- - rvm: 2.0.0
31
- gemfile: gemfiles/Gemfile.rails.4.2.7.1.new.swagger
32
- - rvm: 2.0.0
33
- gemfile: gemfiles/Gemfile.rails.4.2.8
34
33
  - rvm: 2.0.0
35
34
  gemfile: gemfiles/Gemfile.rails.5.0.1
36
35
  - rvm: 2.0.0
37
36
  gemfile: gemfiles/Gemfile.rails.master
38
- - rvm: 2.1.0
39
- gemfile: gemfiles/Gemfile.rails.4.2.7.1.new.swagger
40
- - rvm: 2.1.0
41
- gemfile: gemfiles/Gemfile.rails.4.2.8
42
37
  - rvm: 2.1.0
43
38
  gemfile: gemfiles/Gemfile.rails.5.0.1
44
39
  - rvm: 2.1.0
45
40
  gemfile: gemfiles/Gemfile.rails.master
46
- - rvm: 2.2.0
47
- gemfile: gemfiles/Gemfile.rails.4.2.7.1.new.swagger
48
- - rvm: 2.2.0
49
- gemfile: gemfiles/Gemfile.rails.4.2.8
50
41
  - rvm: 2.2.0
51
42
  gemfile: gemfiles/Gemfile.rails.5.0.1
52
43
  - rvm: 2.2.0
53
44
  gemfile: gemfiles/Gemfile.rails.master
54
- - rvm: 2.4.0
55
- gemfile: gemfiles/Gemfile.rails.4.2.7.1
56
- - rvm: 2.4.0
57
- gemfile: gemfiles/Gemfile.rails.4.2.7.1.new.swagger
58
- - rvm: jruby-9.0.4.0
59
- gemfile: gemfiles/Gemfile.rails.4.2.7.1.new.swagger
60
- - rvm: jruby-9.0.4.0
61
- gemfile: gemfiles/Gemfile.rails.4.2.8
62
45
  - rvm: jruby-9.0.4.0
63
46
  gemfile: gemfiles/Gemfile.rails.5.0.1
64
47
  - rvm: jruby-9.0.4.0
65
48
  gemfile: gemfiles/Gemfile.rails.master
66
- - rvm: ruby-head
67
- gemfile: gemfiles/Gemfile.rails.4.2.7.1
68
- - rvm: ruby-head
69
- gemfile: gemfiles/Gemfile.rails.4.2.7.1.new.swagger
70
- - rvm: jruby-head
71
- gemfile: gemfiles/Gemfile.rails.4.2.7.1
72
- - rvm: jruby-head
73
- gemfile: gemfiles/Gemfile.rails.4.2.7.1.new.swagger
74
49
  allow_failures:
50
+ - gemfile: gemfiles/Gemfile.6.0.0.beta1
75
51
  - rvm: ruby-head
76
52
  - rvm: jruby-head
77
53
 
@@ -1,4 +1,11 @@
1
1
 
2
+ 0.3.6 09/14/2018
3
+ ================
4
+
5
+ Updated to support Rails 5+
6
+
7
+
8
+
2
9
  0.3.5 09/14/2018
3
10
  ================
4
11
 
@@ -6,7 +6,7 @@ source 'https://rubygems.org'
6
6
 
7
7
  gemspec :path => '../'
8
8
 
9
- gem 'grape'
9
+ gem 'grape', '< 1.0.0'
10
10
  gem 'grape-swagger'
11
11
  gem 'coveralls', require: false
12
12
 
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../'
4
+
5
+ gem 'rails', '4.2.10'
6
+ gem 'grape', '> 0.17'
7
+ gem 'grape-swagger', '> 0.12.0'
8
+ gem 'coveralls', require: false
9
+
10
+ group :development,:test do
11
+ gem 'rspec'
12
+ end
@@ -6,6 +6,7 @@ gem 'rails', '4.2.7.1'
6
6
  gem 'grape', '< 0.17'
7
7
  gem 'grape-swagger', '< 0.12.0'
8
8
  gem 'nokogiri', '< 1.6.9'
9
+ gem 'machinist'
9
10
  gem 'coveralls', require: false
10
11
 
11
12
  group :development,:test do
@@ -5,6 +5,7 @@ gemspec :path => '../'
5
5
  gem 'rails', '4.2.7.1'
6
6
  gem 'grape', '> 0.17'
7
7
  gem 'grape-swagger', '> 0.12.0'
8
+ gem 'machinist'
8
9
  gem 'coveralls', require: false
9
10
 
10
11
  group :development,:test do
@@ -5,6 +5,8 @@ gemspec :path => '../'
5
5
  gem 'rails', '4.2.8'
6
6
  gem 'grape', '> 0.17'
7
7
  gem 'grape-swagger', '> 0.12.0'
8
+ gem 'machinist'
9
+ gem 'nokogiri', '< 1.10.1'
8
10
  gem 'coveralls', require: false
9
11
 
10
12
  group :development,:test do
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../'
4
+
5
+ gem 'rails', '5.0.0'
6
+ gem 'grape', '< 1.0.0'
7
+ gem 'grape-swagger'
8
+ gem 'nokogiri'
9
+ gem 'coveralls', require: false
10
+
11
+ group :development,:test do
12
+ gem 'rspec'
13
+ end
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec :path => '../'
4
4
 
5
5
  gem 'rails', '5.0.1'
6
- gem 'grape'
6
+ gem 'grape', '< 1.0.0'
7
7
  gem 'grape-swagger'
8
8
  gem 'nokogiri'
9
9
  gem 'coveralls', require: false
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../'
4
+
5
+ gem 'rails', '5.1.0'
6
+ gem 'grape', '< 1.0.0'
7
+ gem 'grape-swagger'
8
+ gem 'nokogiri'
9
+ gem 'coveralls', require: false
10
+
11
+ group :development,:test do
12
+ gem 'rspec'
13
+ end
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../'
4
+
5
+ gem 'rails', '5.2.0'
6
+ gem 'grape', '< 1.0.0'
7
+ gem 'grape-swagger'
8
+ gem 'nokogiri'
9
+ gem 'coveralls', require: false
10
+
11
+ group :development,:test do
12
+ gem 'rspec'
13
+ end
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../'
4
+
5
+ gem 'rails', '6.0.0.beta1'
6
+ gem 'grape', '< 1.0.0'
7
+ gem 'grape-swagger'
8
+ gem 'nokogiri'
9
+ gem 'coveralls', require: false
10
+
11
+ group :development,:test do
12
+ gem 'rspec'
13
+ end
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec :path => '../'
4
4
 
5
5
  gem 'rails'
6
- gem 'grape'
6
+ gem 'grape', '< 1.0.0'
7
7
  gem 'grape-swagger'
8
8
  gem 'nokogiri'
9
9
  gem 'coveralls', require: false
@@ -18,25 +18,25 @@ Gem::Specification.new do |s|
18
18
  s.files = `git ls-files`.split("\n").sort
19
19
  s.test_files = `git ls-files -- spec/*`.split("\n")
20
20
 
21
- s.required_ruby_version = '~> 2.0'
21
+ s.required_ruby_version = '~> 2.1'
22
22
 
23
- # not yet 5+ compatible
24
- s.add_dependency "rails", '>= 3.0.0', '<5.0'
23
+ s.add_dependency "rails", '> 5.0.0'
25
24
 
26
- s.add_dependency 'grape' #, '~> 0.16.2'
27
- s.add_dependency 'grape-entity' #, '< 0.5.0'
28
- s.add_dependency 'grape-swagger' #, '~>0.11.0'
29
- s.add_dependency 'kaminari', '< 1.0' # There's a version 1.0.0 out there that breaks everything
25
+ # grape 1.0.0 breaks the pagination solution
26
+ s.add_dependency 'grape', '< 1.0.0'
27
+ s.add_dependency 'grape-entity'
28
+ s.add_dependency 'grape-swagger'
29
+ s.add_dependency 'kaminari', '< 1.0' # version 1.0.0 breaks
30
30
  s.add_dependency 'grape-kaminari'
31
31
  # Pundit 2.0 mysteriously made authorize a protected method...
32
- s.add_dependency 'pundit', '<2.0'
32
+ s.add_dependency 'pundit' #, '<2.0'
33
33
  s.add_dependency 'camel_snake_keys', '>0.0.4'
34
34
 
35
35
  if RUBY_PLATFORM == 'java'
36
36
  #s.add_development_dependency "jdbc-sqlite3"
37
37
  s.add_development_dependency "activerecord-jdbcsqlite3-adapter"
38
38
  else
39
- s.add_development_dependency "sqlite3"
39
+ s.add_development_dependency "sqlite3", '<1.4.0' #'< 1.3.14'
40
40
  end
41
41
 
42
42
  #s.add_development_dependency "byebug"
@@ -44,8 +44,8 @@ Gem::Specification.new do |s|
44
44
  s.add_development_dependency "rspec-rails", '>= 3.0'
45
45
  s.add_development_dependency 'devise'
46
46
  #s.add_development_dependency 'devise-async'
47
- s.add_development_dependency 'paperclip', '< 5.0'
48
- s.add_development_dependency 'machinist'
47
+ s.add_development_dependency 'paperclip', ">= 5.2.0" #'< 5.0'
48
+ s.add_development_dependency 'machinist_redux'
49
49
  s.add_development_dependency 'simplecov'
50
50
  s.add_development_dependency 'rufus-mnemo'
51
51
 
@@ -125,6 +125,34 @@ module IntrospectiveGrape
125
125
  end
126
126
  end
127
127
 
128
+ def convert_nested_params_hash(dsl, routes)
129
+ root = routes.first
130
+ klass = root.klass
131
+ dsl.after_validation do
132
+ # After Grape validates its parameters:
133
+ # 1) Find the root model instance for the API if its passed (implicitly either
134
+ # an update/destroy on the root node or it's a nested route
135
+ # 2) For nested endpoints convert the params hash into Rails-compliant nested
136
+ # attributes, to be passed to the root instance for update. This keeps
137
+ # behavior consistent between bulk and single record updates.
138
+
139
+ if params[root.key]
140
+ @model = root.model.includes( klass.default_includes(root.model) ).find(params[root.key])
141
+ end
142
+
143
+ if routes.size > 1
144
+ nested_attributes = klass.build_nested_attributes(routes[1..-1], params.except(root.key,:api_key) )
145
+ @params.merge!( nested_attributes ) if nested_attributes.kind_of?(Hash)
146
+ end
147
+ end
148
+ end
149
+
150
+ def define_restful_api(dsl, routes, model, api_params)
151
+ # declare index, show, update, create, and destroy methods:
152
+ API_ACTIONS.each do |action|
153
+ send("define_#{action}", dsl, routes, model, api_params) unless exclude_actions(model).include?(action)
154
+ end
155
+ end
128
156
 
129
157
  def define_endpoints(routes,api_params)
130
158
  # De-reference these as local variables from their class scope, or when we make
@@ -145,13 +173,6 @@ module IntrospectiveGrape
145
173
  end
146
174
  end
147
175
 
148
- def define_restful_api(dsl, routes, model, api_params)
149
- # declare index, show, update, create, and destroy methods:
150
- API_ACTIONS.each do |action|
151
- send("define_#{action}", dsl, routes, model, api_params) unless exclude_actions(model).include?(action)
152
- end
153
- end
154
-
155
176
  def define_index(dsl, routes, model, api_params)
156
177
  include Grape::Kaminari
157
178
  root = routes.first
@@ -244,28 +265,6 @@ module IntrospectiveGrape
244
265
  end
245
266
  end
246
267
 
247
- def convert_nested_params_hash(dsl, routes)
248
- root = routes.first
249
- klass = root.klass
250
- dsl.after_validation do
251
- # After Grape validates its parameters:
252
- # 1) Find the root model instance for the API if its passed (implicitly either
253
- # an update/destroy on the root node or it's a nested route
254
- # 2) For nested endpoints convert the params hash into Rails-compliant nested
255
- # attributes, to be passed to the root instance for update. This keeps
256
- # behavior consistent between bulk and single record updates.
257
-
258
- if params[root.key]
259
- @model = root.model.includes( klass.default_includes(root.model) ).find(params[root.key])
260
- end
261
-
262
- if routes.size > 1
263
- nested_attributes = klass.build_nested_attributes(routes[1..-1], params.except(root.key,:api_key) )
264
- @params.merge!( nested_attributes ) if nested_attributes.kind_of?(Hash)
265
- end
266
- end
267
- end
268
-
269
268
 
270
269
  def build_routes(routes, model, reflection_name=nil)
271
270
  routes = routes.clone
@@ -5,49 +5,48 @@ require 'active_support/inflector/methods'
5
5
  if IntrospectiveGrape.config.camelize_parameters
6
6
  # Camelize the parameters in the swagger documentation.
7
7
  if Gem::Version.new( GrapeSwagger::VERSION ) <= Gem::Version.new('0.11.0')
8
- Grape::API.class_eval do
9
- class << self
10
- private
11
- def create_documentation_class_with_camelized
12
- doc = create_documentation_class_without_camelized
13
- doc.class_eval do
14
- class << self
15
- def parse_params_with_camelized(params, path, method, _options = {})
16
- parsed_params = parse_params_without_camelized(params, path, method)
17
- parsed_params.each_with_index do |param|
18
- param[:name] = param[:name]
19
- .camelize(:lower)
20
- .gsub(/Destroy/,'_destroy')
21
- end
22
- parsed_params
23
- end
8
+ module ParseParamsWithCamelized
9
+ def parse_params(params, path, method, _options = {})
10
+ parsed_params = parse_params_without_camelized(params, path, method)
11
+ parsed_params.each_with_index do |param|
12
+ param[:name] = param[:name]
13
+ .camelize(:lower)
14
+ .gsub(/Destroy/,'_destroy')
15
+ end
16
+ super(params, path, method, _options = {})
17
+ end
18
+ end
24
19
 
25
- alias_method_chain :parse_params, :camelized
26
- end
27
- end
28
- doc
20
+ module CreateCamelizedDocumentationClass
21
+ private
22
+ def create_documentation_class
23
+ doc = super
24
+ doc.class_eval do
25
+ doc.singleton_class.send(:prepend, ParseParamsWithCamelized)
29
26
  end
30
- alias_method_chain :create_documentation_class, :camelized
27
+ doc
31
28
  end
32
29
  end
30
+
31
+ Grape::API.singleton_class.send(:prepend, CreateCamelizedDocumentationClass)
33
32
  else
33
+ module CallWithCamelized
34
+ def call(*args)
35
+ param = super(*args)
36
+ param[:name] = param[:name].camelize(:lower).gsub(/Destroy/, '_destroy')
37
+ param
38
+ end
39
+ end
40
+
41
+ GrapeSwagger::DocMethods::ParseParams.singleton_class.send(:prepend, CallWithCamelized)
34
42
  module GrapeSwagger
35
43
  module DocMethods
36
44
  def self.extended(mod)
37
45
  # Do not camelize the grape-swagger documentation endpoints.
38
46
  mod.formatter :json, Grape::Formatter::Json
39
47
  end
40
- class ParseParams
41
- class << self
42
- def call_with_camelized(*args)
43
- param = call_without_camelized(*args)
44
- param[:name] = param[:name].camelize(:lower).gsub(/Destroy/, '_destroy')
45
- param
46
- end
47
- alias_method_chain :call, :camelized
48
- end
49
- end
50
48
  end
51
49
  end
52
50
  end
51
+
53
52
  end