source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/lstrip.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 7 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

File size: 779 bytes
Line 
1#
2# lstrip.rb
3#
4
5module Puppet::Parser::Functions
6 newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS
7Strips leading spaces to the left of a string.
8 EOS
9 ) do |arguments|
10
11 raise(Puppet::ParseError, "lstrip(): Wrong number of arguments " +
12 "given (#{arguments.size} for 1)") if arguments.size < 1
13
14 value = arguments[0]
15
16 unless value.is_a?(Array) || value.is_a?(String)
17 raise(Puppet::ParseError, 'lstrip(): Requires either ' +
18 'array or string to work with')
19 end
20
21 if value.is_a?(Array)
22 # Numbers in Puppet are often string-encoded which is troublesome ...
23 result = value.collect { |i| i.is_a?(String) ? i.lstrip : i }
24 else
25 result = value.lstrip
26 end
27
28 return result
29 end
30end
31
32# vim: set ts=2 sw=2 et :
Note: See TracBrowser for help on using the repository browser.