Class: Kojo::Generator
- Inherits:
-
Object
- Object
- Kojo::Generator
- Defined in:
- lib/kojo/generator.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#outdir ⇒ Object
readonly
Returns the value of attribute outdir.
Instance Method Summary collapse
- #generate(opts = {}) ⇒ Object
-
#initialize(config_file) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(config_file) ⇒ Generator
7 8 9 |
# File 'lib/kojo/generator.rb', line 7 def initialize(config_file) @config_file = config_file end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
5 6 7 |
# File 'lib/kojo/generator.rb', line 5 def config_file @config_file end |
#outdir ⇒ Object (readonly)
Returns the value of attribute outdir.
5 6 7 |
# File 'lib/kojo/generator.rb', line 5 def outdir @outdir end |
Instance Method Details
#generate(opts = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kojo/generator.rb', line 11 def generate(opts={}) base_dir = File.dirname config_file infile = "#{base_dir}/#{config['input']}" config['output'].each do |outfile, config_opts| local_opts = opts.merge config_opts.symbolize_keys output = render infile, local_opts yield outfile, output end end |