Class: Kojo::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/kojo/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_fileObject (readonly)

Returns the value of attribute config_file.



5
6
7
# File 'lib/kojo/generator.rb', line 5

def config_file
  @config_file
end

#outdirObject (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