File Coverage

blib/lib/WebService/GData/YouTube/Feed/Comment.pm
Criterion Covered Total %
statement 18 49 36.7
branch 0 18 0.0
condition n/a
subroutine 6 12 50.0
pod 5 5 100.0
total 29 84 34.5


line stmt bran cond sub pod time code
1             package WebService::GData::YouTube::Feed::Comment;
2              
3 2     2   13 use WebService::GData;
  2         5  
  2         15  
4 2     2   12 use base 'WebService::GData::Feed::Entry';
  2         4  
  2         240  
5 2     2   12 use WebService::GData::Constants qw(:all);
  2         4  
  2         1078  
6 2     2   16 use WebService::GData::YouTube::Constants qw(:all);
  2         4  
  2         11265  
7 2     2   19 use WebService::GData::Node::Atom::Link();
  2         5  
  2         259  
8 2     2   11 use WebService::GData::YouTube::StagingServer ();
  2         5  
  2         3316  
9             our $VERSION = 0.01_04;
10              
11             our $BASE_URI = BASE_URI . PROJECTION . '/videos/';
12             our $WRITE_BASE_URI = $BASE_URI;
13             our $RESPONSE_REL = API_DOMAIN_URI . q[schemas/2007#in-reply-to];
14              
15             if(WebService::GData::YouTube::StagingServer->is_on){
16             $WRITE_BASE_URI = STAGING_BASE_URI . PROJECTION . '/videos/';
17             }
18              
19              
20             our $RESPONSE_TYPE = q[application/atom+xml];
21              
22             sub __init {
23 0     0     my ( $this, $feed, $req ) = @_;
24              
25 0 0         if ( ref($feed) eq 'HASH' ) {
26 0           $this->SUPER::__init( $feed, $req );
27             }
28             else {
29 0           $this->SUPER::__init( {}, $feed );#$feed ==$req here
30             }
31             }
32              
33             sub content {
34 0     0 1   my ( $this, $comment ) = @_;
35 0 0         $this->{_content}->text($comment) if $comment;
36 0           $this->{_content}->text;
37             }
38              
39             sub comment_id {
40 0     0 1   my ($this) = @_;
41 0 0         if ( $this->id ) {
42 0           return ( split ':', $this->id )[-1];
43             }
44             }
45              
46             sub video_id {
47 0     0 1   my ( $this, $id ) = @_;
48 0 0         if ($id) {
49 0           $this->{_video_id} = $id;
50 0           return $id;
51             }
52 0 0         if ( ! ref $this->id) {
53 0           $this->{_video_id} = ( split ':', $this->id )[-3];
54             }
55 0           return $this->{_video_id};
56             }
57              
58             sub in_reply_to {
59 0     0 1   my ( $this, $comment_id ) = @_;
60              
61 0 0         if ($comment_id) {
62 0           $this->{_is_in_reply_to} = $comment_id;
63 0           return $comment_id;
64             }
65 0           my $is_in_reply_to = $this->links->rel('#in-reply-to')->[0];
66 0 0         if ($is_in_reply_to) {
67 0           $this->{_is_in_reply_to} = ( split '/', $is_in_reply_to->href )[-1];
68             }
69 0           $this->{_is_in_reply_to};
70             }
71              
72             sub save {
73 0     0 1   my $this = shift;
74              
75 0 0         if ( $this->video_id ) {
76 0 0         if ( $this->in_reply_to ) {
77 0           $this->swap($this->{_link}, new WebService::GData::Node::Atom::Link(
78            
79             rel => $RESPONSE_REL,
80             type => $RESPONSE_TYPE,
81             href => $BASE_URI.$this->video_id.'/comments/'.$this->in_reply_to
82             ));
83             }
84 0           my $content= XML_HEADER . $this->serialize();
85 0           my $ret =$this->{_request}->insert( $WRITE_BASE_URI . $this->video_id . '/comments/', $content );
86             }
87             }
88              
89             "The earth is blue like an orange.";
90              
91             __END__