Class: Apimaster::Generators::AppGenerator
- Defined in:
- lib/apimaster/generators/app_generator.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
Attributes inherited from Base
#active, #args, #destination_root, #logger, #source_root, #spec, #stdout
Attributes included from Options
Instance Method Summary collapse
-
#initialize(runtime_args, runtime_options = {}) ⇒ AppGenerator
constructor
A new instance of AppGenerator.
- #manifest ⇒ Object
Methods inherited from Create
#class_collisions, #complex_template, #directory, #file, #file_copy_each, #folder, #identical?, #migration_template, #readme, #route_resources, #template, #template_copy_each, #write_manifest
Methods inherited from Command
#class_collisions, #dependency, #destination_path, #invoke!, #readme, #source_path, #write_manifest
Methods inherited from Base
#after_generate, #base_name, #camelize, #destination_path, #pluralize, #run, #source_path
Methods included from Options
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ AppGenerator
Returns a new instance of AppGenerator.
6 7 8 9 10 11 12 13 14 |
# File 'lib/apimaster/generators/app_generator.rb', line 6 def initialize(runtime_args, = {}) super #@destination_root = args.shift #@app_name = File.basename(File.expand_path(@destination_root)) @app_name = args[0] raise 'Undefined app name.' unless @app_name @module_name = camelize(app_name) end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
4 5 6 |
# File 'lib/apimaster/generators/app_generator.rb', line 4 def app_name @app_name end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
4 5 6 |
# File 'lib/apimaster/generators/app_generator.rb', line 4 def module_name @module_name end |
Instance Method Details
#manifest ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/apimaster/generators/app_generator.rb', line 16 def manifest record do |m| # Ensure appropriate folder(s) exists m.directory '' BASEDIRS.each { |path| m.directory(app_name + '/' + path) } m.directory "#{app_name}/lib/#{app_name}" # config templates = { "config/boot.rb.erb" => "config/boot.rb", "config/patches.rb.erb" => "config/patches.rb", "config/initializer.rb.erb" => "config/initializer.rb", "config/application.rb.erb" => "config/application.rb", "config/settings/mongoid.yml.erb" => "config/settings/mongoid.yml", "config/settings/app.yml.erb" => "config/settings/app.yml", "config/settings/oauth.yml.erb" => "config/settings/oauth.yml", # Create stubs "config.ru.erb" => "config.ru", "gitignore" => ".gitignore", "lib/module.rb.erb" => "lib/#{app_name}.rb", "app/tasks/test.rake.erb" => "app/tasks/test.rake", "app/tasks/stat.rake.erb" => "app/tasks/stat.rake", "app/controllers/index_controller.rb.erb" => "app/controllers/index_controller.rb", "app/controllers/befores_controller.rb.erb" => "app/controllers/befores_controller.rb", # Test stubs "test/test_helper.rb.erb" => "test/test_helper.rb" }.each { |k, v| m.template(k, app_name + '/' + v) } %w(LICENSE Rakefile README.md Gemfile TODO test.watchr).each do |file| m.template file, app_name + '/' + file end end end |