rest-api-generator 0.1.5 → 0.1.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
  SHA256:
3
- metadata.gz: 04727c112f46dd53f0ab7b45c0e83c13ddd3ae2df45fed5b3aa89cf7fac6efa4
4
- data.tar.gz: 8de60fa55662ef20a6390af3da742c5873e3a2499598790afe759e0afae00352
3
+ metadata.gz: 2856805f0d16c6778be959778e29681c2e6ce306d9b3699e6e766da7f605948b
4
+ data.tar.gz: f9ffabaa5ee380f54ab19a8ad88ddd58de27ee968e44e4ad64794d0110b6979f
5
5
  SHA512:
6
- metadata.gz: 585ad32f866f1e0374dd6051c91ee898a382ed67b1995c511536e3548ed25cc0731725980570ef814d9782d73803b94fd78183af5eee137ed8a054cfb3ab2850
7
- data.tar.gz: 68aedf154d0f0b0472cc082d5cbf8ec47e2276070a60963aa8ab58cbb827221fcde13c709e4d7dcd3341ac6a7787a9373fd7564d904b0595aabd165f009ac41e
6
+ metadata.gz: e92f35591532264731ac9acd69117082954c1ac342a89f298d40c60a11dfee9b02b9f2bc5f9e75251ced9937929d900bbfc8491a00b070220bed04c73f81f014
7
+ data.tar.gz: 5914b7f9b6eb86efbf11ffb1497db57fa9ffec03ce9d4978cfae19e3d6425c52b5ab2fdc564c7baf3ec5acad478ec9d86cbccef19be253389176aee8bb7a2a3c
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rest-api-generator (0.1.4)
4
+ rest-api-generator (0.1.5)
5
+ anyway_config (>= 2.0.0)
5
6
  rails (>= 5.0)
6
7
 
7
8
  GEM
@@ -78,7 +79,7 @@ GEM
78
79
  activesupport (>= 3.0)
79
80
  railties (>= 3.0)
80
81
  rspec-rails (>= 2.2)
81
- anyway_config (2.3.1)
82
+ anyway_config (2.4.0)
82
83
  ruby-next-core (>= 0.14.0)
83
84
  ast (2.4.2)
84
85
  builder (3.2.4)
@@ -93,7 +94,7 @@ GEM
93
94
  date (3.3.3)
94
95
  diff-lcs (1.5.0)
95
96
  erubi (1.12.0)
96
- globalid (1.0.0)
97
+ globalid (1.1.0)
97
98
  activesupport (>= 5.0)
98
99
  i18n (1.12.0)
99
100
  concurrent-ruby (~> 1.0)
@@ -103,7 +104,7 @@ GEM
103
104
  loofah (2.19.1)
104
105
  crass (~> 1.0.2)
105
106
  nokogiri (>= 1.5.9)
106
- mail (2.8.0)
107
+ mail (2.8.1)
107
108
  mini_mime (>= 0.1.1)
108
109
  net-imap
109
110
  net-pop
@@ -111,6 +112,7 @@ GEM
111
112
  marcel (1.0.2)
112
113
  method_source (1.0.0)
113
114
  mini_mime (1.1.2)
115
+ mini_portile2 (2.8.1)
114
116
  minitest (5.16.3)
115
117
  net-imap (0.3.4)
116
118
  date
@@ -121,7 +123,10 @@ GEM
121
123
  timeout
122
124
  net-smtp (0.3.3)
123
125
  net-protocol
124
- nio4r (2.5.8)
126
+ nio4r (2.5.9)
127
+ nokogiri (1.13.10)
128
+ mini_portile2 (~> 2.8.0)
129
+ racc (~> 1.4)
125
130
  nokogiri (1.13.10-x86_64-linux)
126
131
  racc (~> 1.4)
127
132
  parallel (1.22.1)
@@ -222,6 +227,8 @@ GEM
222
227
  rubocop (~> 1.35)
223
228
  ruby-next-core (0.15.3)
224
229
  ruby-progressbar (1.11.0)
230
+ sqlite3 (1.5.4)
231
+ mini_portile2 (~> 2.8.0)
225
232
  sqlite3 (1.5.4-x86_64-linux)
226
233
  switchcop (0.1.2)
227
234
  rubocop (~> 1.40.0)
@@ -230,7 +237,7 @@ GEM
230
237
  rubocop-rspec (~> 2.16.0)
