File Coverage

blib/lib/App/BitBucketCli/PullRequest.pm
Criterion Covered Total %
statement 15 38 39.4
branch 0 4 0.0
condition n/a
subroutine 5 16 31.2
pod 11 11 100.0
total 31 69 44.9


line stmt bran cond sub pod time code
1             package App::BitBucketCli::PullRequest;
2              
3             # Created on: 2015-09-16 16:41:19
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 1     1   8 use Moo;
  1         2  
  1         6  
10 1     1   339 use warnings;
  1         11  
  1         50  
11 1     1   7 use Carp;
  1         2  
  1         63  
12 1     1   6 use Data::Dumper qw/Dumper/;
  1         2  
  1         38  
13 1     1   5 use English qw/ -no_match_vars /;
  1         2  
  1         6  
14              
15             our $VERSION = 0.007;
16              
17             extends qw/App::BitBucketCli::Base/;
18              
19             has [qw/
20             state
21             toRef
22             closed
23             version
24             attributes
25             open
26             fromRef
27             updatedDate
28             createdDate
29             title
30             reviewers
31             participants
32             author
33             /] => (
34             is => 'rw',
35             );
36              
37             sub emails {
38 0     0 1   my $self = shift;
39 0           my %emails;
40              
41             my %email;
42 0           for my $users (qw/author participants reviewers/) {
43 0 0         if ( !$self->$users ) {
44 0           warn "No $users in " . $self->from_branch . "!\n";
45 0           next;
46             }
47 0 0         $self->$users( [$self->{$users}] ) if ref $self->$users ne 'ARRAY';
48              
49 0           for my $user (@{ $self->{$users} }) {
  0            
50 0           $emails{ $user->{user}{emailAddress} }++;
51             }
52             }
53              
54 0           return [ sort keys %emails ];
55             }
56              
57 0     0 1   sub from_branch { $_[0]->fromRef->{displayId}; }
58 0     0 1   sub to_branch { $_[0]->toRef->{displayId}; }
59 0     0 1   sub from_repository { $_[0]->fromRef->{repository}{name}; }
60 0     0 1   sub to_repository { $_[0]->toRef->{repository}{name}; }
61 0     0 1   sub from_project { $_[0]->fromRef->{repository}{project}{name}; }
62 0     0 1   sub to_project { $_[0]->toRef->{repository}{project}{name}; }
63             sub from_name {
64 0     0 1   $_[0]->from_project
65             . '/'
66             . $_[0]->from_repository
67             . '/'
68             . $_[0]->from_branch;
69             }
70             sub to_name {
71 0     0 1   $_[0]->to_project
72             . '/'
73             . $_[0]->to_repository
74             . '/'
75             . $_[0]->to_branch;
76             }
77              
78             sub from_data {
79 0     0 1   my ($self) = @_;
80              
81             return {
82             branch => $self->from_branch,
83             project => $self->from_project,
84             project_key => $self->fromRef->{repository}{project}{key},
85 0           repository => $self->from_repository,
86             release_age => undef,
87             };
88             }
89              
90             sub to_data {
91 0     0 1   my ($self) = @_;
92              
93             return {
94             branch => $self->to_branch,
95             project => $self->to_project,
96             project_key => $self->toRef->{repository}{project}{key},
97 0           repository => $self->to_repository,
98             release_age => undef,
99             };
100             }
101              
102             1;
103              
104             __END__
105              
106             =head1 NAME
107              
108             App::BitBucketCli::PullRequest - Stores details about a pull request
109              
110             =head1 VERSION
111              
112             This documentation refers to App::BitBucketCli::PullRequest version 0.007
113              
114             =head1 SYNOPSIS
115              
116             use App::BitBucketCli::PullRequest;
117              
118             # Brief but working code example(s) here showing the most common usage(s)
119             # This section will be as far as many users bother reading, so make it as
120             # educational and exemplary as possible.
121              
122              
123             =head1 DESCRIPTION
124              
125             =head1 SUBROUTINES/METHODS
126              
127             =head2 C<emails ()>
128              
129             =head2 C<from_branch ()>
130              
131             =head2 C<from_data ()>
132              
133             =head2 C<from_name ()>
134              
135             =head2 C<from_project ()>
136              
137             =head2 C<from_repository ()>
138              
139             =head2 C<to_branch ()>
140              
141             =head2 C<to_data ()>
142              
143             =head2 C<to_name ()>
144              
145             =head2 C<to_project ()>
146              
147             =head2 C<to_repository ()>
148              
149             =head2 C<TO_JSON ()>
150              
151             Used by L<JSON::XS> for dumping the object
152              
153             =head1 ATTRIBUTES
154              
155             =head2 state
156              
157             =head2 id
158              
159             =head2 toRef
160              
161             =head2 closed
162              
163             =head2 version
164              
165             =head2 attributes
166              
167             =head2 open
168              
169             =head2 fromRef
170              
171             =head2 updatedDate
172              
173             =head2 createdDate
174              
175             =head2 title
176              
177             =head2 links
178              
179             =head2 reviewers
180              
181             =head2 participants
182              
183             =head2 link
184              
185             =head2 author
186              
187             =head1 DIAGNOSTICS
188              
189             =head1 CONFIGURATION AND ENVIRONMENT
190              
191             =head1 DEPENDENCIES
192              
193             =head1 INCOMPATIBILITIES
194              
195             =head1 BUGS AND LIMITATIONS
196              
197             There are no known bugs in this module.
198              
199             Please report problems to Ivan Wills (ivan.wills@gmail.com).
200              
201             Patches are welcome.
202              
203             =head1 AUTHOR
204              
205             Ivan Wills - (ivan.wills@gmail.com)
206              
207             =head1 LICENSE AND COPYRIGHT
208              
209             Copyright (c) 2015 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
210             All rights reserved.
211              
212             This module is free software; you can redistribute it and/or modify it under
213             the same terms as Perl itself. See L<perlartistic>. This program is
214             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
215             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
216             PARTICULAR PURPOSE.
217              
218             =cut