line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of GitHub-API |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2013 by Chris Weyl. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package GitHub::API; |
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
$GitHub::API::VERSION = '0.000000_03'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
87216
|
use common::sense; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
7
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# ABSTRACT: An itty-bitty interface to the GitHub API |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
1229
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
54478
|
|
|
1
|
|
|
|
|
37
|
|
20
|
1
|
|
|
1
|
|
1502
|
use IO::Socket::SSL 1.56; |
|
1
|
|
|
|
|
51628
|
|
|
1
|
|
|
|
|
9
|
|
21
|
1
|
|
|
1
|
|
1180
|
use Mozilla::CA; |
|
1
|
|
|
|
|
272
|
|
|
1
|
|
|
|
|
32
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
6
|
use parent 'GitHub::API::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
24
|
1
|
|
|
1
|
|
1089
|
use aliased 'GitHub::API::User'; |
|
1
|
|
|
|
|
688
|
|
|
1
|
|
|
|
|
9
|
|
25
|
1
|
|
|
1
|
|
148
|
use aliased 'GitHub::API::Org'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# debugging... |
28
|
|
|
|
|
|
|
#use Smart::Comments '###', '####'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
0
|
|
|
0
|
1
|
|
my ($class, %opts) = @_; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
0
|
|
|
|
$opts{user} //= $ENV{GH_USER} // `git config github.user`; |
|
|
|
0
|
|
|
|
|
35
|
0
|
|
0
|
|
|
|
$opts{token} //= $ENV{GH_TOKEN} // `git config github.token`; |
|
|
|
0
|
|
|
|
|
36
|
0
|
|
0
|
|
|
|
$opts{url} //= q{}; |
37
|
0
|
|
0
|
|
|
|
$opts{base_url} ||= 'https://api.github.com'; |
38
|
0
|
|
0
|
|
|
|
$opts{ua} ||= HTTP::Tiny->new( |
39
|
|
|
|
|
|
|
verify_ssl => 1, |
40
|
|
|
|
|
|
|
agent => __PACKAGE__ . ' @ ', |
41
|
0
|
|
0
|
|
|
|
%{ $opts{ua_opts} // {} }, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
0
|
|
|
|
$opts{headers}->{Authorization} ||= "token $opts{token}"; |
45
|
|
|
|
|
|
|
$opts{_req} = sub { |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
### fetching: $opts{url} |
48
|
0
|
|
|
0
|
|
|
$opts{ua}->request(shift, $opts{url}, { headers => $opts{headers} }) }; |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return bless \%opts, $class; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
1
|
|
sub user { shift->_next(User, '/user') } |
55
|
|
|
|
|
|
|
#sub users { ... } # needs a Users class |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
|
sub org { shift->_next(Org, "/orgs/$_[0]") } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
!!42; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |