Class: PropertiesGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/serverspec_launcher/generators/properties_generator.rb

Overview

Generates the propetires.yml to be used in tests

Instance Method Summary collapse

Constructor Details

#initialize(root_path = nil) ⇒ PropertiesGenerator

Returns a new instance of PropertiesGenerator.



6
7
8
9
10
# File 'lib/serverspec_launcher/generators/properties_generator.rb', line 6

def initialize(root_path = nil)
  path = root_path ? "#{root_path}/" : ''
  @template_path = File.expand_path('../../../../templates', __FILE__)
  @properties_file = "#{path}properties.yaml"
end

Instance Method Details

#generateObject



16
17
18
19
# File 'lib/serverspec_launcher/generators/properties_generator.rb', line 16

def generate
  renderer = ERB.new properties_template
  File.open(@properties_file, 'w') { |file| file.write renderer.result }
end

#properties_templateObject



12
13
14
# File 'lib/serverspec_launcher/generators/properties_generator.rb', line 12

def properties_template
  File.read "#{@template_path}/properties.yaml.erb"
end