From 92986be8ddf529e5f39a5b17d4e152e1e1e66238 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Mon, 28 Aug 2023 12:51:39 -0500 Subject: [PATCH] Various fixes for Ruby 3 (#77) Also add support for Puppet 8 and stdlib 9 --- CHANGELOG | 3 +++ Gemfile | 6 +++--- lib/puppet/functions/simpkv/support/load.rb | 2 +- metadata.json | 6 +++--- spec/functions/simpkv/delete_spec.rb | 2 +- spec/functions/simpkv/deletetree_spec.rb | 2 +- spec/functions/simpkv/exists_spec.rb | 2 +- spec/functions/simpkv/get_spec.rb | 2 +- spec/functions/simpkv/list_spec.rb | 2 +- spec/functions/simpkv/put_spec.rb | 2 +- spec/functions/simpkv/support/load_spec.rb | 4 ++-- 11 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fe98106..0a13795 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +* Mon Aug 28 2023 Steven Pritchard - 0.11.0 +- Add support for Puppet 8, Ruby 3, and stdlib 9 + * Wed Aug 23 2023 Steven Pritchard - 0.10.0 - Add AlmaLinux 8 support diff --git a/Gemfile b/Gemfile index 57fca16..fdc7aa8 100644 --- a/Gemfile +++ b/Gemfile @@ -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 @@ -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 diff --git a/lib/puppet/functions/simpkv/support/load.rb b/lib/puppet/functions/simpkv/support/load.rb index 898bbe3..2a1c942 100644 --- a/lib/puppet/functions/simpkv/support/load.rb +++ b/lib/puppet/functions/simpkv/support/load.rb @@ -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 diff --git a/metadata.json b/metadata.json index 9bccafb..fd0cd79 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "simp-simpkv", - "version": "0.10.0", + "version": "0.11.0", "author": "simp", "summary": "SIMPkv providers", "license": "Apache-2.0", @@ -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": [ @@ -54,7 +54,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 6.22.1 < 8.0.0" + "version_requirement": ">= 6.22.1 < 9.0.0" } ] } diff --git a/spec/functions/simpkv/delete_spec.rb b/spec/functions/simpkv/delete_spec.rb index e761f86..af9c3a8 100644 --- a/spec/functions/simpkv/delete_spec.rb +++ b/spec/functions/simpkv/delete_spec.rb @@ -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 diff --git a/spec/functions/simpkv/deletetree_spec.rb b/spec/functions/simpkv/deletetree_spec.rb index 0f5c01f..dc53dec 100644 --- a/spec/functions/simpkv/deletetree_spec.rb +++ b/spec/functions/simpkv/deletetree_spec.rb @@ -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 diff --git a/spec/functions/simpkv/exists_spec.rb b/spec/functions/simpkv/exists_spec.rb index d11f1e7..47dbc14 100644 --- a/spec/functions/simpkv/exists_spec.rb +++ b/spec/functions/simpkv/exists_spec.rb @@ -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 diff --git a/spec/functions/simpkv/get_spec.rb b/spec/functions/simpkv/get_spec.rb index 48e1919..c4272de 100644 --- a/spec/functions/simpkv/get_spec.rb +++ b/spec/functions/simpkv/get_spec.rb @@ -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 diff --git a/spec/functions/simpkv/list_spec.rb b/spec/functions/simpkv/list_spec.rb index ef92b69..fa0c404 100644 --- a/spec/functions/simpkv/list_spec.rb +++ b/spec/functions/simpkv/list_spec.rb @@ -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 diff --git a/spec/functions/simpkv/put_spec.rb b/spec/functions/simpkv/put_spec.rb index aaeaf0a..a097efe 100644 --- a/spec/functions/simpkv/put_spec.rb +++ b/spec/functions/simpkv/put_spec.rb @@ -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 diff --git a/spec/functions/simpkv/support/load_spec.rb b/spec/functions/simpkv/support/load_spec.rb index b2412e0..9bfc090 100644 --- a/spec/functions/simpkv/support/load_spec.rb +++ b/spec/functions/simpkv/support/load_spec.rb @@ -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