[Bps-public-commit] r15065 - in sd/trunk: . bin lib/App lib/App/SD lib/App/SD/CLI lib/App/SD/CLI/Command lib/App/SD/CLI/Command/Attachment lib/App/SD/CLI/Command/Ticket lib/App/SD/CLI/Command/Ticket/Attachment lib/App/SD/CLI/Command/Ticket/Comment lib/App/SD/CLI/Model lib/App/SD/Model lib/App/SD/Replica/Hiveminder lib/App/SD/Replica/RT t
spang at bestpractical.com
spang at bestpractical.com
Tue Aug 12 09:09:35 EDT 2008
Author: spang
Date: Tue Aug 12 09:09:25 2008
New Revision: 15065
Added:
sd/trunk/lib/App/SD/CLI/Command/Merge.pm
sd/trunk/t/00-create.t
Modified:
sd/trunk/ (props changed)
sd/trunk/Makefile.PL
sd/trunk/bin/sd
sd/trunk/lib/App/SD.pm
sd/trunk/lib/App/SD/CLI/Command.pm
sd/trunk/lib/App/SD/CLI/Command/Attachment/Create.pm
sd/trunk/lib/App/SD/CLI/Command/Help.pm
sd/trunk/lib/App/SD/CLI/Command/Pull.pm
sd/trunk/lib/App/SD/CLI/Command/Push.pm
sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm
sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm
sd/trunk/lib/App/SD/CLI/Model/Ticket.pm
sd/trunk/lib/App/SD/Model/Ticket.pm
sd/trunk/lib/App/SD/Replica/Hiveminder.pm
sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm
sd/trunk/lib/App/SD/Replica/Hiveminder/PushEncoder.pm
sd/trunk/lib/App/SD/Replica/RT.pm
sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm
sd/trunk/lib/App/SD/Replica/RT/PushEncoder.pm
sd/trunk/lib/App/SD/Test.pm
sd/trunk/t/sd-attachments.t
sd/trunk/t/sd-comments.t
sd/trunk/t/sd-hm.t
sd/trunk/t/sd-rt-hm.t
Log:
r44011 at loki: spang | 2008-07-14 11:00:24 +0100
r43851 at loki (orig r13889): jesse | 2008-07-08 21:47:10 +0100
* testing that we can run the help command
r43875 at loki (orig r13913): jesse | 2008-07-09 17:47:03 +0100
* Better normalization of undef and '' values in the RT pull encoder
r43877 at loki (orig r13915): jesse | 2008-07-09 18:03:53 +0100
* It helps when I don't mess up the moosification
r43886 at loki (orig r13924): jesse | 2008-07-09 20:41:56 +0100
* Extracting the push and pull specific bits of logic into separate classes
r43889 at loki (orig r13927): jesse | 2008-07-09 20:53:56 +0100
* Hiveminder PushEncoder refactoring
r43895 at loki (orig r13933): sartak | 2008-07-09 22:35:22 +0100
r63991 at onn: sartak | 2008-07-09 17:34:31 -0400
Explode bin/sd into App/SD/CLI
r43905 at loki (orig r13943): jesse | 2008-07-10 15:23:09 +0100
* Small cleanups during refactoring
r43907 at loki (orig r13945): sartak | 2008-07-10 17:08:55 +0100
r64036 at onn: sartak | 2008-07-10 12:08:51 -0400
Use the "before" method modifier instead of explicit override/super
r43908 at loki (orig r13946): sartak | 2008-07-10 17:25:22 +0100
r64038 at onn: sartak | 2008-07-10 12:25:16 -0400
hardcoding perl path BAD
r43915 at loki (orig r13953): sartak | 2008-07-10 19:13:40 +0100
r64056 at onn: sartak | 2008-07-10 14:13:34 -0400
Use --batch in the test scripts. t/sd-rt-hm.t is currently failing in more interesting ways
r43916 at loki (orig r13954): sartak | 2008-07-10 19:34:39 +0100
r64058 at onn: sartak | 2008-07-10 14:34:29 -0400
Use --batch when translating between luid and guid
r43918 at loki (orig r13956): sartak | 2008-07-10 20:21:27 +0100
r64063 at onn: sartak | 2008-07-10 15:21:20 -0400
Color ticket status in "ticket show"
r43921 at loki (orig r13959): sartak | 2008-07-10 20:47:53 +0100
r64068 at onn: sartak | 2008-07-10 15:47:41 -0400
Don't require Term::ANSIColor - it's been cored :D
r43922 at loki (orig r13960): sartak | 2008-07-10 20:52:37 +0100
r64070 at onn: sartak | 2008-07-10 15:52:26 -0400
Don't rebless into our parent class, just override/super "run"
r43923 at loki (orig r13961): sartak | 2008-07-10 21:06:33 +0100
r64072 at onn: sartak | 2008-07-10 16:06:26 -0400
Finish fixing Pull and Push to be more Moosey
r43925 at loki (orig r13963): sartak | 2008-07-10 21:20:29 +0100
r64076 at onn: sartak | 2008-07-10 16:20:18 -0400
Steal Prophet's README (how to run all tests)
r43926 at loki (orig r13964): jesse | 2008-07-10 21:36:43 +0100
* Refactor to remove this whole idea of having two versions of a ticket passed around
r43933 at loki (orig r13971): sartak | 2008-07-10 22:07:14 +0100
r64087 at onn: sartak | 2008-07-10 17:06:48 -0400
props_to_show for tickets
r43935 at loki (orig r13973): sartak | 2008-07-10 22:14:47 +0100
r64091 at onn: sartak | 2008-07-10 17:14:05 -0400
Cleanup
r43938 at loki (orig r13976): sartak | 2008-07-10 22:58:43 +0100
r64094 at onn: sartak | 2008-07-10 17:58:38 -0400
Kill "sd details" and phoenix it with "sd ticket details" with less insanity. Some of the code should be API'd though
r43942 at loki (orig r13980): jesse | 2008-07-11 03:59:32 +0100
* syncing with rt3.fsck.com is now happy
Modified: sd/trunk/Makefile.PL
==============================================================================
--- sd/trunk/Makefile.PL (original)
+++ sd/trunk/Makefile.PL Tue Aug 12 09:09:25 2008
@@ -9,6 +9,7 @@
requires('Clone');
requires('Moose'); # Moose::Role
requires('DateTime');
+
features(
'RT sync' => [
-default => 0,
Modified: sd/trunk/bin/sd
==============================================================================
--- sd/trunk/bin/sd (original)
+++ sd/trunk/bin/sd Tue Aug 12 09:09:25 2008
@@ -6,233 +6,6 @@
$ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} || $ENV{'HOME'}.'/.sd';
-use Prophet::CLI;
-use App::SD::Model::Ticket;
-
-package App::SD::CLI::Command;
-use Moose::Role;
-use Path::Class;
-
-sub get_content {
- my $self = shift;
- my $type = shift;
-
- my $content;
- if (my $file = file(delete $self->args->{'file'})) {
- $content = $file->slurp();
- $self->args->{'name'} = $file->basename;
- } elsif ($content = delete $self->args->{'content'}) {
-
- } elsif (exists $self->args->{'edit'}) {
- $content = $self->edit_text('');
- } else {
- print "Please type your $type and press ctrl-d.\n";
- $content = do { local $/; <> };
- }
-
- chomp $content;
- return $content;
-}
-
-package App::SD::CLI::Model::Ticket;
-use Moose::Role;
-use constant record_class => 'App::SD::Model::Ticket';
-
-package App::SD::CLI::Model::TicketComment;
-use Moose::Role;
-use constant record_class => 'App::SD::Model::Comment';
-
-package App::SD::CLI::Model::Attachment;
-use Moose::Role;
-use constant record_class => 'App::SD::Model::Attachment';
-
-
-
-
-
-package App::SD::CLI::Command::Ticket::Comment::Create;
-use Moose;
-
-extends 'Prophet::CLI::Command::Create';
-with 'App::SD::CLI::Model::TicketComment';
-with 'App::SD::CLI::Command';
-
-override run => sub {
- my $self = shift;
- $self->args->{'ticket'} = $self->cli->uuid;
- $self->args->{'content'} = $self->get_content('comment');
- super(@_);
-};
-# override args to feed in that ticket's uuid as an argument to the comment
-
-
-
-package App::SD::CLI::Command::Attachment::Create;
-use Moose;
-extends 'Prophet::CLI::Command::Create';
-with 'App::SD::CLI::Model::Attachment';
-with 'App::SD::CLI::Command';
-
-override run => sub {
- my $self = shift;
- $self->args->{'content'} = $self->get_content('attachment');
- super(@_);
-
-};
-
-package App::SD::CLI::Command::Ticket::Attachment::Create;
-use Moose;
-extends 'App::SD::CLI::Command::Attachment::Create';
-# override args to feed in that ticket's uuid as an argument to the comment
-
-override run => sub {
- my $self = shift;
- $self->args->{'ticket'} = $self->cli->uuid;
- super(@_);
-};
-
-
-package App::SD::CLI::Command::Ticket::Attachment::Search;
-use Moose;
-extends 'Prophet::CLI::Command::Search';
-with 'Prophet::CLI::RecordCommand';
-with 'App::SD::CLI::Model::Attachment';
-# override args to feed in that ticket's uuid as an argument to the comment
-
-
-sub type {'attachment'}
-sub get_search_callback {
- my $self = shift;
- return sub {
- shift->prop('ticket') eq $self->uuid ? 1 : 0;
- }
-
-}
-
-
-package App::SD::CLI::Command::Attachment::Content;
-use Moose;
-extends 'Prophet::CLI::Command::Show';
-with 'App::SD::CLI::Model::Attachment';
-with 'App::SD::CLI::Command';
-
-sub run {
- my $self = shift;
- my $record = $self->_get_record_class;
- $record->load(uuid => $self->cli->uuid);
- print $record->prop('content');
-}
-
-package App::SD::CLI::Command::Help;
-use Moose;
-with 'App::SD::CLI::Command';
-
-sub run {
-
-print <<EOF
-
-$0 ticket create --summary "This is a summary" --status new --somekey value
-$0 ticket update --uuid <uuid> --status resolved
-$0 ticket search --regex .
-$0 ticket delete --uuid <uuid>
-$0 ticket show --uuid <uuid>
-$0 pull --from remote-url
-
-$0 help
- Show this file
-
-EOF
-
-}
-
-package App::SD::CLI::Command::Ticket::Show;
-use Moose;
-extends 'Prophet::CLI::Command::Show';
-with 'App::SD::CLI::Command';
-with 'App::SD::CLI::Model::Ticket';
-
-package App::SD::CLI::Command::Details;
-use Moose;
-with 'App::SD::CLI::Command';
-with 'App::SD::CLI::Model::Ticket';
-
-sub run {
- my $self = shift;
- print "\n=head1 METADATA\n\n";
- $self->App::SD::CLI::Command::Ticket::Show::run();
- print "\n=head1 ATTACHMENTS\n\n";
- use Clone;
- my $foo = Clone::clone($self);
- $foo->type('attachment');
- bless $foo, 'App::SD::CLI::Command::Ticket::Attachment::Search';
- $foo->run;
- print "\n=head1 COMMENTS\n\n";
- my $bar = Clone::clone($self);
- bless $bar, 'App::SD::CLI::Command::Ticket::Comments';
- $bar->type('comment');
- $bar->App::SD::CLI::Command::Ticket::Comments::run();
-}
-
-package App::SD::CLI::Command::Ticket::Comments;
-use Moose;
-extends 'Prophet::CLI::Command';
-with 'Prophet::CLI::RecordCommand';
-with 'App::SD::CLI::Model::Ticket';
-
-sub run {
- my $self = shift;
- my $record = $self->_get_record_class();
- $record->load( uuid => $self->uuid );
- unless (@{$record->comments}) {
- print "No comments found\n";
- }
-
- for (sort { $a->prop('date') cmp $b->prop('date') } @{$record->comments}) {
- print "id: ".$_->luid." (".$_->uuid.")\n";
- print "date: ".$_->prop('date')."\n";
- print $_->prop('content')."\n";
- }
-
-}
-
-
-package App::SD::CLI::Command::Merge;
-use Moose;
-extends qw/Prophet::CLI::Command::Merge/;
-with 'App::SD::CLI::Command';
-
-package App::SD::CLI::Command::Push;
-use Moose;
-extends qw/App::SD::CLI::Command::Merge/;
-
-sub run {
- my $self = shift;
- local $ENV{PROPHET_RESOLVER} = 'Prompt';
- bless $self, 'App::SD::CLI::Command::Merge';
- $self->args( {to => $self->args->{'to'}, from => $self->app_handle->default_replica_type.":file://".$self->app_handle->handle->fs_root });
- $self->run;
-}
-
-package App::SD::CLI::Command::Pull;
-use Moose;
-extends qw/App::SD::CLI::Command::Merge/;
-
-sub run {
- my $self = shift;
-
- die "Please specify a --from.\n" if !defined($self->args->{'from'});
-
- local $ENV{PROPHET_RESOLVER} = 'Prompt';
- bless $self, 'App::SD::CLI::Command::Merge';
- $self->args({ from => $self->args->{'from'},
- to => $self->cli->app_handle->default_replica_type.":file://".$self->cli->app_handle->handle->fs_root });
- $self->run;
-}
-
-package main;
-
-my $cli = Prophet::CLI->new( { app_class => 'App::SD' } );
+my $cli = Prophet::CLI->new({ app_class => 'App::SD' });
$cli->run_one_command;
-
-1;
Modified: sd/trunk/lib/App/SD.pm
==============================================================================
Modified: sd/trunk/lib/App/SD/CLI/Command.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command.pm Tue Aug 12 09:09:25 2008
@@ -2,58 +2,20 @@
use Moose::Role;
use Path::Class;
-=head2 get_content %args
-
-This is a helper routine for use in SD commands to enable getting records
-in different ways such as from a file, on the commandline, or from an
-editor. Returns the record content.
-
-Valid keys in %args are type => str, default_edit => bool, and
-prefill_props => $props_hash_ref, props_order => $order_array_ref,
-footer => str, header => str.
-
-Specifying props with prefill_props allows you to present lists of
-key/value pairs (with possible default values) for a user to fill in.
-If you need a specific ordering of props, specify it with
-C<props_order>. Specifying C<header> and/or C<footer> allows you to
-print some optional text before and/or after the list of props.
-
-Note that you will have to post-process C<$content> from the routine
-calling C<get_content> in order to extract the keys and values from
-the returned text.
-
-=cut
-
sub get_content {
my $self = shift;
- my %args = @_;
+ my $type = shift;
my $content;
- if (my $file = file($self->delete_arg('file'))) {
+ if (my $file = file(delete $self->args->{'file'})) {
$content = $file->slurp();
- $self->set_prop(name => $file->basename);
- } elsif ($content = $self->delete_arg('content')) {
+ $self->args->{'name'} = $file->basename;
+ } elsif ($content = delete $self->args->{'content'}) {
- } elsif ($args{default_edit} || $self->has_arg('edit')) {
- my $text = '';
- if (my $header = $args{header}) {
- $text .= $header;
- }
- if (my $props = $args{prefill_props}) {
- my $props_order;
- my @ordering = ($props_order = $args{props_order}) ?
- @$props_order : keys %$props;
- $text .= join "\n", map { "$_: $props->{$_}" } @ordering;
- }
- if (my $footer = $args{footer}) {
- $text .= $footer;
- }
- $content = $self->edit_text($text);
- # user aborted their text editor without changing anything; signify
- # this to the caller by returning nothing
- $content = '' if $content eq $text;
+ } elsif (exists $self->args->{'edit'}) {
+ $content = $self->edit_text('');
} else {
- print "Please type your $args{type} and press ctrl-d.\n";
+ print "Please type your $type and press ctrl-d.\n";
$content = do { local $/; <> };
}
Modified: sd/trunk/lib/App/SD/CLI/Command/Attachment/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Attachment/Create.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Attachment/Create.pm Tue Aug 12 09:09:25 2008
@@ -6,13 +6,7 @@
before run => sub {
my $self = shift;
-
- my $content = $self->get_content(type => 'attachment');
-
- die "Aborted.\n"
- if length($content) == 0;
-
- $self->set_prop(content => $content);
+ $self->args->{'content'} = $self->get_content('attachment');
};
__PACKAGE__->meta->make_immutable;
Modified: sd/trunk/lib/App/SD/CLI/Command/Help.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Help.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Help.pm Tue Aug 12 09:09:25 2008
@@ -3,46 +3,30 @@
extends 'Prophet::CLI::Command';
with 'App::SD::CLI::Command';
-sub title {
- my $self = shift;
-
-}
-
-sub _get_cmd_name {
- my $self = shift;
- return '' if $self->cli->interactive_shell;
- my $cmd = $0;
- $cmd =~ s{^(.*)/}{}g;
- return $cmd;
-}
+sub run {
+print <<EOF
+$0 @{[$App::SD::VERSION]}
-sub print_header {
- my $self = shift;
- my $title = shift;
- my $string = "sd ".$App::SD::VERSION." - " .$title;
-
- print "\n".$string . "\n";
- print '-' x ( length($string));
- print "\n";
+$0 ticket create --summary "This is a summary" --status new --somekey value
+$0 ticket update --uuid <uuid> --status resolved
+$0 ticket search --regex .
+$0 ticket delete --uuid <uuid>
+$0 ticket show --uuid <uuid>
+$0 pull --from remote-url
-}
-sub run {
- my $self = shift;
- my $cmd = $self->_get_cmd_name;
+$0 help
+ Show this file
- $self->print_header("Help Index");
+= ENVIRONMENT
+ export SD_REPO=/path/to/sd/replica
+ # Specify where the ticket database SD is using should reside
-print <<EOF
+= EXAMPLES
-$cmd help search - Searching for and displaying tickets
-$cmd help tickets - Working with tickets
-$cmd help comments - Working with ticket comments
-$cmd help attachments - Working with ticket attachments
-$cmd help sync - Publishing and importing ticket databases
-$cmd help environment - Environment variables which affect sd
+ sd pull --from rt:http://rt3.fsck.com|QUEUENAME|QUERY
EOF
Added: sd/trunk/lib/App/SD/CLI/Command/Merge.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Merge.pm Tue Aug 12 09:09:25 2008
@@ -0,0 +1,10 @@
+package App::SD::CLI::Command::Merge;
+use Moose;
+extends qw/Prophet::CLI::Command::Merge/;
+with 'App::SD::CLI::Command';
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+
Modified: sd/trunk/lib/App/SD/CLI/Command/Pull.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Pull.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Pull.pm Tue Aug 12 09:09:25 2008
@@ -1,6 +1,18 @@
package App::SD::CLI::Command::Pull;
use Moose;
-extends qw/Prophet::CLI::Command::Pull/;
+extends qw/App::SD::CLI::Command::Merge/;
+
+override run => sub {
+ my $self = shift;
+
+ die "Please specify a --from.\n" if !$self->has_arg('from');
+
+ local $ENV{PROPHET_RESOLVER} = 'Prompt';
+
+ $self->set_arg(to => $self->cli->app_handle->default_replica_type.":file://".$self->cli->app_handle->handle->fs_root);
+
+ super();
+};
__PACKAGE__->meta->make_immutable;
no Moose;
Modified: sd/trunk/lib/App/SD/CLI/Command/Push.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Push.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Push.pm Tue Aug 12 09:09:25 2008
@@ -1,6 +1,18 @@
package App::SD::CLI::Command::Push;
use Moose;
-extends qw/Prophet::CLI::Command::Push/;
+extends qw/App::SD::CLI::Command::Merge/;
+
+override run => sub {
+ my $self = shift;
+
+ die "Please specify a --to.\n" if !$self->has_arg('to');
+
+ local $ENV{PROPHET_RESOLVER} = 'Prompt';
+
+ $self->set_arg(from => $self->app_handle->default_replica_type.":file://".$self->app_handle->handle->fs_root);
+
+ super();
+};
__PACKAGE__->meta->make_immutable;
no Moose;
Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm Tue Aug 12 09:09:25 2008
@@ -5,9 +5,7 @@
before run => sub {
my $self = shift;
- $self->require_uuid;
-
- $self->set_prop(ticket => $self->cli->uuid);
+ $self->args->{'ticket'} = $self->cli->uuid;
};
__PACKAGE__->meta->make_immutable;
Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm Tue Aug 12 09:09:25 2008
@@ -8,15 +8,8 @@
# override args to feed in that ticket's uuid as an argument to the comment
before run => sub {
my $self = shift;
- $self->require_uuid;
-
- my $content = $self->get_content(type => 'comment', default_edit => 1);
-
- die "Aborted.\n"
- if length($content) == 0;
-
- $self->set_prop(ticket => $self->cli->uuid);
- $self->set_prop(content => $content);
+ $self->args->{'ticket'} = $self->cli->uuid;
+ $self->args->{'content'} = $self->get_content('comment');
};
__PACKAGE__->meta->make_immutable;
Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm Tue Aug 12 09:09:25 2008
@@ -7,17 +7,15 @@
sub run {
my $self = shift;
my $record = $self->_get_record_class();
-
- $self->require_uuid;
$record->load( uuid => $self->uuid );
unless (@{$record->comments}) {
print "No comments found\n";
}
- for my $entry (sort { $a->prop('created') cmp $b->prop('created') } @{$record->comments}) {
- print "id: ".$entry->luid." (".$entry->uuid.")\n";
- print "created: ".$entry->prop('created')."\n";
- print $entry->prop('content')."\n";
+ for (sort { $a->prop('date') cmp $b->prop('date') } @{$record->comments}) {
+ print "id: ".$_->luid." (".$_->uuid.")\n";
+ print "date: ".$_->prop('date')."\n";
+ print $_->prop('content')."\n";
}
}
Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm Tue Aug 12 09:09:25 2008
@@ -2,33 +2,30 @@
use Moose;
extends 'App::SD::CLI::Command::Ticket::Show';
-sub by_creation_date { $a->prop('created') cmp $b->prop('created') };
-
override run => sub {
my $self = shift;
-
- $self->require_uuid;
my $record = $self->_load_record;
print "\n=head1 METADATA\n\n";
super();
- my @attachments = sort by_creation_date @{$record->attachments};
- if (@attachments) {
- print "\n=head1 ATTACHMENTS\n\n";
- print $_->format_summary . "\n"
- for @attachments;
- }
-
- my @comments = sort by_creation_date @{$record->comments};
- if (@comments) {
- print "\n=head1 COMMENTS\n\n";
- print $_->prop('created') . "\n" . $_->prop('content') . "\n\n"
- for @comments;
- }
-
- print "\n=head1 HISTORY\n\n";
- print $record->history_as_string;
+ print "\n=head1 ATTACHMENTS\n\n";
+ my $attachments = App::SD::Collection::Attachment->new(
+ handle => $self->app_handle->handle,
+ );
+ $attachments->matching(sub {
+ shift->prop('ticket') eq $self->uuid ? 1 : 0;
+ });
+ print $_->format_summary . "\n" for $attachments->items;
+
+ print "\n=head1 COMMENTS\n\n";
+ my $comments = App::SD::Collection::Comment->new(
+ handle => $self->app_handle->handle,
+ );
+ $comments->matching(sub {
+ shift->prop('ticket') eq $self->uuid ? 1 : 0;
+ });
+ print $_->prop('content') . "\n" for $comments->items;
};
__PACKAGE__->meta->make_immutable;
Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm (original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm Tue Aug 12 09:09:25 2008
@@ -6,6 +6,5 @@
__PACKAGE__->meta->make_immutable;
no Moose;
-
1;
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:09:25 2008
@@ -3,44 +3,6 @@
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;
Modified: sd/trunk/lib/App/SD/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Ticket.pm (original)
+++ sd/trunk/lib/App/SD/Model/Ticket.pm Tue Aug 12 09:09:25 2008
@@ -1,8 +1,8 @@
package App::SD::Model::Ticket;
use Moose;
extends 'App::SD::Record';
+
use Term::ANSIColor;
-use HTTP::Date;
use constant collection_class => 'App::SD::Collection::Ticket';
use constant type => 'ticket';
@@ -47,13 +47,6 @@
}
-=head2 color_prop_status $value
-
-Returns the stats prop value C<$value> wrapped in colorization escape
-codes (from L<Term::ANSIColor>).
-
-=cut
-
sub color_prop_status {
my ($self, $value) = @_;
@@ -67,57 +60,8 @@
return colored($value, $color);
}
-=head2 color_prop_due $due
-
-Returns the due prop value C<$due> wrapped in colorization escape
-codes if it is overdue.
-
-=cut
-
-sub color_prop_due {
- my ($self, $due) = @_;
-
- return colored($due, 'red') if $self->is_overdue($due);
- return $due;
-}
-
-=head2 props_to_show
-
-A list of which properties to display for the C<show> command (in order
-from first to last).
-
-=cut
-
sub props_to_show {
- ('id', 'summary', 'status', 'owner', 'created', 'due', 'creator', 'reported_by')
-}
-
-=head2 is_overdue [$date]
-
-Takes an ISO date (or uses the C<date> prop value if no date is given).
-
-Returns false if the date is not a valid ISO date or its due date is
-in the future. Returns true if the due date has passed.
-
-=cut
-
-# this expects ISO dates. we should improve it in the future to require
-sub is_overdue {
- my $self = shift;
- my $date = shift || $self->prop('due');
-
- return 0 if !$date;
-
- if ($date !~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/) {
- warn "Unknown date format '$date'";
- return 0;
- }
-
- my $then = HTTP::Date::str2time($date, 'GMT');
- return 0 if !$then;
-
- my $now = time();
- return $now > $then;
+ ('id', 'summary', 'status', 'owner', 'due', 'creator', 'reported_by', 'CF-Broken in', 'CF-Severity')
}
__PACKAGE__->register_reference( comments => 'App::SD::Collection::Comment', by => 'ticket');
Modified: sd/trunk/lib/App/SD/Replica/Hiveminder.pm
==============================================================================
Modified: sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm
==============================================================================
Modified: sd/trunk/lib/App/SD/Replica/Hiveminder/PushEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/Hiveminder/PushEncoder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/Hiveminder/PushEncoder.pm Tue Aug 12 09:09:25 2008
@@ -83,11 +83,11 @@
}
sub integrate_comment {
- warn "comment not implemented yet";
+ warn "comment not yet";
}
sub integrate_ticket_update {
- warn "update not implemented yet";
+ warn "update not yet";
}
sub _recode_props_for_integrate {
@@ -105,8 +105,6 @@
return \%attr;
}
-__PACKAGE__->meta->make_immutable;
-no Moose;
1;
Modified: sd/trunk/lib/App/SD/Replica/RT.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/RT.pm (original)
+++ sd/trunk/lib/App/SD/Replica/RT.pm Tue Aug 12 09:09:25 2008
@@ -27,16 +27,6 @@
};
-# XXX: this should be called from superclass, or better, have individual attributes have their own builders.
-
-around 'new' => sub {
- my ($next, $self, @args) = @_;
- my $ret = $self->$next(@args);
- $ret->setup;
- return $ret;
-};
-
-
use File::Temp 'tempdir';
sub setup {
@@ -58,6 +48,7 @@
$self->rt_url($uri->as_string);
$self->rt_queue($type);
$self->rt_query( ( $query ? "($query) AND " :"") . " Queue = '$type'" );
+ warn $self->rt_query;
$self->rt( RT::Client::REST->new( server => $server ) );
( $username, $password ) = $self->prompt_for_login( $uri, $username )
@@ -288,7 +279,4 @@
=cut
-__PACKAGE__->meta->make_immutable;
-no Moose;
-
1;
Modified: sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm Tue Aug 12 09:09:25 2008
@@ -61,23 +61,18 @@
my $ticket = shift;
$ticket->{'id'} =~ s/^ticket\///g;
-
map { $ticket->{ $self->sync_source->uuid . '-' . lc($_) } = delete $ticket->{$_} }
(qw(Queue id));
map { delete $ticket->{$_} if ( !defined $ticket->{$_} || $ticket->{$_} eq '' ) } keys %$ticket;
map { $ticket->{$_} = $self->date_to_iso( $ticket->{$_} ) }
- qw(Created Resolved Told LastUpdated Due Starts Started);
+ qw(Created Resolved Told LastUpdated Starts Started);
map { $ticket->{$_} =~ s/ minutes$// if defined $ticket->{$_} }
qw(TimeWorked TimeLeft TimeEstimated);
$ticket->{'Status'} =~ s/^(resolved|rejected)$/closed/;
return $ticket;
}
- my @changesets;
- for my $txn ( sort { $b->{'id'} <=> $a->{'id'} } @{ $args{'transactions'} } ) {
- my $changeset = $self->txn_to_changeset($txn, $ticket, $create_state);
- unshift @changesets, $changeset if $changeset->has_changes;
- }
+=head2 find_matching_tickets QUERY
Returns an RT::Client ticket collection for all tickets found matching your QUERY string.
@@ -242,7 +237,7 @@
$args{'ticket'}->{ $args{txn}->{Field} } = $args{txn}->{'OldValue'};
} else {
$args{'ticket'}->{ $args{txn}->{Field} } = $args{txn}->{'OldValue'};
- warn "Update consistency problem: " . $args{'ticket'}->{ $args{txn}->{Field} } . " != " . $args{txn}->{'NewValue'};
+ warn $args{'ticket'}->{ $args{txn}->{Field} } . " != " . $args{txn}->{'NewValue'} . "\n\n" . YAML::Dump( \%args ); use YAML;
}
$change->add_prop_change(
name => $args{txn}->{'Field'},
Modified: sd/trunk/lib/App/SD/Replica/RT/PushEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/RT/PushEncoder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/RT/PushEncoder.pm Tue Aug 12 09:09:25 2008
@@ -152,9 +152,4 @@
}
return \%attr;
}
-
-
-__PACKAGE__->meta->make_immutable;
-no Moose;
-
1;
Modified: sd/trunk/lib/App/SD/Test.pm
==============================================================================
Added: sd/trunk/t/00-create.t
==============================================================================
--- (empty file)
+++ sd/trunk/t/00-create.t Tue Aug 12 09:09:25 2008
@@ -0,0 +1,26 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use Prophet::Test tests => 2;
+use App::SD::Test;
+use File::Temp qw/tempdir/;
+use Path::Class;
+
+
+no warnings 'once';
+
+BEGIN {
+ require File::Temp;
+ $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} = File::Temp::tempdir( CLEANUP => 0 ) . '/_svb';
+ warn "export SD_REPO=".$ENV{'PROPHET_REPO'} ."\n";
+}
+# create from sd and push
+my ($yatta_id, $yatta_uuid) = create_ticket_ok( '--summary', 'YATTA', '--status', 'new' );
+
+run_output_matches( 'sd', [ 'ticket',
+ 'list', '--regex', '.' ],
+ [ qr/(\d+) YATTA new/]
+
+);
+
Modified: sd/trunk/t/sd-attachments.t
==============================================================================
--- sd/trunk/t/sd-attachments.t (original)
+++ sd/trunk/t/sd-attachments.t Tue Aug 12 09:09:25 2008
@@ -51,7 +51,7 @@
);
run_output_matches(
'sd',
- [ qw/ticket attachment show --uuid/, $attachment_uuid ],
+ [ qw/ticket attachment show --batch --uuid/, $attachment_uuid ],
[
qr/id: (\d+) \($attachment_uuid\)/,
"content: stub",
Modified: sd/trunk/t/sd-comments.t
==============================================================================
Modified: sd/trunk/t/sd-hm.t
==============================================================================
Modified: sd/trunk/t/sd-rt-hm.t
==============================================================================
More information about the Bps-public-commit
mailing list