| 1 | package WWW::PGXN; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use WWW::PGXN::Distribution; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use WWW::PGXN::Extension; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use WWW::PGXN::User; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use WWW::PGXN::Tag; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use WWW::PGXN::Mirror; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use URI::Template; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use JSON (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 9 | our $VERSION = v0.12.4; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub new { | ||||||||||||||||||||||||||||
| 18 | 9 | ▶ | my($class, %params) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 9 | my $self = bless {} => $class; | |||||||||||||||||||||||||||
| 20 | 9 | for my $key (qw(url proxy)) { | |||||||||||||||||||||||||||
| 21 | 18 | ▶ | $self->$key($params{$key}) if exists $params{$key} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 9 | return $self; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub get_distribution { | ||||||||||||||||||||||||||||
| 27 | 15 | ▶ | my ($self, $dist, $version) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_distribution: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 15 | ▶ | my $data = $self->_fetch_json( | ||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
$version || ''
MC/DC100%1/1
$version || ''
$version
Truth table100%2/2
A
A= $version
| |||||||||||||||||||||||||||||
| 29 | (defined $version ? 'meta' : 'dist'), | ||||||||||||||||||||||||||||
| 30 | { dist => lc $dist, version => lc($version || '') } | ||||||||||||||||||||||||||||
| 31 | ) or return; | ||||||||||||||||||||||||||||
| 32 | 14 | WWW::PGXN::Distribution->new($self, $data); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub get_extension { | ||||||||||||||||||||||||||||
| 36 | 2 | ▶ | my ($self, $ext) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_extension: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 2 | ▶ | my $data = $self->_fetch_json(extension => { extension => lc $ext }) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | or return; | ||||||||||||||||||||||||||||
| 39 | 1 | WWW::PGXN::Extension->new($self, $data); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub get_user { | ||||||||||||||||||||||||||||
| 43 | 2 | ▶ | my ($self, $user) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_user: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 2 | ▶ | my $data = $self->_fetch_json(user => { user => lc $user }) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 1 | WWW::PGXN::User->new($data); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub get_tag { | ||||||||||||||||||||||||||||
| 49 | 2 | ▶ | my ($self, $tag) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_tag: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 2 | ▶ | my $data = $self->_fetch_json(tag => { tag => lc $tag }) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 1 | WWW::PGXN::Tag->new($data); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub get_stats { | ||||||||||||||||||||||||||||
| 55 | 2 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_stats: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 2 | ▶ | my $data = $self->_fetch_json(stats => { stats => lc $name }) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub get_userlist { | ||||||||||||||||||||||||||||
| 60 | 3 | ▶ | my ($self, $letter) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_userlist: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | 3 | ▶ | return undef unless $self->_uri_templates->{userlist}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 2 | ▶ | return $self->_fetch_json(userlist => { letter => lc $letter }) || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->_fetch_json('userlist', {'letter', lc $letter}) || []
MC/DC100%1/1
$self->_fetch_json('userlist', {'letter', lc $letter}) || []
$self->_fetch_json('userlist', {'letter', lc $letter})
Truth table100%2/2
A
A= $self->_fetch_json('userlist', {'letter', lc $letter})
| |||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 9 | my %valid_in = ( map { $_ => undef } qw(docs dists extensions users tags)); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | sub search { | ||||||||||||||||||||||||||||
| 68 | 12 | ▶ | my ($self, %params) = @_; | ||||||||||||||||||||||||||
|
Subroutine
search: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 12 | my $url = $self->url; | |||||||||||||||||||||||||||
| 70 | my $in = delete $params{in} | ||||||||||||||||||||||||||||
| 71 | 12 | ▶ | or croak 'Missing required "in" parameter to search()'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | croak qq{Invalid "in" parameter to search(); Must be one of:\n} | ||||||||||||||||||||||||||||
| 74 | 5 | . join("\n", map { "* $_" } sort keys %valid_in) | |||||||||||||||||||||||||||
| 75 | 11 | ▶ | unless exists $valid_in{$in}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 10 | ▶ | if ($url->scheme eq 'file') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | # Fetch it via PGXN::API::Searcher. | ||||||||||||||||||||||||||||
| 79 | 5 | ▶ | my $searcher = $self->{_searcher} ||= PGXN::API::Searcher->new( | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"_searcher"} ||= "PGXN::API::Searcher"->new("File::Spec"->catdir($url->path_segments))
MC/DC0%0/2
$self->{"_searcher"} ||= "PGXN::API::Searcher"->new("File::Spec"->catdir($url->path_segments))
$self->{"_searcher"}
"PGXN::API::Searcher"->new("File::Spec"->catdir($url->path_segments))
Truth table66%2/3
A ||= B
A= $self->{"_searcher"}B= "PGXN::API::Searcher"->new("File::Spec"->catdir($url->path_segments))
| |||||||||||||||||||||||||||||
| 80 | File::Spec->catdir($url->path_segments) | ||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||
| 82 | 5 | return $searcher->search(in => $in, %params); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 5 | my $qurl = $self->_url_for(search => { in => $in }); | |||||||||||||||||||||||||||
| 86 | $qurl->query_form({ | ||||||||||||||||||||||||||||
| 87 | 5 | map { substr($_, 0, 1) => $params{$_} } keys %params | |||||||||||||||||||||||||||
| 88 | }); | ||||||||||||||||||||||||||||
| 89 | 5 | ▶ | my $res = $self->_fetch($qurl) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 5 | return JSON->new->utf8->decode($res->{content}); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | sub mirrors { | ||||||||||||||||||||||||||||
| 94 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
mirrors: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 1 | ▶ | return @{ $self->{mirrors} ||= do { | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"mirrors"} ||= do {
MC/DC0%0/2
$self->{"mirrors"} ||= do {
my $mirrors = $self->_fetch_json("mirrors");
[map({"WWW::PGXN::Mirror"->new($_);} @{$mirrors;})]
}
$self->{"mirrors"}
do {
my $mirrors = $self->_fetch_json("mirrors");
[map({"WWW::PGXN::Mirror"->new($_);} @{$mirrors;})]
}
Truth table33%1/3
A ||= B
A= $self->{"mirrors"}B= do {
my $mirrors = $self->_fetch_json("mirrors");
[map({"WWW::PGXN::Mirror"->new($_);} @{$mirrors;})]
}
| |||||||||||||||||||||||||||||
| 96 | 1 | my $mirrors = $self->_fetch_json('mirrors'); | |||||||||||||||||||||||||||
| 97 | 1 | [ map { WWW::PGXN::Mirror->new($_) } @{ $mirrors } ]; | |||||||||||||||||||||||||||
| 98 | } }; | ||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub spec { | ||||||||||||||||||||||||||||
| 102 | 3 | ▶ | my ($self, $format) = @_; | ||||||||||||||||||||||||||
|
Subroutine
spec: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | 3 | ▶ | $format ||= 'txt'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$format ||= "txt"
MC/DC100%1/1
$format ||= "txt"
$format
Truth table100%2/2
A
A= $format
| |||||||||||||||||||||||||||||
| 104 | 3 | ▶ | my $res = $self->_fetch( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | $self->_url_for('spec' => { format => $format }) | ||||||||||||||||||||||||||||
| 106 | ) or return; | ||||||||||||||||||||||||||||
| 107 | 3 | utf8::decode $res->{content}; | |||||||||||||||||||||||||||
| 108 | 3 | return $res->{content}; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | sub url { | ||||||||||||||||||||||||||||
| 112 | 106 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
url: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 113 | 106 | ▶ | return $self->{url} unless @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 13 | (my $url = shift) =~ s{/+$}{}g; | |||||||||||||||||||||||||||
| 115 | 13 | $self->{url} = URI->new($url); | |||||||||||||||||||||||||||
| 116 | 13 | ▶ | require PGXN::API::Searcher if $self->{url}->scheme eq 'file'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 13 | delete $self->{_req}; | |||||||||||||||||||||||||||
| 118 | 13 | delete $self->{_searcher}; | |||||||||||||||||||||||||||
| 119 | 13 | $self->{url}; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | sub proxy { | ||||||||||||||||||||||||||||
| 123 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
proxy: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||
| 124 | 2 | ▶ | return $self->{proxy} unless @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 0 | $self->{proxy} = shift; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | BEGIN { | ||||||||||||||||||||||||||||
| 129 | 9 | ▶ | for my $thing (qw(meta download source)) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 130 | 9 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 131 | 27 | *{"$thing\_url_for"} = sub { | |||||||||||||||||||||||||||
| 132 | 3 | ▶ | $_[0]->_url_for( $thing => { dist => lc $_[1], version => lc $_[2] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 133 | 27 | }; | |||||||||||||||||||||||||||
| 134 | 27 | *{"$thing\_path_for"} = sub { | |||||||||||||||||||||||||||
| 135 | 3 | ▶ | $_[0]->_path_for( $thing => { dist => lc $_[1], version => lc $_[2] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 136 | 27 | }; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 9 | for my $thing (qw(tag extension user)) { | |||||||||||||||||||||||||||
| 140 | 9 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 141 | 27 | *{"$thing\_url_for"} = sub { | |||||||||||||||||||||||||||
| 142 | 3 | ▶ | $_[0]->_url_for( $thing => { $thing => lc $_[1] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 143 | 27 | }; | |||||||||||||||||||||||||||
| 144 | 27 | *{"$thing\_path_for"} = sub { | |||||||||||||||||||||||||||
| 145 | 3 | ▶ | $_[0]->_path_for( $thing => { $thing => lc $_[1] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 146 | 27 | }; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | sub html_doc_path_for { | ||||||||||||||||||||||||||||
| 151 | 2 | ▶ | my ($self, $dist, $version, $path) = @_; | ||||||||||||||||||||||||||
|
Subroutine
html_doc_path_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 152 | 2 | $self->_path_for(htmldoc => { | |||||||||||||||||||||||||||
| 153 | dist => lc $dist, | ||||||||||||||||||||||||||||
| 154 | version => lc $version, | ||||||||||||||||||||||||||||
| 155 | docpath => $path, | ||||||||||||||||||||||||||||
| 156 | }); | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub html_doc_url_for { | ||||||||||||||||||||||||||||
| 160 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
html_doc_url_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 161 | 1 | return URI->new($self->url . $self->html_doc_path_for(@_)); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | sub _uri_templates { | ||||||||||||||||||||||||||||
| 165 | 79 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_uri_templates: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 166 | 79 | ▶ | return $self->{uri_templates} ||= { do { | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"uri_templates"} ||= {do {
MC/DC100%1/1
$self->{"uri_templates"} ||= {do {
my $req = $self->_request;
my $url = "URI"->new($self->url . '/index.json');
my $res = $req->get($url);
croak(qq[Request for $url failed: $res->{"status"}: $res->{"reason"}\n]) unless $res->{"success"};
my $tmpl = "JSON"->new->utf8->decode($res->{"content"});
map {$_, "URI::Template"->new($tmpl->{$_});} keys %{$tmpl;}
}}
$self->{"uri_templates"}
Truth table100%2/2
A
A= $self->{"uri_templates"}
| |||||||||||||||||||||||||||||
| 167 | 9 | my $req = $self->_request; | |||||||||||||||||||||||||||
| 168 | 9 | my $url = URI->new($self->url . '/index.json'); | |||||||||||||||||||||||||||
| 169 | 9 | my $res = $req->get($url); | |||||||||||||||||||||||||||
| 170 | croak "Request for $url failed: $res->{status}: $res->{reason}\n" | ||||||||||||||||||||||||||||
| 171 | 9 | ▶ | unless $res->{success}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 8 | my $tmpl = JSON->new->utf8->decode($res->{content}); | |||||||||||||||||||||||||||
| 173 | 8 | map { $_ => URI::Template->new($tmpl->{$_}) } keys %{ $tmpl }; | |||||||||||||||||||||||||||
| 174 | }}; | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | sub _path_for { | ||||||||||||||||||||||||||||
| 178 | 63 | ▶ | my ($self, $name, $vars) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_path_for: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 179 | 63 | ▶ | my $tmpl = $self->_uri_templates->{$name} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | or croak qq{No URI template named "$name"}; | ||||||||||||||||||||||||||||
| 181 | 62 | return $tmpl->process($vars); | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | sub _url_for { | ||||||||||||||||||||||||||||
| 185 | 54 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_url_for: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 186 | 54 | return URI->new($self->url . $self->_path_for(@_)); | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | sub _request { | ||||||||||||||||||||||||||||
| 190 | 53 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_request: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||
| 191 | 53 | ▶ | $self->{_req} ||= $self->url =~ m{^file:} ? WWW::PGXN::FileReq->new : HTTP::Tiny->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_req"} ||= $self->url =~ /^file:/ ? "WWW::PGXN::FileReq"->new : "HTTP::Tiny"->new("agent", 'WWW::PGXN/' . __PACKAGE__->VERSION, "proxy", $self->proxy)
MC/DC0%0/2
$self->{"_req"} ||= $self->url =~ /^file:/ ? "WWW::PGXN::FileReq"->new : "HTTP::Tiny"->new("agent", 'WWW::PGXN/' . __PACKAGE__->VERSION, "proxy", $self->proxy)
$self->{"_req"}
$self->url =~ /^file:/ ? "WWW::PGXN::FileReq"->new : "HTTP::Tiny"->new("agent", 'WWW::PGXN/' . __PACKAGE__->VERSION, "proxy", $self->proxy)
Truth table66%2/3
A ||= B
A= $self->{"_req"}B= $self->url =~ /^file:/ ? "WWW::PGXN::FileReq"->new : "HTTP::Tiny"->new("agent", 'WWW::PGXN/' . __PACKAGE__->VERSION, "proxy", $self->proxy)
| |||||||||||||||||||||||||||||
| 192 | agent => __PACKAGE__ . '/' . __PACKAGE__->VERSION, | ||||||||||||||||||||||||||||
| 193 | proxy => $self->proxy, | ||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | sub _fetch { | ||||||||||||||||||||||||||||
| 198 | 42 | ▶ | my ($self, $url) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_fetch: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||
| 199 | 42 | my $res = $self->_request->get($url); | |||||||||||||||||||||||||||
| 200 | 42 | ▶ | return $res if $res->{success}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 6 | ▶ | return if $res->{status} == 404; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 0 | croak "Request for $url failed: $res->{status}: $res->{reason}\n"; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | sub _fetch_json { | ||||||||||||||||||||||||||||
| 206 | 32 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_fetch_json: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 207 | 32 | ▶ | my $res = $self->_fetch($self->_url_for(@_)) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 26 | return JSON->new->utf8->decode($res->{content}); | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | sub _download_to { | ||||||||||||||||||||||||||||
| 212 | 5 | ▶ | my ($self, $file) = (shift, shift); | ||||||||||||||||||||||||||
|
Subroutine
_download_to: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||
| 213 | 5 | my $url = $self->_url_for(download => @_); | |||||||||||||||||||||||||||
| 214 | 5 | my $res = $self->_fetch($url); | |||||||||||||||||||||||||||
| 215 | 5 | ▶ | if (-e $file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 2 | ▶ | if (-d $file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 2 | my @seg = $url->path_segments; | |||||||||||||||||||||||||||
| 218 | 2 | $file = File::Spec->catfile($file, $seg[-1]); | |||||||||||||||||||||||||||
| 219 | } else { | ||||||||||||||||||||||||||||
| 220 | 0 | croak "$file already exists"; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 5 | ▶ | open my $fh, '>:raw', $file or die "Cannot open $file: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 5 | print $fh $res->{content}; | |||||||||||||||||||||||||||
| 226 | 5 | ▶ | close $fh or die "Cannot close $file: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 5 | return $file; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | package | ||||||||||||||||||||||||||||
| 231 | WWW::PGXN::FileReq; | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 234 | 9 | ▶ | use URI::file (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 235 | 9 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 236 | 9 | ▶ | use URI::Escape (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | sub new { | ||||||||||||||||||||||||||||
| 239 | 10 | ▶ | bless {} => shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | sub get { | ||||||||||||||||||||||||||||
| 243 | 53 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 244 | 53 | my $file = File::Spec->catfile(shift->path_segments); | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | return { | ||||||||||||||||||||||||||||
| 247 | 53 | ▶ | success => 0, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | status => 404, | ||||||||||||||||||||||||||||
| 249 | reason => 'not found', | ||||||||||||||||||||||||||||
| 250 | headers => {}, | ||||||||||||||||||||||||||||
| 251 | } unless -e $file; | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 45 | ▶ | open my $fh, '<:raw', $file or return { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | success => 0, | ||||||||||||||||||||||||||||
| 255 | status => 500, | ||||||||||||||||||||||||||||
| 256 | reason => $!, | ||||||||||||||||||||||||||||
| 257 | headers => {}, | ||||||||||||||||||||||||||||
| 258 | }; | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 45 | local $/; | |||||||||||||||||||||||||||
| 261 | return { | ||||||||||||||||||||||||||||
| 262 | 45 | ▶ | success => 1, | ||||||||||||||||||||||||||
|
Condition50%1/2
readline $fh || undef
MC/DC0%0/1
readline $fh || undef
readline $fh
Truth table50%1/2
A
A= readline $fh
| |||||||||||||||||||||||||||||
| 263 | status => 200, | ||||||||||||||||||||||||||||
| 264 | reason => 'OK', | ||||||||||||||||||||||||||||
| 265 | content => <$fh> || undef, | ||||||||||||||||||||||||||||
| 266 | headers => {}, | ||||||||||||||||||||||||||||
| 267 | }; | ||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 9 | 1; | |||||||||||||||||||||||||||
| 271 | __END__ | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | =head1 Name | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | WWW::PGXN - Interface to PGXN mirrors and the PGXN API | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | =head1 Synopsis | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | my $pgxn = WWW::PGXN->new( url => 'http://api.pgxn.org/' ); | ||||||||||||||||||||||||||||
| 280 | my $dist = $pgxn->get_distribution('pgTAP'); | ||||||||||||||||||||||||||||
| 281 | $dist->download_to('.'); | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | =head1 Description | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | This module provide a simple Perl interface over the the L<PGXN | ||||||||||||||||||||||||||||
| 286 | API|http://github.com/pgxn/pgxn-api/wiki>. It also works with any PGXN mirror | ||||||||||||||||||||||||||||
| 287 | server. It provides an interface for finding distributions, extensions, users, | ||||||||||||||||||||||||||||
| 288 | and tags, as well as for accessing documentation, lists of users, and the | ||||||||||||||||||||||||||||
| 289 | full-text search interface. WWW::PGXN is designed to make it dead simple for | ||||||||||||||||||||||||||||
| 290 | applications such as web apps and command-line clients to get the data they | ||||||||||||||||||||||||||||
| 291 | need from a PGXN mirror with a minimum of hassle, including via the file | ||||||||||||||||||||||||||||
| 292 | system, if there is a local mirror. | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | L<PGXN|http://pgxn.org> is a L<CPAN|http://cpan.org>-inspired network for | ||||||||||||||||||||||||||||
| 295 | distributing extensions for the L<PostgreSQL RDBMS|http://www.postgresql.org>. | ||||||||||||||||||||||||||||
| 296 | All of the infrastructure tools, however, have been designed to be used to | ||||||||||||||||||||||||||||
| 297 | create networks for distributing any kind of release distributions and for | ||||||||||||||||||||||||||||
| 298 | providing a lightweight static file JSON REST API. As such, WWW::PGXN should | ||||||||||||||||||||||||||||
| 299 | work with any mirror that gets its data from a | ||||||||||||||||||||||||||||
| 300 | L<PGXN::Manager|http://github.com/theory/pgxn-manager>-managed master server, | ||||||||||||||||||||||||||||
| 301 | and with any L<PGXN::API>-powered server. | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | =head1 Interface | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | =head2 Constructor | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | =head3 C<new> | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | my $pgxn = WWW::PGXN->new(url => 'http://api.pgxn.org/'); | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | Construct a new WWW::PGXN object. The only required attribute is C<url>. The | ||||||||||||||||||||||||||||
| 312 | supported parameters are: | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =over | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | =item C<url> | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | The base URL for the API server or mirror the client should fetch from. | ||||||||||||||||||||||||||||
| 319 | Required. | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =item C<proxy> | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | URL of a proxy server to use. Ignored if C<url> is a C<file:> URL. | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | =back | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | =head2 Instance Accessors | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | =head3 C<url> | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | my $url = $pgxn->url; | ||||||||||||||||||||||||||||
| 332 | $pgxn->url($url); | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | Get or set the URL for the PGXN mirror or API server. May be a C<file:> URL, | ||||||||||||||||||||||||||||
| 335 | in which case the API will be accessed purely via the file system. Otherwise | ||||||||||||||||||||||||||||
| 336 | it uses L<HTTP::Tiny> to access the API. | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | =head3 C<proxy> | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | my $proxy = $pgxn->proxy; | ||||||||||||||||||||||||||||
| 341 | $pgxn->proxy($proxy); | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | Get or set the URL for a proxy server to use. Ignored if C<url> is a C<file:> | ||||||||||||||||||||||||||||
| 344 | URL. | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =head2 Instance Methods | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | =head3 C<get_distribution> | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | my $dist = $pgxn->get_distribution($dist_name, $version); | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | Finds the data for a distribution. Returns a L<WWW::PGXN::Distribution> | ||||||||||||||||||||||||||||
| 353 | object. The first argument, the name of the distribution, is required. The | ||||||||||||||||||||||||||||
| 354 | second argument, the version, is optional. If not present, the current stable | ||||||||||||||||||||||||||||
| 355 | release will be retrieved. | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | If the distribution cannot be found, C<undef> will be returned. For any other | ||||||||||||||||||||||||||||
| 358 | errors, an exception will be thrown. | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | =head3 C<get_extension> | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | my $extension = $pgxn->get_extension($extension_name); | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | Finds the data for the named extension. Returns a L<WWW::PGXN::Extension> | ||||||||||||||||||||||||||||
| 365 | object. If the extension cannot be found, C<undef> will be returned. For any | ||||||||||||||||||||||||||||
| 366 | other errors, an exception will be thrown. | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | =head3 C<get_user> | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | my $user = $pgxn->get_user($user_name); | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | Finds the data for the named user. Returns a L<WWW::PGXN::User> object. If the | ||||||||||||||||||||||||||||
| 373 | user cannot be found, C<undef> will be returned. For any other errors, an | ||||||||||||||||||||||||||||
| 374 | exception will be thrown. | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =head3 C<get_tag> | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | my $tag = $pgxn->get_tag($tag_name); | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | Finds the data for the named tag. Returns a L<WWW::PGXN::Tag> object. If the | ||||||||||||||||||||||||||||
| 381 | tag cannot be found, C<undef> will be returned. For any other errors, an | ||||||||||||||||||||||||||||
| 382 | exception will be thrown. | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | =head3 C<get_stats> | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | my $stats = $pgxn->get_stats($stats_name); | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | Returns the contents of a stats file. The current stats names are: | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | =over | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | =item * C<summary> | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | =item * C<dist> | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | =item * C<extension> | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | =item * C<user> | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | =item * C<tag> | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | =back | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | =head3 C<get_userlist> | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | my $userlist = $pgxn->get_userlist('t'); | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | Returns a the contents of a user list, which contains data on all users whose | ||||||||||||||||||||||||||||
| 409 | nickname starts with the specified lowercase ASCII letter. If called against a | ||||||||||||||||||||||||||||
| 410 | mirror, this method always returns C<undef>. When called against an API, it | ||||||||||||||||||||||||||||
| 411 | will always return an array of users. If there is no user list file for the | ||||||||||||||||||||||||||||
| 412 | specified letter, the array will be empty. Otherwise, it will contain a list | ||||||||||||||||||||||||||||
| 413 | of hash references with two keys: | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | =over | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | =item * C<user> | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | The user's nickname. | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | =item * C<name> | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | The user's full name. | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | =back | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | =head3 C<mirrors> | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | my @mirrors = $pgxn->mirrors; | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | Returns a list of L<WWW::PGXN::Mirror> objects representing all of the mirrors | ||||||||||||||||||||||||||||
| 432 | in the network to which the PGXN API or mirror server belongs. | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | =head3 C<spec> | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | my $spec = $pgxn->spec; | ||||||||||||||||||||||||||||
| 437 | my $html = $pgxn->spec('html'); | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | Returns the contents of the PGXN Meta Spec document. By default, this is a | ||||||||||||||||||||||||||||
| 440 | text document. But you can get an HTML version by passing C<HTML> as the | ||||||||||||||||||||||||||||
| 441 | argument. Pass C<txt> to be specific about wanting the text document. | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | =head3 C<search> | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | my $results = $pgxn->search( query => 'tap' ); | ||||||||||||||||||||||||||||
| 446 | $results = $pgxn->search( query => 'wicked', index => 'dists' ); | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | Sends a search query to the API server (not supported for mirrors). For an API | ||||||||||||||||||||||||||||
| 449 | server accessed via a C<file:> URL, L<PGXN::API::Searcher> is required and | ||||||||||||||||||||||||||||
| 450 | used to fetch the results directly. Otherwise, an HTTP request is sent to the | ||||||||||||||||||||||||||||
| 451 | server as usual. | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | The supported parameters are: | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =over | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | =item query | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | The search query. See L<Lucy::Search::QueryParser> for the supported syntax of | ||||||||||||||||||||||||||||
| 460 | the query. Required. | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | =item index | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | The name of the search index to query. The default is "docs". The possible | ||||||||||||||||||||||||||||
| 465 | values are: | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | =over | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | =item docs | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | =item dists | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | =item extensions | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | =item users | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | =item tags | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | =back | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | =item offset | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | How many hits to skip before showing results. Defaults to 0. | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =item limit | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | Maximum number of hits to return. Defaults to 50 and may not be greater than | ||||||||||||||||||||||||||||
| 488 | 1024. | ||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | =back | ||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | Currently the return value is a hash composed directly from the JSON returned | ||||||||||||||||||||||||||||
| 493 | by the search request. See L<PGXN::API::Searcher> for details on its | ||||||||||||||||||||||||||||
| 494 | structure. | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | =head3 C<meta_url_for> | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | my $meta_url = $pgxn->meta_url_for($dist_name, $dist_version); | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | Returns the URL for a distribution meta file. This is the file fetched by | ||||||||||||||||||||||||||||
| 501 | C<get_distribution()>. | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | =head3 C<download_url_for> | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | my $download_url = $pgxn->download_url_for($dist_name, $dist_version); | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | Returns the download URL for a distribution and version. This is the zipped | ||||||||||||||||||||||||||||
| 508 | archive file containing the distribution itself. | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | =head3 C<source_url_for> | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | my $source_url = $pgxn->source_url_for($dist_name, $dist_version); | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | Returns the URL for a distribution source file. This URL is available only | ||||||||||||||||||||||||||||
| 515 | from an API server, not a mirror. | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | =head3 C<html_doc_url_for> | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | my $doc_url = $pgxn->html_doc_url_for($dist_name, $dist_version, $doc_path); | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | Returns the URL for a distribution documentation file. This URL is available | ||||||||||||||||||||||||||||
| 522 | only from an API server, not a mirror. | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | =head3 C<extension_url_for> | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | my $extension_url = $pgxn->extension_url_for($extension_name); | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | Returns the URL for an extension metadata file. This is the file fetched by | ||||||||||||||||||||||||||||
| 529 | C<get_extension()>. | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | =head3 C<user_url_for> | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | my $user_url = $pgxn->user_url_for($nickname); | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | Returns the URL for an user metadata file. This is the file fetched by | ||||||||||||||||||||||||||||
| 536 | C<get_user()>. | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | =head3 C<tag_url_for> | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | my $tag_url = $pgxn->tag_url_for($tag_name); | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | Returns the URL for an tag metadata file. This is the file fetched by | ||||||||||||||||||||||||||||
| 543 | C<get_tag()>. | ||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | =head3 C<meta_path_for> | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | my $meta_path = $pgxn->meta_path_for($dist_name, $dist_version); | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | Returns the path for a distribution meta file. | ||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | =head3 C<download_path_for> | ||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | my $download_path = $pgxn->download_path_for($dist_name, $dist_version); | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | Returns the download path for a distribution and version. | ||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | =head3 C<source_path_for> | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | my $source_path = $pgxn->source_path_for($dist_name, $dist_version); | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | Returns the path for a distribution source file. This path is available only | ||||||||||||||||||||||||||||
| 562 | from an API server, not a mirror. | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | =head3 C<html_doc_path_for> | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | my $doc_path = $pgxn->html_doc_path_for($dist_name, $dist_version, $doc_path); | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | Returns the PATH for a distribution documentation file. This PATH is available | ||||||||||||||||||||||||||||
| 569 | only from an API server, not a mirror. | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | =head3 C<extension_path_for> | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | my $extension_path = $pgxn->extension_path_for($extension_name); | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | Returns the path for an extension metadata file. | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | =head3 C<user_path_for> | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | my $user_path = $pgxn->user_path_for($nickname); | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | Returns the path for an user metadata file. | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | =head3 C<tag_path_for> | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | my $tag_path = $pgxn->tag_path_for($tag_name); | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | Returns the path for an tag metadata file. | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | =head1 See Also | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | =over | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | =item * L<PGXN|http://pgxn.org/> | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | The PostgreSQL Extension Network, the reference implementation of the PGXN | ||||||||||||||||||||||||||||
| 596 | infrastructure. | ||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | =item * L<PGXN::API> | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | Creates and serves a PGXN API implementation from a PGXN mirror. | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | =item * L<API Documentation|http://github.com/theory/pgxn-api> | ||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | Comprehensive documentation of the REST API provided by L<PGXN::API> and | ||||||||||||||||||||||||||||
| 605 | consumed by WWW::PGXN. | ||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | =item * L<PGXN::Manager|http://github.com/theory/pgxn-manager> | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | Server for managing a master PGXN mirror and allowing users to upload | ||||||||||||||||||||||||||||
| 610 | distributions to it. | ||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | =back | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | =head1 Support | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | This module is stored in an open L<GitHub | ||||||||||||||||||||||||||||
| 617 | repository|http://github.com/theory/www-pgxn/>. Feel free to fork and | ||||||||||||||||||||||||||||
| 618 | contribute! | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | Please file bug reports via L<GitHub | ||||||||||||||||||||||||||||
| 621 | Issues|http://github.com/theory/www-pgxn/issues/> or by sending mail to | ||||||||||||||||||||||||||||
| 622 | L<bug-WWW-PGXN@rt.cpan.org|mailto:bug-WWW-PGXN@rt.cpan.org>. | ||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | =head1 Author | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | David E. Wheeler <david@justatheory.com> | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | =head1 Copyright and License | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | Copyright (c) 2011 David E. Wheeler. Some Rights Reserved. | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | This module is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 633 | the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||
| 635 | =cut | ||||||||||||||||||||||||||||