rspec-puppet-facts 2.0.0 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,6 @@ module RspecPuppetFacts
2
2
  # This module contains the current version constant
3
3
  module Version
4
4
  # The current version of this gem
5
- STRING = '2.0.0'
5
+ STRING = '2.0.5'
6
6
  end
7
7
  end
@@ -7,6 +7,8 @@ require 'json'
7
7
  # module's RSpec tests by looping through all supported
8
8
  # OS'es and their facts data which is received from the FacterDB.
9
9
  module RspecPuppetFacts
10
+ FACTS_CACHE = {}
11
+
10
12
  # Use the provided options or the data from the metadata.json file
11
13
  # to find a set of matching facts in the FacterDB.
12
14
  # OS names and facts can be used in the Puppet RSpec tests
@@ -32,6 +34,28 @@ module RspecPuppetFacts
32
34
  opts[:supported_os] ||= RspecPuppetFacts.meta_supported_os
33
35
  opts[:facterversion] ||= RSpec.configuration.default_facter_version
34
36
 
37
+ # This should list all variables that on_supported_os_implementation uses
38
+ cache_key = [
39
+ opts.to_s,
40
+ RspecPuppetFacts.custom_facts.to_s,
41
+ RspecPuppetFacts.spec_facts_os_filter,
42
+ RspecPuppetFacts.spec_facts_strict?,
43
+ ]
44
+
45
+ result = FACTS_CACHE[cache_key] ||= on_supported_os_implementation(opts)
46
+
47
+ # Marshalling is used to get unique instances which is needed for test
48
+ # isolation when facts are overridden.
49
+ Marshal.load(Marshal.dump(result))
50
+ end
51
+
52
+ # The real implementation of on_supported_os.
53
+ #
54
+ # Generating facts is slow - this allows memoization of the facts between
55
+ # multiple calls.
56
+ #
57
+ # @api private
58
+ def on_supported_os_implementation(opts = {})
35
59
  unless (facterversion = opts[:facterversion]) =~ /\A\d+\.\d+(?:\.\d+)*\z/
36
60
  raise ArgumentError, ":facterversion must be in the format 'n.n' or " \
37
61
  "'n.n.n' (n is numeric), not '#{facterversion}'"
@@ -88,6 +112,8 @@ module RspecPuppetFacts
88
112
  end
89
113
  end
90
114
 
115
+ facterversion_obj = Gem::Version.new(facterversion)
116
+
91
117
  # FacterDB may have newer versions of facter data for which it contains a subset of all possible
92
118
  # facter data (see FacterDB 0.5.2 for Facter releases 3.8 and 3.9). In this situation we need to
93
119
  # cycle through and downgrade Facter versions per platform type until we find matching Facter data.
@@ -100,8 +126,6 @@ module RspecPuppetFacts
100
126
  raise ArgumentError, "No facts were found in the FacterDB for Facter v#{facterversion} on #{filter_spec}, aborting"
101
127
  end
102
128
 
103
- facterversion_obj = Gem::Version.new(facterversion)
104
-
105
129
  version = FacterDB.get_facts(filter_spec).map { |facts| Gem::Version.new(facts[:facterversion]) }.sort.reverse.detect { |v| v <= facterversion_obj }
106
130
 
107
131
  next unless version
@@ -125,12 +149,17 @@ module RspecPuppetFacts
125
149
  os_facts_hash = {}
126
150
  received_facts.map do |facts|
127
151
  # Fix facter bug
152
+ # Todo: refactor the whole block to rely on structured facts and use legacy facts as fallback
128
153
  if facts[:operatingsystem] == 'Ubuntu'
129
154
  operatingsystemmajrelease = facts[:operatingsystemrelease].split('.')[0..1].join('.')
130
155
  elsif facts[:operatingsystem] == 'OpenBSD'
131
156
  operatingsystemmajrelease = facts[:operatingsystemrelease]
132
157
  elsif facts[:operatingsystem] == 'windows' && facts[:operatingsystemrelease].start_with?('10.0.')
133
158
  operatingsystemmajrelease = '2016'
159
+ elsif facts.dig(:os, 'release', 'major')
160
+ operatingsystemmajrelease = facts[:os]['release']['major']
161
+ elsif facts.dig(:os, 'distro', 'release', 'major')
162
+ operatingsystemmajrelease = facts[:os]['distro']['release']['major']
134
163
  else
135
164
  if facts[:operatingsystemmajrelease].nil?
136
165
  operatingsystemmajrelease = facts[:operatingsystemrelease].split('.')[0]
@@ -203,6 +232,13 @@ module RspecPuppetFacts
203
232
  facts
204
233
  end
205
234
 
235
+ # Get custom facts
236
+ # @return [nil,Hash]
237
+ # @api private
238
+ def self.custom_facts
239
+ @custom_facts
240
+ end
241
+
206
242
  # If provided this filter can be used to limit the set
207
243
  # of retrieved facts only to the matched OS names.
208
244
  # The value is being taken from the SPEC_FACTS_OS environment
@@ -6,9 +6,9 @@ require 'rspec-puppet-facts/version'
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'rspec-puppet-facts'
8
8
  s.version = RspecPuppetFacts::Version::STRING
9
- s.authors = ['Mickaël Canévet']
10
- s.email = ['mickael.canevet@camptocamp.com']
11
- s.homepage = 'http://github.com/mcanevet/rspec-puppet-facts'
9
+ s.authors = ['Vox Pupuli']
10
+ s.email = ['voxpupuli@groups.io']
11
+ s.homepage = 'http://github.com/voxpupuli/rspec-puppet-facts'
12
12
  s.summary = 'Standard facts fixtures for Puppet'
