summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/values_at.rb
diff options
context:
space:
mode:
authorVarac <varac@leap.se>2017-10-13 14:22:08 +0200
committerVarac <varac@leap.se>2017-10-13 14:22:08 +0200
commitf7779ce2eacaca51790d4e8d7756442b02612d30 (patch)
tree56871c123e1c964fc26e36bb86831a4a3511bd4f /lib/puppet/parser/functions/values_at.rb
parent066c08f8362d53f0f30897cb8710d11260c726ea (diff)
parent2339ea8db67ac7ef02d707c2a6011ae50f5d82b5 (diff)
Merge remote-tracking branch 'origin/master' into leap_masterHEADmaster
Diffstat (limited to 'lib/puppet/parser/functions/values_at.rb')
-rw-r--r--lib/puppet/parser/functions/values_at.rb18
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/puppet/parser/functions/values_at.rb b/lib/puppet/parser/functions/values_at.rb
index f350f53..04a3d1a 100644
--- a/lib/puppet/parser/functions/values_at.rb
+++ b/lib/puppet/parser/functions/values_at.rb
@@ -29,8 +29,7 @@ Would return ['a','c','d'].
EOS
) do |arguments|
- raise(Puppet::ParseError, "values_at(): Wrong number of " +
- "arguments given (#{arguments.size} for 2)") if arguments.size < 2
+ raise(Puppet::ParseError, "values_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
array = arguments.shift
@@ -41,8 +40,7 @@ Would return ['a','c','d'].
indices = [arguments.shift].flatten() # Get them all ... Pokemon ...
if not indices or indices.empty?
- raise(Puppet::ParseError, 'values_at(): You must provide ' +
- 'at least one positive index to collect')
+ raise(Puppet::ParseError, 'values_at(): You must provide at least one positive index to collect')
end
result = []
@@ -57,11 +55,9 @@ Would return ['a','c','d'].
type = m[2]
if start > stop
- raise(Puppet::ParseError, 'values_at(): Stop index in ' +
- 'given indices range is smaller than the start index')
+ raise(Puppet::ParseError, 'values_at(): Stop index in given indices range is smaller than the start index')
elsif stop > array.size - 1 # First element is at index 0 is it not?
- raise(Puppet::ParseError, 'values_at(): Stop index in ' +
- 'given indices range exceeds array size')
+ raise(Puppet::ParseError, 'values_at(): Stop index in given indices range exceeds array size')
end
range = case type
@@ -73,16 +69,14 @@ Would return ['a','c','d'].
else
# Only positive numbers allowed in this case ...
if not i.match(/^\d+$/)
- raise(Puppet::ParseError, 'values_at(): Unknown format ' +
- 'of given index')
+ raise(Puppet::ParseError, 'values_at(): Unknown format of given index')
end
# In Puppet numbers are often string-encoded ...
i = i.to_i
if i > array.size - 1 # Same story. First element is at index 0 ...
- raise(Puppet::ParseError, 'values_at(): Given index ' +
- 'exceeds array size')
+ raise(Puppet::ParseError, 'values_at(): Given index exceeds array size')
end
indices_list << i