| 1 | package Net::Google::Code::Issue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use Any::Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | with 'Net::Google::Code::TypicalRoles'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use Net::Google::Code::DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use Net::Google::Code::Issue::Comment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Net::Google::Code::Issue::Attachment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Net::Google::Code::Issue::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | extends 'Net::Google::Code::Issue::Base'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # set this to true to enable hybrid load, create and update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | our $USE_HYBRID; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use XML::FeedPP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | has 'id' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | has 'status' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | has 'owner' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 7 | has 'cc' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 7 | has 'summary' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 7 | has 'reporter' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 7 | has 'reported' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | isa => 'DateTime', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 7 | has 'merged' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 7 | has 'stars' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 7 | has 'closed' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 7 | has 'description' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | has 'labels' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 51 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | has 'comments' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | isa => 'ArrayRef[Net::Google::Code::Issue::Comment]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 57 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | has 'attachments' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | isa => 'ArrayRef[Net::Google::Code::Issue::Attachment]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 57 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=7 SCAR=29.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | my $id = shift || $self->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
shift() || $self->id
MC/DC0%0/2
shift() || $self->id
shift()
$self->id
Truth table33%1/3
A || B
A= shift()B= $self->id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | die "current object doesn't have id and load() is not passed an id either" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | unless $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | ▶ | if ($USE_HYBRID) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | unless ( $self->{loaded_way} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"loaded_way"} and $self->{"loaded_way"} eq "api" and $id == $self->id
$self->{"loaded_way"} and $self->{"loaded_way"} eq "api"
MC/DC0%0/3
$self->{"loaded_way"} and $self->{"loaded_way"} eq "api" and $id == $self->id
$self->{"loaded_way"}
$self->{"loaded_way"} eq "api"
$id == $self->id
Truth table0%0/4
A and B and C
A= $self->{"loaded_way"}B= $self->{"loaded_way"} eq "api"C= $id == $self->id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | && $self->{loaded_way} eq 'api' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | && $id == $self->id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my ($issue) = $self->list( id => $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | %$self = %$issue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $self->{loaded_way} = 'hybrid'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $self->load_comments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # here we do scraping to get stuff not can be seen from feeds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $content = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | $self->fetch( $self->base_url . "issues/detail?id=" . $id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return $self->parse_hybrid($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | my $content = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | $self->fetch( $self->base_url . "issues/detail?id=" . $id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | $self->id( $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | $self->{loaded_way} = 'scraping'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | return $self->parse($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=23 SCAR=33.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | my $tree = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | my $need_delete = not blessed $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | ▶ | $tree = $self->html_tree( html => $tree ) unless blessed $tree; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # extract summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | my ($summary) = $tree->look_down( class => 'h3' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | $self->summary( $summary->as_text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # extract reporter, reported and description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | my $description = $tree->look_down( class => 'vt issuedescription' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | my $author_tag = $description->look_down( class => "author" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | $self->reporter( $author_tag->content_array_ref->[1]->as_text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | $self->reported( Net::Google::Code::DateTime->new_from_string($author_tag->look_down( class => 'date' )->attr('title') )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | my $text = $description->find_by_tag_name('pre')->as_text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | $text =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | $text =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | $text =~ s/\r\n/\n/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | $self->description( $text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | my $att_tag = $description->look_down( class => 'attachments' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | my @attachments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | @attachments = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | Net::Google::Code::Issue::Attachment->parse_attachments($att_tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | if $att_tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | $self->attachments( \@attachments ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | my ($meta) = $tree->look_down( id => 'issuemeta' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # let's find stars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | my ($header) = $tree->look_down( id => 'issueheader' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | if ( $header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$header and $header->as_text =~ /(\d+) \w+ starred this issue/
MC/DC0%0/2
$header and $header->as_text =~ /(\d+) \w+ starred this issue/
$header
$header->as_text =~ /(\d+) \w+ starred this issue/
Truth table33%1/3
A and B
A= $headerB= $header->as_text =~ /(\d+) \w+ starred this issue/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | && $header->as_text =~ /(\d+) \w+ starred this issue/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # the \w+ is person or people, I don't know if google will change that word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # some time, so just use \w+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | my $stars = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | $self->stars($stars); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | my @meta = $meta->find_by_tag_name('tr'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | my @labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | for my $meta (@meta) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 9 | my ( $key, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 9 | ▶ | if ( my $k = $meta->find_by_tag_name('th') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5 | my $v = $meta->find_by_tag_name('td'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 5 | my $k_content = $k->content_array_ref->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 5 | ▶ | while ( ref $k_content ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $k_content = $k_content->content_array_ref->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 5 | $key = $k_content; # $key is like 'Status:#' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | $key =~ s/:.$//; # s/:#$// doesn't work, no idea why | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | $key = lc $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | ▶ | if ($v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 5 | $value = $v->as_text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 5 | $value =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5 | $value =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | ▶ | if ( $self->can( $key ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | ▶ | if ( $key eq 'merged' && $value =~ /issue\s+(\d+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$key eq "merged" and $value =~ /issue\s+(\d+)/
MC/DC0%0/2
$key eq "merged" and $value =~ /issue\s+(\d+)/
$key eq "merged"
$value =~ /issue\s+(\d+)/
Truth table33%1/3
A and B
A= $key eq "merged"B= $value =~ /issue\s+(\d+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $value = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | $self->$key( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | warn "no idea where to keep $key"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | my $href = $meta->look_down( class => 'label' )->attr('href'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 4 | ▶ | if ( $href =~ /list\?q=label:(.+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | push @labels, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | $self->labels( \@labels ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # extract comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | my @comments_tag = $tree->look_down( class => 'vt issuecomment' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | my @comments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | for my $tag (@comments_tag) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 9 | ▶ | next unless $tag->look_down( class => 'author' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 7 | my $comment = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | Net::Google::Code::Issue::Comment->new( project => $self->project ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 7 | $comment->parse($tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 7 | push @comments, $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | my $initial_comment = Net::Google::Code::Issue::Comment->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | project => $self->project, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | sequence => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | date => $self->reported, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | author => $self->reporter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | content => $self->description, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | attachments => $self->attachments, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | my @initial_labels = @{$self->labels}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | my %meta = map { $_ => 1 } qw/summary status cc owner/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | for my $c ( reverse @comments ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 7 | my $updates = $c->updates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 7 | for ( keys %meta ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # once these changes, we can't know the inital value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 23 | ▶ | delete $meta{$_} if exists $updates->{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 7 | ▶ | if ( $updates->{labels} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my @labels = @{$updates->{labels}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | for my $label (@labels) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if ( $label =~ /^-(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | unshift @initial_labels, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | @initial_labels = grep { $_ ne $label } @initial_labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | $initial_comment->updates->{labels} = \@initial_labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | for ( keys %meta ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 6 | $initial_comment->updates->{$_} = $self->$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | unshift @comments, $initial_comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | $self->comments( \@comments ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | ▶ | $tree->delete if $need_delete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub load_comments { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_comments: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | require Net::Google::Code::Issue::Comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | my $comment = Net::Google::Code::Issue::Comment->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | issue_id => $self->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | map { $_ => $self->$_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | grep { $self->$_ } qw/project email password token/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # $comment is for initial comment we will work out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->comments( [ $comment, $comment->list ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | sub parse_hybrid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_hybrid: not called CC=20 SCAR=60.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $tree = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $need_delete = not blessed $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | $tree = $self->html_tree( html => $tree ) unless blessed $tree; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $description = $tree->look_down( class => 'vt issuedescription' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $att_tag = $description->look_down( class => 'attachments' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my @attachments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | @attachments = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | Net::Google::Code::Issue::Attachment->parse_attachments($att_tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | if $att_tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $self->attachments( \@attachments ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my ($meta) = $tree->look_down( id => 'issuemeta' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my @meta = $meta->find_by_tag_name('tr'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my @labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | for my $meta (@meta) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my ( $key, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ( my $k = $meta->find_by_tag_name('th') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $v = $meta->find_by_tag_name('td'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $k_content = $k->content_array_ref->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | while ( ref $k_content ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $k_content = $k_content->content_array_ref->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $key = $k_content; # $key is like 'Status:#' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $key =~ s/:.$//; # s/:#$// doesn't work, no idea why | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $key = lc $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ($v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $value = $v->as_text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $value =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $value =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if ( $self->can( $key ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | if ( $key eq 'merged' && $value =~ /issue\s+(\d+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key eq "merged" and $value =~ /issue\s+(\d+)/
MC/DC0%0/2
$key eq "merged" and $value =~ /issue\s+(\d+)/
$key eq "merged"
$value =~ /issue\s+(\d+)/
Truth table0%0/3
A and B
A= $key eq "merged"B= $value =~ /issue\s+(\d+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $value = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $self->$key( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | warn "no idea where to keep $key"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # extract comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my @comments_tag = $tree->look_down( class => 'vt issuecomment' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ( undef, my @comments ) = @{$self->comments}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $number = 1; # 0 is for initial comment | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | for my $tag (@comments_tag) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | next unless $tag->look_down( class => 'author' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $comment = $self->comments->[$number++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $comment->parse_hybrid($tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | my $initial_comment = Net::Google::Code::Issue::Comment->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | sequence => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | date => $self->reported, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | author => $self->reporter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | content => $self->description, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | attachments => $self->attachments, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | issue_id => $self->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | map { $_ => $self->$_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | grep { $self->$_ } qw/project email password token/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my @initial_labels = @{$self->labels}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my %meta = map { $_ => 1 } qw/summary status cc owner/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | for my $c ( reverse @comments ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $updates = $c->updates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | for ( keys %meta ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # once these changes, we can't know the inital value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | delete $meta{$_} if exists $updates->{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if ( $updates->{labels} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my @labels = @{$updates->{labels}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | for my $label (@labels) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if ( $label =~ /^-(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | unshift @initial_labels, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | @initial_labels = grep { $_ ne $label } @initial_labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $initial_comment->updates->{labels} = \@initial_labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | for ( keys %meta ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $initial_comment->updates->{$_} = $self->$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $self->comments->[0] = $initial_comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | $tree->delete if $need_delete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 22 | ▶ | sub _load_from_xml { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_from_xml: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 22 | my $ref = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | Net::Google::Code::Issue::Util->translate_from_xml( shift, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | type => 'issue' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 22 | for my $k ( keys %$ref ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 332 | ▶ | if ( $self->can($k) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 222 | $self->{$k} = $ref->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 22 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | my %args = validate( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | labels => { type => ARRAYREF, optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | files => { type => ARRAYREF, optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | map { $_ => { type => SCALAR, optional => 1 } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | qw/comment summary status owner cc/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | if ( $args{files} || !$USE_HYBRID) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"files"} or not $Net::Google::Code::Issue::USE_HYBRID
MC/DC0%0/2
$args{"files"} or not $Net::Google::Code::Issue::USE_HYBRID
$args{"files"}
not $Net::Google::Code::Issue::USE_HYBRID
Truth table0%0/3
A or not(B)
A= $args{"files"}B= not $Net::Google::Code::Issue::USE_HYBRID
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $self->sign_in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $self->fetch( $self->base_url . 'issues/entry' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ( $args{files} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # hack hack hack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # manually add file fields since we don't have them in page. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my $html = $self->mech->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | for ( 1 .. @{ $args{files} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $html =~ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | s{(?<=id="attachmentareadeventry"></div>)}{<input name="file$_" type="file">}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $self->mech->update_html($html); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $self->mech->form_with_fields( 'comment', 'summary' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # leave labels alone unless there're labels. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | $self->mech->field( 'label', $args{labels} ) if $args{labels}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | if ( $args{files} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | for ( my $i = 0 ; $i < scalar @{ $args{files} } ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $self->mech->field( 'file' . ( $i + 1 ), $args{files}[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | $self->mech->submit_form( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | map { $_ => $args{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | grep { exists $args{$_} } qw/comment summary status owner cc/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my ( $contains, $id ) = $self->html_tree_contains( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | html => $self->mech->content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | look_down => [ class => 'notice' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | as_text => qr/Issue\s+(\d+)/i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | if ($contains) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $self->load($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | return $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | warn 'create issue failed'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # we can use google's official api here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $author = $self->email; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $author =~ s/@.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my %args = ( author => $author, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $xml = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | Net::Google::Code::Issue::Util->translate_to_xml( \%args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | type => 'create' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $ua = $self->ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my $url = $self->feeds_issues_url . '/full'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $request = HTTP::Request->new( 'POST', $url, undef, $xml ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $res = $ua->request($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if ( $res->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $content = $res->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # let's fake wrap the entry with <feed> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $content =~ s!<entry!<feed><entry!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $content =~ s{$}{</feed>}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | my $feed = XML::FeedPP->new($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my ($item) = $feed->get_item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $self->_load_from_xml($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $self->load( $self->id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | die "try to POST $url failed: " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | . $res->status_line . "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | . $res->content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | my %args = validate( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | labels => { type => ARRAYREF, optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | files => { type => ARRAYREF, optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | map { $_ => { type => SCALAR, optional => 1 } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | qw/comment summary status owner merge_into cc blocked_on/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | if ( $args{files} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$args{"files"} or $args{"merge_into"} or $args{"blocked_on"} or not $Net::Google::Code::Issue::USE_HYBRID
$args{"files"} or $args{"merge_into"} or $args{"blocked_on"}
$args{"files"} or $args{"merge_into"}
MC/DC0%0/4
$args{"files"} or $args{"merge_into"} or $args{"blocked_on"} or not $Net::Google::Code::Issue::USE_HYBRID
$args{"files"}
$args{"merge_into"}
$args{"blocked_on"}
not $Net::Google::Code::Issue::USE_HYBRID
Truth table0%0/5
A or B or C or not(D)
A= $args{"files"}B= $args{"merge_into"}C= $args{"blocked_on"}D= not $Net::Google::Code::Issue::USE_HYBRID
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | || $args{merge_into} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | || $args{blocked_on} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | || !$USE_HYBRID ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $self->sign_in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $self->fetch( $self->base_url . 'issues/detail?id=' . $self->id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | if ( $args{files} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # hack hack hack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # manually add file fields since we don't have them in page. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my $html = $self->mech->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | for ( 1 .. @{ $args{files} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $html =~ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | s{(?<=id="attachmentarea"></div>)}{<input name="file$_" type="file">}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $self->mech->update_html($html); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $self->mech->form_with_fields( 'comment', 'summary' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # leave labels alone unless there're labels. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | $self->mech->field( 'label', $args{labels} ) if $args{labels}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | if ( $args{files} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | for ( my $i = 0 ; $i < scalar @{ $args{files} } ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $self->mech->field( 'file' . ( $i + 1 ), $args{files}[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | $self->mech->submit_form( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | map { $_ => $args{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | grep { exists $args{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | qw/comment summary status owner merge_into cc blocked_on/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | $self->html_tree_contains( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | html => $self->mech->content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | look_down => [ class => 'notice' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | as_text => qr/has been updated/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $self->load( $self->id ); # maybe this is too much? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | warn 'update failed'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $author = $self->email; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $author =~ s/@.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | my %args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | author => $author, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | map { $_ => $self->$_ } qw/title content status owner cc labels/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my $xml = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | Net::Google::Code::Issue::Util->translate_to_xml( \%args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | type => 'update' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $ua = $self->ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $url = $self->feeds_issues_url . '/' . $self->id . '/comments/full'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $request = HTTP::Request->new( 'POST', $url, undef, $xml ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $res = $ua->request($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | if ( $res->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $self->load( $self->id ); # let's reload | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | die "try to POST $url failed: " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | . $res->status_line . "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | . $res->content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | ▶ | sub updated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
updated: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | my $last_comment = $self->comments->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | ▶ | return $last_comment ? $last_comment->date : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | ▶ | sub list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 2 | validate( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | q => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | can => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | author => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | id => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | label => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | max_results => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | owner => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | published_min => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | published_max => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | updated_min => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | updated_max => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | start_index => { optional => 1, type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 2 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 2 | my $url = $self->feeds_issues_url . '/full?'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 2 | require URI::Escape; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 2 | for my $k ( keys %args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 1 | ▶ | next unless $args{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 1 | my $v = $args{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 1 | $k =~ s/_/-/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 1 | $url .= "$k=" . URI::Escape::uri_escape($v) . '&'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 2 | my $ua = $self->ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 2 | my $res = $ua->get($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 2 | ▶ | if ( $res->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 2 | my $feed = XML::FeedPP->new($res->content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 2 | my @items = $feed->get_item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | my @list = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 2 | my $t = Net::Google::Code::Issue->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | loaded_way => 'api', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 22 | map { $_ => $self->$_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 22 | grep { $self->$_ } qw/project email password token/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 22 | $t->_load_from_xml($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | ▶ | return wantarray ? @list : \@list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | die "try to get $url failed: " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | . $res->status_line . "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | . $res->content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 7 | ▶ | no Any::Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 7 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||