Class: Bosh::PluginGenerator::Generator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, options = {}) ⇒ Generator

Returns a new instance of Generator.



8
9
10
11
# File 'lib/bosh/plugin_generator/generator.rb', line 8

def initialize(context, options = {})
  @options = options
  @context = context
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



7
8
9
# File 'lib/bosh/plugin_generator/generator.rb', line 7

def context
  @context
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/bosh/plugin_generator/generator.rb', line 7

def options
  @options
end

Instance Method Details

#generate(source, target) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/bosh/plugin_generator/generator.rb', line 13

def generate(source, target)
  folder = File.dirname(target)
  FileUtils.mkdir_p(folder)
  template = File.read(File.join(source_folder, source))
  result = Erubis::Eruby.new(template).result(context)
  File.write(target, result)
end