231
238
  rubocop-shopify (~> 2.10.1)
232
239
  thor (1.2.1)
233
- timeout (0.3.1)
240
+ timeout (0.3.2)
234
241
  tzinfo (2.0.5)
235
242
  concurrent-ruby (~> 1.0)
236
243
  unicode-display_width (2.3.0)
@@ -245,7 +252,6 @@ PLATFORMS
245
252
 
246
253
  DEPENDENCIES
247
254
  ammeter (~> 1.1.5)
248
- anyway_config (>= 2.0.0)
249
255
  database_cleaner
250
256
  rake (~> 13.0)
251
257
  rest-api-generator!
data/README.md CHANGED
@@ -24,6 +24,7 @@ Following [Switch Dreams's](https://www.switchdreams.com.br/]) coding practices,
24
24
  - :memo: [Automated documentation](#specsdocs)
25
25
  - [Resource ordering](#ordering)
26
26
  - [Resource filter](#filtering)
27
+ - [Configurable](#configuration)
27
28
 
28
29
  ## Next Features
29
30
 
@@ -243,19 +244,11 @@ This spec options work as generators too, so you can call them individually:
243
244
  rails g rest_api_generator:spec:rswag Car name:string color:string
244
245
  ```
245
246
 
246
- ##### Custom paths
247
+ #### Configuration for specs
247
248
 
248
249
  By default, the plain rspec and rswag specs are going to be generated in the _spec/requests_ and _spec/docs_
249
- directories, respectively. You can override this configuration with an initializer inside your project:
250
+ directories, respectively. You can override using the (config options)[#configuration]]. :
250
251
 
251
- ```rb
252
- # config/initializers/rest_api_generator.rb
253
-
254
- RestApiGenerator.configure do |config|
255
- config.test_path = "custom_test_dir/requests"
256
- config.docs_path = "custom_docs_dir/rswag"
257
- end
258
- ```
259
252
 
260
253
  ### Resource Features
261
254
 
@@ -301,6 +294,20 @@ And It's done, you can filter your index end-point:
301
294
 
302
295
  - `GET /cars?color=blue or GET /cars?color=red&name=Ferrari`
303
296
 
297
+ ## Configuration
298
+
299
+ You can override this gem configuration using the initializer or any other method from [anyway_config](https://github.com/palkan/anyway_config):
300
+
301
+ ```rb
302
+ # config/initializers/rest_api_generator.rb
303
+
304
+ RestApiGenerator.configure do |config|
305
+ config.test_path = "custom_test_dir/requests" # default: spec/requests
306
+ config.docs_path = "custom_docs_dir/rswag" # default: spec/docs
307
+ config.parent_class = "ApplicationController" # default: RestApiGenerator::ResourceController
308
+ end
309
+ ```
310
+
304
311
  ## Development
305
312
 
306
313
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RestApiGenerator
4
- class ChildResourceController < RestApiGenerator.parent_controller.constantize
4
+ class ChildResourceController < RestApiGenerator.configuration.parent_controller.constantize
5
5
  include Orderable
6
6
 
7
7
  before_action :set_parent_resource
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RestApiGenerator
4
- class ResourceController < RestApiGenerator.parent_controller.constantize
4
+ class ResourceController < RestApiGenerator.configuration.parent_controller.constantize
5
5
  include Orderable
6
6
 
7
7
  before_action :set_resource, only: [:show, :update, :destroy]
@@ -2,10 +2,14 @@
2
2
 
3
3
  require "anyway_config"
4
4
 
5
+ Anyway::Settings.default_config_path = ->(_name) { Rails.root ? Rails.root.join("config/rest_api_generator.yml") : "" }
6
+
5
7
  module RestApiGenerator
6
8
  class Config < Anyway::Config
7
9
  config_name :rest_api_generator
8
10
 
9
- attr_config test_path: "spec/requests", docs_path: "spec/docs"
11
+ attr_config test_path: "spec/requests",
12
+ docs_path: "spec/docs",
13
+ parent_controller: "RestApiGenerator::ApplicationController"
10
14
  end
11
15
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RestApiGenerator
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RestApiGenerator
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "rails"
4
4
  require_relative "rest_api_generator/version"
5
- require_relative "rest_api_generator/application_controller"
6
5
  require_relative "rest_api_generator/error_handler"
7
6
  require_relative "rest_api_generator/config"
8
7
  require_relative "rest_api_generator/custom_error"
@@ -13,20 +12,13 @@ require_relative "rest_api_generator/orderable"
13
12
  module RestApiGenerator
14
13
  class Error < StandardError; end
15
14
 
16
- class << self
17
- def configuration
18
- @configuration ||= Config.new
19
- end
20
-
21
- def configure
22
- yield(configuration)
23
- end
15
+ def self.configuration
16
+ @config ||= Config.new
24
17
  end
25
18
 
26
- def self.parent_controller
27
- "RestApiGenerator::ApplicationController"
19
+ def self.configure
20
+ yield(configuration) if block_given?
28
21
  end
29
22
  end
30
23
 
31
- require_relative "rest_api_generator/resource_controller"
32
- require_relative "rest_api_generator/child_resource_controller"
24
+ require "rest_api_generator/rails" if defined?(Rails)
@@ -22,8 +22,13 @@ Gem::Specification.new do |spec|
22
22
  spec.metadata["source_code_uri"] = "https://github.com/SwitchDreams/rest-api-generator"
23
23
  spec.metadata["changelog_uri"] = "https://github.com/SwitchDreams/rest-api-generator"
24
24
 
25
- spec.files = Dir["{bin,sig,lib,public}/**/*", "MIT-LICENSE", "Rakefile", "README.md", "rest-api-generator.gemspec",
26
- "Gemfile", "Gemfile.lock"]
25
+ spec.files = Dir["{bin,sig,lib,public,app}/**/*",
26
+ "MIT-LICENSE",
27
+ "Rakefile",
28
+ "README.md",
29
+ "rest-api-generator.gemspec",
30
+ "Gemfile",
31
+ "Gemfile.lock"]
27
32
  spec.bindir = "exe"
28
33
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
34
  spec.require_paths = ["lib"]
@@ -32,10 +37,10 @@ Gem::Specification.new do |spec|
32
37
  # guide at: https://bundler.io/guides/creating_gem.html
33
38
  spec.metadata["rubygems_mfa_required"] = "true"
34
39
 
40
+ spec.add_dependency "anyway_config", ">= 2.0.0"
35
41
  spec.add_dependency "rails", ">= 5.0"
36
42
 
37
43
  spec.add_development_dependency "ammeter", "~> 1.1.5"
38
- spec.add_development_dependency "anyway_config", ">= 2.0.0"
39
44
  spec.add_development_dependency "database_cleaner"
40
45
  spec.add_development_dependency "rspec-rails", "~> 6.0.0"
41
46
  spec.add_development_dependency "rswag"
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-api-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - PedroAugustoRamalhoDuarte
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-27 00:00:00.000000000 Z
11
+ date: 2023-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: anyway_config
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: ammeter
28
+ name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.5
34
- type: :development
33
+ version: '5.0'
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.5
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: anyway_config
42
+ name: ammeter
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0
47
+ version: 1.1.5
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0
54
+ version: 1.1.5
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: database_cleaner
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +120,9 @@ files:
120
120
  - Gemfile.lock
121
121
  - README.md
122
122
  - Rakefile
123
+ - app/controllers/rest_api_generator/application_controller.rb
124
+ - app/controllers/rest_api_generator/child_resource_controller.rb
125
+ - app/controllers/rest_api_generator/resource_controller.rb
123
126
  - bin/console
124
127
  - bin/setup
125
128
  - lib/generators/rest_api_generator/USAGE
@@ -137,15 +140,13 @@ files:
137
140
  - lib/generators/rest_api_generator/templates/rest_api_controller.rb.tt
138
141
  - lib/rest-api-generator.rb
139
142
  - lib/rest_api_generator.rb
140
- - lib/rest_api_generator/application_controller.rb
141
- - lib/rest_api_generator/child_resource_controller.rb
142
143
  - lib/rest_api_generator/config.rb
143
144
  - lib/rest_api_generator/custom_error.rb
144
145
  - lib/rest_api_generator/error_handler.rb
145
146
  - lib/rest_api_generator/filterable.rb
146
147
  - lib/rest_api_generator/helpers/render.rb
147
148
  - lib/rest_api_generator/orderable.rb
148
- - lib/rest_api_generator/resource_controller.rb
149
+ - lib/rest_api_generator/rails.rb
149
150
  - lib/rest_api_generator/version.rb
150
151
  - rest-api-generator.gemspec
151
152
  - sig/rest_api_generator.rbs