Class: Lotus::Generators::Action Private
- Defined in:
- lib/lotus/generators/action.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- ACTION_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\/|\#/
- ROUTE_ENDPOINT_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'#'.freeze
- QUOTED_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/(\"|\'|\\)/
- SUFFIX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'.rb'.freeze
- TEMPLATE_SUFFIX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'.html.'.freeze
- DEFAULT_TEMPLATE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'erb'.freeze
- DEFAULT_HTTP_METHOD =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default HTTP method used when generating an action.
'GET'.freeze
Instance Method Summary collapse
-
#initialize(command) ⇒ Action
constructor
private
A new instance of Action.
- #start ⇒ Object private
Constructor Details
#initialize(command) ⇒ Action
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Action.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/lotus/generators/action.rb', line 41 def initialize(command) super @name = Utils::String.new(name).underscore.gsub(QUOTED_NAME, '') @controller, @action = @name.split(ACTION_SEPARATOR) @controller_name = Utils::String.new(@controller).classify @action_name = Utils::String.new(@action).classify cli.class.source_root(source) end |
Instance Method Details
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/lotus/generators/action.rb', line 54 def start assert_existing_app! assert_action! assert_http_method! opts = { app: app, controller: @controller_name, action: @action_name, action_path: _action_path_without_suffix, relative_action_path: _relative_action_path, relative_view_path: _relative_view_path, view_path: _view_path_without_suffix, template_path: _template_path, } test_type = case [:test] when 'rspec' 'rspec' else 'minitest' end templates = { "action_spec.#{test_type}.tt" => _action_spec_path, } if ![:skip_view] templates.merge!({ 'action.rb.tt' => _action_path, 'view.rb.tt' => _view_path, 'template.tt' => _template_path, "view_spec.#{test_type}.tt" => _view_spec_path, }) else templates.merge!({ 'action_without_view.rb.tt' => _action_path, }) end generate_route templates.each do |src, dst| cli.template(source.join(src), target.join(dst), opts) end end |