| 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.005'; # 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 | sub subscribe { | ||||||||||||
| 20 | 2 | ▶ | use Variable::Disposition qw(retain_future); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | 2 | ▶ | use namespace::clean qw(retain_future); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 0 | ▶ | my ($self, %args) = @_; | ||||||||||
|
Subroutine
subscribe: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 23 | 0 | my $trello = $self->trello; | |||||||||||
| 24 | 0 | my $board_id = $self->id; | |||||||||||
| 25 | 0 | $log->tracef("Attempting to subscribe to board %s", $board_id); | |||||||||||
| 26 | 0 | ▶ | $self->{subscribed} ||= {}; | ||||||||||
|
Condition0%0/2
$self->{"subscribed"} ||= {}
MC/DC0%0/1
$self->{"subscribed"} ||= {}
$self->{"subscribed"}
Truth table0%0/2
A
A= $self->{"subscribed"}
| |||||||||||||
| 27 | 0 | ▶ | unless($self->{subscribed}{board}{$board_id}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 28 | 0 | $self->{subscribed}{board}{$board_id} = my $src = $trello->ryu->source( | |||||||||||
| 29 | label => "board:$board_id" | ||||||||||||
| 30 | ); | ||||||||||||
| 31 | retain_future( | ||||||||||||
| 32 | $trello->websocket->then(sub { | ||||||||||||
| 33 | 0 | ▶ | my $req_id = $trello->next_request_id; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 34 | 0 | my $txt = $json->encode({ | |||||||||||
| 35 | type => "subscribe", | ||||||||||||
| 36 | modelType => "Board", | ||||||||||||
| 37 | idModel => $board_id, | ||||||||||||
| 38 | tags => [qw(clientActions updates)], | ||||||||||||
| 39 | invitationTokens => [], | ||||||||||||
| 40 | reqid => $req_id, | ||||||||||||
| 41 | }); | ||||||||||||
| 42 | # $txt = '3:::{"sFxn":"ping","rgarg":[],"reqid":' . $req_id . ',"token":"' . $trello->token . '"}'; | ||||||||||||
| 43 | 0 | $log->tracef(">> %s", $txt); | |||||||||||
| 44 | $trello->loop->delay_future(after => 1.1)->then(sub { | ||||||||||||
| 45 | $trello->{ws}->send_frame( | ||||||||||||
| 46 | 0 | ▶ | buffer => $txt, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 47 | masked => 1, | ||||||||||||
| 48 | ) | ||||||||||||
| 49 | }) | ||||||||||||
| 50 | 0 | }) | |||||||||||
| 51 | 0 | ); | |||||||||||
| 52 | 0 | ▶ | $self->{updated_channel} ||= {}; | ||||||||||
|
Condition0%0/2
$self->{"updated_channel"} ||= {}
MC/DC0%0/1
$self->{"updated_channel"} ||= {}
$self->{"updated_channel"}
Truth table0%0/2
A
A= $self->{"updated_channel"}
| |||||||||||||
| 53 | 0 | $self->{update_channel}{$board_id} = $src; | |||||||||||
| 54 | } | ||||||||||||
| 55 | 0 | $self->{subscribed}{board}{$board_id} | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | =head2 lists | ||||||||||||
| 59 | |||||||||||||
| 60 | =cut | ||||||||||||
| 61 | |||||||||||||
| 62 | sub lists { | ||||||||||||
| 63 | 0 | ▶ | my ($self, %args) = @_; | ||||||||||
|
Subroutine
lists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 64 | 0 | $self->trello->api_get_list( | |||||||||||
| 65 | uri => 'boards/' . $self->id . '/lists', | ||||||||||||
| 66 | class => 'Net::Async::Trello::List', | ||||||||||||
| 67 | extra => { | ||||||||||||
| 68 | board => $self, | ||||||||||||
| 69 | }, | ||||||||||||
| 70 | ) | ||||||||||||
| 71 | } | ||||||||||||
| 72 | |||||||||||||
| 73 | =head2 cards | ||||||||||||
| 74 | |||||||||||||
| 75 | =cut | ||||||||||||
| 76 | |||||||||||||
| 77 | sub cards { | ||||||||||||
| 78 | 0 | ▶ | my ($self, %args) = @_; | ||||||||||
|
Subroutine
cards: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 79 | 0 | $self->trello->api_get_list( | |||||||||||
| 80 | uri => 'boards/' . $self->id . '/cards?filter=visible', | ||||||||||||
| 81 | class => 'Net::Async::Trello::Card', | ||||||||||||
| 82 | per_page => 1000, | ||||||||||||
| 83 | extra => { | ||||||||||||
| 84 | board => $self, | ||||||||||||
| 85 | }, | ||||||||||||
| 86 | ) | ||||||||||||
| 87 | } | ||||||||||||
| 88 | |||||||||||||
| 89 | =head2 create_card | ||||||||||||
| 90 | |||||||||||||
| 91 | Creates a new card on this board. | ||||||||||||
| 92 | |||||||||||||
| 93 | =cut | ||||||||||||
| 94 | |||||||||||||
| 95 | sub create_card { | ||||||||||||
| 96 | 0 | ▶ | my ($self, %args) = @_; | ||||||||||
|
Subroutine
create_card: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 97 | my %body = ( | ||||||||||||
| 98 | name => $args{name}, | ||||||||||||
| 99 | desc => $args{description}, | ||||||||||||
| 100 | 0 | ▶ | pos => $args{position} // 'bottom', | ||||||||||
|
Condition0%0/2
$args{"position"} // "bottom"
MC/DC0%0/1
$args{"position"} // "bottom"
$args{"position"}
Truth table0%0/2
A
A= $args{"position"}
| |||||||||||||
| 101 | ); | ||||||||||||
| 102 | 0 | ▶ | $body{idList} = ref($args{list}) ? $args{list}->id : $args{list}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 103 | 0 | $body{idMembers} = join(',', map $_->id, @{$args{members}}); | |||||||||||
| 104 | $self->trello->http_post( | ||||||||||||
| 105 | uri => URI->new($self->trello->base_uri . 'cards'), | ||||||||||||
| 106 | body => \%body, | ||||||||||||
| 107 | )->transform( | ||||||||||||
| 108 | done => sub { | ||||||||||||
| 109 | Net::Async::Trello::Card->new( | ||||||||||||
| 110 | 0 | ▶ | %{ $_[0] }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 111 | board => $self, | ||||||||||||
| 112 | trello => $self->trello, | ||||||||||||
| 113 | ) | ||||||||||||
| 114 | } | ||||||||||||
| 115 | ) | ||||||||||||
| 116 | 0 | } | |||||||||||
| 117 | |||||||||||||
| 118 | 2 | 1; | |||||||||||
| 119 | |||||||||||||