lib/simp/rspec-puppet-facts.rb in simp-rspec-puppet-facts-2.0.1 vs lib/simp/rspec-puppet-facts.rb in simp-rspec-puppet-facts-2.1.0
- old
+ new
@@ -1,15 +1,14 @@
-require 'json'
-require 'puppet'
-
module Simp; end
module Simp::RspecPuppetFacts
+ require 'json'
+ require 'puppet'
+
require File.expand_path('version', File.dirname(__FILE__))
SELINUX_MODES = [:enforcing, :disabled, :permissive]
-
def supported_os_strings( opts )
supported_os = opts.fetch(:supported_os, RspecPuppetFacts.meta_supported_os)
hardwaremodels = opts.fetch(:hardwaremodels, ['x86_64'])
os_strings = []
supported_os.each do |os|
@@ -25,11 +24,11 @@
# Don't ask rspec-puppet-facts for operatingsystems we've already recorded
# because if it doesn't have them it will crash
def filter_opts( opts, simp_h, filter_type = :reject )
rfh_hw = opts.fetch(:hardwaremodels, ['x86_64'])
rfh_os = opts.fetch(:supported_os, RspecPuppetFacts.meta_supported_os).dup
- _os = rfh_os.send(filter_type) do |os|
+ _os = rfh_os.send(filter_type) do |os|
_name = os['operatingsystem']
_rels = os['operatingsystemrelease'].send(filter_type) do |rel|
_hw = rfh_hw.send(filter_type) do |hw|
simp_h.key? [_name,rel,hw].map{|x| x.downcase }.join('-')
end
@@ -45,10 +44,10 @@
def on_supported_os( opts = {} )
opts[:selinux_mode] ||= :enforcing
opts[:simp_fact_dir_path] ||= File.expand_path("../../facts/",
File.dirname(__FILE__))
- simp_h = load_facts(opts[:simp_fact_dir_path])
+ simp_h = load_facts(opts[:simp_fact_dir_path])
strings = supported_os_strings(opts)
masked_opts = filter_opts(opts, simp_h, :reject)
selected_opts = filter_opts(opts, simp_h, :select)
rfh_h = Simp::RspecPuppetFacts::Shim.on_supported_os(masked_opts)