Class: Merb::GeneratorBase

Inherits:
RubiGen::Base
  • Object
show all
Includes:
GeneratorHelpers
Defined in:
lib/merb-gen/base.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GeneratorHelpers

#copy_dirs, #copy_files, #interpolate_path, #relative

Constructor Details

#initialize(args, runtime_options = {}) ⇒ GeneratorBase

Returns a new instance of GeneratorBase.



12
13
14
15
16
17
18
# File 'lib/merb-gen/base.rb', line 12

def initialize(args, runtime_options = {})
  super
  usage if args.empty?
  self.class.use_component_sources! Merb.generator_scope
  @destination_root = Dir.pwd
  @choices ||= []
end

Instance Attribute Details

#assignsObject (readonly)

Returns the value of attribute assigns.



5
6
7
# File 'lib/merb-gen/base.rb', line 5

def assigns
  @assigns
end

#baseObject (readonly)

Returns the value of attribute base.



5
6
7
# File 'lib/merb-gen/base.rb', line 5

def base
  @base
end

#choicesObject (readonly)

Returns the value of attribute choices.



5
6
7
# File 'lib/merb-gen/base.rb', line 5

def choices
  @choices
end

#mObject (readonly)

Returns the value of attribute m.



5
6
7
# File 'lib/merb-gen/base.rb', line 5

def m
  @m
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/merb-gen/base.rb', line 5

def name
  @name
end

Instance Method Details

#manifestObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/merb-gen/base.rb', line 20

def manifest
  record do |m|
    @m = m
    
    options["spec"] = true unless options["test"]

    # Set directories that should be optional based on command-line args
    @choices = %w(test spec)
    
    # Set the assigns that should be used for path-interpolation and building templates
    @assigns = {:base_name => File.basename(@name), :test_type => options["spec"] ? "rspec" : "test_unit"}
    
    FileUtils.mkdir_p @name 
    copy_dirs
    copy_files

    display_framework_selections
  end
end