Trello/Board.pm

filter: Statementstmt 36.0% 18 / 50 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 38.4% 5 / 13 Podpod 100% 5 / 5 totaltotal 34.5% 28 / 81 CC 7 SCAR 20.2
CC
7
Cov
30%
subscribe
20.0
create_card
12.0
cards
6.0
CRAP 7.5
« Trello.pm ↑ Summary Trello/Card.pm »
1 package Net::Async::Trello::Board;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.007'; # VERSION
7  
8 2 ▶use parent qw(Net::Async::Trello::Generated::Board);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 my $json = JSON::MaybeXS->new;
14  
15 =head2 subscribe
16  
17 =cut
18  
19 0 ▶sub subscribe {
Subroutine subscribe: not called CC=4 SCAR=30.0
Pod documented
20 0 my ($self, %args) = @_;
21 0 my $trello = $self->trello;
22 0 my $board_id = $self->id;
23 0 $log->tracef("Attempting to subscribe to board %s", $board_id);
24 0 ▶ $self->{subscribed} ||= {};
Condition0%0/2
$self->{"subscribed"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"subscribed"} ||= {}
$self->{"subscribed"}
Truth table0%0/2
A
A= $self->{"subscribed"}
Aresult
11
00
25 0 ▶ unless($self->{subscribed}{board}{$board_id}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"subscribed"}{"board"}{$board_id}) 0 0 0
26 0 $self->{subscribed}{board}{$board_id} = my $src = $trello->ryu->source(
27 label => "board:$board_id"
28 );
29 0 ▶ $trello->websocket->then(sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 my $req_id = $trello->next_request_id;
31 0 my $txt = $json->encode({
32 type => "subscribe",
33 modelType => "Board",
34 idModel => $board_id,
35 tags => [qw(clientActions updates)],
36 invitationTokens => [],
37 reqid => $req_id,
38 });
39 # $txt = '3:::{"sFxn":"ping","rgarg":[],"reqid":' . $req_id . ',"token":"' . $trello->token . '"}';
40 0 $log->tracef(">> %s", $txt);
41 0 ▶ $trello->loop->delay_future(after => 1.1)->then(sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 $trello->{ws}->send_frame(
43 0 buffer => $txt,
44 masked => 1,
45 )
46 })
47 0 })->retain;
48 0 ▶ $self->{updated_channel} ||= {};
Condition0%0/2
$self->{"updated_channel"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"updated_channel"} ||= {}
$self->{"updated_channel"}
Truth table0%0/2
A
A= $self->{"updated_channel"}
Aresult
11
00
49 0 $self->{update_channel}{$board_id} = $src;
50 }
51 0 $self->{subscribed}{board}{$board_id}
52 }
53  
54 =head2 lists
55  
56 =cut
57  
58 0 ▶sub lists {
Subroutine lists: not called CC=1 SCAR=6.9
Pod documented
59 0 my ($self, %args) = @_;
60 0 $self->trello->api_get_list(
61 uri => 'boards/' . $self->id . '/lists', # ?filter=closed',
62 class => 'Net::Async::Trello::List',
63 extra => {
64 board => $self,
65 },
66 )
67 }
68  
69 =head2 cards
70  
71 =cut
72  
73 0 ▶sub cards {
Subroutine cards: not called CC=2 SCAR=17.9
Pod documented
74 0 my ($self, %args) = @_;
75 0 my $uri = URI->new($self->trello->base_uri . 'boards/' . $self->id . '/cards?filter=visible');
76 0 $uri->query_param($_ => $args{$_}) for keys %args;
77 0 $self->trello->api_get_list(
78 uri => $uri,
79 class => 'Net::Async::Trello::Card',
80 per_page => 1000,
81 extra => {
82 board => $self,
83 },
84 )
85 }
86  
87 =head2 members
88  
89 =cut
90  
91 0 ▶sub members {
Subroutine members: not called CC=1 SCAR=6.9
Pod documented
92 0 my ($self, %args) = @_;
93 0 $self->trello->api_get_list(
94 uri => 'boards/' . $self->id . '/members',
95 class => 'Net::Async::Trello::Member',
96 per_page => 1000,
97 extra => {
98 board => $self,
99 },
100 )
101 }
102  
103 =head2 create_card
104  
105 Creates a new card on this board.
106  
107 =cut
108  
109 0 ▶sub create_card {
Subroutine create_card: not called CC=3 SCAR=24.8
Pod documented
110 0 my ($self, %args) = @_;
111 my %body = (
112 name => $args{name},
113 desc => $args{description},
114 0 ▶ pos => $args{position} // 'bottom',
Condition0%0/2
$args{"position"} // "bottom"
l!l
00
MC/DC0%0/1
$args{"position"} // "bottom"
$args{"position"}
Truth table0%0/2
A
A= $args{"position"}
Aresult
11
00
115 );
116 0 ▶ $body{idList} = ref($args{list}) ? $args{list}->id : $args{list};
Branch: 1 branch
BranchTrueFalseTotal
ref $args{'list'} ? : 0 0 0
117 0 $body{idMembers} = join(',', map $_->id, @{$args{members}});
118 $self->trello->http_post(
119 uri => URI->new($self->trello->base_uri . 'cards'),
120 body => \%body,
121 )->transform(
122 0 ▶ done => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
123 Net::Async::Trello::Card->new(
124 0 %{ $_[0] },
125 board => $self,
126 trello => $self->trello,
127 )
128 }
129 )
130 0 }
131  
132 2 1;
133  
134 __END__
« Trello.pm ↑ Summary Trello/Card.pm »