diff --git a/lib/puppet/parser/functions/lstrip.rb b/lib/puppet/parser/functions/lstrip.rb deleted file mode 100644 index 62c73f1c3..000000000 --- a/lib/puppet/parser/functions/lstrip.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# -# lstrip.rb -# -module Puppet::Parser::Functions - newfunction(:lstrip, type: :rvalue, doc: <<-DOC - @summary - **Deprecated:** Strips leading spaces to the left of a string. - - @return [String] - The stripped string - - > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a - built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function. - DOC - ) do |arguments| - raise(Puppet::ParseError, "lstrip(): 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, 'lstrip(): 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.lstrip : i } - else - value.lstrip - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/spec/functions/lstrip_spec.rb b/spec/functions/lstrip_spec.rb deleted file mode 100644 index ee822232d..000000000 --- a/spec/functions/lstrip_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'lstrip', 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}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - 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("\t").and_return('') } - it { is_expected.to run.with_params("\t ").and_return('') } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params("\tone").and_return('one') } - it { is_expected.to run.with_params("\t one").and_return('one') } - it { is_expected.to run.with_params('one ').and_return('one ') } - it { is_expected.to run.with_params(' one ').and_return('one ') } - it { is_expected.to run.with_params(' one ').and_return('one ') } - it { is_expected.to run.with_params(' ǿňè ').and_return('ǿňè ') } - it { is_expected.to run.with_params("\tone ").and_return('one ') } - it { is_expected.to run.with_params("\t one ").and_return('one ') } - it { is_expected.to run.with_params("one \t").and_return("one \t") } - it { is_expected.to run.with_params(" one \t").and_return("one \t") } - it { is_expected.to run.with_params(" one \t").and_return("one \t") } - it { is_expected.to run.with_params("\tone \t").and_return("one \t") } - it { is_expected.to run.with_params("\t one \t").and_return("one \t") } - it { is_expected.to run.with_params(' o n e ').and_return('o n e ') } - it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one ') } -end