Class: Padrino::Generators::Decorator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Padrino::Generators::Decorator
- Includes:
- Actions, Thor::Actions
- Defined in:
- lib/generators/decorator.rb
Overview
Responsible for the generating decorators and associated tests within a Padrino application.
Class Method Summary collapse
-
.banner ⇒ Object
Defines the banner for this CLI generator.
-
.source_root ⇒ Object
Define the source template root.
Instance Method Summary collapse
-
#create_decorator ⇒ Object
private
Execute decorator generation.
Methods included from Actions
#apply_test_component_for_decorator_by
Class Method Details
.banner ⇒ Object
Defines the banner for this CLI generator
16 |
# File 'lib/generators/decorator.rb', line 16 def self.; "padrino-gen decorator [name]"; end |
.source_root ⇒ Object
Define the source template root
14 |
# File 'lib/generators/decorator.rb', line 14 def self.source_root; File.(File.dirname(__FILE__)); end |
Instance Method Details
#create_decorator ⇒ 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.
Execute decorator generation
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/decorator.rb', line 36 def create_decorator self.destination_root = [:root] if in_app_root? app = [:app] check_app_existence(app) inject_into_file(destination_root(app, "app.rb"), " register Padrino::Decorator::Helpers\n", :after => "Padrino::Application\n") self.behavior = :revoke if [:destroy] @object_name = name.to_s.underscore @project_name = [:namespace].underscore.camelize @project_name = fetch_project_name(app) if @project_name.empty? @app_name = fetch_app_name(app) template 'templates/decorator.rb.tt', destination_root(app, 'decorators', "#{@object_name}_decorator.rb") if test? choice = fetch_component_choice(:test) apply_test_component_for_decorator_by choice generate_decorator_test(name) end else say 'You are not at the root of a Padrino application! (config/boot.rb not found)' end end |