| 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.10'; | |||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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 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 | ||||||||||