13
13
  s.description = 'Contains facts from many Facter version on many Operating Systems'
14
14
  s.licenses = 'Apache-2.0'
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
22
 
23
23
  s.add_development_dependency 'mime-types'
24
- s.add_development_dependency 'coveralls'
25
24
  s.add_development_dependency 'rake'
26
25
  s.add_development_dependency 'rspec'
27
26
  s.add_development_dependency 'yard'
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,25 @@
1
- if ENV['COVERAGE']
2
- require 'coveralls'
3
- Coveralls.wear!
1
+ begin
2
+ require 'simplecov'
3
+ require 'simplecov-console'
4
+ require 'codecov'
5
+ rescue LoadError
6
+ else
7
+ SimpleCov.start do
8
+ track_files 'lib/**/*.rb'
9
+
10
+ add_filter '/spec'
11
+
12
+ enable_coverage :branch
13
+
14
+ # do not track vendored files
15
+ add_filter '/vendor'
16
+ add_filter '/.vendor'
17
+ end
18
+
19
+ SimpleCov.formatters = [
20
+ SimpleCov::Formatter::Console,
21
+ SimpleCov::Formatter::Codecov,
22
+ ]
4
23
  end
5
24
 
6
25
  require 'rspec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-puppet-facts
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
- - Mickaël Canévet
7
+ - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-05 00:00:00.000000000 Z
11
+ date: 2022-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: coveralls
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -124,16 +110,19 @@ dependencies:
124
110
  version: 0.5.0
125
111
  description: Contains facts from many Facter version on many Operating Systems
126
112
  email:
127
- - mickael.canevet@camptocamp.com
113
+ - voxpupuli@groups.io
128
114
  executables: []
129
115
  extensions: []
130
116
  extra_rdoc_files: []
131
117
  files:
118
+ - ".github/dependabot.yml"
119
+ - ".github/workflows/release.yml"
120
+ - ".github/workflows/test.yml"
132
121
  - ".gitignore"
133
122
  - ".rspec"
134
- - ".travis.yml"
135
123
  - CHANGELOG.md
136
124
  - Gemfile
125
+ - HISTORY.md
137
126
  - LICENSE
138
127
  - README.md
139
128
  - Rakefile
@@ -145,7 +134,7 @@ files:
145
134
  - spec/fixtures/metadata.json_with_missing_operatingsystem_support
146
135
  - spec/rspec_puppet_facts_spec.rb
147
136
  - spec/spec_helper.rb
148
- homepage: http://github.com/mcanevet/rspec-puppet-facts
137
+ homepage: http://github.com/voxpupuli/rspec-puppet-facts
149
138
  licenses:
150
139
  - Apache-2.0
151
140
  metadata: {}
@@ -164,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
153
  - !ruby/object:Gem::Version
165
154
  version: '0'
166
155
  requirements: []
167
- rubygems_version: 3.1.2
156
+ rubygems_version: 3.2.33
168
157
  signing_key:
169
158
  specification_version: 4
170
159
  summary: Standard facts fixtures for Puppet
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- script:
5
- - bundle exec rake spec
6
- - bundle exec rake puppet_versions:test
7
- - bundle exec rake build
8
- rvm:
9
- - 2.4
10
- - 2.5
11
- - 2.7
12
- matrix:
13
- fast_finish: true
14
- include:
15
- - rvm: 2.6
16
- env: COVERAGE=true
17
- notifications:
18
- email: false
19
- deploy:
20
- provider: rubygems
21
- api_key:
22
- secure: EGvtHfBYUSjhZjLPGZHHH7Exsu9xyYSNlbI/F9SNRDmY568tBZs1Pw05Pr9dhUXajs3xXPkHQwMEBgNs2Rg2SPc6+dCyvabbNM2U58yj5R5D7+ZdUWC1APgjiDvBhm0N5hihmAnoBKPlmPKMh91OQwKI/8/GOhWAQaIZRnNBzMQ+gwHQ8xIkqt3unxJ/LtRybFDzTF5aMtIHrfE8kV08BLaKUzJptzj7Wt5Ms1zE/2UV1S7DhSvZnxWaWtNZwaQPo9NFhjHr5k3nLIoWi6Ge3khVSukZcAki9cR37Tjeyms5B10hp6jW5c6EgCDQp5VNcD/1LgtTs8fWI6mvTsa3YCyaQdVy2SvhUD88/CohFvLXbGcdkFFzwhPa57aCKazq14fh5epScRzAfGpJojkPcxdc5/fiuZiaPg+jmT/OMFqNjQW1C6m2S+VltlXVCyjT83Ri9J9/AEu708akErhz7XjcspxJL8//KVvS/3o4hjtoef1OXxRN+oh3VGwbEZSiqOmjxr6/AigaYsrWOTdz+OZa4fGYbUb9hMHnq314cjgGUMyzZ9tQN8v4mMZb1ZKZPuqrP6um1Y7WbHQJvwl3sXEUuDN68eyWp103M1nyma6hON4+F+r58kTuoWRmy06ZsaEjz57bFxdnDjB8It8V7pI0bcmfs/q5tMIPw6Gh14w=
23
- gem: rspec-puppet-facts
24
- on:
25
- tags: true
26
- repo: mcanevet/rspec-puppet-facts
27
- all_branches: true
28
- rvm: 2.6