[Bps-public-commit] net-lighthouse branch, master, updated. 49ae40d9ca124f5b767e7e3518c515605870abdd

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Sep 3 08:55:31 EDT 2009


The branch, master has been updated
       via  49ae40d9ca124f5b767e7e3518c515605870abdd (commit)
      from  04101dc2e302ea8ad487922c405f3e06350c32ce (commit)

Summary of changes:
 lib/Net/Lighthouse/Project/Ticket/Attachment.pm |   18 ++++++++++++++++++
 t/05-ticket-attachment.t                        |    5 +++--
 2 files changed, 21 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 49ae40d9ca124f5b767e7e3518c515605870abdd
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Sep 3 20:55:27 2009 +0800

    add ua and contnet attrs for attachment

diff --git a/lib/Net/Lighthouse/Project/Ticket/Attachment.pm b/lib/Net/Lighthouse/Project/Ticket/Attachment.pm
index b9649ea..4218c3f 100644
--- a/lib/Net/Lighthouse/Project/Ticket/Attachment.pm
+++ b/lib/Net/Lighthouse/Project/Ticket/Attachment.pm
@@ -20,6 +20,24 @@ has [ 'content_type', 'filename', 'url', 'type', 'code' ] => (
     is  => 'ro',
 );
 
+has 'ua' => ( is => 'ro', );
+
+has 'content' => (
+    is      => 'ro',
+    lazy    => 1,
+    default => sub {
+        my $self = shift;
+        my $ua   = $self->ua;
+        my $res  = $ua->get( $self->url );
+        if ( $res->is_success ) {
+            return $res->content;
+        }
+        else {
+            return;
+        }
+    }
+);
+
 no Any::Moose;
 __PACKAGE__->meta->make_immutable;
 
diff --git a/t/05-ticket-attachment.t b/t/05-ticket-attachment.t
index fb512db..0bf77c9 100644
--- a/t/05-ticket-attachment.t
+++ b/t/05-ticket-attachment.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 27;
+use Test::More tests => 29;
 use DateTime;
 
 use_ok('Net::Lighthouse::Project::Ticket::Attachment');
@@ -13,7 +13,8 @@ isa_ok( $attachment, 'Net::Lighthouse::Project::Ticket::Attachment' );
 my @attrs = (
     'width',        'created_at',  'height',   'size',
     'content_type', 'uploader_id', 'filename', 'url',
-    'type',         'id',          'code'
+    'type',         'id',          'code',
+    'content', 'ua',
 );
 
 for my $attr (@attrs) {

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



More information about the Bps-public-commit mailing list