Class: Rail::Generator
- Inherits:
-
Support::Generator
- Object
- Support::Generator
- Rail::Generator
- Defined in:
- lib/rail/generator.rb
Constant Summary collapse
- FILES =
[ 'app/assets/javascripts/application.js.coffee', 'app/assets/stylesheets/application.css.scss', 'app/helpers/application_helper.rb', 'app/views/layouts/application.html.haml.erb', 'config/application.rb.erb', 'config.ru.erb', 'Gemfile', 'public/favicon.png', 'Rakefile.erb', ]
Instance Attribute Summary
Attributes inherited from Support::Generator
Instance Method Summary collapse
-
#initialize(options) ⇒ Generator
constructor
A new instance of Generator.
- #run ⇒ Object
Methods inherited from Support::Generator
Constructor Details
#initialize(options) ⇒ Generator
Returns a new instance of Generator.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rail/generator.rb', line 18 def initialize() destination = .fetch(:destination) source = File.('../templates', __FILE__) directory = destination.split('/').last || '' project_name = Support::Inflector.titelize(directory) class_name = project_name.gsub(' ', '') @locals = { class_name: class_name, project_name: project_name } raise ArgumentError, 'The project name is invalid.' if class_name.empty? super(destination: destination, source: source) end |
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 |
# File 'lib/rail/generator.rb', line 33 def run if File.directory?(destination) raise ArgumentError, 'The directory already exists.' end process(FILES, @locals) end |