Class: Lotus::Generators::Action Private

Inherits:
Abstract
  • Object
show all
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.

Since:

  • 0.3.0

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.

Since:

  • 0.3.0

/\/|\#/
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.

Since:

  • 0.3.0

'.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.

Since:

  • 0.3.0

'.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.

Since:

  • 0.3.0

'erb'.freeze

Instance Method Summary collapse

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.

Since:

  • 0.3.0



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

#startObject

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.

Since:

  • 0.3.0



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 options[: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