From 03bd7aa0339be0a428f7f482312975b61cefbbf7 Mon Sep 17 00:00:00 2001 From: martyewings Date: Tue, 25 Apr 2023 10:26:33 +0100 Subject: [PATCH] remove deprecated abs function --- lib/puppet/parser/functions/abs.rb | 44 ------------------------------ spec/functions/abs_spec.rb | 16 ----------- 2 files changed, 60 deletions(-) delete mode 100644 lib/puppet/parser/functions/abs.rb delete mode 100644 spec/functions/abs_spec.rb diff --git a/lib/puppet/parser/functions/abs.rb b/lib/puppet/parser/functions/abs.rb deleted file mode 100644 index 822bc5dbb..000000000 --- a/lib/puppet/parser/functions/abs.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# -# abs.rb -# -module Puppet::Parser::Functions - newfunction(:abs, type: :rvalue, doc: <<-DOC - @summary - **Deprecated:** Returns the absolute value of a number - - For example -34.56 becomes 34.56. - Takes a single integer or float value as an argument. - - > *Note:* - **Deprected** from Puppet 6.0.0, the built-in - ['abs'](https://puppet.com/docs/puppet/6.4/function.html#abs)function will be used instead. - - @return The absolute value of the given number if it was an Integer - - DOC - ) do |arguments| - raise(Puppet::ParseError, "abs(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? - - value = arguments[0] - - # Numbers in Puppet are often string-encoded which is troublesome ... - if value.is_a?(String) - if %r{^-?(?:\d+)(?:\.\d+){1}$}.match?(value) - value = value.to_f - elsif %r{^-?\d+$}.match?(value) - value = value.to_i - else - raise(Puppet::ParseError, 'abs(): Requires float or integer to work with') - end - end - - # We have numeric value to handle ... - result = value.abs - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/spec/functions/abs_spec.rb b/spec/functions/abs_spec.rb deleted file mode 100644 index 00448640e..000000000 --- a/spec/functions/abs_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -if Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 - describe 'abs' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params(-34).and_return(34) } - it { is_expected.to run.with_params('-34').and_return(34) } - it { is_expected.to run.with_params(34).and_return(34) } - it { is_expected.to run.with_params('34').and_return(34) } - it { is_expected.to run.with_params(-34.5).and_return(34.5) } - it { is_expected.to run.with_params('-34.5').and_return(34.5) } - it { is_expected.to run.with_params(34.5).and_return(34.5) } - it { is_expected.to run.with_params('34.5').and_return(34.5) } - end -end