Skip to content

Commit

Permalink
Various fixes for Ruby 3 (#77)
Browse files Browse the repository at this point in the history
Also add support for Puppet 8 and stdlib 9
  • Loading branch information
silug authored Aug 28, 2023
1 parent 8cecec7 commit 92986be
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Mon Aug 28 2023 Steven Pritchard <[email protected]> - 0.11.0
- Add support for Puppet 8, Ruby 3, and stdlib 9

* Wed Aug 23 2023 Steven Pritchard <[email protected]> - 0.10.0
- Add AlmaLinux 8 support

Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ENV['PDK_DISABLE_ANALYTICS'] ||= 'true'
gem_sources.each { |gem_source| source gem_source }

group :test do
puppet_version = ENV['PUPPET_VERSION'] || '~> 7'
puppet_version = ENV['PUPPET_VERSION'] || '~> 8'
major_puppet_version = puppet_version.scan(/(\d+)(?:\.|\Z)/).flatten.first.to_i
gem 'rake'
gem 'puppet', puppet_version
Expand All @@ -22,9 +22,9 @@ group :test do
gem 'metadata-json-lint'
gem 'puppet-strings'
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'simp-rspec-puppet-facts', ENV['SIMP_RSPEC_PUPPET_FACTS_VERSION'] || '~> 3.1'
gem 'simp-rspec-puppet-facts', ENV['SIMP_RSPEC_PUPPET_FACTS_VERSION'] || '~> 3.7'
gem 'simp-rake-helpers', ENV['SIMP_RAKE_HELPERS_VERSION'] || ['>= 5.12.1', '< 6']
gem( 'pdk', ENV['PDK_VERSION'] || '~> 2.0', :require => false) if major_puppet_version > 5
gem( 'pdk', ENV['PDK_VERSION'] || ['>= 2.0', '< 4.0'], :require => false) if major_puppet_version > 5
gem 'pathspec', '~> 0.2' if Gem::Requirement.create('< 2.6').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
end

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/simpkv/support/load.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def load
# 'simpkv' attribute to the catalog instance
lib_dir = File.dirname(File.dirname(File.dirname(File.dirname(File.dirname("#{__FILE__}")))))
filename = File.join(lib_dir, 'puppet_x', 'simpkv', 'loader.rb')
if File.exists?(filename)
if File.exist?(filename)
begin
catalog.instance_eval(File.read(filename), filename)
rescue SyntaxError => e
Expand Down
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-simpkv",
"version": "0.10.0",
"version": "0.11.0",
"author": "simp",
"summary": "SIMPkv providers",
"license": "Apache-2.0",
Expand All @@ -14,7 +14,7 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 8.0.0 < 9.0.0"
"version_requirement": ">= 8.0.0 < 10.0.0"
}
],
"operatingsystem_support": [
Expand Down Expand Up @@ -54,7 +54,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 6.22.1 < 8.0.0"
"version_requirement": ">= 6.22.1 < 9.0.0"
}
]
}
2 changes: 1 addition & 1 deletion spec/functions/simpkv/delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
end

it 'should fail when simpkv cannot be added to the catalog instance' do
allow(File).to receive(:exists?).and_return(false)
allow(File).to receive(:exist?).and_return(false)
is_expected.to run.with_params('mykey', @options_test_file).
and_raise_error(LoadError, /simpkv Internal Error: unable to load/)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/simpkv/deletetree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
end

it 'should fail when simpkv cannot be added to the catalog instance' do
allow(File).to receive(:exists?).and_return(false)
allow(File).to receive(:exist?).and_return(false)
is_expected.to run.with_params(keydir, @options_test_file).
and_raise_error(LoadError, /simpkv Internal Error: unable to load/)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/simpkv/exists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
end

it 'should fail when simpkv cannot be added to the catalog instance' do
allow(File).to receive(:exists?).and_return(false)
allow(File).to receive(:exist?).and_return(false)
is_expected.to run.with_params('mykey', @options_test_file).
and_raise_error(LoadError, /simpkv Internal Error: unable to load/)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/simpkv/get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
end

it 'should fail when simpkv cannot be added to the catalog instance' do
allow(File).to receive(:exists?).and_return(false)
allow(File).to receive(:exist?).and_return(false)
is_expected.to run.with_params('mykey', @options_test_file).
and_raise_error(LoadError, /simpkv Internal Error: unable to load/)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/simpkv/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def prepopulate_key_files(root_dir, keydir)
end

it 'should fail when simpkv cannot be added to the catalog instance' do
allow(File).to receive(:exists?).and_return(false)
allow(File).to receive(:exist?).and_return(false)
is_expected.to run.with_params(keydir, @options_test_file).
and_raise_error(LoadError, /simpkv Internal Error: unable to load/)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/simpkv/put_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
end

it 'should fail when simpkv cannot be added to the catalog instance' do
allow(File).to receive(:exists?).and_return(false)
allow(File).to receive(:exist?).and_return(false)
is_expected.to run.with_params('mykey', 'myvalue' , {}, @options_test_file).
and_raise_error(LoadError, /simpkv Internal Error: unable to load/)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/functions/simpkv/support/load_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
end

it 'should fail when simpkv.rb does not exist' do
allow(File).to receive(:exists?).with(any_args).and_call_original
allow(File).to receive(:exists?).with(/simpkv\/loader.rb/).and_return(false)
allow(File).to receive(:exist?).with(any_args).and_call_original
allow(File).to receive(:exist?).with(/simpkv\/loader.rb/).and_return(false)
is_expected.to run.with_params().and_raise_error(LoadError, /simpkv Internal Error: unable to load .* File not found/)
end

Expand Down

0 comments on commit 92986be

Please sign in to comment.