lib/JIRA/REST/Class/Issue/TimeTracking.pm

filter: Statementstmt 36.1% 17 / 47 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 27.7% 5 / 18 Podpod 100% 7 / 7 totaltotal 38.1% 29 / 76 SCAR 21.7
CC
4
Cov
33%
update
20.0
init
2.0
originalEstimate
2.0
CRAP 8.7
« blib/lib/JIRA/REST/Class/Issue/TimeTracking.pm ↑ Summary blib/lib/JIRA/REST/Class/Factory.pm »
1 package JIRA::REST::Class::Issue::TimeTracking;
2 4 ▶use parent qw( JIRA::REST::Class::Abstract );
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our $VERSION = '0.11';
8 4 our $SOURCE = 'CPAN';
9 ## $SOURCE = 'GitHub'; # COMMENT
10 # the line above will be commented out by Dist::Zilla
11  
12 # ABSTRACT: A helper class for L<JIRA::REST::Class|JIRA::REST::Class> that represents the time tracking for a JIRA issue as an object.
13  
14 4 ▶use Contextual::Return;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 sub init {
17 0 ▶ my $self = shift;
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
18 0 $self->SUPER::init( @_ );
19  
20 0 my $data = $self->issue->get( q{}, { fields => 'timetracking' } );
21 0 $self->{data} = $data->{fields}->{timetracking};
22  
23 0 return;
24 }
25  
26 #pod =accessor B<originalEstimate>
27 #pod
28 #pod Returns the original estimate as a number of seconds in numeric context, and as a w/d/h/m/s string in a string context.
29 #pod
30 #pod =cut
31  
32 sub originalEstimate {
33 0 ▶ my $self = shift;
Subroutine originalEstimate: not called CC=1 SCAR=6.9
Pod documented
34 #<<<
35 return
36 0 ▶ NUM { $self->data->{originalEstimateSeconds} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
37 0 ▶ STR { $self->data->{originalEstimate} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 0 ;
39 #>>>
40 }
41  
42 #pod =accessor B<remainingEstimate>
43 #pod
44 #pod Returns the remaining estimate as a number of seconds in numeric context, and as a w/d/h/m/s string in a string context.
45 #pod
46 #pod =cut
47  
48 sub remainingEstimate {
49 0 ▶ my $self = shift;
Subroutine remainingEstimate: not called CC=1 SCAR=6.9
Pod documented
50 #<<<
51 return
52 0 ▶ NUM { $self->data->{remainingEstimateSeconds} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 0 ▶ STR { $self->data->{remainingEstimate} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 ;
55 #>>>
56 }
57  
58 #pod =accessor B<timeSpent>
59 #pod
60 #pod Returns the time spent as a number of seconds in numeric context, and as a w/d/h/m/s string in a string context.
61 #pod
62 #pod =cut
63  
64 sub timeSpent {
65 0 ▶ my $self = shift;
Subroutine timeSpent: not called CC=1 SCAR=6.9
Pod documented
66 #<<<
67 return
68 0 ▶ NUM { $self->data->{timeSpentSeconds} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
69 0 ▶ STR { $self->data->{timeSpent} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
70 0 ;
71 #>>>
72 }
73  
74 #pod =method B<set_originalEstimate>
75 #pod
76 #pod Sets the original estimate to the amount of time given. Accepts any time format that JIRA uses.
77 #pod
78 #pod =cut
79  
80 sub set_originalEstimate {
81 0 ▶ my $self = shift;
Subroutine set_originalEstimate: not called CC=1 SCAR=6.9
Pod documented
82 0 my $est = shift;
83 0 return $self->update( { originalEstimate => $est } );
84 }
85  
86 #pod =method B<set_remainingEstimate>
87 #pod
88 #pod Sets the remaining estimate to the amount of time given. Accepts any time format that JIRA uses.
89 #pod
90 #pod =cut
91  
92 sub set_remainingEstimate {
93 0 ▶ my $self = shift;
Subroutine set_remainingEstimate: not called CC=1 SCAR=6.9
Pod documented
94 0 my $est = shift;
95 0 return $self->update( { remainingEstimate => $est } );
96 }
97  
98 #pod =method B<update>
99 #pod
100 #pod Accepts a hashref of timetracking fields to update. The acceptable fields are determined by JIRA, but I think they're originalEstimate and remainingEstimate.
101 #pod
102 #pod =cut
103  
104 sub update {
105 0 ▶ my $self = shift;
Subroutine update: not called CC=4 SCAR=30.0
Pod documented
106 0 my $update = shift;
107  
108 0 foreach my $key ( qw/ originalEstimate remainingEstimate / ) {
109  
110 # if we're updating the key, don't change it
111 0 ▶ next if exists $update->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $update->{$key} 0 0 0
112  
113 # since we're not updating the key, copy the original value
114 # into the update, because the REST interface has an annoying
115 # tendency to reset those values if you don't explicitly set them
116 0 ▶ if ( defined $self->data->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->data->{$key}) 0 0 0
117 0 $update->{$key} = $self->data->{$key};
118 }
119 }
120  
121 0 return $self->issue->put_field( timetracking => $update );
122 }
123  
124 4 1;
125  
126 __END__
127  
128 =pod
129  
130 =encoding UTF-8
131  
132 =for :stopwords Packy Anderson Alexandr Alexey Ciornii Melezhik Atlassian GreenHopper JRC
133 ScriptRunner TODO aggregateprogress aggregatetimeestimate
134 aggregatetimeoriginalestimate assigneeType avatar avatarUrls completeDate
135 displayName duedate emailAddress endDate fieldtype fixVersions fromString
136 genericized iconUrl isAssigneeTypeValid issueTypes issuekeys issuelinks
137 issuetype jira jql lastViewed maxResults originalEstimate
138 originalEstimateSeconds parentkey projectId rapidViewId remainingEstimate
139 remainingEstimateSeconds resolutiondate sprintlist startDate
140 subtaskIssueTypes timeSpent timeSpentSeconds timeestimate
141 timeoriginalestimate timespent timetracking toString updateAuthor worklog
142 workratio
143  
144 =head1 NAME
145  
146 JIRA::REST::Class::Issue::TimeTracking - A helper class for L<JIRA::REST::Class|JIRA::REST::Class> that represents the time tracking for a JIRA issue as an object.
147  
148 =head1 VERSION
149  
150 version 0.11
151  
152 =head1 METHODS
153  
154 =head2 B<set_originalEstimate>
155  
156 Sets the original estimate to the amount of time given. Accepts any time format that JIRA uses.
157  
158 =head2 B<set_remainingEstimate>
159  
160 Sets the remaining estimate to the amount of time given. Accepts any time format that JIRA uses.
161  
162 =head2 B<update>
163  
164 Accepts a hashref of timetracking fields to update. The acceptable fields are determined by JIRA, but I think they're originalEstimate and remainingEstimate.
165  
166 =head1 READ-ONLY ACCESSORS
167  
168 =head2 B<originalEstimate>
169  
170 Returns the original estimate as a number of seconds in numeric context, and as a w/d/h/m/s string in a string context.
171  
172 =head2 B<remainingEstimate>
173  
174 Returns the remaining estimate as a number of seconds in numeric context, and as a w/d/h/m/s string in a string context.
175  
176 =head2 B<timeSpent>
177  
178 Returns the time spent as a number of seconds in numeric context, and as a w/d/h/m/s string in a string context.
179  
180 =head1 RELATED CLASSES
181  
182 =over 2
183  
184 =item * L<JIRA::REST::Class|JIRA::REST::Class>
185  
186 =item * L<JIRA::REST::Class::Abstract|JIRA::REST::Class::Abstract>
187  
188 =back
189  
190 =head1 AUTHOR
191  
192 Packy Anderson <packy@cpan.org>
193  
194 =head1 COPYRIGHT AND LICENSE
195  
196 This software is Copyright (c) 2017 by Packy Anderson.
197  
198 This is free software, licensed under:
199  
200 The Artistic License 2.0 (GPL Compatible)
201  
202 =cut
« blib/lib/JIRA/REST/Class/Issue/TimeTracking.pm ↑ Summary blib/lib/JIRA/REST/Class/Factory.pm »