File Coverage

lib/JIRA/REST/Class/Issue/TimeTracking.pm
Criterion Covered Total %
statement 14 44 31.8
branch 0 4 0.0
condition n/a
subroutine 5 18 27.7
pod 7 7 100.0
total 26 73 35.6


line stmt bran cond sub pod time code
1             package JIRA::REST::Class::Issue::TimeTracking;
2 4     4   1655 use parent qw( JIRA::REST::Class::Abstract );
  4         4  
  4         15  
3 4     4   272 use strict;
  4         4  
  4         56  
4 4     4   12 use warnings;
  4         4  
  4         76  
5 4     4   48 use 5.010;
  4         8  
6              
7             our $VERSION = '0.10';
8             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     4   2915 use Contextual::Return;
  4         45219  
  4         19  
15              
16             sub init {
17 0     0 1   my $self = shift;
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     0 1   my $self = shift;
34             #<<<
35             return
36 0     0     NUM { $self->data->{originalEstimateSeconds} }
37 0     0     STR { $self->data->{originalEstimate} }
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     0 1   my $self = shift;
50             #<<<
51             return
52 0     0     NUM { $self->data->{remainingEstimateSeconds} }
53 0     0     STR { $self->data->{remainingEstimate} }
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     0 1   my $self = shift;
66             #<<<
67             return
68 0     0     NUM { $self->data->{timeSpentSeconds} }
69 0     0     STR { $self->data->{timeSpent} }
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     0 1   my $self = shift;
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     0 1   my $self = shift;
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     0 1   my $self = shift;
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 0         next if exists $update->{$key};
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 0         if ( defined $self->data->{$key} ) {
117 0           $update->{$key} = $self->data->{$key};
118             }
119             }
120              
121 0           return $self->issue->put_field( timetracking => $update );
122             }
123              
124             1;
125              
126             __END__
127              
128             =pod
129              
130             =encoding UTF-8
131              
132             =for :stopwords Packy Anderson Alexey Melezhik Atlassian GreenHopper JRC ScriptRunner TODO
133             aggregateprogress aggregatetimeestimate aggregatetimeoriginalestimate
134             assigneeType avatar avatarUrls completeDate displayName duedate
135             emailAddress endDate fieldtype fixVersions fromString genericized iconUrl
136             isAssigneeTypeValid issueTypes issuekeys issuelinks issuetype jira jql
137             lastViewed maxResults originalEstimate originalEstimateSeconds parentkey
138             projectId rapidViewId remainingEstimate remainingEstimateSeconds
139             resolutiondate sprintlist startDate subtaskIssueTypes timeSpent
140             timeSpentSeconds timeestimate timeoriginalestimate timespent timetracking
141             toString updateAuthor worklog workratio
142              
143             =head1 NAME
144              
145             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.
146              
147             =head1 VERSION
148              
149             version 0.10
150              
151             =head1 METHODS
152              
153             =head2 B<set_originalEstimate>
154              
155             Sets the original estimate to the amount of time given. Accepts any time format that JIRA uses.
156              
157             =head2 B<set_remainingEstimate>
158              
159             Sets the remaining estimate to the amount of time given. Accepts any time format that JIRA uses.
160              
161             =head2 B<update>
162              
163             Accepts a hashref of timetracking fields to update. The acceptable fields are determined by JIRA, but I think they're originalEstimate and remainingEstimate.
164              
165             =head1 READ-ONLY ACCESSORS
166              
167             =head2 B<originalEstimate>
168              
169             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.
170              
171             =head2 B<remainingEstimate>
172              
173             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.
174              
175             =head2 B<timeSpent>
176              
177             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.
178              
179             =head1 RELATED CLASSES
180              
181             =over 2
182              
183             =item * L<JIRA::REST::Class|JIRA::REST::Class>
184              
185             =item * L<JIRA::REST::Class::Abstract|JIRA::REST::Class::Abstract>
186              
187             =back
188              
189             =head1 AUTHOR
190              
191             Packy Anderson <packy@cpan.org>
192              
193             =head1 COPYRIGHT AND LICENSE
194              
195             This software is Copyright (c) 2017 by Packy Anderson.
196              
197             This is free software, licensed under:
198              
199             The Artistic License 2.0 (GPL Compatible)
200              
201             =cut