Skip to content

Commit

Permalink
Use FacterDB.filter_results
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Jul 21, 2023
1 parent 2663141 commit f7a1e25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ group :coverage, optional: ENV['COVERAGE']!='yes' do
gem 'codecov', :require => false
gem 'simplecov-console', :require => false
end

gem 'facterdb', github: 'ekohl/facterdb', branch: 'filter-results'
6 changes: 1 addition & 5 deletions lib/rspec-puppet-facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ def on_supported_os_implementation(opts = {})
# facter data (see FacterDB 0.5.2 for Facter releases 3.8 and 3.9). In this situation we need to
# cycle through and downgrade Facter versions per platform type until we find matching Facter data.
filter.each do |filter_spec|
versions = JGrep.jgrep(db.to_json, FacterDB.generate_filter_str(filter_spec)) \
.to_h do |facts|
result = facts.to_h { |k, v| [k.to_sym, v] }
[Gem::Version.new(result[:facterversion]), result]
end
versions = FacterDB.filter_results(db, filter_spec).to_h { |facts| [Gem::Version.new(facts[:facterversion]), facts] }

version, facts = versions.select { |v, _f| strict_requirement =~ v }.max_by { |v, _f| v }

Expand Down

0 comments on commit f7a1e25

Please sign in to comment.