rails_ops 1.4.2 → 1.4.3

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: 545583c613d3f9b9c7599f93af3351790cc5b223ab3c2a8ec3a7962eb4143e2c
4
- data.tar.gz: 9bc1a949fd81b6e05744561f76550ae72ddb8c18795de7dce47a6220ba9622a1
3
+ metadata.gz: dcb574a4ebd4148a9db8bc6ae9e129b015140175352dccb01b0f9eb6e53a4afd
4
+ data.tar.gz: 31322cd290160be87eee75fe5ca3604d7611344f4b77faff2681364a34b166f5
5
5
  SHA512:
6
- metadata.gz: 23c48dbf356b7aa7032d2be737a93e405bd7fd1e63148d28f8c05036cf709a7c20e4951ec76dcfa72e55a71bdcbb5361bb67a29fcd3f13aba45c6b1e52592aec
7
- data.tar.gz: 5e9d9889e87a6a98450aa97d0b24487cfe3526376b1cb05dc0ec90d899b0372a93ca3675485a7491cb23a02fb80644e579355f545ffb5ce23e343af61a8a7e96
6
+ metadata.gz: 81e0839e7d210cc6011868a3ea69bf5dd2714aabe96137ee6109468a00ff69400ccfe6fcc5a52a93c772dad15e3638bd0944ffc073f18f010ebd33f648cae1b1
7
+ data.tar.gz: 1bbc3608339025bd703a5a74a192056f462a5fb756f76531f570cedf754b0d5009d2e69319afc940a1dfc57e38a67fbf1a4fae8f62fb702fc35cb378adcc7825
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## 1.4.2 (2023-03-20)
3
+ ## 1.4.3 (2023-03-27)
4
+
5
+ * Extend the `operation` generator to accept additional flags to skip the
6
+ generation of certain actions. In particular, the `--skip-index`,
7
+ `--skip-show`, `--skip-create`, `--skip-update` and `--skip-destroy` flags
8
+ were added.
9
+
10
+ Internal reference: `#111041`.
11
+
12
+ ## 1.4.2 (2023-03-27)
4
13
 
5
14
  * Update the `operation` generator such that it complies with the naming
