Class: SinatraAppGenerator
- Inherits:
-
RubiGen::Base
- Object
- RubiGen::Base
- SinatraAppGenerator
- Defined in:
- lib/generators/sinatra_app/sinatra_app_generator.rb
Constant Summary collapse
- DEFAULT_SHEBANG =
File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(runtime_args, runtime_options = {}) ⇒ SinatraAppGenerator
constructor
A new instance of SinatraAppGenerator.
- #manifest ⇒ Object
- #template(m, filename) ⇒ Object
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ SinatraAppGenerator
Returns a new instance of SinatraAppGenerator.
12 13 14 15 16 17 |
# File 'lib/generators/sinatra_app/sinatra_app_generator.rb', line 12 def initialize(runtime_args, = {}) super usage if args.empty? @destination_root = File.(args.shift) @name = ([:namespace] || base_name).camelize end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/generators/sinatra_app/sinatra_app_generator.rb', line 10 def name @name end |
Instance Method Details
#manifest ⇒ Object
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 51 52 53 54 55 56 57 58 59 |
# File 'lib/generators/sinatra_app/sinatra_app_generator.rb', line 23 def manifest record do |m| # Ensure appropriate folder(s) exists m.directory '' BASEDIRS.each { |path| m.directory path } # root template m, "app.rb" template m, "config.ru" template m, "Gemfile" template m, "Rakefile" # config m.directory "config" template m, "config/test.yml" if use_cucumber? # cucumber m.directory "features/support" m.directory "features/step_definitions" template m, "features/support/env.rb" template m, "features/support/paths.rb" template m, "features/support/blueprints.rb" unless use_rspec? template m, "features/step_definitions/web_steps.rb" end if use_rspec? # rspec m.directory "spec" template m, "spec/spec_helper.rb" m.directory "spec/support" template m, "spec/support/blueprints.rb" m.directory "spec/models" template m, "spec/models/demo_spec.rb" end end end |
#template(m, filename) ⇒ Object
19 20 21 |
# File 'lib/generators/sinatra_app/sinatra_app_generator.rb', line 19 def template(m, filename) m.template "#{filename}.erb", filename end |