introspective_grape 0.4.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +23 -0
  3. data/.github/workflows/security.yml +32 -0
  4. data/.github/workflows/test.yml +18 -0
  5. data/.rubocop.yml +84 -1173
  6. data/.ruby-version +1 -1
  7. data/CHANGELOG.md +35 -0
  8. data/Gemfile +3 -5
  9. data/README.md +94 -63
  10. data/Rakefile +1 -6
  11. data/introspective_grape.gemspec +63 -51
  12. data/lib/introspective_grape/api.rb +167 -136
  13. data/lib/introspective_grape/camel_snake.rb +5 -3
  14. data/lib/introspective_grape/create_helpers.rb +3 -5
  15. data/lib/introspective_grape/doc.rb +19 -5
  16. data/lib/introspective_grape/filters.rb +98 -83
  17. data/lib/introspective_grape/formatter/camel_json.rb +2 -3
  18. data/lib/introspective_grape/helpers.rb +55 -48
  19. data/lib/introspective_grape/snake_params.rb +1 -2
  20. data/lib/introspective_grape/traversal.rb +56 -54
  21. data/lib/introspective_grape/validators.rb +23 -23
  22. data/lib/introspective_grape/version.rb +3 -1
  23. data/spec/dummy/.ruby-version +1 -0
  24. data/spec/dummy/Gemfile +5 -4
  25. data/spec/dummy/app/api/api_helpers.rb +1 -1
  26. data/spec/dummy/app/api/dummy/company_api.rb +10 -1
  27. data/spec/dummy/app/api/dummy/project_api.rb +1 -0
  28. data/spec/dummy/app/api/dummy/sessions.rb +1 -1
  29. data/spec/dummy/app/api/dummy_api.rb +8 -2
  30. data/spec/dummy/app/assets/config/manifest.js +4 -0
  31. data/spec/dummy/app/models/user.rb +1 -1
  32. data/spec/dummy/config/database.yml +1 -1
  33. data/spec/rails_helper.rb +1 -1
  34. data/spec/requests/company_api_spec.rb +9 -0
  35. metadata +150 -42
  36. data/.coveralls.yml +0 -2
  37. data/.travis.yml +0 -40
  38. data/bin/rails +0 -12
  39. data/gemfiles/Gemfile.rails.5.0.0 +0 -14
  40. data/gemfiles/Gemfile.rails.5.0.1 +0 -14
  41. data/gemfiles/Gemfile.rails.5.1.0 +0 -14
  42. data/gemfiles/Gemfile.rails.5.2.0 +0 -14
  43. data/gemfiles/Gemfile.rails.master +0 -14
@@ -70,7 +70,7 @@ class User < AbstractAdapter
70
70
  end
71
71
 
72
72
  def self.grape_param_types
73
- { "skip_confirmation_email" => Virtus::Attribute::Boolean }
73
+ { "skip_confirmation_email" => Grape::API::Boolean }
74
74
  end
75
75
 
76
76
  def skip_confirmation_email=(s)
@@ -4,7 +4,7 @@
4
4
  default: &default
5
5
  adapter: sqlite3
6
6
  database: ":memory:"
7
- pool: 1
7
+ pool: 5
8
8
  timeout: 5000
9
9
 
10
10
  development:
data/spec/rails_helper.rb CHANGED
@@ -3,7 +3,7 @@ Coveralls.wear!('rails')
3
3
  ENV["RAILS_ENV"] = 'test'
4
4
  require File.expand_path("../dummy/config/environment", __FILE__)
5
5
  require 'rspec/rails'
6
- #require 'byebug'
6
+ require 'byebug'
7
7
  require 'support/request_helpers'
8
8
  require 'support/pundit_helpers'
9
9
  Dir[Rails.root.join("../support/**/*.rb")].each { |f| require f }
@@ -27,6 +27,15 @@ describe Dummy::CompanyAPI, type: :request do
27
27
  json.first['id'].should eq Company.first.id
