summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-06 20:42:39 -0800
committerMatt Robinson <matt@puppetlabs.com>2011-03-07 14:02:17 -0800
commit28095d7435bcab15b76ddfa4435d61653f2f890d (patch)
tree74ae5f037aaee78ed31de178c6e6f4203e9d7959 /lib/puppet/parser/functions
parent6869385300dc694c4f087e134949dff9e1e43df9 (diff)
parente8145f91debc863b341a270e1d8cff6c43d93ef5 (diff)
downloadpuppet-28095d7435bcab15b76ddfa4435d61653f2f890d.tar.gz
puppet-28095d7435bcab15b76ddfa4435d61653f2f890d.tar.xz
puppet-28095d7435bcab15b76ddfa4435d61653f2f890d.zip
Merge branch '2.6.next' into next
This was a particularly nasty merge, so rather than hold up merges into next any longer, I'm going to push this merge with a few outstanding problems. The tests that were failing in the following areas have been marked pending, and will be addressed separately, immediately following this push. TODO: Verify that brice's rdoc change is still valid: tests to show that line numbers from class, define and node get into the ast Fix mount parsed_spec spec/unit/provider/mount/parsed_spec.rb * 2.6.next: (85 commits) (#5148) Fix failing spec due to timezone (#5148) Add support for PSON to facts (#6338) Remove inventory indirection, and move to facts indirection (#6445) Fix inline docs: puppet agent does not accept --mkusers Update CHANGELOG and version for 2.6.6rc1 (#6541) Fix content with checksum truncation bug (#6418) Recursive files shouldn't be audited (#6541) maint: whitespace cleanup on the file integration spec (#6541) Fix content with checksum truncation bug (#5466) Write specs for output of puppet resource (#5466) Monkey patch Symbol so that you can sort them (#5466) Fixed puppet resource bug with trailing , Update CHANGELOG for 2.6.5 (#4922) Don't truncate remotely-sourced files on 404 (#6338) Remove unused version control tags Maint: Align tabs in a code block in the Augeas type. (#6509) Inline docs: Fix erroneous code block in directoryservice provider for computer type Maint: Rewrite comments about symlinks to reflect best practice. (#6509) Inline docs: Fix broken lists in Launchd provider. (#6509) Inline docs: Fix broken code blocks in zpool type ... Manually Resolved Conflicts: lib/puppet/application/inspect.rb lib/puppet/defaults.rb lib/puppet/file_bucket/dipper.rb lib/puppet/network/http/handler.rb lib/puppet/node/facts.rb lib/puppet/parser/parser.rb lib/puppet/parser/parser_support.rb lib/puppet/util/command_line/puppet lib/puppet/util/command_line/puppetd lib/puppet/util/command_line/puppetmasterd lib/puppet/util/monkey_patches.rb lib/puppet/util/rdoc/parser.rb spec/unit/application/agent_spec.rb spec/unit/file_bucket/file_spec.rb spec/unit/indirector/file_bucket_file/file_spec.rb spec/unit/network/http/handler_spec.rb spec/unit/parser/parser_spec.rb spec/unit/provider/mount/parsed_spec.rb
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r--lib/puppet/parser/functions/regsubst.rb21
-rw-r--r--lib/puppet/parser/functions/split.rb14
2 files changed, 14 insertions, 21 deletions
diff --git a/lib/puppet/parser/functions/regsubst.rb b/lib/puppet/parser/functions/regsubst.rb
index f655db7b3..b6bb5afcf 100644
--- a/lib/puppet/parser/functions/regsubst.rb
+++ b/lib/puppet/parser/functions/regsubst.rb
@@ -4,25 +4,18 @@ module Puppet::Parser::Functions
:regsubst, :type => :rvalue,
:doc => "
- Perform regexp replacement on a string or array of strings.
+Perform regexp replacement on a string or array of strings.
* *Parameters* (in order):
-
- _target_ The string or array of strings to operate on. If an array, the replacement will be performed on each of the elements in the array, and the return value will be an array.
-
- _regexp_ The regular expression matching the target string. If you want it anchored at the start and or end of the string, you must do that with ^ and $ yourself.
-
- _replacement_ Replacement string. Can contain back references to what was matched using \\0, \\1, and so on.
-
- _flags_ Optional. String of single letter flags for how the regexp is interpreted:
-
+ * _target_ The string or array of strings to operate on. If an array, the replacement will be performed on each of the elements in the array, and the return value will be an array.
+ * _regexp_ The regular expression matching the target string. If you want it anchored at the start and or end of the string, you must do that with ^ and $ yourself.
+ * _replacement_ Replacement string. Can contain backreferences to what was matched using \\0 (whole match), \\1 (first set of parentheses), and so on.
+ * _flags_ Optional. String of single letter flags for how the regexp is interpreted:
- *E* Extended regexps
- *I* Ignore case in regexps
- *M* Multiline regexps
- *G* Global replacement; all occurrences of the regexp in each target string will be replaced. Without this, only the first occurrence will be replaced.
-
- _lang_ Optional. How to handle multibyte characters. A single-character string with the following values:
-
+ * _encoding_ Optional. How to handle multibyte characters. A single-character string with the following values:
- *N* None
- *E* EUC
- *S* SJIS
@@ -32,7 +25,7 @@ module Puppet::Parser::Functions
Get the third octet from the node's IP address:
- $i3 = regsubst($ipaddress,'^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$','\\3')
+ $i3 = regsubst($ipaddress,'^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$','\\3')
Put angle brackets around each octet in the node's IP address:
diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb
index 52394095a..ad027865b 100644
--- a/lib/puppet/parser/functions/split.rb
+++ b/lib/puppet/parser/functions/split.rb
@@ -6,21 +6,21 @@ module Puppet::Parser::Functions
:doc => "\
Split a string variable into an array using the specified split regexp.
- Usage:
+*Example:*
$string = 'v1.v2:v3.v4'
$array_var1 = split($string, ':')
$array_var2 = split($string, '[.]')
$array_var3 = split($string, '[.:]')
-$array_var1 now holds the result ['v1.v2', 'v3.v4'],
-while $array_var2 holds ['v1', 'v2:v3', 'v4'], and
-$array_var3 holds ['v1', 'v2', 'v3', 'v4'].
+`$array_var1` now holds the result `['v1.v2', 'v3.v4']`,
+while `$array_var2` holds `['v1', 'v2:v3', 'v4']`, and
+`$array_var3` holds `['v1', 'v2', 'v3', 'v4']`.
-Note that in the second example, we split on a string that contains
-a regexp meta-character (.), and that needs protection. A simple
+Note that in the second example, we split on a literal string that contains
+a regexp meta-character (.), which must be escaped. A simple
way to do that for a single character is to enclose it in square
-brackets.") do |args|
+brackets; a backslash will also escape a single character.") do |args|
raise Puppet::ParseError, ("split(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2