Class: DefaultGenerator

Inherits:
RubiGen::Base
  • Object
show all
Defined in:
lib/generators/default/default_generator.rb

Constant Summary collapse

DEFAULT_SHEBANG =
File.join(Config::CONFIG['bindir'],
Config::CONFIG['ruby_install_name'])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ DefaultGenerator

Returns a new instance of DefaultGenerator.



8
9
10
11
12
13
14
# File 'lib/generators/default/default_generator.rb', line 8

def initialize(runtime_args, runtime_options = {})
  super
  usage if args.empty?
  @destination_root = File.expand_path(args.shift)
  @name = base_name
  extract_options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/generators/default/default_generator.rb', line 6

def name
  @name
end

Instance Method Details

#manifestObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/generators/default/default_generator.rb', line 16

def manifest
  record do |m|
    # Ensure appropriate folder(s) exists
    m.directory ''
    BASEDIRS.each { |path| m.directory path }
    m.directory "lib/#{name}"

    # Create stubs
    m.template "config.ru.erb", "config.ru"
    m.template "lib/templates.rb.erb", "lib/#{name}.rb"
    m.template "lib/templates/app.rb.erb", "lib/#{name}/app.rb"

    # rspec stubs
    m.template "spec/spec_helper.rb.erb", "spec/spec_helper.rb"
    m.template "spec/templates_spec.rb.erb", "spec/#{name}_spec.rb"

    %w(LICENSE Rakefile README.md Gemfile).each do |file|
      m.template file, file
    end
    %w(TODO).each do |file|
      m.file file, file
    end
  end
end