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.
/\/|\#/
- 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
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.
27 28 29 30 31 32 33 34 35 |
# File 'lib/lotus/generators/action.rb', line 27 def initialize(command) super @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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/lotus/generators/action.rb', line 39 def start assert_existing_app! opts = { app: app, controller: @controller_name, action: @action_name, action_path: _action_path_without_suffix, view_path: _view_path_without_suffix, template_path: _template_path, } templates = { 'action.rb.tt' => _action_path, 'view.rb.tt' => _view_path, 'template.tt' => _template_path } case [:test] when 'rspec' templates.merge!({ 'action_spec.rspec.tt' => _action_spec_path, 'view_spec.rspec.tt' => _view_spec_path, }) else templates.merge!({ 'action_spec.minitest.tt' => _action_spec_path, 'view_spec.minitest.tt' => _view_spec_path, }) end generate_route templates.each do |src, dst| cli.template(source.join(src), target.join(dst), opts) end end |