rest-api-generator 0.1.4 → 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: 4873b5f52ba8ca76abbc7449e0c0398ee1d38fbfb47ebec80dabb293b3ca0cea
4
- data.tar.gz: bd96d06619b7a14eb9e6b953d60bc6a2f84bb7d48b0cca5181c0a588bb066cba
3
+ metadata.gz: 2856805f0d16c6778be959778e29681c2e6ce306d9b3699e6e766da7f605948b
4
+ data.tar.gz: f9ffabaa5ee380f54ab19a8ad88ddd58de27ee968e44e4ad64794d0110b6979f
5
5
  SHA512:
6
- metadata.gz: 7cd7f1d823c9b0abba38301024eefb393eb460b10a0ff92e41b7f377b401f09f37771afd039701539fd697a4612e0b0a46ef99b6eccf81d118a23e5fff63bfbb
7
- data.tar.gz: dbb337a4c098fdc2b04e71456b5664be8ca670fdd277436cf05111897a7f72ac0559bd47bacf840c6248406aae0e931506e00ad6f3715d9f22da4a9a30984b90
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,6 +79,8 @@ GEM
78
79
  activesupport (>= 3.0)
79
80
  railties (>= 3.0)
80
81
  rspec-rails (>= 2.2)
82
+ anyway_config (2.4.0)
83
+ ruby-next-core (>= 0.14.0)
81
84
  ast (2.4.2)
82
85
  builder (3.2.4)
83
86
  concurrent-ruby (1.1.10)
@@ -91,7 +94,7 @@ GEM
91
94
  date (3.3.3)
92
95
  diff-lcs (1.5.0)
93
96
  erubi (1.12.0)
94
- globalid (1.0.0)
97
+ globalid (1.1.0)
95
98
  activesupport (>= 5.0)
96
99
  i18n (1.12.0)
97
100
  concurrent-ruby (~> 1.0)
@@ -101,7 +104,7 @@ GEM
101
104
  loofah (2.19.1)
102
105
  crass (~> 1.0.2)
103
106
  nokogiri (>= 1.5.9)
104
- mail (2.8.0)
107
+ mail (2.8.1)
105
108
  mini_mime (>= 0.1.1)
106
109
  net-imap
107
110
  net-pop
@@ -109,6 +112,7 @@ GEM
109
112
  marcel (1.0.2)
110
113
  method_source (1.0.0)
111
114
  mini_mime (1.1.2)
115
+ mini_portile2 (2.8.1)
112
116
  minitest (5.16.3)
113
117
  net-imap (0.3.4)
114
118
  date
@@ -119,7 +123,10 @@ GEM
119
123
  timeout
120
124
  net-smtp (0.3.3)
121
125
  net-protocol
122
- nio4r (2.5.8)
126
+ nio4r (2.5.9)
127
+ nokogiri (1.13.10)
128
+ mini_portile2 (~> 2.8.0)
129
+ racc (~> 1.4)
123
130
  nokogiri (1.13.10-x86_64-linux)
124
131
  racc (~> 1.4)
125
132
  parallel (1.22.1)
@@ -218,7 +225,10 @@ GEM
218
225
  rubocop (~> 1.33)
219
226
  rubocop-shopify (2.10.1)
220
227
  rubocop (~> 1.35)
228
+ ruby-next-core (0.15.3)
221
229
  ruby-progressbar (1.11.0)
230
+ sqlite3 (1.5.4)
231
+ mini_portile2 (~> 2.8.0)
222
232
  sqlite3 (1.5.4-x86_64-linux)
223
233
  switchcop (0.1.2)
224
234
  rubocop (~> 1.40.0)
@@ -227,7 +237,7 @@ GEM
227
237
  rubocop-rspec (~> 2.16.0)
228
238
  rubocop-shopify (~> 2.10.1)
229
239
  thor (1.2.1)
230
- timeout (0.3.1)
240
+ timeout (0.3.2)
231
241
  tzinfo (2.0.5)
232
242
  concurrent-ruby (~> 1.0)
233
243
  unicode-display_width (2.3.0)
@@ -237,6 +247,7 @@ GEM
237
247
  zeitwerk (2.6.6)
238
248
 
239
249
  PLATFORMS
250
+ ruby
240
251
  x86_64-linux
241
252
 
242
253
  DEPENDENCIES
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,6 +244,12 @@ 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
 
