Sha256: eceb38efa6491336134cb1ee8ad68373340d924fa153fcdad7c6637b7c334c63
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
require 'facter' require 'json' module RspecPuppetFacts def on_supported_os( opts = {} ) opts[:hardwaremodels] ||= ['x86_64'] opts[:supported_os] ||= RspecPuppetFacts.meta_supported_os h = {} opts[:supported_os].map do |os_sup| operatingsystem = os_sup['operatingsystem'].downcase os_sup['operatingsystemrelease'].map do |operatingsystemmajrelease| opts[:hardwaremodels].each do |hardwaremodel| facts = {} os = "#{operatingsystem}-#{operatingsystemmajrelease.split(" ")[0]}-#{hardwaremodel}" # TODO: use SemVer here facter_minor_version = Facter.version[0..2] file = File.expand_path(File.join(File.dirname(__FILE__), "../facts/#{facter_minor_version}/#{os}.facts")) if ! File.file?(file) fail StandardError, "Can't find facts for '#{os}' for facter #{facter_minor_version}" end File.read(file).each_line do |line| key, value = line.split(' => ') facts[key.to_sym] = value.chomp unless value.nil? end h[os] = facts end end end h end # @api private def self.meta_supported_os @meta_supported_os ||= get_meta_supported_os end # @api private def self.get_meta_supported_os metadata = get_metadata if metadata['operatingsystem_support'].nil? fail StandardError, "Unknown operatingsystem support" end metadata['operatingsystem_support'] end # @api private def self.get_metadata if ! File.file?('metadata.json') fail StandardError, "Can't find metadata.json... dunno why" end metadata = JSON.parse(File.read('metadata.json')) if metadata.nil? fail StandardError, "Metadata is empty" end metadata end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-puppet-facts-0.2.4 | lib/rspec-puppet-facts.rb |