| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ixchel::Actions::github_fetch_release_asset; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
112024
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
1
|
|
|
1
|
|
12
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
50
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
72
|
|
|
6
|
1
|
|
|
1
|
|
656
|
use File::Slurp; |
|
|
1
|
|
|
|
|
49655
|
|
|
|
1
|
|
|
|
|
131
|
|
|
7
|
1
|
|
|
1
|
|
841
|
use JSON; |
|
|
1
|
|
|
|
|
11729
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
1
|
|
|
1
|
|
671
|
use Ixchel::functions::github_fetch_release_asset; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
87
|
|
|
9
|
1
|
|
|
1
|
|
10
|
use base 'Ixchel::Actions::base'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
866
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Ixchel::Actions::github_fetch_release_asset - Fetch an release asset from a github repo. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.1.0 |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 CLI SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
ixchel -a github_fetch_release_asset B<-o> B<-r> B<-f> B<-P> [B<--pre>] B<-P> |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
ixchel -a github_fetch_release_asset B<-o> B<-r> B<-f> B<-w> |
|
28
|
|
|
|
|
|
|
[B<--ppre>] [B<-N>] [B<-A>] [B<-B>] [B<-U>] |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 CODE SYNOPSIS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Data::Dumper; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $results=$ixchel->action(action=>'github_fetch_release_asset', |
|
35
|
|
|
|
|
|
|
opts=>{o=>'mikefarah', r=>'yq', f=>'checksums' w=>'/tmp/yq-checksums' }); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
print Dumper($results); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 FLAGS |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Fetch an release asset from a github repo for the latest release. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 -o |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The repo owner. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 -r |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The repo to fetch it from in org/repo format. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 -f |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
The name of the asset to fetch for a release. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 --pre |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Pre-releases are okay. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 -d |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Draft-releases are okay. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 -P |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Print it out instead of writing it out. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 -w |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Where to write the output to. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 -N |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Do not overwrite if the file already exists. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 -A |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Write the file out in append mode. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 -B |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Write the file in a atomicly if possible. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 -U |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Umask to use. If undef will default to what ever sysopen is. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 RESULT HASH REF |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
.errors :: A array of errors encountered. |
|
90
|
|
|
|
|
|
|
.status_text :: A string description of what was done and the results. |
|
91
|
|
|
|
|
|
|
.ok :: Set to zero if any of the above errored. |
|
92
|
|
|
|
|
|
|
.content :: Fetched content. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
0
|
0
|
|
sub new_extra { } |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub action_extra { |
|
99
|
0
|
|
|
0
|
0
|
|
my $self = $_[0]; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# if neither are defined error and return |
|
102
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}{r} ) ) { |
|
103
|
0
|
|
|
|
|
|
$self->status_add( |
|
104
|
|
|
|
|
|
|
error => 1, |
|
105
|
|
|
|
|
|
|
status => '-r not specified' |
|
106
|
|
|
|
|
|
|
); |
|
107
|
0
|
|
|
|
|
|
return undef; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# if neither are defined error and return |
|
111
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}{o} ) ) { |
|
112
|
0
|
|
|
|
|
|
$self->status_add( |
|
113
|
|
|
|
|
|
|
error => 1, |
|
114
|
|
|
|
|
|
|
status => '-o not specified' |
|
115
|
|
|
|
|
|
|
); |
|
116
|
0
|
|
|
|
|
|
return undef; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# if neither are defined error and return |
|
120
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}{f} ) ) { |
|
121
|
0
|
|
|
|
|
|
$self->status_add( |
|
122
|
|
|
|
|
|
|
error => 1, |
|
123
|
|
|
|
|
|
|
status => '-fs not specified' |
|
124
|
|
|
|
|
|
|
); |
|
125
|
0
|
|
|
|
|
|
return undef; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $content; |
|
129
|
0
|
|
|
|
|
|
eval { |
|
130
|
|
|
|
|
|
|
$content = github_fetch_release_asset( |
|
131
|
|
|
|
|
|
|
owner => $self->{opts}{o}, |
|
132
|
|
|
|
|
|
|
repo => $self->{opts}{r}, |
|
133
|
|
|
|
|
|
|
asset => $self->{opts}{f}, |
|
134
|
|
|
|
|
|
|
output => $self->{opts}{w}, |
|
135
|
|
|
|
|
|
|
pre => $self->{opts}{p}, |
|
136
|
|
|
|
|
|
|
draft => $self->{opts}{d}, |
|
137
|
|
|
|
|
|
|
atomic => $self->{opts}{B}, |
|
138
|
|
|
|
|
|
|
append => $self->{opts}{A}, |
|
139
|
|
|
|
|
|
|
return => $self->{opts}{P}, |
|
140
|
0
|
|
|
|
|
|
); |
|
141
|
|
|
|
|
|
|
}; |
|
142
|
0
|
0
|
|
|
|
|
if ($@) { |
|
143
|
|
|
|
|
|
|
$self->status_add( |
|
144
|
|
|
|
|
|
|
error => 1, |
|
145
|
0
|
|
|
|
|
|
status => 'Fetching ' . $self->{opts}{o} . '/' . $self->{opts}{r} . ' failed... ' . $@ |
|
146
|
|
|
|
|
|
|
); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
0
|
|
|
|
|
|
$self->{results}{content} = $content; |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
|
|
|
if ( $self->{opts}{P} ) { |
|
151
|
0
|
|
|
|
|
|
print $content; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
0
|
|
|
|
|
|
return undef; |
|
154
|
|
|
|
|
|
|
} ## end sub action_extra |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub short { |
|
157
|
0
|
|
|
0
|
1
|
|
return 'Fetch an release asset from a github repo.'; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub opts_data { |
|
161
|
0
|
|
|
0
|
1
|
|
return ' |
|
162
|
|
|
|
|
|
|
r=s |
|
163
|
|
|
|
|
|
|
f=s |
|
164
|
|
|
|
|
|
|
pre |
|
165
|
|
|
|
|
|
|
d |
|
166
|
|
|
|
|
|
|
o=s |
|
167
|
|
|
|
|
|
|
w=s |
|
168
|
|
|
|
|
|
|
P |
|
169
|
|
|
|
|
|
|
N |
|
170
|
|
|
|
|
|
|
A |
|
171
|
|
|
|
|
|
|
B |
|
172
|
|
|
|
|
|
|
U |
|
173
|
|
|
|
|
|
|
'; |
|
174
|
|
|
|
|
|
|
} ## end sub opts_data |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |