Class: Nezu::Generators::Application::AppGenerator
- Inherits:
-
Object
- Object
- Nezu::Generators::Application::AppGenerator
- Includes:
- Nezu::Generators
- Defined in:
- lib/nezu/generators/application/app_generator.rb
Instance Method Summary collapse
- #generate! ⇒ Object
-
#generate_files_from_manifest! ⇒ Object
TODO rewrite so a MANIFEST isn´t needed.
-
#initialize(destination_root) ⇒ AppGenerator
constructor
A new instance of AppGenerator.
- #rename_app_name_template ⇒ Object
Methods included from Nezu::Generators
Constructor Details
#initialize(destination_root) ⇒ AppGenerator
Returns a new instance of AppGenerator.
7 8 9 10 11 12 |
# File 'lib/nezu/generators/application/app_generator.rb', line 7 def initialize(destination_root) Nezu::Config.destination_root = destination_root Nezu::Config.app_name = File.basename(destination_root) name_space = Nezu::Config.app_name.split(/_/).map(&:capitalize).join('').to_sym Nezu::Config.name_space = Object.const_set(name_space, Module.new) unless Object.const_defined?(name_space) end |
Instance Method Details
#generate! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/nezu/generators/application/app_generator.rb', line 14 def generate! raise Nezu::Generators::Application::AppGeneratorError, "\"#{Nezu::Config.destination_root}\" already exists" if Dir.exist?(Nezu::Config.destination_root) FileUtils.mkdir_p(Nezu::Config.destination_root) generate_files_from_manifest! rename_app_name_template end |
#generate_files_from_manifest! ⇒ Object
TODO rewrite so a MANIFEST isn´t needed
26 27 28 29 30 |
# File 'lib/nezu/generators/application/app_generator.rb', line 26 def generate_files_from_manifest! # TODO rewrite so a MANIFEST isn´t needed File.readlines(File.join(File.dirname(__FILE__), 'MANIFEST')).each do |filename| template_to(filename.chomp) end end |
#rename_app_name_template ⇒ Object
21 22 23 24 |
# File 'lib/nezu/generators/application/app_generator.rb', line 21 def rename_app_name_template File.rename(File.join(Nezu::Config.destination_root,'app/consumers/$app_name.rb'), File.join(Nezu::Config.destination_root,"app/consumers/#{Nezu::Config.app_name}.rb")) end |