| 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 | 2 | $GitHub::API::VERSION = '0.000000_03'; | |||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | # ABSTRACT: An itty-bitty interface to the GitHub API | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use IO::Socket::SSL 1.56; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Mozilla::CA; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use parent 'GitHub::API::Base'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use aliased 'GitHub::API::User'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use aliased 'GitHub::API::Org'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | # debugging... | ||||||||||||||||||||||||||||||||||
| 28 | #use Smart::Comments '###', '####'; | ||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 32 | 0 | my ($class, %opts) = @_; | |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $opts{user} //= $ENV{GH_USER} // `git config github.user`; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$opts{"user"} //= $ENV{"GH_USER"} // `git config github.user`
$ENV{"GH_USER"} // `git config github.user`
MC/DC0%0/3
$opts{"user"} //= $ENV{"GH_USER"} // `git config github.user`
$opts{"user"}
$ENV{"GH_USER"}
`git config github.user`
Truth table0%0/4
A //= B // C
A= $opts{"user"}B= $ENV{"GH_USER"}C= `git config github.user`
| |||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $opts{token} //= $ENV{GH_TOKEN} // `git config github.token`; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$opts{"token"} //= $ENV{"GH_TOKEN"} // `git config github.token`
$ENV{"GH_TOKEN"} // `git config github.token`
MC/DC0%0/3
$opts{"token"} //= $ENV{"GH_TOKEN"} // `git config github.token`
$opts{"token"}
$ENV{"GH_TOKEN"}
`git config github.token`
Truth table0%0/4
A //= B // C
A= $opts{"token"}B= $ENV{"GH_TOKEN"}C= `git config github.token`
| |||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $opts{url} //= q{}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"url"} //= ""
MC/DC0%0/1
$opts{"url"} //= ""
$opts{"url"}
Truth table0%0/2
A
A= $opts{"url"}
| |||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $opts{base_url} ||= 'https://api.github.com'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"base_url"} ||= "https://api.github.com"
MC/DC0%0/1
$opts{"base_url"} ||= "https://api.github.com"
$opts{"base_url"}
Truth table0%0/2
A
A= $opts{"base_url"}
| |||||||||||||||||||||||||||||||||||
| 38 | $opts{ua} ||= HTTP::Tiny->new( | ||||||||||||||||||||||||||||||||||
| 39 | verify_ssl => 1, | ||||||||||||||||||||||||||||||||||
| 40 | agent => __PACKAGE__ . ' @ ', | ||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | %{ $opts{ua_opts} // {} }, | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$opts{"ua"} ||= "HTTP::Tiny"->new("verify_ssl", 1, "agent", "GitHub::API \@ ", %{$opts{"ua_opts"} // {};})
$opts{"ua_opts"} // {}
MC/DC0%0/2
$opts{"ua"} ||= "HTTP::Tiny"->new("verify_ssl", 1, "agent", "GitHub::API \@ ", %{$opts{"ua_opts"} // {};})
$opts{"ua"}
"HTTP::Tiny"->new("verify_ssl", 1, "agent", "GitHub::API \@ ", %{$opts{"ua_opts"} // {};})
MC/DC0%0/1
$opts{"ua_opts"} // {}
$opts{"ua_opts"}
Truth table0%0/3
A ||= B
A= $opts{"ua"}B= "HTTP::Tiny"->new("verify_ssl", 1, "agent", "GitHub::API \@ ", %{$opts{"ua_opts"} // {};})
Truth table0%0/2
A
A= $opts{"ua_opts"}
| |||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $opts{headers}->{Authorization} ||= "token $opts{token}"; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"headers"}{"Authorization"} ||= qq[token $opts{"token"}]
MC/DC0%0/1
$opts{"headers"}{"Authorization"} ||= qq[token $opts{"token"}]
$opts{"headers"}{"Authorization"}
Truth table0%0/2
A
A= $opts{"headers"}{"Authorization"}
| |||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $opts{_req} = sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | ### fetching: $opts{url} | ||||||||||||||||||||||||||||||||||
| 48 | 0 | $opts{ua}->request(shift, $opts{url}, { headers => $opts{headers} }) }; | |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 0 | return bless \%opts, $class; | |||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub user { shift->_next(User, '/user') } | ||||||||||||||||||||||||||||||||
|
Subroutine
user: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 55 | #sub users { ... } # needs a Users class | ||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub org { shift->_next(Org, "/orgs/$_[0]") } | ||||||||||||||||||||||||||||||||
|
Subroutine
org: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | 2 | !!42; | |||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||||||||