source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/squeeze.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: 815 bytes
Line 
1#
2# squeeze.rb
3#
4
5module Puppet::Parser::Functions
6 newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS
7Returns a new string where runs of the same character that occur in this set are replaced by a single character.
8 EOS
9 ) do |arguments|
10
11 if ((arguments.size != 2) and (arguments.size != 1)) then
12 raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+
13 "given #{arguments.size} for 2 or 1")
14 end
15
16 item = arguments[0]
17 squeezeval = arguments[1]
18
19 if item.is_a?(Array) then
20 if squeezeval then
21 item.collect { |i| i.squeeze(squeezeval) }
22 else
23 item.collect { |i| i.squeeze }
24 end
25 else
26 if squeezeval then
27 item.squeeze(squeezeval)
28 else
29 item.squeeze
30 end
31 end
32
33 end
34end
35
36# vim: set ts=2 sw=2 et :
Note: See TracBrowser for help on using the repository browser.