28
28
  response.headers.slice("X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "X-Offset").values.should eq ["30", "2", "25", "1", "2", "", "0"]
29
29
  end
30
+
31
+ it "should allow pagination in a custom index" do
32
+ Company.destroy_all
33
+ 30.times { Company.make! }
34
+
35
+ get '/api/v1/companies/paginated/list'
36
+ response.should be_successful
37
+ response.headers.slice("X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "X-Offset").values.should eq ["30", "2", "25", "1", "2", "", "0"]
38
+ end
30
39
  end
31
40
 
32
41
  before :all do
metadata CHANGED
@@ -1,63 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: introspective_grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Buermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-29 00:00:00.000000000 Z
11
+ date: 2022-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">"
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: schema_validations
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: 5.0.0
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rack
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "<"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: 2.0.9
47
+ version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "<"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: 2.0.9
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: grape
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - '='
46
60
  - !ruby/object:Gem::Version
47
- version: 1.2.0
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: 1.2.5
61
+ version: 1.6.0
51
62
  type: :runtime
52
63
  prerelease: false
53
64
  version_requirements: !ruby/object:Gem::Requirement
54
65
  requirements:
55
- - - "~>"
66
+ - - '='
56
67
  - !ruby/object:Gem::Version
57
- version: 1.2.0
58
- - - "<"
68
+ version: 1.6.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: dry-types
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
59
74
  - !ruby/object:Gem::Version
60
- version: 1.2.5
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
61
83
  - !ruby/object:Gem::Dependency
62
84
  name: grape-entity
63
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +122,20 @@ dependencies:
100
122
  - - ">="
101
123
  - !ruby/object:Gem::Version
102
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: grape-kaminari
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
103
139
  - !ruby/object:Gem::Dependency
104
140
  name: pundit
105
141
  requirement: !ruby/object:Gem::Requirement
@@ -132,16 +168,16 @@ dependencies:
132
168
  name: sqlite3
133
169
  requirement: !ruby/object:Gem::Requirement
134
170
  requirements:
135
- - - "<"
171
+ - - ">="
136
172
  - !ruby/object:Gem::Version
137
- version: 1.4.0
173
+ version: '0'
138
174
  type: :development
139
175
  prerelease: false
140
176
  version_requirements: !ruby/object:Gem::Requirement
141
177
  requirements:
142
- - - "<"
178
+ - - ">="
143
179
  - !ruby/object:Gem::Version
144
- version: 1.4.0
180
+ version: '0'
145
181
  - !ruby/object:Gem::Dependency
146
182
  name: rspec-rails
147
183
  requirement: !ruby/object:Gem::Requirement
@@ -157,7 +193,7 @@ dependencies:
157
193
  - !ruby/object:Gem::Version
158
194
  version: '3.0'
159
195
  - !ruby/object:Gem::Dependency
160
- name: devise
196
+ name: coveralls_reborn
161
197
  requirement: !ruby/object:Gem::Requirement
162
198
  requirements:
163
199
  - - ">="
@@ -171,19 +207,75 @@ dependencies:
171
207
  - !ruby/object:Gem::Version
172
208
  version: '0'
173
209
  - !ruby/object:Gem::Dependency
174
- name: paperclip
210
+ name: simplecov
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: bundler-audit
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: brakeman
175
239
  requirement: !ruby/object:Gem::Requirement
176
240
  requirements:
177
241
  - - ">="
178
242
  - !ruby/object:Gem::Version
179
- version: 5.2.0
243
+ version: '0'
180
244
  type: :development
181
245
  prerelease: false
182
246
  version_requirements: !ruby/object:Gem::Requirement
183
247
  requirements:
184
248
  - - ">="
185
249
  - !ruby/object:Gem::Version
186
- version: 5.2.0
250
+ version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: rubocop
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
265
+ - !ruby/object:Gem::Dependency
266
+ name: byebug
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
187
279
  - !ruby/object:Gem::Dependency
188
280
  name: machinist_redux
189
281
  requirement: !ruby/object:Gem::Requirement
@@ -199,7 +291,7 @@ dependencies:
199
291
  - !ruby/object:Gem::Version
200
292
  version: '0'
201
293
  - !ruby/object:Gem::Dependency
202
- name: simplecov
294
+ name: paperclip
203
295
  requirement: !ruby/object:Gem::Requirement
204
296
  requirements:
205
297
  - - ">="
@@ -226,19 +318,37 @@ dependencies:
226
318
  - - ">="
227
319
  - !ruby/object:Gem::Version
228
320
  version: '0'
229
- description: Introspectively configure deeply nested RESTful Grape APIs for ActiveRecord
230
- models.
321
+ - !ruby/object:Gem::Dependency
322
+ name: devise
323
+ requirement: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - ">="
326
+ - !ruby/object:Gem::Version
327
+ version: '0'
328
+ type: :development
329
+ prerelease: false
330
+ version_requirements: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - ">="
333
+ - !ruby/object:Gem::Version
334
+ version: '0'
335
+ description: |2
336
+ IntrospectiveGrape provides handling for deeply nested relations according to the models'
337
+ `accepts_nested_attributes_for` declarations, generating all the necessary
338
+ boilerplate for flexible and consistent bulk endpoints on plural associations,
339
+ and building nested routes for the same.
231
340
  email:
232
341
  - buermann@gmail.com
233
342
  executables: []
234
343
  extensions: []
235
344
  extra_rdoc_files: []
236
345
  files:
237
- - ".coveralls.yml"
346
+ - ".github/workflows/lint.yml"
347
+ - ".github/workflows/security.yml"
348
+ - ".github/workflows/test.yml"
238
349
  - ".gitignore"
239
350
  - ".rubocop.yml"
240
351
  - ".ruby-version"
241
- - ".travis.yml"
242
352
  - CHANGELOG.md
243
353
  - Gemfile
244
354
  - MIT-LICENSE
@@ -251,12 +361,6 @@ files:
251
361
  - app/mailers/.keep
252
362
  - app/models/.keep
253
363
  - app/views/.keep
254
- - bin/rails
255
- - gemfiles/Gemfile.rails.5.0.0
256
- - gemfiles/Gemfile.rails.5.0.1
257
- - gemfiles/Gemfile.rails.5.1.0
258
- - gemfiles/Gemfile.rails.5.2.0
259
- - gemfiles/Gemfile.rails.master
260
364
  - introspective_grape.gemspec
261
365
  - lib/introspective_grape.rb
262
366
  - lib/introspective_grape/api.rb
@@ -272,6 +376,7 @@ files:
272
376
  - lib/introspective_grape/validators.rb
273
377
  - lib/introspective_grape/version.rb
274
378
  - lib/tasks/introspective_grape_tasks.rake
379
+ - spec/dummy/.ruby-version
275
380
  - spec/dummy/Gemfile
276
381
  - spec/dummy/README.rdoc
277
382
  - spec/dummy/Rakefile
@@ -287,6 +392,7 @@ files:
287
392
  - spec/dummy/app/api/dummy_api.rb
288
393
  - spec/dummy/app/api/error_handlers.rb
289
394
  - spec/dummy/app/api/permissions_helper.rb
395
+ - spec/dummy/app/assets/config/manifest.js
290
396
  - spec/dummy/app/assets/images/.keep
291
397
  - spec/dummy/app/assets/javascripts/application.js
292
398
  - spec/dummy/app/assets/stylesheets/application.css
@@ -427,19 +533,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
427
533
  requirements:
428
534
  - - ">="
429
535
  - !ruby/object:Gem::Version
430
- version: '2.3'
536
+ version: '2.5'
431
537
  required_rubygems_version: !ruby/object:Gem::Requirement
432
538
  requirements:
433
539
  - - ">="
434
540
  - !ruby/object:Gem::Version
435
541
  version: '0'
436
542
  requirements: []
437
- rubygems_version: 3.1.2
543
+ rubyforge_project:
544
+ rubygems_version: 2.7.3
438
545
  signing_key:
439
546
  specification_version: 4
440
- summary: Introspectively configure deeply nested RESTful Grape APIs for ActiveRecord
441
- models.
547
+ summary: Quickly configure Grape APIs around your database schema and models.
442
548
  test_files:
549
+ - spec/dummy/.ruby-version
443
550
  - spec/dummy/Gemfile
444
551
  - spec/dummy/README.rdoc
445
552
  - spec/dummy/Rakefile
@@ -455,6 +562,7 @@ test_files:
455
562
  - spec/dummy/app/api/dummy_api.rb
456
563
  - spec/dummy/app/api/error_handlers.rb
457
564
  - spec/dummy/app/api/permissions_helper.rb
565
+ - spec/dummy/app/assets/config/manifest.js
458
566
  - spec/dummy/app/assets/images/.keep
459
567
  - spec/dummy/app/assets/javascripts/application.js
460
568
  - spec/dummy/app/assets/stylesheets/application.css
data/.coveralls.yml DELETED
@@ -1,2 +0,0 @@
1
- service_name: travis-ci
2
-
data/.travis.yml DELETED
@@ -1,40 +0,0 @@
1
- language: ruby
2
- before_install:
3
- - gem install bundler -v 1.17.3
4
- install: bundle install --jobs=1 --retry=1
5
- script:
6
- - bundle install
7
- - bundle exec rspec
8
-
9
- rvm:
10
- - 2.3.1
11
- - 2.4.0
12
- - 2.5.0
13
- - ruby-head
14
- - jruby-head
15
- gemfile:
16
- - gemfiles/Gemfile.rails.5.0.1
17
- - gemfiles/Gemfile.rails.5.1.0
18
- - gemfiles/Gemfile.rails.5.2.0
19
- - gemfiles/Gemfile.rails.master
20
-
21
- matrix:
22
- exclude:
23
- - rvm: jruby-9.0.4.0
24
- gemfile: gemfiles/Gemfile.rails.5.0.1
25
- - rvm: jruby-9.0.4.0
26
- gemfile: gemfiles/Gemfile.rails.master
27
- allow_failures:
28
- - rvm: ruby-head
29
- - rvm: jruby-head
30
-
31
- env:
32
- global:
33
- - JRUBY_OPTS="-J-Xmx1024m --debug"
34
-
35
- notifications:
36
- email:
37
- recipients:
38
- - buermann@gmail.com
39
- on_success: change
40
- on_failure: always
data/bin/rails DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
-
4
- ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
- ENGINE_PATH = File.expand_path('../../lib/introspective_grape/engine', __FILE__)
6
-
7
- # Set up gems listed in the Gemfile.
8
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
-
11
- require 'rails/all'
12
- require 'rails/engine/commands'
@@ -1,14 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'rails', '5.0.0'
6
- gem 'grape'
7
- gem 'grape-kaminari', :github => 'alexey-klimuk/grape-kaminari'
8
- gem 'grape-swagger'
9
- gem 'nokogiri'
10
- gem 'coveralls', require: false
11
-
12
- group :development,:test do
13
- gem 'rspec'
14
- end
@@ -1,14 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'rails', '5.0.1'
6
- gem 'grape'
7
- gem 'grape-kaminari', :github => 'alexey-klimuk/grape-kaminari'
8
- gem 'grape-swagger'
9
- gem 'nokogiri'
10
- gem 'coveralls', require: false
11
-
12
- group :development,:test do
13
- gem 'rspec'
14
- end
@@ -1,14 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'rails', '5.1.0'
6
- gem 'grape'
7
- gem 'grape-kaminari', :github => 'alexey-klimuk/grape-kaminari'
8
- gem 'grape-swagger'
9
- gem 'nokogiri'
10
- gem 'coveralls', require: false
11
-
12
- group :development,:test do
13
- gem 'rspec'
14
- end
@@ -1,14 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'rails', '5.2.0'
6
- gem 'grape'
7
- gem 'grape-kaminari', :github => 'alexey-klimuk/grape-kaminari'
8
- gem 'grape-swagger'
9
- gem 'nokogiri'
10
- gem 'coveralls', require: false
11
-
12
- group :development,:test do
13
- gem 'rspec'
14
- end
@@ -1,14 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'rails'
6
- gem 'grape'
7
- gem 'grape-kaminari', :github => 'alexey-klimuk/grape-kaminari'
8
- gem 'grape-swagger'
9
- gem 'nokogiri'
10
- gem 'coveralls', require: false
11
-
12
- group :development,:test do
13
- gem 'rspec'
14
- end