Class: Ramix::Template
- Inherits:
-
Object
- Object
- Ramix::Template
- Defined in:
- lib/ramix/template.rb
Constant Summary collapse
- DIR_PATH =
File.(File.dirname(__FILE__) + '/../../recipes')
- THOR_CLASS_OPTION =
%w(desc required default aliases type banner group)
- SELF_ATTRIBUTE =
%w(dependence)
- ATTRIBUTE =
THOR_CLASS_OPTION + SELF_ATTRIBUTE
Instance Method Summary collapse
-
#initialize(name, path = nil) ⇒ Template
constructor
A new instance of Template.
- #name ⇒ Object
- #order ⇒ Object
- #output(*args) ⇒ Object
Constructor Details
#initialize(name, path = nil) ⇒ Template
Returns a new instance of Template.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ramix/template.rb', line 11 def initialize(name, path = nil) @name = name @path = path || DIR_PATH begin draft, attribute, @output = File.read( File.join(@path, name + '.rb') ).split('---') @attribute = YAML.load(attribute) rescue @attribute, @output = {}, "\n\ngem '#{name}'" end end |
Instance Method Details
#name ⇒ Object
22 23 24 |
# File 'lib/ramix/template.rb', line 22 def name @attribute['name'] || @name end |
#order ⇒ Object
26 27 28 |
# File 'lib/ramix/template.rb', line 26 def order @attribute['order'] || 0 end |
#output(*args) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/ramix/template.rb', line 38 def output(*args) <<-OUTPUT instance_variable_set '@#{name}', #{args.dup.pop.inspect} #{@output} OUTPUT end |