line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pithub::Gists; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PLU'; |
3
|
|
|
|
|
|
|
our $VERSION = '0.01040'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Github v3 Gists API |
5
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
9106
|
use Moo; |
|
16
|
|
|
|
|
10477
|
|
|
16
|
|
|
|
|
91
|
|
7
|
16
|
|
|
16
|
|
5567
|
use Carp qw( croak ); |
|
16
|
|
|
|
|
36
|
|
|
16
|
|
|
|
|
892
|
|
8
|
16
|
|
|
16
|
|
6460
|
use Pithub::Gists::Comments; |
|
16
|
|
|
|
|
40
|
|
|
16
|
|
|
|
|
9015
|
|
9
|
|
|
|
|
|
|
extends 'Pithub::Base'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub comments { |
13
|
1
|
|
|
1
|
1
|
398
|
return shift->_create_instance('Pithub::Gists::Comments', @_); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub create { |
18
|
3
|
|
|
3
|
1
|
6437
|
my ( $self, %args ) = @_; |
19
|
3
|
100
|
|
|
|
23
|
croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH'; |
20
|
2
|
|
|
|
|
19
|
return $self->request( |
21
|
|
|
|
|
|
|
method => 'POST', |
22
|
|
|
|
|
|
|
path => '/gists', |
23
|
|
|
|
|
|
|
%args, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub delete { |
29
|
4
|
|
|
4
|
1
|
2751
|
my ( $self, %args ) = @_; |
30
|
4
|
100
|
|
|
|
20
|
croak 'Missing key in parameters: gist_id' unless $args{gist_id}; |
31
|
|
|
|
|
|
|
return $self->request( |
32
|
|
|
|
|
|
|
method => 'DELETE', |
33
|
3
|
|
|
|
|
27
|
path => sprintf( '/gists/%s', delete $args{gist_id} ), |
34
|
|
|
|
|
|
|
%args, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub fork { |
40
|
3
|
|
|
3
|
1
|
1800
|
my ( $self, %args ) = @_; |
41
|
3
|
100
|
|
|
|
18
|
croak 'Missing key in parameters: gist_id' unless $args{gist_id}; |
42
|
|
|
|
|
|
|
return $self->request( |
43
|
|
|
|
|
|
|
method => 'POST', |
44
|
2
|
|
|
|
|
19
|
path => sprintf( '/gists/%s/forks', delete $args{gist_id} ), |
45
|
|
|
|
|
|
|
%args, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get { |
51
|
3
|
|
|
3
|
1
|
1801
|
my ( $self, %args ) = @_; |
52
|
3
|
100
|
|
|
|
19
|
croak 'Missing key in parameters: gist_id' unless $args{gist_id}; |
53
|
|
|
|
|
|
|
return $self->request( |
54
|
|
|
|
|
|
|
method => 'GET', |
55
|
2
|
|
|
|
|
19
|
path => sprintf( '/gists/%s', delete $args{gist_id} ), |
56
|
|
|
|
|
|
|
%args, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub is_starred { |
62
|
4
|
|
|
4
|
1
|
2743
|
my ( $self, %args ) = @_; |
63
|
4
|
100
|
|
|
|
22
|
croak 'Missing key in parameters: gist_id' unless $args{gist_id}; |
64
|
|
|
|
|
|
|
return $self->request( |
65
|
|
|
|
|
|
|
method => 'GET', |
66
|
3
|
|
|
|
|
25
|
path => sprintf( '/gists/%s/star', delete $args{gist_id} ), |
67
|
|
|
|
|
|
|
%args, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub list { |
73
|
6
|
|
|
6
|
1
|
6941
|
my ( $self, %args ) = @_; |
74
|
6
|
100
|
|
|
|
25
|
if ( my $user = delete $args{user} ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
75
|
2
|
|
|
|
|
19
|
return $self->request( |
76
|
|
|
|
|
|
|
method => 'GET', |
77
|
|
|
|
|
|
|
path => sprintf( '/users/%s/gists', $user ), |
78
|
|
|
|
|
|
|
%args, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
elsif ( delete $args{starred} ) { |
82
|
2
|
|
|
|
|
8
|
return $self->request( |
83
|
|
|
|
|
|
|
method => 'GET', |
84
|
|
|
|
|
|
|
path => '/gists/starred', |
85
|
|
|
|
|
|
|
%args, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
elsif ( delete $args{public} ) { |
89
|
1
|
|
|
|
|
4
|
return $self->request( |
90
|
|
|
|
|
|
|
method => 'GET', |
91
|
|
|
|
|
|
|
path => '/gists/public', |
92
|
|
|
|
|
|
|
%args, |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
1
|
|
|
|
|
5
|
return $self->request( |
96
|
|
|
|
|
|
|
method => 'GET', |
97
|
|
|
|
|
|
|
path => '/gists', |
98
|
|
|
|
|
|
|
%args, |
99
|
|
|
|
|
|
|
); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub star { |
104
|
4
|
|
|
4
|
1
|
2762
|
my ( $self, %args ) = @_; |
105
|
4
|
100
|
|
|
|
19
|
croak 'Missing key in parameters: gist_id' unless $args{gist_id}; |
106
|
|
|
|
|
|
|
return $self->request( |
107
|
|
|
|
|
|
|
method => 'PUT', |
108
|
3
|
|
|
|
|
24
|
path => sprintf( '/gists/%s/star', delete $args{gist_id} ), |
109
|
|
|
|
|
|
|
%args, |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub unstar { |
115
|
4
|
|
|
4
|
1
|
2727
|
my ( $self, %args ) = @_; |
116
|
4
|
100
|
|
|
|
21
|
croak 'Missing key in parameters: gist_id' unless $args{gist_id}; |
117
|
|
|
|
|
|
|
return $self->request( |
118
|
|
|
|
|
|
|
method => 'DELETE', |
119
|
3
|
|
|
|
|
24
|
path => sprintf( '/gists/%s/star', delete $args{gist_id} ), |
120
|
|
|
|
|
|
|
%args, |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub update { |
126
|
5
|
|
|
5
|
1
|
3267
|
my ( $self, %args ) = @_; |
127
|
5
|
100
|
|
|
|
26
|
croak 'Missing key in parameters: gist_id' unless $args{gist_id}; |
128
|
4
|
100
|
|
|
|
20
|
croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH'; |
129
|
|
|
|
|
|
|
return $self->request( |
130
|
|
|
|
|
|
|
method => 'PATCH', |
131
|
3
|
|
|
|
|
29
|
path => sprintf( '/gists/%s', delete $args{gist_id} ), |
132
|
|
|
|
|
|
|
%args, |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
__END__ |