diff options
-rw-r--r-- | chomp.rb | 5 | ||||
-rw-r--r-- | chop.rb | 3 | ||||
-rw-r--r-- | count.rb | 4 | ||||
-rw-r--r-- | fact.rb | 2 | ||||
-rw-r--r-- | join.rb | 4 | ||||
-rw-r--r-- | join_with_prefix.rb | 4 | ||||
-rw-r--r-- | keys.rb | 4 | ||||
-rw-r--r-- | lstrip.rb | 4 | ||||
-rw-r--r-- | prefix.rb | 4 | ||||
-rw-r--r-- | reverse.rb | 4 | ||||
-rw-r--r-- | rstrip.rb | 4 | ||||
-rw-r--r-- | str2bool.rb | 5 | ||||
-rw-r--r-- | values.rb | 4 | ||||
-rw-r--r-- | values_at.rb | 5 |
14 files changed, 29 insertions, 27 deletions
@@ -13,12 +13,13 @@ module Puppet::Parser::Functions value = arguments[0] klass = value.class - if not [Array, String].include?(klass) - raise(Puppet::ParseError, 'chomp(): Requires either an ' + + unless [Array, String].include?(klass) + raise(Puppet::ParseError, 'chomp(): Requires either ' + 'array or string to work with') end if value.is_a?(Array) + # Numbers in Puppet are often string-encoded ... result = value.collect { |i| i.is_a?(String) ? i.chomp : i } else result = value.chomp @@ -13,12 +13,13 @@ module Puppet::Parser::Functions value = arguments[0] klass = value.class - if not [Array, String].include?(klass) + unless [Array, String].include?(klass) raise(Puppet::ParseError, 'chop(): Requires either an ' + 'array or string to work with') end if value.is_a?(Array) + # Numbers in Puppet are often string-encoded ... result = value.collect { |i| i.is_a?(String) ? i.chop : i } else result = value.chop @@ -16,8 +16,8 @@ module Puppet::Parser::Functions array = arguments[0] - if not array.is_a?(Array) - raise(Puppet::ParseError, 'count(): Requires an array to work with') + unless array.is_a?(Array) + raise(Puppet::ParseError, 'count(): Requires array to work with') end item = arguments[1] if arguments[1] @@ -12,7 +12,7 @@ module Puppet::Parser::Functions fact = arguments[0] - if not fact.is_a?(String) + unless fact.is_a?(String) raise(Puppet::ParseError, 'fact(): Requires fact name to be a string') end @@ -13,8 +13,8 @@ module Puppet::Parser::Functions array = arguments[0] - if not array.is_a?(Array) - raise(Puppet::ParseError, 'join(): Requires an array to work with') + unless array.is_a?(Array) + raise(Puppet::ParseError, 'join(): Requires array to work with') end suffix = arguments[1] if arguments[1] diff --git a/join_with_prefix.rb b/join_with_prefix.rb index c0a2e4e..8bf96d9 100644 --- a/join_with_prefix.rb +++ b/join_with_prefix.rb @@ -13,8 +13,8 @@ module Puppet::Parser::Functions array = arguments[0] - if not array.is_a?(Array) - raise(Puppet::ParseError, 'join_with_prefix(): Requires an ' + + unless array.is_a?(Array) + raise(Puppet::ParseError, 'join_with_prefix(): Requires ' + 'array to work with') end @@ -12,8 +12,8 @@ module Puppet::Parser::Functions hash = arguments[0] - if not hash.is_a?(Hash) - raise(Puppet::ParseError, 'keys(): Requires a hash to work with') + unless hash.is_a?(Hash) + raise(Puppet::ParseError, 'keys(): Requires hash to work with') end result = hash.keys @@ -13,8 +13,8 @@ module Puppet::Parser::Functions value = arguments[0] klass = value.class - if not [Array, String].include?(klass) - raise(Puppet::ParseError, 'lstrip(): Requires either an ' + + unless [Array, String].include?(klass) + raise(Puppet::ParseError, 'lstrip(): Requires either ' + 'array or string to work with') end @@ -13,8 +13,8 @@ module Puppet::Parser::Functions array = arguments[0] - if not array.is_a?(Array) - raise(Puppet::ParseError, 'prefix(): Requires an array to work with') + unless array.is_a?(Array) + raise(Puppet::ParseError, 'prefix(): Requires array to work with') end prefix = arguments[1] if arguments[1] @@ -13,8 +13,8 @@ module Puppet::Parser::Functions value = arguments[0] klass = value.class - if not [Array, String].include?(klass) - raise(Puppet::ParseError, 'reverse(): Requires either an ' + + unless [Array, String].include?(klass) + raise(Puppet::ParseError, 'reverse(): Requires either ' + 'array or string to work with') end @@ -13,8 +13,8 @@ module Puppet::Parser::Functions value = arguments[0] klass = value.class - if not [Array, String].include?(klass) - raise(Puppet::ParseError, 'rstrip(): Requires either an ' + + unless [Array, String].include?(klass) + raise(Puppet::ParseError, 'rstrip(): Requires either ' + 'array or string to work with') end diff --git a/str2bool.rb b/str2bool.rb index 02b5aae..5a52f25 100644 --- a/str2bool.rb +++ b/str2bool.rb @@ -12,11 +12,12 @@ module Puppet::Parser::Functions string = arguments[0] - if not string.is_a?(String) - raise(Puppet::ParseError, 'str2bool(): Requires either a ' + + unless string.is_a?(String) + raise(Puppet::ParseError, 'str2bool(): Requires either ' + 'string to work with') end + # We consider all the yes, no, y, n and so on too ... result = case string # # This is how undef looks like in Puppet ... @@ -12,8 +12,8 @@ module Puppet::Parser::Functions hash = arguments[0] - if not hash.is_a?(Hash) - raise(Puppet::ParseError, 'values(): Requires a hash to work with') + unless hash.is_a?(Hash) + raise(Puppet::ParseError, 'values(): Requires hash to work with') end result = hash.values diff --git a/values_at.rb b/values_at.rb index cd7205d..331af6a 100644 --- a/values_at.rb +++ b/values_at.rb @@ -15,9 +15,8 @@ module Puppet::Parser::Functions array = arguments.shift - if not array.is_a?(Array) - raise(Puppet::ParseError, 'values_at(): Requires an array ' + - 'to work with') + unless array.is_a?(Array) + raise(Puppet::ParseError, 'values_at(): Requires array to work with') end indices = *arguments # Get them all ... Pokemon ... |