class PuppetfileFixturesGenerator::Fixtures

Giant hack of a class because puppetlabs_spec_helper doesn't have a good library implmentation to read .fixtures.yml. If that changes in the future this class will be rewritten.

Public Class Methods

new(fixtures_file, modules = nil, symlink_name = nil) click to toggle source
# File lib/puppetfile_fixtures_generator/fixtures.rb, line 9
def initialize(fixtures_file, modules = nil, symlink_name = nil)
  @fixtures = Pathname.new(fixtures_file)
  @modules = modules
  @module_hash = { 'fixtures' => {} }
  @symlink_name = symlink_name
end

Public Instance Methods

modules_hash() click to toggle source
# File lib/puppetfile_fixtures_generator/fixtures.rb, line 16
def modules_hash
  YAML.safe_load(@fixtures.read)
end
write(fixtures_pn = @fixtures) click to toggle source
# File lib/puppetfile_fixtures_generator/fixtures.rb, line 21
def write(fixtures_pn = @fixtures)
  return 'Cannot write empty modules' if @modules.nil?
  # create hash of modules
  @module_hash['fixtures'] = @modules
  symlink_builder(@symlink_name)
  # convert hash to yaml
  yaml = @module_hash.to_yaml
  # write yaml
  fixtures_pn.write(yaml)
end

Private Instance Methods