File Coverage

lib/JIRA/REST/Class/Project/Version.pm
Criterion Covered Total %
statement 22 28 78.5
branch 2 8 25.0
condition n/a
subroutine 8 11 72.7
pod n/a
total 32 47 68.0


line stmt bran cond sub pod time code
1             package JIRA::REST::Class::Project::Version;
2 4     4   1797 use parent qw( JIRA::REST::Class::Abstract );
  4         8  
  4         22  
3 4     4   257 use strict;
  4         6  
  4         62  
4 4     4   15 use warnings;
  4         8  
  4         75  
5 4     4   54 use 5.010;
  4         13  
6              
7             our $VERSION = '0.11';
8             our $SOURCE = 'CPAN';
9             ## $SOURCE = 'GitHub'; # COMMENT
10             # the line above will be commented out by Dist::Zilla
11              
12 4     4   20 use Readonly 2.04;
  4         44  
  4         762  
13              
14             # ABSTRACT: A helper class for L<JIRA::REST::Class|JIRA::REST::Class> that represents a version of a JIRA project as an object.
15              
16             Readonly my @ACCESSORS => qw( archived id name projectId released self );
17              
18             __PACKAGE__->mk_data_ro_accessors( @ACCESSORS );
19              
20             #pod =head1 DESCRIPTION
21             #pod
22             #pod This object represents a version of JIRA project as an object. It is
23             #pod overloaded so it returns the C<name> of the project version when
24             #pod stringified, the C<id> of the project version when it is used in a numeric
25             #pod context, and the value of the C<released> field if is used in a boolean
26             #pod context. If two of these objects are compared I<as strings>, the C<name> of
27             #pod the project versions will be used for the comparison, while numeric
28             #pod comparison will compare the C<id>s of the project versions.
29             #pod
30             #pod =cut
31              
32             #<<<
33             use overload
34 6     6   824 '""' => sub { shift->name },
35 0     0   0 '0+' => sub { shift->id },
36 0     0   0 'bool' => sub { shift->released },
37             '<=>' => sub {
38 0     0   0 my($A, $B) = @_;
39 0 0       0 my $AA = ref $A ? $A->id : $A;
40 0 0       0 my $BB = ref $B ? $B->id : $B;
41 0         0 $AA <=> $BB
42             },
43             'cmp' => sub {
44 6     6   2823 my($A, $B) = @_;
45 6 50       21 my $AA = ref $A ? $A->name : $A;
46 6 50       23 my $BB = ref $B ? $B->name : $B;
47 6         19 $AA cmp $BB
48 4     4   25 };
  4         36  
  4         62  
49             #>>>
50              
51             1;
52              
53             #pod =accessor B<archived>
54             #pod
55             #pod A boolean indicating whether the version is archived.
56             #pod
57             #pod =accessor B<id>
58             #pod
59             #pod The id of the project version.
60             #pod
61             #pod =accessor B<name>
62             #pod
63             #pod The name of the project version.
64             #pod
65             #pod =accessor B<projectId>
66             #pod
67             #pod The ID of the project this is a version of.
68             #pod
69             #pod =accessor B<released>
70             #pod
71             #pod A boolean indicating whether the version is released.
72             #pod
73             #pod =accessor B<self>
74             #pod
75             #pod Returns the JIRA REST API URL of the project version.
76             #pod
77             #pod =for stopwords projectId
78             #pod
79             #pod =cut
80              
81             __END__
82              
83             =pod
84              
85             =encoding UTF-8
86              
87             =for :stopwords Packy Anderson Alexandr Alexey Ciornii Melezhik projectId
88              
89             =head1 NAME
90              
91             JIRA::REST::Class::Project::Version - A helper class for L<JIRA::REST::Class|JIRA::REST::Class> that represents a version of a JIRA project as an object.
92              
93             =head1 VERSION
94              
95             version 0.11
96              
97             =head1 DESCRIPTION
98              
99             This object represents a version of JIRA project as an object. It is
100             overloaded so it returns the C<name> of the project version when
101             stringified, the C<id> of the project version when it is used in a numeric
102             context, and the value of the C<released> field if is used in a boolean
103             context. If two of these objects are compared I<as strings>, the C<name> of
104             the project versions will be used for the comparison, while numeric
105             comparison will compare the C<id>s of the project versions.
106              
107             =head1 READ-ONLY ACCESSORS
108              
109             =head2 B<archived>
110              
111             A boolean indicating whether the version is archived.
112              
113             =head2 B<id>
114              
115             The id of the project version.
116              
117             =head2 B<name>
118              
119             The name of the project version.
120              
121             =head2 B<projectId>
122              
123             The ID of the project this is a version of.
124              
125             =head2 B<released>
126              
127             A boolean indicating whether the version is released.
128              
129             =head2 B<self>
130              
131             Returns the JIRA REST API URL of the project version.
132              
133             =head1 RELATED CLASSES
134              
135             =over 2
136              
137             =item * L<JIRA::REST::Class|JIRA::REST::Class>
138              
139             =item * L<JIRA::REST::Class::Abstract|JIRA::REST::Class::Abstract>
140              
141             =back
142              
143             =head1 AUTHOR
144              
145             Packy Anderson <packy@cpan.org>
146              
147             =head1 COPYRIGHT AND LICENSE
148              
149             This software is Copyright (c) 2017 by Packy Anderson.
150              
151             This is free software, licensed under:
152              
153             The Artistic License 2.0 (GPL Compatible)
154              
155             =cut