6
15
  conventions laid out in [Placing and naming
data/README.md CHANGED
@@ -70,11 +70,11 @@ Requirements & Installation
70
70
 
71
71
  # Define the Operations module
72
72
  module Operations; end
73
-
73
+
74
74
  # Add the folder to the autoloader, but namespaced
75
75
  loader = Rails.autoloaders.main
76
76
  loader.push_dir(app_operations, namespace: Operations)
77
-
77
+
78
78
  # Add the folder to the watched directories (for re-loading in development)
79
79
  Rails.application.config.watchable_dirs.merge!({
80
80
  app_operations => [:rb]
@@ -1674,6 +1674,16 @@ flags:
1674
1674
 
1675
1675
  Or if you want to skip them all: `--only-operations`.
1676
1676
 
1677
+ If you want to skip a certain action, you can do so using the flags:
1678
+ * `--skip-index`
1679
+ * `--skip-show`
1680
+ * `--skip-create`
1681
+ * `--skip-update`
1682
+ * `--skip-destroy`
1683
+
1684
+ This will skip the creation of the respective route, controller action, view file and the operation itself.
1685
+ For `--skip-create`, the `new` action will also be skipped and for `--skip-update`, the `edit` action will be skipped respectively.
1686
+
1677
1687
  You can also add a module as a namespace, all generated files will be put in
1678
1688
  the proper subfolders and modules by using the `--module` option.
1679
1689
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.2
1
+ 1.4.3
@@ -1,12 +1,41 @@
1
1
  class OperationGenerator < Rails::Generators::NamedBase
2
2
  source_root File.expand_path('templates', __dir__)
3
3
 
4
+ class_option :skip_index, type: :boolean, desc: "Don't create the index route / view / controller action"
5
+ class_option :skip_show, type: :boolean, desc: "Don't create the show route / view / controller action and the load operation"
6
+ class_option :skip_create, type: :boolean, desc: "Don't create the new / create route / view / controller action and the create operation"
7
+ class_option :skip_update, type: :boolean, desc: "Don't create the edit / update route / view / controller action and the update operation"
8
+ class_option :skip_destroy, type: :boolean, desc: "Don't create the destroy route / view / controller action and the destroy operation"
4
9
  class_option :skip_controller, type: :boolean, desc: "Don't add a controller."
5
10
  class_option :skip_views, type: :boolean, desc: "Don't add the views."
6
11
  class_option :skip_routes, type: :boolean, desc: "Don't add routes to config/routes.rb."
7
12
  class_option :only_operations, type: :boolean, desc: 'Only add the operations. This is equal to specifying --skip-controller --skip-routes --skip-views'
8
13
  class_option :module, type: :string, desc: 'Add the operations in a module, e.g. "Admin" results in namespacing everything in the Admin module'
9
14
 
15
+ def excluded_actions
16
+ @excluded_actions = []
17
+
18
+ if options[:skip_index]
19
+ @excluded_actions += %i[index]
20
+ end
21
+
22
+ if options[:skip_show]
23
+ @excluded_actions += %i[show]
24
+ end
25
+
26
+ if options[:skip_create]
27
+ @excluded_actions += %i[new create]
28
+ end
29
+
30
+ if options[:skip_update]
31
+ @excluded_actions += %i[edit update]
32
+ end
33
+
34
+ if options[:skip_destroy]
35
+ @excluded_actions += %i[destroy]
36
+ end
37
+ end
38
+
10
39
  def add_operations
11
40
  @class_name = name.classify
12
41
  @underscored_name = @class_name.underscore
@@ -23,10 +52,18 @@ class OperationGenerator < Rails::Generators::NamedBase
23
52
 
24
53
  operations_path += @underscored_name.to_s
25
54
 
26
- template 'load.erb', "#{operations_path}/load.rb"
27
- template 'create.erb', "#{operations_path}/create.rb"
28
- template 'update.erb', "#{operations_path}/update.rb"
29
- template 'destroy.erb', "#{operations_path}/destroy.rb"
55
+ if !@excluded_actions.include?(:show)
56
+ template 'load.erb', "#{operations_path}/load.rb"
57
+ end
58
+ if !@excluded_actions.include?(:create)
59
+ template 'create.erb', "#{operations_path}/create.rb"
60
+ end
61
+ if !@excluded_actions.include?(:update)
62
+ template 'update.erb', "#{operations_path}/update.rb"
63
+ end
64
+ if !@excluded_actions.include?(:destroy)
65
+ template 'destroy.erb', "#{operations_path}/destroy.rb"
66
+ end
30
67
  end
31
68
 
32
69
  def add_controller
@@ -39,7 +76,7 @@ class OperationGenerator < Rails::Generators::NamedBase
39
76
  controller_file_path += "#{@underscored_pluralized_name}_controller.rb"
40
77
  @controller_name = "#{@class_name.pluralize}Controller"
41
78
 
42
- template 'controller.erb', controller_file_path
79
+ template 'controller_wrapper.erb', controller_file_path
43
80
  end
44
81
 
45
82
  def add_views
@@ -51,7 +88,13 @@ class OperationGenerator < Rails::Generators::NamedBase
51
88
  end
52
89
  views_folder += @underscored_pluralized_name.to_s
53
90
 
54
- %w[index show new edit].each do |view|
91
+ actions = %w[index show new edit]
92
+
93
+ @excluded_actions.each do |a|
94
+ actions.delete(a.to_s)
95
+ end
96
+
97
+ actions.each do |view|
55
98
  template 'view.erb', "#{views_folder}/#{view}.html.haml"
56
99
  end
57
100
  end
@@ -59,6 +102,10 @@ class OperationGenerator < Rails::Generators::NamedBase
59
102
  def add_routes
60
103
  return if options[:skip_routes] || options[:only_operations]
61
104
 
62
- route "resources :#{@underscored_pluralized_name}"
105
+ if @excluded_actions.empty?
106
+ route "resources :#{@underscored_pluralized_name}"
107
+ else
108
+ route "resources :#{@underscored_pluralized_name}, except: #{@excluded_actions}"
109
+ end
63
110
  end
64
111
  end
@@ -1,56 +1,67 @@
1
- <%
2
- controller_code = <<-RUBY
3
- class #{@controller_name} < ApplicationController
1
+ class <%=@controller_name%> < ApplicationController
2
+ <% first=true -%>
3
+ <% if !@excluded_actions&.include?(:index) -%>
4
+ <% first=false -%>
4
5
  def index; end
6
+ <% end -%>
7
+ <% if !@excluded_actions&.include?(:show) -%>
8
+ <% if first -%>
9
+ <% first=false -%>
10
+ <% else -%>
5
11
 
12
+ <% end -%>
6
13
  def show
7
- op Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Load
14
+ op Operations<%="::#{@module_name}" if @module_name.present?%>::<%=@class_name%>::Load
8
15
  end
16
+ <% end -%>
17
+ <% if !@excluded_actions&.include?(:create) -%>
18
+ <% if first -%>
19
+ <% first=false -%>
20
+ <% else -%>
9
21
 
22
+ <% end -%>
10
23
  def new
11
- op Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Create
24
+ op Operations<%="::#{@module_name}" if @module_name.present?%>::<%=@class_name%>::Create
12
25
  end
13
26
 
14
27
  def create
15
- if run Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Create
28
+ if run Operations<%="::#{@module_name}" if @module_name.present?%>::<%=@class_name%>::Create
16
29
  # handle successful case
17
30
  else
18
31
  # handle error case
19
32
  end
20
33
  end
34
+ <% end -%>
35
+ <% if !@excluded_actions&.include?(:update) -%>
36
+ <% if first -%>
37
+ <% first=false -%>
38
+ <% else -%>
21
39
 
40
+ <% end -%>
22
41
  def edit
23
- op Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Update
42
+ op Operations<%="::#{@module_name}" if @module_name.present?%>::<%=@class_name%>::Update
24
43
  end
25
44
 
26
45
  def update
27
- if run Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Update
46
+ if run Operations<%="::#{@module_name}" if @module_name.present?%>::<%=@class_name%>::Update
28
47
  # handle successful case
29
48
  else
30
49
  # handle error case
31
50
  end
32
51
  end
52
+ <% end -%>
53
+ <% if !@excluded_actions&.include?(:destroy) -%>
54
+ <% if first -%>
55
+ <% first=false -%>
56
+ <% else -%>
33
57
 
58
+ <% end -%>
34
59
  def destroy
35
- if run Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Destroy
60
+ if run Operations<%="::#{@module_name}" if @module_name.present?%>::<%=@class_name%>::Destroy
36
61
  # handle successful case
37
62
  else
38
63
  # handle error case
39
64
  end
40
65
  end
41
- end
42
- RUBY
43
- -%>
44
- <% if @module_name.present? -%>
45
- module <%= @module_name %>
46
- <% controller_code.split("\n").each do |line| -%>
47
- <% if line.blank? -%>
48
-
49
- <% else -%>
50
- <%= line %>
51
- <% end -%>
52
66
  <% end -%>
53
67
  end
54
- <% else -%>
55
- <%= controller_code -%>
56
- <% end -%>
@@ -0,0 +1,14 @@
1
+ <% controller_template = ERB.new(File.read(File.join(File.dirname(__FILE__), '/controller.erb')), trim_mode: '-').result(binding).strip -%>
2
+ <% if @module_name.present? -%>
3
+ module <%= @module_name %>
4
+ <% controller_template.split("\n").each do |line| -%>
5
+ <% if line.blank? -%>
6
+
7
+ <% else -%>
8
+ <%= line %>
9
+ <% end -%>
10
+ <% end -%>
11
+ end
12
+ <% else -%>
13
+ <%= controller_template %>
14
+ <% end -%>
data/rails_ops.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rails_ops 1.4.2 ruby lib
2
+ # stub: rails_ops 1.4.3 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rails_ops".freeze
6
- s.version = "1.4.2"
6
+ s.version = "1.4.3"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Sitrox".freeze]
11
11
  s.date = "2023-03-27"
12
- s.files = [".github/workflows/rubocop.yml".freeze, ".github/workflows/ruby.yml".freeze, ".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, "Appraisals".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "gemfiles/rails_6.0.gemfile".freeze, "gemfiles/rails_6.1.gemfile".freeze, "gemfiles/rails_7.0.gemfile".freeze, "lib/generators/operation/USAGE".freeze, "lib/generators/operation/operation_generator.rb".freeze, "lib/generators/operation/templates/controller.erb".freeze, "lib/generators/operation/templates/create.erb".freeze, "lib/generators/operation/templates/destroy.erb".freeze, "lib/generators/operation/templates/load.erb".freeze, "lib/generators/operation/templates/update.erb".freeze, "lib/generators/operation/templates/view.erb".freeze, "lib/rails_ops.rb".freeze, "lib/rails_ops/authorization_backend/abstract.rb".freeze, "lib/rails_ops/authorization_backend/can_can_can.rb".freeze, "lib/rails_ops/configuration.rb".freeze, "lib/rails_ops/context.rb".freeze, "lib/rails_ops/controller_mixin.rb".freeze, "lib/rails_ops/exceptions.rb".freeze, "lib/rails_ops/hooked_job.rb".freeze, "lib/rails_ops/hookup.rb".freeze, "lib/rails_ops/hookup/dsl.rb".freeze, "lib/rails_ops/hookup/dsl_validator.rb".freeze, "lib/rails_ops/hookup/hook.rb".freeze, "lib/rails_ops/log_subscriber.rb".freeze, "lib/rails_ops/mixins.rb".freeze, "lib/rails_ops/mixins/authorization.rb".freeze, "lib/rails_ops/mixins/log_settings.rb".freeze, "lib/rails_ops/mixins/model.rb".freeze, "lib/rails_ops/mixins/model/authorization.rb".freeze, "lib/rails_ops/mixins/model/nesting.rb".freeze, "lib/rails_ops/mixins/param_authorization.rb".freeze, "lib/rails_ops/mixins/policies.rb".freeze, "lib/rails_ops/mixins/require_context.rb".freeze, "lib/rails_ops/mixins/routes.rb".freeze, "lib/rails_ops/mixins/schema_validation.rb".freeze, "lib/rails_ops/mixins/sub_ops.rb".freeze, "lib/rails_ops/model_mixins.rb".freeze, "lib/rails_ops/model_mixins/ar_extension.rb".freeze, "lib/rails_ops/model_mixins/marshalling.rb".freeze, "lib/rails_ops/model_mixins/parent_op.rb".freeze, "lib/rails_ops/model_mixins/sti_fixes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes/virtual_column_wrapper.rb".freeze, "lib/rails_ops/model_mixins/virtual_has_one.rb".freeze, "lib/rails_ops/model_mixins/virtual_model_name.rb".freeze, "lib/rails_ops/operation.rb".freeze, "lib/rails_ops/operation/model.rb".freeze, "lib/rails_ops/operation/model/create.rb".freeze, "lib/rails_ops/operation/model/destroy.rb".freeze, "lib/rails_ops/operation/model/load.rb".freeze, "lib/rails_ops/operation/model/update.rb".freeze, "lib/rails_ops/profiler.rb".freeze, "lib/rails_ops/profiler/node.rb".freeze, "lib/rails_ops/railtie.rb".freeze, "lib/rails_ops/scoped_env.rb".freeze, "lib/rails_ops/virtual_model.rb".freeze, "rails_ops.gemspec".freeze, "test/db/models.rb".freeze, "test/db/schema.rb".freeze, "test/dummy/Rakefile".freeze, "test/dummy/app/assets/config/manifest.js".freeze, "test/dummy/app/assets/images/.keep".freeze, "test/dummy/app/assets/javascripts/application.js".freeze, "test/dummy/app/assets/javascripts/cable.js".freeze, "test/dummy/app/assets/javascripts/channels/.keep".freeze, "test/dummy/app/assets/stylesheets/application.css".freeze, "test/dummy/app/channels/application_cable/channel.rb".freeze, "test/dummy/app/channels/application_cable/connection.rb".freeze, "test/dummy/app/controllers/application_controller.rb".freeze, "test/dummy/app/controllers/concerns/.keep".freeze, "test/dummy/app/helpers/application_helper.rb".freeze, "test/dummy/app/jobs/application_job.rb".freeze, "test/dummy/app/mailers/application_mailer.rb".freeze, "test/dummy/app/models/animal.rb".freeze, "test/dummy/app/models/application_record.rb".freeze, "test/dummy/app/models/bird.rb".freeze, "test/dummy/app/models/cat.rb".freeze, "test/dummy/app/models/computer.rb".freeze, "test/dummy/app/models/concerns/.keep".freeze, "test/dummy/app/models/cpu.rb".freeze, "test/dummy/app/models/dog.rb".freeze, "test/dummy/app/models/flower.rb".freeze, "test/dummy/app/models/group.rb".freeze, "test/dummy/app/models/mainboard.rb".freeze, "test/dummy/app/models/nightingale.rb".freeze, "test/dummy/app/models/phoenix.rb".freeze, "test/dummy/app/models/user.rb".freeze, "test/dummy/app/views/layouts/application.html.erb".freeze, "test/dummy/app/views/layouts/mailer.html.erb".freeze, "test/dummy/app/views/layouts/mailer.text.erb".freeze, "test/dummy/bin/bundle".freeze, "test/dummy/bin/rails".freeze, "test/dummy/bin/rake".freeze, "test/dummy/bin/setup".freeze, "test/dummy/bin/update".freeze, "test/dummy/bin/yarn".freeze, "test/dummy/config.ru".freeze, "test/dummy/config/application.rb".freeze, "test/dummy/config/boot.rb".freeze, "test/dummy/config/cable.yml".freeze, "test/dummy/config/database.yml".freeze, "test/dummy/config/environment.rb".freeze, "test/dummy/config/environments/development.rb".freeze, "test/dummy/config/environments/production.rb".freeze, "test/dummy/config/environments/test.rb".freeze, "test/dummy/config/initializers/application_controller_renderer.rb".freeze, "test/dummy/config/initializers/assets.rb".freeze, "test/dummy/config/initializers/backtrace_silencers.rb".freeze, "test/dummy/config/initializers/cookies_serializer.rb".freeze, "test/dummy/config/initializers/filter_parameter_logging.rb".freeze, "test/dummy/config/initializers/inflections.rb".freeze, "test/dummy/config/initializers/mime_types.rb".freeze, "test/dummy/config/initializers/rails_ops.rb".freeze, "test/dummy/config/initializers/wrap_parameters.rb".freeze, "test/dummy/config/locales/en.yml".freeze, "test/dummy/config/puma.rb".freeze, "test/dummy/config/routes.rb".freeze, "test/dummy/config/secrets.yml".freeze, "test/dummy/config/spring.rb".freeze, "test/dummy/db/schema.rb".freeze, "test/dummy/lib/assets/.keep".freeze, "test/dummy/log/.keep".freeze, "test/dummy/package.json".freeze, "test/dummy/public/404.html".freeze, "test/dummy/public/422.html".freeze, "test/dummy/public/500.html".freeze, "test/dummy/public/apple-touch-icon-precomposed.png".freeze, "test/dummy/public/apple-touch-icon.png".freeze, "test/dummy/public/favicon.ico".freeze, "test/dummy/tmp/.keep".freeze, "test/test_helper.rb".freeze, "test/unit/rails_ops/generators/operation_generator_test.rb".freeze, "test/unit/rails_ops/mixins/model/deep_nesting_test.rb".freeze, "test/unit/rails_ops/mixins/param_authorization_test.rb".freeze, "test/unit/rails_ops/mixins/policies_test.rb".freeze, "test/unit/rails_ops/operation/model/create_test.rb".freeze, "test/unit/rails_ops/operation/model/load_test.rb".freeze, "test/unit/rails_ops/operation/model/sti_test.rb".freeze, "test/unit/rails_ops/operation/model/update_test.rb".freeze, "test/unit/rails_ops/operation/model_test.rb".freeze, "test/unit/rails_ops/operation/update_auth_test.rb".freeze, "test/unit/rails_ops/operation/update_lazy_auth_test.rb".freeze, "test/unit/rails_ops/operation_test.rb".freeze]
12
+ s.files = [".github/workflows/rubocop.yml".freeze, ".github/workflows/ruby.yml".freeze, ".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, "Appraisals".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "gemfiles/rails_6.0.gemfile".freeze, "gemfiles/rails_6.1.gemfile".freeze, "gemfiles/rails_7.0.gemfile".freeze, "lib/generators/operation/USAGE".freeze, "lib/generators/operation/operation_generator.rb".freeze, "lib/generators/operation/templates/controller.erb".freeze, "lib/generators/operation/templates/controller_wrapper.erb".freeze, "lib/generators/operation/templates/create.erb".freeze, "lib/generators/operation/templates/destroy.erb".freeze, "lib/generators/operation/templates/load.erb".freeze, "lib/generators/operation/templates/update.erb".freeze, "lib/generators/operation/templates/view.erb".freeze, "lib/rails_ops.rb".freeze, "lib/rails_ops/authorization_backend/abstract.rb".freeze, "lib/rails_ops/authorization_backend/can_can_can.rb".freeze, "lib/rails_ops/configuration.rb".freeze, "lib/rails_ops/context.rb".freeze, "lib/rails_ops/controller_mixin.rb".freeze, "lib/rails_ops/exceptions.rb".freeze, "lib/rails_ops/hooked_job.rb".freeze, "lib/rails_ops/hookup.rb".freeze, "lib/rails_ops/hookup/dsl.rb".freeze, "lib/rails_ops/hookup/dsl_validator.rb".freeze, "lib/rails_ops/hookup/hook.rb".freeze, "lib/rails_ops/log_subscriber.rb".freeze, "lib/rails_ops/mixins.rb".freeze, "lib/rails_ops/mixins/authorization.rb".freeze, "lib/rails_ops/mixins/log_settings.rb".freeze, "lib/rails_ops/mixins/model.rb".freeze, "lib/rails_ops/mixins/model/authorization.rb".freeze, "lib/rails_ops/mixins/model/nesting.rb".freeze, "lib/rails_ops/mixins/param_authorization.rb".freeze, "lib/rails_ops/mixins/policies.rb".freeze, "lib/rails_ops/mixins/require_context.rb".freeze, "lib/rails_ops/mixins/routes.rb".freeze, "lib/rails_ops/mixins/schema_validation.rb".freeze, "lib/rails_ops/mixins/sub_ops.rb".freeze, "lib/rails_ops/model_mixins.rb".freeze, "lib/rails_ops/model_mixins/ar_extension.rb".freeze, "lib/rails_ops/model_mixins/marshalling.rb".freeze, "lib/rails_ops/model_mixins/parent_op.rb".freeze, "lib/rails_ops/model_mixins/sti_fixes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes/virtual_column_wrapper.rb".freeze, "lib/rails_ops/model_mixins/virtual_has_one.rb".freeze, "lib/rails_ops/model_mixins/virtual_model_name.rb".freeze, "lib/rails_ops/operation.rb".freeze, "lib/rails_ops/operation/model.rb".freeze, "lib/rails_ops/operation/model/create.rb".freeze, "lib/rails_ops/operation/model/destroy.rb".freeze, "lib/rails_ops/operation/model/load.rb".freeze, "lib/rails_ops/operation/model/update.rb".freeze, "lib/rails_ops/profiler.rb".freeze, "lib/rails_ops/profiler/node.rb".freeze, "lib/rails_ops/railtie.rb".freeze, "lib/rails_ops/scoped_env.rb".freeze, "lib/rails_ops/virtual_model.rb".freeze, "rails_ops.gemspec".freeze, "test/db/models.rb".freeze, "test/db/schema.rb".freeze, "test/dummy/Rakefile".freeze, "test/dummy/app/assets/config/manifest.js".freeze, "test/dummy/app/assets/images/.keep".freeze, "test/dummy/app/assets/javascripts/application.js".freeze, "test/dummy/app/assets/javascripts/cable.js".freeze, "test/dummy/app/assets/javascripts/channels/.keep".freeze, "test/dummy/app/assets/stylesheets/application.css".freeze, "test/dummy/app/channels/application_cable/channel.rb".freeze, "test/dummy/app/channels/application_cable/connection.rb".freeze, "test/dummy/app/controllers/application_controller.rb".freeze, "test/dummy/app/controllers/concerns/.keep".freeze, "test/dummy/app/helpers/application_helper.rb".freeze, "test/dummy/app/jobs/application_job.rb".freeze, "test/dummy/app/mailers/application_mailer.rb".freeze, "test/dummy/app/models/animal.rb".freeze, "test/dummy/app/models/application_record.rb".freeze, "test/dummy/app/models/bird.rb".freeze, "test/dummy/app/models/cat.rb".freeze, "test/dummy/app/models/computer.rb".freeze, "test/dummy/app/models/concerns/.keep".freeze, "test/dummy/app/models/cpu.rb".freeze, "test/dummy/app/models/dog.rb".freeze, "test/dummy/app/models/flower.rb".freeze, "test/dummy/app/models/group.rb".freeze, "test/dummy/app/models/mainboard.rb".freeze, "test/dummy/app/models/nightingale.rb".freeze, "test/dummy/app/models/phoenix.rb".freeze, "test/dummy/app/models/user.rb".freeze, "test/dummy/app/views/layouts/application.html.erb".freeze, "test/dummy/app/views/layouts/mailer.html.erb".freeze, "test/dummy/app/views/layouts/mailer.text.erb".freeze, "test/dummy/bin/bundle".freeze, "test/dummy/bin/rails".freeze, "test/dummy/bin/rake".freeze, "test/dummy/bin/setup".freeze, "test/dummy/bin/update".freeze, "test/dummy/bin/yarn".freeze, "test/dummy/config.ru".freeze, "test/dummy/config/application.rb".freeze, "test/dummy/config/boot.rb".freeze, "test/dummy/config/cable.yml".freeze, "test/dummy/config/database.yml".freeze, "test/dummy/config/environment.rb".freeze, "test/dummy/config/environments/development.rb".freeze, "test/dummy/config/environments/production.rb".freeze, "test/dummy/config/environments/test.rb".freeze, "test/dummy/config/initializers/application_controller_renderer.rb".freeze, "test/dummy/config/initializers/assets.rb".freeze, "test/dummy/config/initializers/backtrace_silencers.rb".freeze, "test/dummy/config/initializers/cookies_serializer.rb".freeze, "test/dummy/config/initializers/filter_parameter_logging.rb".freeze, "test/dummy/config/initializers/inflections.rb".freeze, "test/dummy/config/initializers/mime_types.rb".freeze, "test/dummy/config/initializers/rails_ops.rb".freeze, "test/dummy/config/initializers/wrap_parameters.rb".freeze, "test/dummy/config/locales/en.yml".freeze, "test/dummy/config/puma.rb".freeze, "test/dummy/config/routes.rb".freeze, "test/dummy/config/secrets.yml".freeze, "test/dummy/config/spring.rb".freeze, "test/dummy/db/schema.rb".freeze, "test/dummy/lib/assets/.keep".freeze, "test/dummy/log/.keep".freeze, "test/dummy/package.json".freeze, "test/dummy/public/404.html".freeze, "test/dummy/public/422.html".freeze, "test/dummy/public/500.html".freeze, "test/dummy/public/apple-touch-icon-precomposed.png".freeze, "test/dummy/public/apple-touch-icon.png".freeze, "test/dummy/public/favicon.ico".freeze, "test/dummy/tmp/.keep".freeze, "test/test_helper.rb".freeze, "test/unit/rails_ops/generators/operation_generator_test.rb".freeze, "test/unit/rails_ops/mixins/model/deep_nesting_test.rb".freeze, "test/unit/rails_ops/mixins/param_authorization_test.rb".freeze, "test/unit/rails_ops/mixins/policies_test.rb".freeze, "test/unit/rails_ops/operation/model/create_test.rb".freeze, "test/unit/rails_ops/operation/model/load_test.rb".freeze, "test/unit/rails_ops/operation/model/sti_test.rb".freeze, "test/unit/rails_ops/operation/model/update_test.rb".freeze, "test/unit/rails_ops/operation/model_test.rb".freeze, "test/unit/rails_ops/operation/update_auth_test.rb".freeze, "test/unit/rails_ops/operation/update_lazy_auth_test.rb".freeze, "test/unit/rails_ops/operation_test.rb".freeze]
13
13
  s.rubygems_version = "3.4.6".freeze
14
14
  s.summary = "An operations service layer for rails projects.".freeze
15
15
  s.test_files = ["test/db/models.rb".freeze, "test/db/schema.rb".freeze, "test/dummy/Rakefile".freeze, "test/dummy/app/assets/config/manifest.js".freeze, "test/dummy/app/assets/images/.keep".freeze, "test/dummy/app/assets/javascripts/application.js".freeze, "test/dummy/app/assets/javascripts/cable.js".freeze, "test/dummy/app/assets/javascripts/channels/.keep".freeze, "test/dummy/app/assets/stylesheets/application.css".freeze, "test/dummy/app/channels/application_cable/channel.rb".freeze, "test/dummy/app/channels/application_cable/connection.rb".freeze, "test/dummy/app/controllers/application_controller.rb".freeze, "test/dummy/app/controllers/concerns/.keep".freeze, "test/dummy/app/helpers/application_helper.rb".freeze, "test/dummy/app/jobs/application_job.rb".freeze, "test/dummy/app/mailers/application_mailer.rb".freeze, "test/dummy/app/models/animal.rb".freeze, "test/dummy/app/models/application_record.rb".freeze, "test/dummy/app/models/bird.rb".freeze, "test/dummy/app/models/cat.rb".freeze, "test/dummy/app/models/computer.rb".freeze, "test/dummy/app/models/concerns/.keep".freeze, "test/dummy/app/models/cpu.rb".freeze, "test/dummy/app/models/dog.rb".freeze, "test/dummy/app/models/flower.rb".freeze, "test/dummy/app/models/group.rb".freeze, "test/dummy/app/models/mainboard.rb".freeze, "test/dummy/app/models/nightingale.rb".freeze, "test/dummy/app/models/phoenix.rb".freeze, "test/dummy/app/models/user.rb".freeze, "test/dummy/app/views/layouts/application.html.erb".freeze, "test/dummy/app/views/layouts/mailer.html.erb".freeze, "test/dummy/app/views/layouts/mailer.text.erb".freeze, "test/dummy/bin/bundle".freeze, "test/dummy/bin/rails".freeze, "test/dummy/bin/rake".freeze, "test/dummy/bin/setup".freeze, "test/dummy/bin/update".freeze, "test/dummy/bin/yarn".freeze, "test/dummy/config.ru".freeze, "test/dummy/config/application.rb".freeze, "test/dummy/config/boot.rb".freeze, "test/dummy/config/cable.yml".freeze, "test/dummy/config/database.yml".freeze, "test/dummy/config/environment.rb".freeze, "test/dummy/config/environments/development.rb".freeze, "test/dummy/config/environments/production.rb".freeze, "test/dummy/config/environments/test.rb".freeze, "test/dummy/config/initializers/application_controller_renderer.rb".freeze, "test/dummy/config/initializers/assets.rb".freeze, "test/dummy/config/initializers/backtrace_silencers.rb".freeze, "test/dummy/config/initializers/cookies_serializer.rb".freeze, "test/dummy/config/initializers/filter_parameter_logging.rb".freeze, "test/dummy/config/initializers/inflections.rb".freeze, "test/dummy/config/initializers/mime_types.rb".freeze, "test/dummy/config/initializers/rails_ops.rb".freeze, "test/dummy/config/initializers/wrap_parameters.rb".freeze, "test/dummy/config/locales/en.yml".freeze, "test/dummy/config/puma.rb".freeze, "test/dummy/config/routes.rb".freeze, "test/dummy/config/secrets.yml".freeze, "test/dummy/config/spring.rb".freeze, "test/dummy/db/schema.rb".freeze, "test/dummy/lib/assets/.keep".freeze, "test/dummy/log/.keep".freeze, "test/dummy/package.json".freeze, "test/dummy/public/404.html".freeze, "test/dummy/public/422.html".freeze, "test/dummy/public/500.html".freeze, "test/dummy/public/apple-touch-icon-precomposed.png".freeze, "test/dummy/public/apple-touch-icon.png".freeze, "test/dummy/public/favicon.ico".freeze, "test/dummy/tmp/.keep".freeze, "test/test_helper.rb".freeze, "test/unit/rails_ops/generators/operation_generator_test.rb".freeze, "test/unit/rails_ops/mixins/model/deep_nesting_test.rb".freeze, "test/unit/rails_ops/mixins/param_authorization_test.rb".freeze, "test/unit/rails_ops/mixins/policies_test.rb".freeze, "test/unit/rails_ops/operation/model/create_test.rb".freeze, "test/unit/rails_ops/operation/model/load_test.rb".freeze, "test/unit/rails_ops/operation/model/sti_test.rb".freeze, "test/unit/rails_ops/operation/model/update_test.rb".freeze, "test/unit/rails_ops/operation/model_test.rb".freeze, "test/unit/rails_ops/operation/update_auth_test.rb".freeze, "test/unit/rails_ops/operation/update_lazy_auth_test.rb".freeze, "test/unit/rails_ops/operation_test.rb".freeze]
@@ -32,6 +32,104 @@ class OperationGeneratorTest < Rails::Generators::TestCase
32
32
  assert_routes
33
33
  end
34
34
 
35
+ def test_no_index_action
36
+ run_generator ['User', '--skip-index']
37
+
38
+ # Check that the index view is not created
39
+ assert_no_file 'app/views/users/index.html.haml'
40
+
41
+ # Check that the index route is not created
42
+ assert_file 'config/routes.rb' do |routes|
43
+ assert_match(/resources :users, except: \[:index\]/, routes)
44
+ end
45
+
46
+ # Check that the controller action is not created
47
+ assert_file 'app/controllers/users_controller.rb' do |controller|
48
+ assert_no_match(/def index/, controller)
49
+ end
50
+ end
51
+
52
+ def test_no_show_action
53
+ run_generator ['User', '--skip-show']
54
+
55
+ # Check that the show view is not created
56
+ assert_no_file 'app/views/users/show.html.haml'
57
+
58
+ # Check that the show route is not created
59
+ assert_file 'config/routes.rb' do |routes|
60
+ assert_match(/resources :users, except: \[:show\]/, routes)
61
+ end
62
+
63
+ # Check that the controller action is not created
64
+ assert_file 'app/controllers/users_controller.rb' do |controller|
65
+ assert_no_match(/def show/, controller)
66
+ end
67
+
68
+ # Check that the load operation is not created
69
+ assert_no_file 'app/operations/users/load.rb'
70
+ end
71
+
72
+ def test_no_create_action
73
+ run_generator ['User', '--skip-create']
74
+
75
+ # Check that the new and create view are not created
76
+ assert_no_file 'app/views/users/new.html.haml'
77
+ assert_no_file 'app/views/users/create.html.haml'
78
+
79
+ # Check that the new, create route is not created
80
+ assert_file 'config/routes.rb' do |routes|
81
+ assert_match(/resources :users, except: \[:new, :create\]/, routes)
82
+ end
83
+
84
+ # Check that the controller actions are not created
85
+ assert_file 'app/controllers/users_controller.rb' do |controller|
86
+ assert_no_match(/def new/, controller)
87
+ assert_no_match(/def create/, controller)
88
+ end
89
+
90
+ # Check that the load operation is not created
91
+ assert_no_file 'app/operations/users/create.rb'
92
+ end
93
+
94
+ def test_no_update_action
95
+ run_generator ['User', '--skip-update']
96
+
97
+ # Check that the edit and update view are not created
98
+ assert_no_file 'app/views/users/edit.html.haml'
99
+ assert_no_file 'app/views/users/update.html.haml'
100
+
101
+ # Check that the edit, update route is not created
102
+ assert_file 'config/routes.rb' do |routes|
103
+ assert_match(/resources :users, except: \[:edit, :update\]/, routes)
104
+ end
105
+
106
+ # Check that the controller actions are not created
107
+ assert_file 'app/controllers/users_controller.rb' do |controller|
108
+ assert_no_match(/def edit/, controller)
109
+ assert_no_match(/def update/, controller)
110
+ end
111
+
112
+ # Check that the load operation is not created
113
+ assert_no_file 'app/operations/users/update.rb'
114
+ end
115
+
116
+ def test_no_destory_action
117
+ run_generator ['User', '--skip-destroy']
118
+
119
+ # Check that the destroy view is not created
120
+ assert_no_file 'app/views/users/destroy.html.haml'
121
+
122
+ # Check that the destroy route is not created
123
+ assert_file 'config/routes.rb' do |routes|
124
+ assert_match(/resources :users, except: \[:destroy\]/, routes)
125
+ end
126
+
127
+ # Check that the controller action is not created
128
+ assert_file 'app/controllers/users_controller.rb' do |controller|
129
+ assert_no_match(/def destroy/, controller)
130
+ end
131
+ end
132
+
35
133
  def test_no_views
36
134
  run_generator ['User', '--skip-views']
37
135
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
@@ -236,6 +236,7 @@ files:
236
236
  - lib/generators/operation/USAGE
237
237
  - lib/generators/operation/operation_generator.rb
238
238
  - lib/generators/operation/templates/controller.erb
239
+ - lib/generators/operation/templates/controller_wrapper.erb
239
240
  - lib/generators/operation/templates/create.erb
240
241
  - lib/generators/operation/templates/destroy.erb
241
242
  - lib/generators/operation/templates/load.erb