Class: Cramp::Generators::Application
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Cramp::Generators::Application
- Includes:
- Thor::Actions
- Defined in:
- lib/cramp/generators/application.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_config ⇒ Object
- #create_home_action ⇒ Object
- #create_models ⇒ Object
- #create_root ⇒ Object
- #create_root_files ⇒ Object
-
#initialize(*args) ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize(*args) ⇒ Application
Returns a new instance of Application.
15 16 17 18 19 |
# File 'lib/cramp/generators/application.rb', line 15 def initialize(*args) raise Thor::Error, "No application name supplied. Please run: cramp --help" if args[0].blank? super end |
Class Method Details
.banner ⇒ Object
25 26 27 |
# File 'lib/cramp/generators/application.rb', line 25 def self. "cramp new #{self.arguments.map(&:usage).join(' ')} [options]" end |
.source_root ⇒ Object
21 22 23 |
# File 'lib/cramp/generators/application.rb', line 21 def self.source_root @_source_root ||= File.join(File.dirname(__FILE__), "templates/application") end |
Instance Method Details
#create_config ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/cramp/generators/application.rb', line 46 def create_config empty_directory "config" inside "config" do template "routes.rb" template 'database.yml' if active_record? end end |
#create_home_action ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/cramp/generators/application.rb', line 55 def create_home_action empty_directory "app/actions" inside "app/actions" do template "home_action.rb" end end |
#create_models ⇒ Object
63 64 65 66 67 |
# File 'lib/cramp/generators/application.rb', line 63 def create_models if active_record? empty_directory "app/models" end end |
#create_root ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/cramp/generators/application.rb', line 29 def create_root self.destination_root = File.(application_path, destination_root) valid_const? empty_directory '.' FileUtils.cd(destination_root) end |
#create_root_files ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/cramp/generators/application.rb', line 37 def create_root_files template 'config.ru' template 'Gemfile' template 'application.rb' empty_directory "public" empty_directory "public/javascripts" end |