[Bps-public-commit] r12113 - in sd/branches/attachment-content: bin

jesse at bestpractical.com jesse at bestpractical.com
Tue May 6 16:14:09 EDT 2008


Author: jesse
Date: Tue May  6 16:14:08 2008
New Revision: 12113

Modified:
   sd/branches/attachment-content/bin/sd
   sd/branches/attachment-content/lib/App/SD/Model/Attachment.pm

Log:
* yay. plain text attachments wokr

Modified: sd/branches/attachment-content/bin/sd
==============================================================================
--- sd/branches/attachment-content/bin/sd	(original)
+++ sd/branches/attachment-content/bin/sd	Tue May  6 16:14:08 2008
@@ -14,31 +14,60 @@
 use base qw/Prophet::CLI::Command/;
 
 package App::SD::CLI::Command::Ticket::Comment;
-use base qw/App::SD::CLI::Command/;
 
 use constant record_class => 'App::SD::Model::Comment';
 
 package App::SD::CLI::Command::Ticket::Comment::Create;
 use base qw/App::SD::CLI::Command::Ticket::Comment Prophet::CLI::Command::Create/;
 
-# override args to feed in that ticket's uuid as an argument to the comment
-sub args {
+sub run {
     my $self = shift;
-    return { %{$self->SUPER::args}, ticket => $self->uuid};
+    $self->args->{'ticket'} = $self->uuid;
+    $self->SUPER::run(@_);
 }
+# override args to feed in that ticket's uuid as an argument to the comment
 
+package App::SD::CLI::Command::Attachment;
+use constant record_class => 'App::SD::Model::Attachment';
 
-package App::SD::CLI::Command::Ticket::Attachment::Create;
-use base qw/App::SD::CLI::Command::Ticket::Attachment Prophet::CLI::Command::Create/;
+package App::SD::CLI::Command::Attachment::Create;
+use base qw/App::SD::CLI::Command::Attachment Prophet::CLI::Command::Create/;
+use Path::Class;
 
-# override args to feed in that ticket's uuid as an argument to the comment
-sub args {
+sub run {
     my $self = shift;
-    return { %{$self->SUPER::args}, ticket => $self->uuid};
+
+    if  (my $file = file(delete $self->args->{'file'})) {
+        $self->args->{'tricksy'} = 'abc';
+        $self->args->{'content'} = $file->slurp();
+        $self->args->{'name'} = $file->basename;
+    }
+
+    $self->SUPER::run(@_);
+
 }
 
+package App::SD::CLI::Command::Ticket::Attachment::Create;
+use base qw/App::SD::CLI::Command::Attachment::Create/;
+# override args to feed in that ticket's uuid as an argument to the comment
+#
+
 
+sub run {
+    my $self = shift;
+    $self->args->{'ticket'} = $self->uuid;
+    $self->SUPER::run(@_);
+}
 
+package App::SD::CLI::Command::Attachment::Content;
+use base qw/App::SD::CLI::Command::Attachment App::SD::CLI::Command Prophet::CLI::Command::Show/;
+
+sub run {
+    my $self = shift;
+    my $record =  $self->_get_record;
+    $record->load(uuid => $self->cli->uuid);
+    print $record->prop('content') ."\n";
+}
 
 package App::SD::CLI::Command::Help;
 use base qw/App::SD::CLI::Command/;
@@ -61,14 +90,9 @@
 
 }
 
-
 package App::SD::CLI::Command::Ticket::Show;
 use base qw/App::SD::CLI::Command Prophet::CLI::Command::Show/;
 
-
-
-
-
 package App::SD::CLI::Command::Details;
 use base qw/App::SD::CLI::Command/;
 sub run {

Modified: sd/branches/attachment-content/lib/App/SD/Model/Attachment.pm
==============================================================================
--- sd/branches/attachment-content/lib/App/SD/Model/Attachment.pm	(original)
+++ sd/branches/attachment-content/lib/App/SD/Model/Attachment.pm	Tue May  6 16:14:08 2008
@@ -16,7 +16,10 @@
 sub create {
     my $self = shift;
     my %args = validate( @_,  {props => 1});
-    
+
+
+    return (0,"You can't create an attachment without specifying a 'ticket' uuid") unless ($args{'props'}->{'ticket'});
+
     $args{'props'}->{'content_type'} ||=  'text/plain'; # XXX TODO use real mime typing;
     
 



More information about the Bps-public-commit mailing list