[Bps-public-commit] RT-Extension-ExtractCustomFieldValues branch, master, updated. 3.07-4-g3a043e0

Thomas Sibley trs at bestpractical.com
Tue Jul 30 20:50:58 EDT 2013


The branch, master has been updated
       via  3a043e046ae3359dc22eda9c177d2c755a34445b (commit)
      from  5da69469921c1654a1fdea79b0a7da5b5a768600 (commit)

Summary of changes:
 etc/initialdata                              |  5 +++++
 lib/RT/Action/ExtractCustomFieldValues.pm    | 21 +++++++++++++++++++++
 lib/RT/Extension/ExtractCustomFieldValues.pm | 10 +++++++---
 3 files changed, 33 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 3a043e046ae3359dc22eda9c177d2c755a34445b
Author: Kevin Riggle <kriggle at akamai.com>
Date:   Tue Jul 2 23:01:12 2013 +0000

    add a '+' option to capture multiple values
    
    Signed-off-by: Thomas Sibley <trs at bestpractical.com>

diff --git a/etc/initialdata b/etc/initialdata
index 87be810..bee0309 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -28,6 +28,11 @@
 #     capturing groups, the first of which is the CF name,
 #     the second of which is the value.  If this option is
 #     given, the <cf-name> field is ignored.
+#     (Supercedes '+'.)
+# + - (multiple) The MatchString regex will be applied with
+#     the /g option and all matching values will be added to
+#     the CF, which should probably be a multi-value CF for
+#     best results.  (Superceded by '*'.)
 
 #### Examples:
 
diff --git a/lib/RT/Action/ExtractCustomFieldValues.pm b/lib/RT/Action/ExtractCustomFieldValues.pm
index 15aa469..dad0189 100644
--- a/lib/RT/Action/ExtractCustomFieldValues.pm
+++ b/lib/RT/Action/ExtractCustomFieldValues.pm
@@ -93,6 +93,27 @@ sub Commit {
                     return $found;
                 },
             );
+        } elsif ( $config{Options} =~ /\+/ ) {
+            my $cf;
+            $cf = $self->LoadCF( Name => $config{CFName} )
+                if $config{CFName};
+
+            $self->FindContent(
+                %config,
+                Callback    => sub {
+                    my $content = shift;
+                    my $found = 0;
+                    while ( $content =~ /($config{Match})/mg ) {
+                        $found++;
+                        $self->ProcessCF(
+                            %config,
+                            CustomField => $cf,
+                            Value       => $2 || $1,
+                        );
+                    }
+                    return $found;
+                }
+            );
         } else {
             my $cf;
             $cf = $self->LoadCF( Name => $config{CFName} )
diff --git a/lib/RT/Extension/ExtractCustomFieldValues.pm b/lib/RT/Extension/ExtractCustomFieldValues.pm
index 6e9be25..f103271 100644
--- a/lib/RT/Extension/ExtractCustomFieldValues.pm
+++ b/lib/RT/Extension/ExtractCustomFieldValues.pm
@@ -57,8 +57,8 @@ based on your match.
 of the email or "headers" to search all of the headers.
 
 =item <MatchString> - a regular expression to find a match in the header or
-body if the MatchString matches a comma separated list and the CF is a multi
-value CF then each item in the list is added as a separate value.
+body.  If the MatchString matches a comma separated list and the CF is a
+multi-value CF then each item in the list is added as a separate value.
 
 =item <Postcmd>  - a perl code to be evaluated on C<$value>, where C<$value> is
 either $1 or full match text from the match performed with <MatchString>
@@ -72,7 +72,11 @@ options include:
 
 =item '*' - (wildcard) The MatchString regex should contain _two_ capturing
 groups, the first of which is the CF name, the second of which is the value.
-If this option is given, the <cf-name> field is ignored.
+If this option is given, the <cf-name> field is ignored.  (Supercedes '+'.)
+
+=item '+' - (multiple) The MatchString regex will be applied with the /g option
+and all matching values will be added to the CF, which should probably be a
+multi-value CF for best results.  (Superceded by '*'.)
 
 =back
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list