diff --git a/Gemfile b/Gemfile index 1571dd49..66a69c37 100644 --- a/Gemfile +++ b/Gemfile @@ -5,20 +5,13 @@ gemspec gem 'json_pure' -if RUBY_VERSION < '2.1' - # Technically not needed, but avoids issues with bundler versions - gem 'rdoc', '< 5.0.0' -elsif RUBY_VERSION < '2.2' - gem 'rdoc', '< 6.0.0' -end - if ENV['PUPPET_VERSION'] gem 'puppet', "~> #{ENV['PUPPET_VERSION']}" else gem 'puppet', '>= 4.5.0', '< 8.0.0' end -gem 'puppet-strings', RUBY_VERSION >= '2.1' ? '>= 1.2.1' : '~> 1.2.1' +gem 'puppet-strings', '>= 1.2.1' group :puppet_module do gem 'metadata-json-lint' diff --git a/lib/kafo/fact_writer.rb b/lib/kafo/fact_writer.rb index e530cf52..85316ce1 100644 --- a/lib/kafo/fact_writer.rb +++ b/lib/kafo/fact_writer.rb @@ -14,10 +14,9 @@ def self.write_facts(facts, directory) end def self.wrapper - # Ruby 2.0 doesn't have <<~ heredocs - <<-WRAPPER - require 'yaml' - Facter.add(:kafo) { setcode { YAML.load_file(File.join(__dir__, '#{DATA_FILENAME}')) } } + <<~WRAPPER + require 'yaml' + Facter.add(:kafo) { setcode { YAML.load_file(File.join(__dir__, '#{DATA_FILENAME}')) } } WRAPPER end end diff --git a/lib/kafo/kafo_configure.rb b/lib/kafo/kafo_configure.rb index d0bfc8fd..41389c75 100644 --- a/lib/kafo/kafo_configure.rb +++ b/lib/kafo/kafo_configure.rb @@ -525,8 +525,8 @@ def run_installation @progress_bar.update(line) if @progress_bar end rescue Errno::EIO # we reach end of input - exit_status = PTY.check(pid, true) if PTY.respond_to?(:check) # ruby >= 1.9.2 - if exit_status.nil? # process is still running or we have old ruby so we don't know + exit_status = PTY.check(pid, true) + if exit_status.nil? # process is still running begin Process.wait(pid) rescue Errno::ECHILD # process could exit meanwhile so we rescue @@ -535,7 +535,7 @@ def run_installation end end end - rescue PTY::ChildExited => e # could be raised by Process.wait on older ruby or by PTY.check + rescue PTY::ChildExited => e # could be raised by PTY.check self.class.exit_handler.exit_code = e.status.exitstatus end @@ -564,11 +564,7 @@ def config_file end def normalize_encoding(line) - if line.respond_to?(:encode) && line.respond_to?(:valid_encoding?) - line.valid_encoding? ? line : line.encode('UTF-16be', :invalid => :replace, :replace => '?').encode('UTF-8') - else # Ruby 1.8.7, doesn't worry about invalid encodings - line - end + line.valid_encoding? ? line : line.encode('UTF-16be', :invalid => :replace, :replace => '?').encode('UTF-8') end end end diff --git a/test/kafo/fact_writer_test.rb b/test/kafo/fact_writer_test.rb index 6a661f92..6c3ae86b 100644 --- a/test/kafo/fact_writer_test.rb +++ b/test/kafo/fact_writer_test.rb @@ -18,7 +18,7 @@ module Kafo end describe '#wrapper' do - specify { _(subject.wrapper).must_equal(" require 'yaml'\n Facter.add(:kafo) { setcode { YAML.load_file(File.join(__dir__, 'kafo.yaml')) } }\n") } + specify { _(subject.wrapper).must_equal("require 'yaml'\nFacter.add(:kafo) { setcode { YAML.load_file(File.join(__dir__, 'kafo.yaml')) } }\n") } end end end