From 5dc8996feda910bfd5ffc8defd1cf94f55d8650e Mon Sep 17 00:00:00 2001 From: martyewings Date: Tue, 25 Apr 2023 10:59:39 +0100 Subject: [PATCH] Remove deprecated downcase function --- lib/puppet/parser/functions/downcase.rb | 41 ------------------------- spec/functions/downcase_spec.rb | 17 ---------- 2 files changed, 58 deletions(-) delete mode 100644 lib/puppet/parser/functions/downcase.rb delete mode 100644 spec/functions/downcase_spec.rb diff --git a/lib/puppet/parser/functions/downcase.rb b/lib/puppet/parser/functions/downcase.rb deleted file mode 100644 index 32e338c8a..000000000 --- a/lib/puppet/parser/functions/downcase.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -# -# downcase.rb -# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. -# -module Puppet::Parser::Functions - newfunction(:downcase, type: :rvalue, doc: <<-DOC - @summary - **Deprecated:** Converts the case of a string or all strings in an array to lower case. - - > *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a - built-in [`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase) function. - > - This function is an implementation of a Ruby class and might not be UTF8 compatible. - To ensure compatibility, use this function with Ruby 2.4.0 or greater. - - @return [String] The converted String, if it was a String that was given - @return [Array[String]] The converted Array, if it was a Array that was given - DOC - ) do |arguments| - raise(Puppet::ParseError, "downcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'downcase(): Requires either array or string to work with') - end - - result = if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - value.map { |i| i.is_a?(String) ? i.downcase : i } - else - value.downcase - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/spec/functions/downcase_spec.rb b/spec/functions/downcase_spec.rb deleted file mode 100644 index 07c6374c3..000000000 --- a/spec/functions/downcase_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'downcase', if: Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError, %r{Requires either array or string}) } - it { is_expected.to run.with_params('abc').and_return('abc') } - it { is_expected.to run.with_params('Abc').and_return('abc') } - it { is_expected.to run.with_params('ABC').and_return('abc') } - - it { is_expected.to run.with_params(AlsoString.new('ABC')).and_return('abc') } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['ONE', 'TWO']).and_return(['one', 'two']) } - it { is_expected.to run.with_params(['One', 1, 'Two']).and_return(['one', 1, 'two']) } -end