@@ -58,16 +58,14 @@ def on_supported_os(opts = {})
5858 # @api private
5959 def on_supported_os_implementation ( opts = { } )
6060 unless /\A \d +\. \d +(?:\. \d +)*\z / . match? ( ( facterversion = opts [ :facterversion ] ) )
61- raise ArgumentError , ":facterversion must be in the format 'n.n' or " \
62- "'n.n.n' (n is numeric), not '#{ facterversion } '"
61+ raise ArgumentError , ":facterversion must be in the format 'n.n' or 'n.n.n' (n is numeric), not '#{ facterversion } '"
6362 end
6463
6564 filter = [ ]
6665 opts [ :supported_os ] . map do |os_sup |
6766 if os_sup [ 'operatingsystemrelease' ]
6867 Array ( os_sup [ 'operatingsystemrelease' ] ) . map do |operatingsystemmajrelease |
6968 opts [ :hardwaremodels ] . each do |hardwaremodel |
70-
7169 os_release_filter = "/^#{ Regexp . escape ( operatingsystemmajrelease . split ( ' ' ) [ 0 ] ) } /"
7270 case os_sup [ 'operatingsystem' ]
7371 when /BSD/i
@@ -119,7 +117,9 @@ def on_supported_os_implementation(opts = {})
119117 # facter data (see FacterDB 0.5.2 for Facter releases 3.8 and 3.9). In this situation we need to
120118 # cycle through and downgrade Facter versions per platform type until we find matching Facter data.
121119 filter . each do |filter_spec |
122- versions = FacterDB . get_facts ( filter_spec , symbolize_keys : !RSpec . configuration . facterdb_string_keys ) . to_h { |facts | [ Gem ::Version . new ( facts [ :facterversion ] ) , facts ] }
120+ versions = FacterDB . get_facts ( filter_spec , symbolize_keys : !RSpec . configuration . facterdb_string_keys ) . to_h do |facts |
121+ [ Gem ::Version . new ( facts [ :facterversion ] ) , facts ]
122+ end
123123
124124 version , facts = versions . select { |v , _f | strict_requirement =~ v } . max_by { |v , _f | v }
125125
@@ -150,6 +150,7 @@ def on_supported_os_implementation(opts = {})
150150
151151 os = "#{ os_fact [ 'name' ] . downcase } -#{ os_fact [ 'release' ] [ 'major' ] } -#{ os_fact [ 'hardware' ] } "
152152 next if RspecPuppetFacts . spec_facts_os_filter && !os . start_with? ( RspecPuppetFacts . spec_facts_os_filter )
153+
153154 facts . merge! RspecPuppetFacts . common_facts
154155 os_facts_hash [ os ] = RspecPuppetFacts . with_custom_facts ( os , facts )
155156 end
@@ -191,7 +192,7 @@ def add_custom_fact(name, value, options = {})
191192 def self . register_custom_fact ( name , value , options )
192193 @custom_facts ||= { }
193194 name = RSpec . configuration . facterdb_string_keys ? name . to_s : name . to_sym
194- @custom_facts [ name ] = { options : options , value : value }
195+ @custom_facts [ name ] = { options : options , value : value }
195196 end
196197
197198 # Adds any custom facts according to the rules defined for the operating
@@ -210,7 +211,7 @@ def self.with_custom_facts(os, facts)
210211 value = fact [ :value ] . respond_to? ( :call ) ? fact [ :value ] . call ( os , facts ) : fact [ :value ]
211212 # if merge_facts passed, merge supplied facts into facts hash
212213 if fact [ :options ] [ :merge_facts ]
213- facts . deep_merge! ( { name => value } )
214+ facts . deep_merge! ( { name => value } )
214215 else
215216 facts [ name ] = value
216217 end
@@ -249,6 +250,7 @@ def self.spec_facts_strict?
249250 # @return [Hash <Symbol => String>]
250251 def self . common_facts
251252 return @common_facts if @common_facts
253+
252254 @common_facts = {
253255 puppetversion : Puppet . version ,
254256 rubysitedir : RbConfig ::CONFIG [ 'sitelibdir' ] ,
@@ -295,6 +297,7 @@ def self.mcollective?
295297 # @api private
296298 def self . meta_supported_os
297299 raise StandardError , 'Unknown operatingsystem support in the metadata file!' unless metadata [ 'operatingsystem_support' ] . is_a? Array
300+
298301 metadata [ 'operatingsystem_support' ]
299302 end
300303
@@ -306,6 +309,7 @@ def self.meta_supported_os
306309 def self . metadata
307310 return @metadata if @metadata
308311 raise StandardError , "Can't find metadata.json... dunno why" unless File . file? metadata_file
312+
309313 content = File . read metadata_file
310314 @metadata = JSON . parse content
311315 end
@@ -411,8 +415,6 @@ def self.facter_version_for_puppet_version(puppet_version)
411415end
412416
413417RSpec . configure do |c |
414- c . add_setting :default_facter_version ,
415- default : RspecPuppetFacts . facter_version_for_puppet_version ( Puppet . version )
416- c . add_setting :facterdb_string_keys ,
417- default : false
418+ c . add_setting :default_facter_version , default : RspecPuppetFacts . facter_version_for_puppet_version ( Puppet . version )
419+ c . add_setting :facterdb_string_keys , default : false
418420end
0 commit comments