line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Github.com API Client |
2
|
|
|
|
|
|
|
package API::Github; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1414
|
use Data::Object::Class; |
|
1
|
|
|
|
|
24378
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
2381
|
use Data::Object::Signatures; |
|
1
|
|
|
|
|
308254
|
|
|
1
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
|
|
5
|
use Data::Object::Library qw( |
8
|
|
|
|
|
|
|
Str |
9
|
1
|
|
|
1
|
|
8826
|
); |
|
1
|
|
|
|
|
2
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'API::Client'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.06'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $DEFAULT_URL = "https://api.github.com"; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# ATTRIBUTES |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has username => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
isa => Str, |
22
|
|
|
|
|
|
|
required => 1, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has token => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
isa => Str, |
28
|
|
|
|
|
|
|
required => 1, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# DEFAULTS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has '+identifier' => ( |
34
|
|
|
|
|
|
|
default => 'API::Github (Perl)', |
35
|
|
|
|
|
|
|
required => 0, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has '+url' => ( |
39
|
|
|
|
|
|
|
default => $DEFAULT_URL, |
40
|
|
|
|
|
|
|
required => 0, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has '+version' => ( |
44
|
|
|
|
|
|
|
default => 1, |
45
|
|
|
|
|
|
|
required => 0, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# CONSTRUCTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
after BUILD => method { |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $identifier = $self->identifier; |
53
|
|
|
|
|
|
|
my $username = $self->username; |
54
|
|
|
|
|
|
|
my $token = $self->token; |
55
|
|
|
|
|
|
|
my $version = $self->version; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $userinfo = "$username:$token"; |
58
|
|
|
|
|
|
|
my $agent = $self->user_agent; |
59
|
|
|
|
|
|
|
my $url = $self->url; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$agent->transactor->name($identifier); |
62
|
|
|
|
|
|
|
$url->userinfo($userinfo); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $self; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
0
|
|
method PREPARE ($ua, $tx, %args) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $headers = $tx->req->headers; |
71
|
0
|
|
|
|
|
|
my $url = $tx->req->url; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# default headers |
74
|
0
|
|
|
|
|
|
$headers->header('Content-Type' => 'application/json'); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $self; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
0
|
|
method resource (@segments) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# build new resource instance |
83
|
0
|
|
|
|
|
|
my $instance = __PACKAGE__->new( |
84
|
|
|
|
|
|
|
debug => $self->debug, |
85
|
|
|
|
|
|
|
fatal => $self->fatal, |
86
|
|
|
|
|
|
|
retries => $self->retries, |
87
|
|
|
|
|
|
|
timeout => $self->timeout, |
88
|
|
|
|
|
|
|
user_agent => $self->user_agent, |
89
|
|
|
|
|
|
|
identifier => $self->identifier, |
90
|
|
|
|
|
|
|
username => $self->username, |
91
|
|
|
|
|
|
|
token => $self->token, |
92
|
|
|
|
|
|
|
version => $self->version, |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# resource locator |
96
|
0
|
|
|
|
|
|
my $url = $instance->url; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# modify resource locator if possible |
99
|
0
|
|
|
|
|
|
$url->path(join '/', $self->url->path, @segments); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# return resource instance |
102
|
0
|
|
|
|
|
|
return $instance; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |