Skip to content

Commit 4080a39

Browse files
authored
Merge pull request puppetlabs#2674 from mhashizume/drop-ruby-25
Drop Ruby 2.5 support
2 parents c483c51 + c30fd7b commit 4080a39

File tree

14 files changed

+31
-30
lines changed

14 files changed

+31
-30
lines changed

.github/workflows/unit_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
ruby:
21-
- '2.5'
21+
- '2.6'
2222
- '2.7'
2323
- '3.0'
2424
- '3.2'

.rubocop.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
inherit_from: .rubocop_todo.yml
33

44
AllCops:
5-
TargetRubyVersion: 2.5
5+
TargetRubyVersion: 2.6
66
Exclude:
77
- acceptance/**/*
88
- vendor/**/*
@@ -88,9 +88,6 @@ RSpec/MessageSpies:
8888
RSpec/MultipleExpectations:
8989
Max: 3
9090

91-
RSpec/MultipleMemoizedHelpers:
92-
Enabled: false
93-
9491
RSpec/NestedGroups:
9592
Enabled: 6
9693

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
[![Test Coverage](https://api.codeclimate.com/v1/badges/3bd4be86f4b0b49bc0ca/test_coverage)](https://codeclimate.com/github/puppetlabs/facter/test_coverage)
1010
[![Maintainability](https://api.codeclimate.com/v1/badges/3bd4be86f4b0b49bc0ca/maintainability)](https://codeclimate.com/github/puppetlabs/facter/maintainability)
1111

12-
1312
Facter is a command-line tool that gathers basic facts about nodes (systems)
1413
such as hardware details, network settings, OS type and version, and more.
1514
These facts are made available as variables in your Puppet manifests and can be
@@ -21,17 +20,20 @@ Documentation for the Facter project can be found on the [Puppet Docs
2120
site](https://puppet.com/docs/puppet/latest/facter.html).
2221

2322
## Supported platforms
23+
2424
* Linux
2525
* macOS
2626
* Windows
2727
* Solaris
2828
* AIX
2929

3030
## Requirements
31-
* Ruby 2.5+
31+
32+
* Ruby 2.6+
3233
* FFI (for facts like `mountpoints` which are resolved using C API calls)
3334

3435
## Basic concepts
36+
3537
The project has three main parts, the framework, facts and resolvers.
3638
In the framework we implement functionality that is agnostic of specific facts like parsing user input, formatting output, etc.
3739

@@ -52,9 +54,10 @@ sequenceDiagram
5254
resolver->>fact: system information
5355
fact->>framework: fact value
5456
framework->>user: formatted user output
55-
````
57+
```
5658

5759
## Getting started
60+
5861
After cloning the project, run `bundle install` to install all dependencies.
5962

6063
You can run facter by executing `./bin/facter`.
@@ -63,11 +66,13 @@ The command will output all the facts that facter detected for the current OS.
6366
The implementation can be validated locally by running `bundle exec rake check`.
6467

6568
## Goals - fast, easy, compatible
69+
6670
* Gain performance similar to the C++ version of Facter. We plan to achieve this goal by gathering multiple facts with only one call and by using the faster Win32 API rather than WMI for the Windows implementation.
6771
* Facilitate community contribution. At the moment, C++ presents a possible impediment for community contributions.
6872
* Enable native integration with other Ruby-based projects such as Bolt and puppet.
6973
* Enable native integration for custom facts.
7074
* Provide 100% compatibility with C++ Facter (drop-in replacement).
7175

7276
## Licensing
77+
7378
See [LICENSE](https://github.com/puppetlabs/facter/blob/main/LICENSE) file. Puppet is licensed by Puppet, Inc. under the Apache license. Puppet, Inc. can be contacted at: [email protected]

ext/project_data.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gem_require_path: 'lib'
1212
gem_executables: 'facter'
1313
gem_license: 'Apache-2.0'
1414
gem_default_executables: 'facter'
15-
gem_required_ruby_version: ['>= 2.5', '< 4.0']
15+
gem_required_ruby_version: ['>= 2.6', '< 4.0']
1616
gem_runtime_dependencies:
1717
hocon: ~> 1.3
1818
thor: ['>= 1.0.1', '< 2.0']

facter.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
2424
base = "#{__dir__}#{File::SEPARATOR}"
2525
spec.files = dirs.map { |path| path.sub(base, '') }
2626

27-
spec.required_ruby_version = '>= 2.5', '< 4.0'
27+
spec.required_ruby_version = '>= 2.6', '< 4.0'
2828
spec.bindir = 'bin'
2929
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
3030
spec.require_paths = ['lib']
@@ -37,9 +37,9 @@ Gem::Specification.new do |spec|
3737
spec.add_development_dependency 'ffi', '1.15.5'
3838
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
3939
spec.add_development_dependency 'rspec', '~> 3.0'
40-
spec.add_development_dependency 'rubocop', '~> 1.28' # last version to support 2.5
41-
spec.add_development_dependency 'rubocop-performance', '~> 1.5.2'
42-
spec.add_development_dependency 'rubocop-rspec', '~> 2.10' # last version to support 2.5
40+
spec.add_development_dependency 'rubocop', '~> 1.50' # last version to support 2.6
41+
spec.add_development_dependency 'rubocop-performance', '~> 1.17'
42+
spec.add_development_dependency 'rubocop-rspec', '~> 2.20'
4343
spec.add_development_dependency 'simplecov', '~> 0.17.1'
4444
spec.add_development_dependency 'sys-filesystem', '~> 1.4'
4545
spec.add_development_dependency 'webmock', '~> 3.12'

install.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,15 @@ def prepare_installation
208208
# Join two paths. On Windows, dir must be converted to a relative path,
209209
# by stripping the drive letter, but only if the basedir is not empty.
210210
#
211+
# We can't use endless ranges here because we still use older Rubies when building puppet-agent on older platforms
212+
# (such as Solaris 10).
213+
# rubocop:disable Style/SlicingWithRange
211214
def join(basedir, dir)
212215
return "#{basedir}#{dir[2..-1]}" if windows? && !basedir.empty? && (dir.length > 2)
213216

214217
"#{basedir}#{dir}"
215218
end
219+
# rubocop:enable Style/SlicingWithRange
216220

217221
##
218222
# Install file(s) from ./bin to RbConfig::CONFIG['bindir']. Patch it on the way

lib/docs/generate.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ def format_facts(fact_hash)
1717
scope = OpenStruct.new({
1818
facts: fact_hash
1919
})
20-
21-
erb = if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
22-
ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
23-
else
24-
ERB.new(File.read(PATH_TO_TEMPLATE), nil, '-')
25-
end
20+
erb = ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
2621
erb.result(scope.instance_eval { binding })
2722
end
2823

lib/facter/facts/solaris/ldom.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def resolve(key)
5454
def create_resolved_facts_list(fact_value)
5555
resolved_facts = [Facter::ResolvedFact.new(FACT_NAME, fact_value)]
5656
ALIASES.each do |fact_alias|
57-
key = fact_alias.split('_')[1..-1].map!(&:to_sym)
57+
key = fact_alias.split('_')[1..].map!(&:to_sym)
5858
resolved_facts << Facter::ResolvedFact.new(fact_alias, fact_value.dig(*key), :legacy)
5959
end
6060

lib/facter/framework/cli/cli.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def man(*args)
113113
negate_options = %w[block cache custom_facts external_facts]
114114

115115
template = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'man.erb')
116-
erb = ERB.new(File.read(template), nil, '-')
116+
erb = ERB.new(File.read(template), trim_mode: '-')
117117
erb.filename = template
118118
puts erb.result(binding)
119119
end
@@ -148,7 +148,7 @@ def list_block_groups
148148
options = @options.map { |(k, v)| [k.to_sym, v] }.to_h
149149
Facter::Options.init_from_cli(options)
150150

151-
block_groups = Facter::FactGroups.new.groups.to_yaml.lines[1..-1].join
151+
block_groups = Facter::FactGroups.new.groups.to_yaml.lines[1..].join
152152
block_groups.gsub!(/:\s*\n/, "\n")
153153

154154
puts block_groups
@@ -160,7 +160,7 @@ def list_cache_groups
160160
options = @options.map { |(k, v)| [k.to_sym, v] }.to_h
161161
Facter::Options.init_from_cli(options)
162162

163-
cache_groups = Facter::FactGroups.new.groups.to_yaml.lines[1..-1].join
163+
cache_groups = Facter::FactGroups.new.groups.to_yaml.lines[1..].join
164164
cache_groups.gsub!(/:\s*\n/, "\n")
165165

166166
puts cache_groups

lib/facter/resolvers/aix/serialnumber.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def read_serialnumber(fact_name)
2222

2323
result.each_line do |line|
2424
if line.include?('value')
25-
@fact_list[:serialnumber] = line.split('=')[1].strip.delete('\"')[6..-1]
25+
@fact_list[:serialnumber] = line.split('=')[1].strip.delete('\"')[6..]
2626
break
2727
end
2828
end

0 commit comments

Comments
 (0)