Code/Role/Predefined.pm

filter: Statementstmt 95.6% 44 / 46 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 83.5% 56 / 67 CC 10 SCAR 20.9
CC
10
Cov
85%
load_predefined
10.9
BEGIN
1.0
BEGIN
1.0
CRAP 8.1
« Code/Download.pm ↑ Summary Code/Issue/Base.pm »
1 package Net::Google::Code::Role::Predefined;
2 10 ▶use Any::Moose 'Role';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use Params::Validate ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 with 'Net::Google::Code::Role::Fetchable';
6  
7 10 has 'predefined_status' => (
8 isa => 'HashRef',
9 is => 'rw',
10 );
11  
12 10 has 'predefined_labels' => (
13 isa => 'ArrayRef',
14 is => 'rw',
15 );
16  
17 10 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶sub load_predefined {
Subroutine load_predefined: called CC=10 SCAR=23.9
Pod documented
20 1 my $self = shift;
21 1 ▶ my $class = ref $self || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
100
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
22 1 my $last_name;
23 1 ▶ $last_name = lc $1 if $class =~ /::(\w+)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $class =~ /::(\w+)$/ 1 0 1
24  
25 1 ▶ return unless $self->signed_in;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->signed_in 0 1 1
26 1 my $base_url = $self->base_url;
27 1 my $content = $self->fetch($self->base_url);
28 1 ▶ if ( $content =~ /codesite_token\s*=\s*"(\w+)"/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ /codesite_token\s*=\s*"(\w+)"/) { } 1 0 1
29 1 my $token = $1;
30 1 my $mech = $self->mech;
31 # I tried to use $mech->post( $url, token => $token )
32 # but without luck :(
33 1 $mech->update_html(<<"EOF");
34 <form action="${base_url}feeds/${last_name}OptionsJSON"
35 method="POST" >
36 <input type="text" name="token" value="$token" />
37 <input type="submit" value="submit" />
38 </form>
39 EOF
40 1 $mech->submit_form( form_number => 1 );
41 1 ▶ die "failed to post to OptionsJSON page" unless $mech->success;
Branch: 1 branch
BranchTrueFalseTotal
unless $mech->success 0 1 1
42  
43 1 my $js = $mech->content;
44 1 my $object = from_json $js;
45 1 ▶ return unless $object;
Branch: 1 branch
BranchTrueFalseTotal
unless $object 0 1 1
46  
47 1 $self->predefined_status( { open => [], closed => [] } );
48 1 for my $type (qw/open closed/) {
49 2 for ( @{ $object->{$type} } ) {
50 9 push @{ $self->predefined_status->{$type} }, $_->{name};
51 }
52 }
53  
54 1 $self->predefined_labels( [] );
55 1 for ( @{ $object->{labels} } ) {
56 23 push @{ $self->predefined_labels }, $_->{name};
57 }
58  
59 1 return 1;
60 }
61 else {
62 0 warn "can't get user token";
63 0 return;
64 }
65  
66 }
67  
68 10 1;
69  
70 __END__
« Code/Download.pm ↑ Summary Code/Issue/Base.pm »