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::Base; |
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
$GitHub::API::Base::VERSION = '0.000000_03'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
539
|
use common::sense; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
16
|
1
|
|
|
1
|
|
846
|
use autobox::JSON; |
|
1
|
|
|
|
|
27427
|
|
|
1
|
|
|
|
|
15
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# ABSTRACT: Base class for GitHub::API classes |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# debugging... |
21
|
|
|
|
|
|
|
#use Smart::Comments '###'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _get { |
24
|
0
|
|
|
0
|
|
|
my $self = shift @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
### fetching: $self->{base_url} . $self->{url} |
27
|
0
|
|
|
|
|
|
my $items = $self |
28
|
|
|
|
|
|
|
->{ua} |
29
|
|
|
|
|
|
|
->get( |
30
|
|
|
|
|
|
|
$self->{base_url} . $self->{url}, |
31
|
|
|
|
|
|
|
{ headers => $self->{headers} }, |
32
|
|
|
|
|
|
|
) |
33
|
|
|
|
|
|
|
->{content} |
34
|
|
|
|
|
|
|
->from_json |
35
|
|
|
|
|
|
|
; |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
return ref $items eq 'ARRAY' ? $items : [ $items ]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _post { |
41
|
0
|
|
|
0
|
|
|
my ($self, $content, $path_part) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $url = $self->{base_url} . $self->{url}; |
44
|
0
|
|
0
|
|
|
|
$url .= $path_part // q{}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
### POST to: $url |
47
|
|
|
|
|
|
|
#### $content |
48
|
0
|
|
|
|
|
|
my $resp = $self |
49
|
|
|
|
|
|
|
->{ua} |
50
|
|
|
|
|
|
|
->post($url, { content => $content->to_json, headers => $self->{headers} }) |
51
|
|
|
|
|
|
|
; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $resp->{content}->from_json; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _delete { |
57
|
0
|
|
|
0
|
|
|
my ($self, $content, $path_part) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $url = $self->{base_url} . $self->{url}; |
60
|
0
|
|
0
|
|
|
|
$url .= $path_part // q{}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
### DELETE to: $url |
63
|
0
|
|
|
|
|
|
my $resp = $self |
64
|
|
|
|
|
|
|
->{ua} |
65
|
|
|
|
|
|
|
->delete($url, { headers => $self->{headers} }) |
66
|
|
|
|
|
|
|
; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $resp; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _next_append { |
72
|
0
|
|
|
0
|
|
|
my ($self, $class, $url_append) = @_; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my %thing = %$self; |
75
|
0
|
|
|
|
|
|
$thing{url} .= $url_append; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#### %thing |
78
|
0
|
|
|
|
|
|
return bless \%thing, $class; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _next { |
82
|
0
|
|
|
0
|
|
|
my ($self, $class, $url) = @_; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my %thing = %$self; |
85
|
0
|
|
|
|
|
|
$thing{url} = $url; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#### %thing |
88
|
0
|
|
|
|
|
|
return bless \%thing, $class; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
!!42; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |