[Bps-public-commit] r15072 - in sd/trunk: . lib/App/SD/CLI/Model
spang at bestpractical.com
spang at bestpractical.com
Tue Aug 12 09:27:48 EDT 2008
Author: spang
Date: Tue Aug 12 09:27:48 2008
New Revision: 15072
Modified:
sd/trunk/ (props changed)
sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm
sd/trunk/lib/App/SD/CLI/Model/Ticket.pm
Log:
r47465 at loki: spang | 2008-07-31 12:45:06 +0100
add new ticket create command which overrides prophet's and allows us to create new tickets with a comment attached in an EDITOR window
Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm
==============================================================================
Modified: sd/trunk/lib/App/SD/CLI/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Model/Ticket.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Model/Ticket.pm Tue Aug 12 09:27:48 2008
@@ -3,6 +3,44 @@
use constant record_class => 'App::SD::Model::Ticket';
+=head2 comment_separator
+
+Returns a string that separates the prop: value lines from the comment,
+which will be free text to the end of the new ticket. May contain
+arbitrary newlines.
+
+=cut
+
+sub comment_separator { "\n\n=== add ticket comment below ===\n"; }
+
+=head2 parse_record $str
+
+Takes a string containing a ticket record consisting of prop: value pairs
+followed by a separator, followed by an optional comment.
+
+Returns a list of (hashref of prop => value pairs, string contents of comment)
+with props with false values filtered out.
+
+=cut
+
+sub parse_record {
+ my $self = shift;
+ my $ticket = shift;
+
+ my %props;
+ my ($new_props, $comment) = split comment_separator(), $ticket;
+ my @lines = split "\n", $new_props;
+ foreach my $line (@lines) {
+ # match prop: value pairs. whitespace in between is ignored.
+ if ($line =~ m/^(.+):\s*(.*)$/) {
+ my $prop = $1;
+ my $val = $2;
+ $props{$prop} = $val unless !($val);
+ }
+ }
+ return \%props, $comment;
+}
+
no Moose::Role;
1;
More information about the Bps-public-commit
mailing list