Class: PropertiesGenerator
- Inherits:
-
Object
- Object
- PropertiesGenerator
- Defined in:
- lib/serverspec_launcher/generators/properties_generator.rb
Overview
Generates the propetires.yml to be used in tests
Instance Method Summary collapse
- #full_properties_template ⇒ Object
- #generate ⇒ Object
-
#initialize(root_path = nil) ⇒ PropertiesGenerator
constructor
A new instance of PropertiesGenerator.
- #properties_template ⇒ Object
Constructor Details
#initialize(root_path = nil) ⇒ PropertiesGenerator
Returns a new instance of PropertiesGenerator.
6 7 8 9 10 11 |
# File 'lib/serverspec_launcher/generators/properties_generator.rb', line 6 def initialize(root_path = nil) path = root_path ? "#{root_path}/" : '' @template_path = File.('../../../../templates', __FILE__) @properties_file = "#{path}properties.yml" @full_properties_file = "#{path}properties.full.example.yml" end |
Instance Method Details
#full_properties_template ⇒ Object
17 18 19 |
# File 'lib/serverspec_launcher/generators/properties_generator.rb', line 17 def full_properties_template File.read "#{@template_path}/properties.yaml.erb" end |
#generate ⇒ Object
21 22 23 24 25 |
# File 'lib/serverspec_launcher/generators/properties_generator.rb', line 21 def generate renderer = ERB.new properties_template File.open(@properties_file, 'w') { |file| file.write renderer.result } unless File.exists? @properties_file File.open(@full_properties_file, 'w') { |file| file.write renderer.result } unless File.exists? @full_properties_file end |
#properties_template ⇒ Object
13 14 15 |
# File 'lib/serverspec_launcher/generators/properties_generator.rb', line 13 def properties_template File.read "#{@template_path}/properties-light.yaml.erb" end |