From 4778b06c16d8ef062799998bb64a9b8255affb49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 25 Apr 2023 12:47:05 -1000 Subject: [PATCH] Remove deprecated camelcase function From Puppet 6.0.0, this function has been replaced with a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase) function. --- lib/puppet/parser/functions/camelcase.rb | 41 ------------------------ spec/functions/camelcase_spec.rb | 19 ----------- 2 files changed, 60 deletions(-) delete mode 100644 lib/puppet/parser/functions/camelcase.rb delete mode 100644 spec/functions/camelcase_spec.rb diff --git a/lib/puppet/parser/functions/camelcase.rb b/lib/puppet/parser/functions/camelcase.rb deleted file mode 100644 index 4e6330cbd..000000000 --- a/lib/puppet/parser/functions/camelcase.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -# -# camelcase.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(:camelcase, type: :rvalue, doc: <<-DOC - @summary - **Deprecated** Converts the case of a string or all strings in an array to camel case. - - > *Note:* - **Deprecated** from Puppet 6.0.0, this function has been replaced with - a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase) - function. - - @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, "camelcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? - - value = arguments[0] - klass = value.class - - unless [Array, String].include?(klass) - raise(Puppet::ParseError, 'camelcase(): 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.split('_').map { |e| e.capitalize }.join : i } - else - value.split('_').map { |e| e.capitalize }.join - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/spec/functions/camelcase_spec.rb b/spec/functions/camelcase_spec.rb deleted file mode 100644 index aa78fcbdc..000000000 --- a/spec/functions/camelcase_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'camelcase', 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) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('abc').and_return('Abc') } - it { is_expected.to run.with_params('aa_bb_cc').and_return('AaBbCc') } - it { is_expected.to run.with_params('_aa__bb__cc_').and_return('AaBbCc') } - it { is_expected.to run.with_params('100').and_return('100') } - it { is_expected.to run.with_params('1_00').and_return('100') } - it { is_expected.to run.with_params('_').and_return('') } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['abc', 'aa_bb_cc']).and_return(['Abc', 'AaBbCc']) } - it { is_expected.to run.with_params(['abc', 1, 'aa_bb_cc']).and_return(['Abc', 1, 'AaBbCc']) } -end