247
+ #### Configuration for specs
248
+
249
+ By default, the plain rspec and rswag specs are going to be generated in the _spec/requests_ and _spec/docs_
250
+ directories, respectively. You can override using the (config options)[#configuration]]. :
251
+
252
+
246
253
  ### Resource Features
247
254
 
248
255
  #### Modular Error Handler
@@ -287,6 +294,20 @@ And It's done, you can filter your index end-point:
287
294
 
288
295
  - `GET /cars?color=blue or GET /cars?color=red&name=Ferrari`
289
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
+
290
311
  ## Development
291
312
 
292
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]
@@ -5,7 +5,8 @@ module RestApiGenerator
5
5
  attr_accessor :options, :attributes
6
6
 
7
7
  API_CONTROLLER_DIR_PATH = "app/controllers"
8
- API_TEST_DIR_PATH = "spec/requests"
8
+ API_TEST_DIR_PATH = RestApiGenerator.configuration.test_path
9
+ API_DOCS_DIR_PATH = RestApiGenerator.configuration.docs_path
9
10
 
10
11
  private
11
12
 
@@ -39,7 +39,7 @@ module RestApiGenerator
39
39
  end
40
40
 
41
41
  def controller_test_path
42
- "#{API_TEST_DIR_PATH}#{scope_path}/#{file_name.pluralize}_spec.rb"
42
+ "#{API_DOCS_DIR_PATH}#{scope_path}/#{file_name.pluralize}_spec.rb"
43
43
  end
44
44
 
45
45
  def spec_controller_template
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "anyway_config"
4
+
5
+ Anyway::Settings.default_config_path = ->(_name) { Rails.root ? Rails.root.join("config/rest_api_generator.yml") : "" }
6
+
7
+ module RestApiGenerator
8
+ class Config < Anyway::Config
9
+ config_name :rest_api_generator
10
+
11
+ attr_config test_path: "spec/requests",
12
+ docs_path: "spec/docs",
13
+ parent_controller: "RestApiGenerator::ApplicationController"
14
+ end
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.4"
4
+ VERSION = "0.1.6"
5
5
  end
@@ -2,8 +2,8 @@
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"
6
+ require_relative "rest_api_generator/config"
7
7
  require_relative "rest_api_generator/custom_error"
8
8
  require_relative "rest_api_generator/helpers/render"
9
9
  require_relative "rest_api_generator/filterable"
@@ -12,10 +12,13 @@ require_relative "rest_api_generator/orderable"
12
12
  module RestApiGenerator
13
13
  class Error < StandardError; end
14
14
 
15
- def self.parent_controller
16
- "RestApiGenerator::ApplicationController"
15
+ def self.configuration
16
+ @config ||= Config.new
17
+ end
18
+
19
+ def self.configure
20
+ yield(configuration) if block_given?
17
21
  end
18
22
  end
19
23
 
20
- require_relative "rest_api_generator/resource_controller"
21
- 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,6 +37,7 @@ 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"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-api-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
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-01-06 00:00:00.000000000 Z
11
+ date: 2023-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: anyway_config
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -106,6 +120,9 @@ files:
106
120
  - Gemfile.lock
107
121
  - README.md
108
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
109
126
  - bin/console
110
127
  - bin/setup
111
128
  - lib/generators/rest_api_generator/USAGE
@@ -123,14 +140,13 @@ files:
123
140
  - lib/generators/rest_api_generator/templates/rest_api_controller.rb.tt
124
141
  - lib/rest-api-generator.rb
125
142
  - lib/rest_api_generator.rb
126
- - lib/rest_api_generator/application_controller.rb
127
- - lib/rest_api_generator/child_resource_controller.rb
143
+ - lib/rest_api_generator/config.rb
128
144
  - lib/rest_api_generator/custom_error.rb
129
145
  - lib/rest_api_generator/error_handler.rb
130
146
  - lib/rest_api_generator/filterable.rb
131
147
  - lib/rest_api_generator/helpers/render.rb
132
148
  - lib/rest_api_generator/orderable.rb
133
- - lib/rest_api_generator/resource_controller.rb
149
+ - lib/rest_api_generator/rails.rb
134
150
  - lib/rest_api_generator/version.rb
135
151
  - rest-api-generator.gemspec
136
152
  - sig/rest_api_generator.rbs
@@ -158,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
174
  - !ruby/object:Gem::Version
159
175
  version: '0'
160
176
  requirements: []
161
- rubygems_version: 3.3.7
177
+ rubygems_version: 3.3.3
162
178
  signing_key:
163
179
  specification_version: 4
164
180
  summary: Build a Ruby on Rails REST API faster