| 1 | package PGXN::API::Indexer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use v5.14; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use utf8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Moose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use PGXN::API; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use File::Spec::Functions qw(catfile catdir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use File::Path qw(make_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use File::Copy::Recursive qw(fcopy dircopy); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use File::Basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Text::Markup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Text::Markup::None qr/te?xt/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use XML::LibXML; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use List::Util qw(first); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use List::MoreUtils qw(uniq); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use Lucy::Plan::Schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | use Lucy::Analysis::PolyAnalyzer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Lucy::Analysis::RegexTokenizer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use Lucy::Index::Indexer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use Try::Tiny; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use Archive::Zip qw(AZ_OK); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use namespace::autoclean; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | our $VERSION = v0.21.1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | has verbose => (is => 'rw', isa => 'Int', default => 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | has _index_it => (is => 'rw', isa => 'Bool', default => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | has to_index => (is => 'ro', isa => 'HashRef', default => sub { +{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | map { $_ => [] } qw(docs dists extensions users tags) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | has _user_names => (is => 'ro', isa => 'HashRef', default => sub { +{ } }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | has libxml => (is => 'ro', isa => 'XML::LibXML', lazy => 1, default => sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | XML::LibXML->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | recover => 2, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | no_network => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | no_blanks => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | no_cdata => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | has index_dir => (is => 'ro', isa => 'Str', lazy => 1, default => sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | my $dir = catdir +PGXN::API->instance->doc_root, '_index'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | if (!-e $dir) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | require File::Path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | File::Path::make_path($dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | has schemas => ( is => 'ro', isa => 'HashRef', lazy => 1, default => sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | my $polyanalyzer = Lucy::Analysis::PolyAnalyzer->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | language => 'en', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | my $fti = Lucy::Plan::FullTextType->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | analyzer => $polyanalyzer, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | highlightable => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my $ftih = Lucy::Plan::FullTextType->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | analyzer => $polyanalyzer, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | highlightable => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | my $string = Lucy::Plan::StringType->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | indexed => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | stored => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | my $indexed = Lucy::Plan::StringType->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | indexed => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | stored => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | my $stored = Lucy::Plan::StringType->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | indexed => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | stored => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | my $list = Lucy::Plan::FullTextType->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | indexed => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | stored => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | highlightable => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | analyzer => Lucy::Analysis::RegexTokenizer->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | pattern => '[^\003]+' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | my %schemas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | for my $spec ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | [ docs => [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | [ key => $indexed ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | [ title => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | [ abstract => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | [ body => $ftih ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | [ dist => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | [ version => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | [ docpath => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | [ date => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | [ user => $string ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | [ user_name => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ]], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | [ dists => [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | [ key => $indexed ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | [ dist => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | [ abstract => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | [ description => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | [ readme => $ftih ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | [ tags => $list ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | [ version => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | [ date => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | [ user => $string ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | [ user_name => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ]], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | [ extensions => [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | [ key => $indexed ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | [ extension => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | [ abstract => $ftih ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | [ docpath => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | [ dist => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | [ version => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | [ date => $stored ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | [ user => $string ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | [ user_name => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ]], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | [ users => [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | [ key => $indexed ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | [ user => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | [ name => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | [ email => $string ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | [ uri => $string ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | [ details => $ftih ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ]], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | [ tags => [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | [ key => $indexed ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | [ tag => $fti ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ]], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | my ($name, $fields) = @{ $spec }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | my $schema = Lucy::Plan::Schema->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | $schema->spec_field(name => $_->[0], type => $_->[1] ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | for @{ $fields }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | $schemas{$name} = $schema; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | return \%schemas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | sub indexer_for { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 25 | ▶ | my ($self, $iname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indexer_for: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | Lucy::Index::Indexer->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | index => catdir($self->index_dir, $iname), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 25 | schema => $self->schemas->{$iname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | create => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | sub update_root_json { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_root_json: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | my $api = PGXN::API->instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | say "Updating mirror root JSON" if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # Augment and write index.json. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | my $src = catfile $api->mirror_root, 'index.json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | my $dst = catfile $api->doc_root, 'index.json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | my $tmpl = $api->read_json_from($src); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | $tmpl->{source} = "/src/{dist}/{dist}-{version}/"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | $tmpl->{search} = '/search/{in}/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | $tmpl->{userlist} = '/users/{letter}.json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | ($tmpl->{htmldoc} = $tmpl->{meta}) =~ s{/META[.]json$}{/{+docpath}.html}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | $api->write_json_to($dst, $tmpl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | sub copy_from_mirror { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_from_mirror: called CC=3 SCAR=11.2
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | my @path = split qr{/} => shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | my $api = PGXN::API->instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | my $src = catfile $api->mirror_root, @path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | my $dst = catfile $api->doc_root, @path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | say "Copying $src to $dst" if $self->verbose > 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | ▶ | fcopy $src, $dst or die "Cannot copy $src to $dst: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | sub parse_from_mirror { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | ▶ | my ($self, $path, $format) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_from_mirror: called CC=5 SCAR=16.2
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | my @path = split qr{/} => $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 3 | my $api = PGXN::API->instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | my $src = catfile $api->mirror_root, @path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 3 | my $dst = catfile $api->doc_root, @path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | my $mark = Text::Markup->new(default_encoding => 'UTF-8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | $dst =~ s/[.][^.]+$/.html/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | say "Parsing $src to $dst" if $self->verbose > 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | ▶ | my $html = $mark->parse( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | file => $src, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | format => $format, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ) or return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | my $doc = $self->_parse_html_string($html); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | make_path dirname $dst; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | ▶ | open my $fh, '>:utf8', $dst or die "Cannot open $dst: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | $doc = _clean_html_body($doc->findnodes('/html/body')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | print $fh $doc->toString, "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | close $fh or die "Cannot close $dst: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | sub add_distribution { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 4 | ▶ | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_distribution: called CC=6 SCAR=19.1
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # merge_distmeta will set _index_it, but we don't want it changed after this | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # method finishes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | local $self->{_index_it} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | ▶ | $self->copy_files($params) or return $self->_rollback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | ▶ | $self->merge_distmeta($params) or return $self->_rollback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | ▶ | $self->update_user($params) or return $self->_rollback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | ▶ | $self->update_tags($params) or return $self->_rollback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | $self->update_extensions($params) or return $self->_rollback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | return $self->_commit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | sub copy_files { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 5 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_files: called CC=7 SCAR=19.5
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 5 | my $meta = $p->{meta}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 5 | ▶ | say " Copying \L$meta->{name}-$meta->{version}\E files" if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # Need to copy the README, zip file, and dist meta file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 5 | for my $file (qw(download readme)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 9 | my $src = $self->mirror_file_for($file => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 9 | my $dst = $self->doc_root_file_for($file => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 9 | ▶ | next if $file eq 'readme' && !-e $src; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$file eq "readme" and not -e $src
MC/DC100%2/2
$file eq "readme" and not -e $src
$file eq "readme"
not -e $src
Truth table100%3/3
A and not(B)
A= $file eq "readme"B= not -e $src
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 7 | ▶ | say " \L$meta->{name}-$meta->{version}\E.$file" if $self->verbose > 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 7 | ▶ | fcopy $src, $dst or die "Cannot copy $src to $dst: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 4 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | sub merge_distmeta { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 6 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_distmeta: called CC=20 SCAR=30.5
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 6 | my $meta = $p->{meta}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 6 | ▶ | say " Merging \L$meta->{name}-$meta->{version}\E META.json" if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # Merge the list of versions into the meta file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 6 | my $api = PGXN::API->instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 6 | my $dist_file = $self->mirror_file_for(dist => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 6 | my $dist_meta = $api->read_json_from($dist_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 6 | $meta->{releases} = $dist_meta->{releases}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # Determine whether to full-text index this distribution. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | $self->_index_it( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # Always index a stable release. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | $meta->{release_status} eq 'stable' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # Index if testing and no stable. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | || ($meta->{release_status} eq 'testing' && !$meta->{releases}{stable}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # Index if there are only unstable releases. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | || !$meta->{releases}{testing} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 6 | ▶ | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition55%5/9
$meta->{'release_status'} eq 'stable' || $meta->{'release_status'} eq 'testing' && !$meta->{'releases'}{'stable'} || !$meta->{'releases'}{'testing'}
$meta->{"release_status"} eq "stable" or $meta->{"release_status"} eq "testing" and not $meta->{"releases"}{"stable"}
$meta->{"release_status"} eq "testing" and not $meta->{"releases"}{"stable"}
MC/DC25%1/4
$meta->{'release_status'} eq 'stable' || $meta->{'release_status'} eq 'testing' && !$meta->{'releases'}{'stable'} || !$meta->{'releases'}{'testing'}
$meta->{"release_status"} eq "stable"
$meta->{"release_status"} eq "testing"
not $meta->{"releases"}{"stable"}
!$meta->{'releases'}{'testing'}
Truth table33%2/6
A or B and not(C) || not(D)
A= $meta->{"release_status"} eq "stable"B= $meta->{"release_status"} eq "testing"C= not $meta->{"releases"}{"stable"}D= !$meta->{'releases'}{'testing'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # Add a list of special files and docs. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 6 | $meta->{special_files} = $self->_source_files($p); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 6 | $meta->{docs} = $self->parse_docs($p); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # Add doc paths to provided extensions where appropriate. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 6 | ▶ | while (my ($noext_path, $data) = each %{ $meta->{docs} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 9 | ▶ | if (my $ext = delete $data->{extension}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # The extension referenced a docfile. Use it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | ▶ | my $d = $meta->{provides}{$ext} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$meta->{'provides'}{$ext} || die("Extension $ext missing from meta spec")
MC/DC0%0/1
$meta->{'provides'}{$ext} || die("Extension $ext missing from meta spec")
$meta->{'provides'}{$ext}
Truth table50%1/2
A
A= $meta->{'provides'}{$ext}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | || die "Extension $ext missing from meta spec"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | $d->{docpath} = $noext_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # No doc specified or it wasn't found. Try to find a likely candidate | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # where the extension name is the file base name. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 8 | my ($basename) = $noext_path =~ m{([^/]+)$}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 8 | ▶ | if (my $d = $meta->{provides}{$basename}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 5 | ▶ | $d->{docpath} ||= $noext_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$d->{"docpath"} ||= $noext_path
MC/DC0%0/2
$d->{"docpath"} ||= $noext_path
$d->{"docpath"}
$noext_path
Truth table66%2/3
A ||= B
A= $d->{"docpath"}B= $noext_path
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # Write the merge metadata to the file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 6 | my $fn = $self->doc_root_file_for(meta => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 6 | make_path dirname $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 6 | $api->write_json_to($fn, $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 6 | $dist_file = $self->doc_root_file_for(dist => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 6 | ▶ | if ($meta->{release_status} eq 'stable') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # Copy it to its dist home. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 4 | ▶ | fcopy $fn, $dist_file or die "Cannot copy $fn to $dist_file: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # Determine latest stable release or fall back on testing, unstable. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | for my $status (qw(stable testing unstable)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | ▶ | my $rels = $meta->{releases}{$status} or next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | $meta->{version} = $rels->[0]{version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # Now write out the dist version. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | $api->write_json_to($dist_file => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # Index it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | $self->_index(dists => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | key => lc $meta->{name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | dist => $meta->{name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | abstract => $meta->{abstract}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | description => $meta->{description} || '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | readme => $self->_readme($p), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | ▶ | tags => join("\003" => @{ $meta->{tags} || [] }), | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | version => $meta->{version}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | date => $meta->{date}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | user_name => $self->_get_user_name($meta), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | user => $meta->{user}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 6 | ▶ | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$meta->{'description'} || ''
MC/DC0%0/1
$meta->{'description'} || ''
$meta->{'description'}
Truth table50%1/2
A
A= $meta->{'description'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # Now update all older versions with the complete list of releases. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 6 | for my $releases ( values %{ $meta->{releases} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 11 | for my $release (@{ $releases}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 16 | ▶ | next if $release->{version} eq $meta->{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 10 | local $meta->{version} = $release->{version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 10 | my $vmeta_file = $self->doc_root_file_for(meta => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 10 | ▶ | next unless -e $vmeta_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 9 | my $vmeta = $api->read_json_from($vmeta_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 9 | $vmeta->{releases} = $meta->{releases}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 9 | $api->write_json_to($vmeta_file => $vmeta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 6 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | sub merge_user { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 3 | ▶ | my ($self, $nick) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_user: called CC=5 SCAR=16.1
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 3 | ▶ | return $self if $self->_user_names->{$nick}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 2 | ▶ | say " Merging user $nick" if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | my $api = PGXN::API->instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | my $mir_file = $self->mirror_file_for('user', undef, user => $nick); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | my $mir_data = $api->read_json_from($mir_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | my $doc_file = $self->doc_root_file_for('user', undef, user => $nick); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | ▶ | my $doc_data = -e $doc_file ? $api->read_json_from($doc_file) : {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # Merge in the releases and rewrite. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | ▶ | $mir_data->{releases} = $doc_data->{releases} || {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$doc_data->{'releases'} || {}
MC/DC100%1/1
$doc_data->{'releases'} || {}
$doc_data->{'releases'}
Truth table100%2/2
A
A= $doc_data->{'releases'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 2 | $api->write_json_to($doc_file, $mir_data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # Update the full name lookup & the search index and return. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 2 | $self->_user_names->{lc $nick} = $mir_data->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | $self->_index_user($mir_data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | sub update_user { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 6 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_user: called CC=2 SCAR=7.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 6 | ▶ | say " Updating user $p->{meta}{user}" if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 6 | my $user = $self->_update_releases(user => $p->{meta}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 6 | $self->_index_user($user); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 6 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | sub update_tags { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 6 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_tags: called CC=5 SCAR=16.4
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 6 | my $meta = $p->{meta}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 6 | ▶ | say " Updating \L$meta->{name}-$meta->{version}\E tags" if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 6 | ▶ | my $tags = $meta->{tags} or return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 6 | for my $tag (@{ $tags }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 16 | ▶ | say " $tag" if $self->verbose > 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 16 | my $data = $self->_update_releases(tag => $meta, tag => lc $tag); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 16 | $self->_index(tags => { key => lc $tag, tag => $tag }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 6 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | sub update_extensions { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 8 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_extensions: called CC=21 SCAR=30.8
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 8 | my $meta = $p->{meta}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 8 | my $api = PGXN::API->instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 8 | ▶ | say " Updating \L$meta->{name}-$meta->{version}\E extensions" | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 8 | ▶ | while (my ($ext, $data) = each %{ $meta->{provides} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 8 | ▶ | say " $ext" if $self->verbose > 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 8 | $ext = lc $ext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # Read in extension metadata from the mirror. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 8 | my $mir_file = $self->mirror_file_for( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | extension => $meta, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | extension => $ext, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 8 | my $mir_meta = $api->read_json_from($mir_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # Read in extension metadata from the doc root. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 8 | my $doc_file = $self->doc_root_file_for( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | extension => $meta, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | extension => $ext, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 8 | ▶ | my $doc_meta = -e $doc_file ? $api->read_json_from($doc_file) : {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # Add the abstract and doc path to the mirror data. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 8 | my $status = $meta->{release_status}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 8 | $mir_meta->{$status}{abstract} = $data->{abstract}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 8 | ▶ | $mir_meta->{$status}{docpath} = $data->{docpath} if $data->{docpath}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # Copy the other release status data from the doc data. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 8 | $mir_meta->{$_} = $doc_meta->{$_} for grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 24 | ▶ | $doc_meta->{$_} && $_ ne $status | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } qw(stable testing unstable); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # Copy the version info from the doc to the mirror and add the date. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 8 | my $version = $data->{version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 8 | my $mir_vers = $mir_meta->{versions}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 8 | my $mir_dists = $mir_vers->{$version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 8 | ▶ | my $doc_dists = $doc_meta->{versions}{$version} ||= []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$doc_meta->{"versions"}{$version} ||= []
MC/DC100%1/1
$doc_meta->{"versions"}{$version} ||= []
$doc_meta->{"versions"}{$version}
Truth table100%2/2
A
A= $doc_meta->{"versions"}{$version}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # Copy the doc root versions. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 8 | $mir_meta->{versions} = $doc_meta->{versions}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # Find the current release distribution in the versions. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 8 | for my $i (0..$#$mir_dists) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 11 | my $dist = $mir_dists->[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # Make sure the doc dists are in sync. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 11 | ▶ | if (!$doc_dists->[$i] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not $doc_dists->[$i] or $dist->{"dist"} ne $doc_dists->[$i]{"dist"} or $dist->{"version"} ne $doc_dists->[$i]{"version"}
not $doc_dists->[$i] or $dist->{"dist"} ne $doc_dists->[$i]{"dist"}
MC/DC66%2/3
not $doc_dists->[$i] or $dist->{"dist"} ne $doc_dists->[$i]{"dist"} or $dist->{"version"} ne $doc_dists->[$i]{"version"}
not $doc_dists->[$i]
$dist->{"dist"} ne $doc_dists->[$i]{"dist"}
$dist->{"version"} ne $doc_dists->[$i]{"version"}
Truth table75%3/4
not(A) or B or C
A= not $doc_dists->[$i]B= $dist->{"dist"} ne $doc_dists->[$i]{"dist"}C= $dist->{"version"} ne $doc_dists->[$i]{"version"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | || $dist->{dist} ne $doc_dists->[$i]{dist} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | || $dist->{version} ne $doc_dists->[$i]{version} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 5 | splice @{ $doc_dists }, $i, 0, $dist; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # Is this the distribution we're currently updating? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 11 | ▶ | if ($dist->{dist} eq $meta->{name} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$dist->{"dist"} eq $meta->{"name"} and $dist->{"version"} eq $meta->{"version"}
MC/DC50%1/2
$dist->{"dist"} eq $meta->{"name"} and $dist->{"version"} eq $meta->{"version"}
$dist->{"dist"} eq $meta->{"name"}
$dist->{"version"} eq $meta->{"version"}
Truth table66%2/3
A and B
A= $dist->{"dist"} eq $meta->{"name"}B= $dist->{"version"} eq $meta->{"version"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | && $dist->{version} eq $meta->{version} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | # Got it. Add the release date. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 8 | $dist->{date} = $meta->{date}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # Remove any deleted versions. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 8 | my $ddvers = $doc_meta->{versions}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 8 | for my $v (keys %{ $ddvers }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 21 | ▶ | delete $ddvers->{$v} unless $mir_vers->{$v}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # Only index testing if no stable, and unstable if no testing. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | my $release = $mir_meta->{stable} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | || $mir_meta->{testing} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 8 | ▶ | || $mir_meta->{unstable}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$mir_meta->{'stable'} || $mir_meta->{'testing'} || $mir_meta->{'unstable'}
$mir_meta->{"stable"} or $mir_meta->{"testing"}
MC/DC0%0/3
$mir_meta->{'stable'} || $mir_meta->{'testing'} || $mir_meta->{'unstable'}
$mir_meta->{"stable"}
$mir_meta->{"testing"}
$mir_meta->{'unstable'}
Truth table25%1/4
A or B || C
A= $mir_meta->{"stable"}B= $mir_meta->{"testing"}C= $mir_meta->{'unstable'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # Write it back out and index it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 8 | $api->write_json_to($doc_file => $mir_meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | $self->_index(extensions => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | key => lc $mir_meta->{extension}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | extension => $mir_meta->{extension}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | abstract => $release->{abstract} || '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | docpath => $data->{docpath} || '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | dist => $meta->{name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | version => $release->{version}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | date => $meta->{date}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | user_name => $self->_get_user_name($meta), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | user => $meta->{user}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 8 | ▶ | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$release->{'abstract'} || ''
$data->{'docpath'} || ''
MC/DC0%0/1
$release->{'abstract'} || ''
$release->{'abstract'}
MC/DC100%1/1
$data->{'docpath'} || ''
$data->{'docpath'}
Truth table50%1/2
A
A= $release->{'abstract'}
Truth table100%2/2
A
A= $data->{'docpath'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 8 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | sub find_docs { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 19 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_docs: called CC=13 SCAR=25.7
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 19 | my $meta = $p->{meta}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 19 | my $dir = $self->doc_root_file_for(source => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 19 | my $prefix = quotemeta lc "$meta->{name}-$meta->{version}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 19 | ▶ | my $skip = { directory => [], file => [], %{ $meta->{no_index} || {} } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 19 | my $markup = Text::Markup->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 19 | my (%seen, @docs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 19 | ▶ | while (my ($ext, $info) = each %{ $meta->{provides} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 19 | my $fn = $info->{docfile}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 19 | ▶ | next unless $fn && $markup->guess_format($fn) && -e catfile $dir, $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$fn and $markup->guess_format($fn) and -e catfile($dir, $fn)
$fn and $markup->guess_format($fn)
MC/DC100%3/3
$fn and $markup->guess_format($fn) and -e catfile($dir, $fn)
$fn
$markup->guess_format($fn)
-e catfile($dir, $fn)
Truth table100%4/4
A and B and C
A= $fnB= $markup->guess_format($fn)C= -e catfile($dir, $fn)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 8 | push @docs => { extension => $ext, filename => $fn }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 8 | $seen{$fn}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 19 | for my $member ($p->{zip}->members) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 275 | ▶ | next if $member->isDirectory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # Skip files that should not be indexed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 161 | (my $fn = $member->fileName) =~ s{^$prefix/}{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 161 | ▶ | next if $seen{$fn}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 158 | ▶ | next if first { $fn eq $_ } @{ $skip->{file} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 156 | ▶ | next if first { $fn =~ /^\Q$_/ } @{ $skip->{directory} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 152 | ▶ | next unless $markup->guess_format($fn) || $fn =~ /^README(?:[.][^.]+)?$/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$markup->guess_format($fn) or $fn =~ /^README(?:[.][^.]+)?$/iu
MC/DC50%1/2
$markup->guess_format($fn) or $fn =~ /^README(?:[.][^.]+)?$/iu
$markup->guess_format($fn)
$fn =~ /^README(?:[.][^.]+)?$/iu
Truth table66%2/3
A or B
A= $markup->guess_format($fn)B= $fn =~ /^README(?:[.][^.]+)?$/iu
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 29 | push @docs => { filename => $fn }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 19 | return @docs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | sub parse_docs { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 11 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_docs: called CC=18 SCAR=29.2
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 11 | my $meta = $p->{meta}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 11 | ▶ | say " Parsing \L$meta->{name}-$meta->{version}\E docs" if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 11 | my $markup = Text::Markup->new(default_encoding => 'UTF-8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 11 | my $dir = $self->doc_root_file_for(source => $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | # Find all doc files and write them out. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 11 | my (%docs, $readme); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 11 | my @files = $self->find_docs($p); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 11 | for my $spec (@files) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 18 | my $fn = $spec->{filename}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 18 | my $src = catfile $dir, $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 18 | ▶ | next unless -e $src; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 16 | ▶ | say " Parsing markup in $src" if $self->verbose > 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 16 | ▶ | my $doc = $self->_parse_html_string($markup->parse(file => $src) or next); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$markup->parse('file', $src) || (next)
MC/DC100%1/1
$markup->parse('file', $src) || (next)
$markup->parse('file', $src)
Truth table100%2/2
A
A= $markup->parse('file', $src)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 15 | (my $noext = $fn) =~ s{[.][^.]+$}{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 15 | my $dst = $self->doc_root_file_for( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | htmldoc => $meta, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | docpath => $noext, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 15 | make_path dirname $dst; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | # Determine the title before we mangle the HTML. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 15 | my $basename = basename $noext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 15 | ▶ | my $title = $doc->findvalue('/html/head/title') | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$doc->findvalue('/html/head/title') || $doc->findvalue('//h1[1]') || $basename
$doc->findvalue("/html/head/title") or $doc->findvalue("//h1[1]")
MC/DC0%0/3
$doc->findvalue('/html/head/title') || $doc->findvalue('//h1[1]') || $basename
$doc->findvalue("/html/head/title")
$doc->findvalue("//h1[1]")
$basename
Truth table25%1/4
A or B || C
A= $doc->findvalue("/html/head/title")B= $doc->findvalue("//h1[1]")C= $basename
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | || $doc->findvalue('//h1[1]') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | || $basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # Grab abstract if this looks like extension documentation. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | my $abstract = $meta->{provides}{$basename} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | ? $meta->{provides}{$basename}{abstract} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 15 | ▶ | : undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # Clean up the HTML and write it out. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 15 | ▶ | open my $fh, '>:utf8', $dst or die "Cannot open $dst: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 15 | $doc = _clean_html_body($doc->findnodes('/html/body')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 15 | print $fh $doc->toString, "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 15 | ▶ | close $fh or die "Cannot close $dst: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | $docs{$noext} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 15 | ▶ | ($spec->{extension} ? (extension => $spec->{extension}) : ()), | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | title => $title, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | ($abstract) ? (abstract => $abstract) : () | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # Prepare the index entry. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | my $to_index = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | key => lc "$meta->{name}/$noext", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | docpath => $noext, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | title => $title, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | abstract => $abstract || '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | body => _strip_html( $doc->findnodes('.//div[@id="pgxnbod"]')->shift), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | dist => $meta->{name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | version => $meta->{version}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | date => $meta->{date}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | user_name => $self->_get_user_name($meta), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | user => $meta->{user}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 15 | ▶ | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$abstract || ''
MC/DC100%1/1
$abstract || ''
$abstract
Truth table100%2/2
A
A= $abstract
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # If $fn is a README and isn't referenced by a docfile field... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 15 | ▶ | if (!$spec->{extension} && $fn =~ qr{^(?i:README(?:[.][^.]+)?)$}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $spec->{"extension"} and $fn =~ qr/^(?i:README(?:[.][^.]+)?)$/u
MC/DC100%2/2
not $spec->{"extension"} and $fn =~ qr/^(?i:README(?:[.][^.]+)?)$/u
not $spec->{"extension"}
$fn =~ qr/^(?i:README(?:[.][^.]+)?)$/u
Truth table100%3/3
not(A) and B
A= not $spec->{"extension"}B= $fn =~ qr/^(?i:README(?:[.][^.]+)?)$/u
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # Hang on to it to use in case there are no other docs. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 8 | $readme = $to_index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # Add it to the search index. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 7 | $self->_index(docs => $to_index); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # No docs found, just the README. So index it as documentation. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 11 | ▶ | $self->_index(docs => $readme) if @files == 1 && $readme; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@files == 1 and $readme
MC/DC100%2/2
@files == 1 and $readme
@files == 1
$readme
Truth table100%3/3
A and B
A= @files == 1B= $readme
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 11 | return \%docs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | sub _parse_html_string { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | shift->libxml->parse_html_string(shift, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 17 | ▶ | suppress_warnings => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_html_string: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | suppress_errors => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | recover => 2, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | sub mirror_file_for { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 49 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mirror_file_for: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 49 | return catfile +PGXN::API->instance->mirror_root, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | $self->_uri_for(@_)->path_segments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | sub doc_root_file_for { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 115 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doc_root_file_for: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 115 | return catfile +PGXN::API->instance->doc_root, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | $self->_uri_for(@_)->path_segments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | sub finalize { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 1 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 1 | $self->update_user_lists; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 1 | $self->_commit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 1 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | sub update_user_lists { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 2 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_user_lists: called CC=7 SCAR=19.5
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 2 | my $api = PGXN::API->instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 2 | my $names = $self->_user_names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 2 | my %users_for; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 2 | ▶ | say "Updating user lists" if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 2 | ▶ | while (my ($nick, $name) = each %{ $names }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 7 | my $letter = lc substr $nick, 0, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 7 | ▶ | push @{ $users_for{$letter} ||= [] } => { user => $nick, name => $name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$users_for{$letter} ||= []
MC/DC100%1/1
$users_for{$letter} ||= []
$users_for{$letter}
Truth table100%2/2
A
A= $users_for{$letter}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 2 | ▶ | while (my ($letter, $users) = each %users_for ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 4 | ▶ | say " Updating $letter.json" if $self->verbose > 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 4 | my $fn = $self->doc_root_file_for('userlist', undef, letter => $letter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 4 | ▶ | my $list = -e $fn ? $api->read_json_from($fn) : do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 2 | make_path dirname $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 2 | []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # Load the users into a hash to eliminate dupes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 4 | my %updated = map { lc $_->{user} => $_ } @{ $list }, @{ $users }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # Write them out in order by nickname. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | $api->write_json_to($fn, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 7 | map { $updated{ $_ } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 4 | sort { $a cmp $b } keys %updated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | sub _idx_distmeta { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | my $meta = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_idx_distmeta: not called CC=5 SCAR=34.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | my @lines = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | "$meta->{license} license", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | (ref $meta->{maintainer} ? @{ $meta->{maintainer} } : ($meta->{maintainer})), | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | while (my ($k, $v) = each %{ $meta->{provides}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | push @lines => $v->{abstract} ? "$k: $v->{abstract}" : $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | push @lines, $meta->{description} if $meta->{description}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | return join $/ => @lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | sub _get_user_name { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 32 | ▶ | my ($self, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_user_name: called CC=2 SCAR=7.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 32 | ▶ | return $self->_user_names->{ lc $meta->{user} } ||= do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->_user_names->{lc $meta->{"user"}} ||= do {
MC/DC0%0/2
$self->_user_names->{lc $meta->{"user"}} ||= do {
my $user = "PGXN::API"->instance->read_json_from($self->mirror_file_for("user", $meta));
$user->{"name"}
}
$self->_user_names->{lc $meta->{"user"}}
do {
my $user = "PGXN::API"->instance->read_json_from($self->mirror_file_for("user", $meta));
$user->{"name"}
}
Truth table66%2/3
A ||= B
A= $self->_user_names->{lc $meta->{"user"}}B= do {
my $user = "PGXN::API"->instance->read_json_from($self->mirror_file_for("user", $meta));
$user->{"name"}
}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 2 | my $user = PGXN::API->instance->read_json_from( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | $self->mirror_file_for(user => $meta) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 2 | $user->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | sub _strip_html { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 715 | ▶ | my $ret = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_html: called CC=5 SCAR=16.6
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 715 | for my $elem (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 1855 | ▶ | $ret .= $elem->nodeType == XML_TEXT_NODE ? $elem->data | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$elem->nodeType == 1 and $elem->nodeName eq "br"
MC/DC0%0/2
$elem->nodeType == 1 and $elem->nodeName eq "br"
$elem->nodeType == 1
$elem->nodeName eq "br"
Truth table33%1/3
A and B
A= $elem->nodeType == 1B= $elem->nodeName eq "br"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | : $elem->nodeType == XML_ELEMENT_NODE && $elem->nodeName eq 'br' ? ' ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | : _strip_html($elem->childNodes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | # Normalize whitespace. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 715 | $ret =~ s/^\s+//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 715 | $ret =~ s/\s+$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 715 | $ret =~ s/[\t\n\r]+|\s{2,}/ /gms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 715 | return $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | sub _update_releases { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 22 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_releases: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 22 | my $meta = $_[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 22 | my $api = PGXN::API->instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # Read in metadata from the mirror. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 22 | my $mir_file = $self->mirror_file_for(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 22 | my $mir_meta = $api->read_json_from($mir_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # Read in metadata from the doc root. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 22 | my $doc_file = $self->doc_root_file_for(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 22 | ▶ | my $doc_meta = -e $doc_file ? $api->read_json_from($doc_file) : $mir_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | # Update with latest release info and abstract. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | my $rels = $doc_meta->{releases}{$meta->{name}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 22 | = $mir_meta->{releases}{$meta->{name}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 22 | $rels->{abstract} = $meta->{abstract}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # Write out the data to the doc root. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 22 | $api->write_json_to($doc_file => $doc_meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 22 | return $doc_meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | sub _index_user { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 8 | ▶ | my ($self, $user) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_user: called CC=5 SCAR=16.2
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | my $data = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | key => lc $user->{nickname}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | user => $user->{nickname}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | name => $user->{name} || '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | email => $user->{email}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 8 | ▶ | uri => $user->{uri} || '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$user->{'name'} || ''
$user->{'uri'} || ''
MC/DC0%0/1
$user->{'name'} || ''
$user->{'name'}
MC/DC0%0/1
$user->{'uri'} || ''
$user->{'uri'}
Truth table50%1/2
A
A= $user->{'name'}
Truth table50%1/2
A
A= $user->{'uri'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | # Gather up any other details. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | $data->{details} = join( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | "\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 1 | grep { $_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | map { $user->{$_} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 41 | ▶ | sort grep { !$data->{$_} && !ref $user->{$_} && $_ ne 'nickname' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$data->{$_} || ref $user->{$_}
MC/DC100%2/2
$data->{$_} || ref $user->{$_}
$data->{$_}
ref $user->{$_}
Truth table100%3/3
A || B
A= $data->{$_}B= ref $user->{$_}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 8 | keys %{ $user } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 8 | $self->_index(users => $data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | sub _index { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 50 | ▶ | my ($self, $index, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 50 | ▶ | push @{ $self->to_index->{ $index } } => $data if $self->_index_it; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | sub _rollback { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 2 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rollback: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 2 | @{ $self->to_index->{$_} } = () for keys %{ $self->to_index }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 2 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | sub _commit { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 4 | ▶ | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_commit: called CC=3 SCAR=11.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 4 | my $to_index = $self->to_index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 4 | for my $iname (keys %{ $to_index }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 20 | my $indexer = $self->indexer_for($iname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 20 | for my $doc (@{ $to_index->{$iname} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 14 | $indexer->delete_by_term( field => 'key', term => $doc->{key} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 14 | $indexer->add_doc($doc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 20 | $indexer->commit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 20 | @{ $to_index->{$iname} } = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 4 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | sub _uri_for { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 164 | ▶ | my ($self, $name, $meta, @params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uri_for: called CC=4 SCAR=13.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | PGXN::API->instance->uri_templates->{$name}->process( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | dist => lc($meta->{name} || ''), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | version => lc($meta->{version} || ''), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 164 | ▶ | user => lc($meta->{user} || ''), | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$meta->{'name'} || ''
$meta->{'version'} || ''
$meta->{'user'} || ''
MC/DC100%1/1
$meta->{'name'} || ''
$meta->{'name'}
MC/DC100%1/1
$meta->{'version'} || ''
$meta->{'version'}
MC/DC100%1/1
$meta->{'user'} || ''
$meta->{'user'}
Truth table100%2/2
A
A= $meta->{'name'}
Truth table100%2/2
A
A= $meta->{'version'}
Truth table100%2/2
A
A= $meta->{'user'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | @params, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | sub _source_files { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 6 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_source_files: called CC=4 SCAR=13.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 6 | my $zip = $p->{zip}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 6 | my $prefix = quotemeta lc "$p->{meta}{name}-$p->{meta}{version}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 6 | my @files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 6 | for my $regex ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | qr{Change(?:s|Log)(?:[.][^.]+)?}i, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | qr{(?:README|LICENSE|INSTALL|COPYING|AUTHORS)(?:[.][^.]+)?}i, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | qr{META[.]json}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | qr{Makefile}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | qr{MANIFEST}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | qr{\Q$p->{meta}{name}\E[.]control}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 36 | my ($member) = $zip->membersMatching(qr{^$prefix/$regex$}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 36 | ▶ | unless ($member) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 14 | ($member) = $zip->membersMatching(qr{^$prefix/$regex[.]in$}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 14 | ▶ | next unless $member; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 23 | (my $fn = $member->fileName) =~ s{^$prefix/}{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 23 | push @files => $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 6 | return \@files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | sub _readme { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 6 | ▶ | my ($self, $p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readme: called CC=2 SCAR=9.2
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 6 | my $zip = $p->{zip}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 6 | my $prefix = quotemeta lc "$p->{meta}{name}-$p->{meta}{version}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 6 | my ($member) = $zip->membersMatching( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | qr{^$prefix/(?i:README(?:[.][^.]+)?)$} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 6 | ▶ | return '' unless $member; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 6 | my $contents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | try { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | local $SIG{__WARN__} = sub { die @_ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=8.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 6 | ▶ | $contents = $member->contents || ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$member->contents || ''
MC/DC0%0/1
$member->contents || ''
$member->contents
Truth table50%1/2
A
A= $member->contents
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } catch { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | die $_ unless /CRC or size mismatch/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | # Oy. Work around https://rt.cpan.org/Ticket/Display.html?id=74255. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | my $zip_path = $zip->fileName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | warn "CRC or size mismatch error reading from $zip_path; reloading.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | $zip = Archive::Zip->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | die "Error re-reading $zip_path\n" if $zip->read($zip_path) != AZ_OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | ($member) = $zip->membersMatching( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | qr{^$prefix/(?i:README(?:[.][^.]+)?)$} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | $contents = $member->contents || ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$member->contents || ''
MC/DC0%0/1
$member->contents || ''
$member->contents
Truth table0%0/2
A
A= $member->contents
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 6 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 6 | utf8::decode $contents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | # Normalize whitespace. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 6 | $contents =~ s/^\s+//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 6 | $contents =~ s/\s+$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 6 | $contents =~ s/[\t\n\r]+|\s{2,}/ /gms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 6 | return $contents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | # List of allowed elements and attributes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 3 | my %allowed = do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 3 | my $attrs = { title => 1, dir => 1, lang => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 3 | map { $_ => $attrs } qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | abbr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | acronym | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | address | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | area | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | article | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | aside | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | audio | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | b | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | bdi | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | bdo | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | big | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | blockquote | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | br | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | canvas | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | caption | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | cite | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | col | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | colgroup | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | data | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | dd | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | del | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | details | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | dfn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | dir | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | div | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | dl | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | dt | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | em | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | figcaption | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | figure | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | footer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | h1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | h2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | h3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | h4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | h5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | h6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | header | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | hgroup | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | hr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | i | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | img | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | ins | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | kbd | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | li | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | map | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | mark | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | meter | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | ol | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | output | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | p | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | picture | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | pre | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | q | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | rp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | rt | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ruby | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | s | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | samp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | section | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | small | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | source | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | span | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | strike | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | strong | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | sub | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | summary | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | sup | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | table | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | tbody | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | td | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | tfoot | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | th | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | thead | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | time | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | tr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | tt | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | u | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | ul | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | var | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | video | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | wbr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | xmp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | # A few elements may retain other attributes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 3 | $allowed{a} = { %{ $allowed{a} }, map { $_ => 1 } qw(href hreflang media rel target type) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 3 | $allowed{area} = { %{ $allowed{area} }, map { $_ => 1 } qw(alt coords href hreflang media rel shape target tytpe) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 3 | $allowed{article} = { %{ $allowed{article} }, cite => 1, pubdate => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 3 | $allowed{audio} = { %{ $allowed{audio} }, map { $_ => 1 } qw(src) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 3 | $allowed{canvas} = { %{ $allowed{canvas} }, map { $_ => 1 } qw(height width) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 3 | $allowed{col} = { %{ $allowed{col} }, map { $_ => 1 } qw(span align valign width) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 3 | $allowed{colgroup} = $allowed{col}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 3 | $allowed{del} = { %{ $allowed{del} }, cite => 1, datetime => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 3 | $allowed{details} = { %{ $allowed{details} }, open => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 3 | $allowed{img} = { %{ $allowed{img} }, map { $_ => 1 } qw(alt src height ismap usemap width) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 3 | $allowed{ins} = $allowed{del}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 3 | $allowed{li} = { %{ $allowed{li} }, value => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 3 | $allowed{map} = { %{ $allowed{map} }, name => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 3 | $allowed{meter} = { %{ $allowed{meter} }, map { $_ => 1 } qw(high low min max optimum value) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 3 | $allowed{source} = { %{ $allowed{source} }, map { $_ => 1 } qw(media src type) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 3 | $allowed{ol} = { %{ $allowed{ol} }, revese => 1, start => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 3 | $allowed{q} = { %{ $allowed{q} }, cite => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 3 | $allowed{section} = $allowed{q}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 3 | $allowed{table} = { %{ $allowed{table} }, map { $_ => 1 } qw(sumary width) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 3 | $allowed{tbody} = { %{ $allowed{tbody} }, map { $_ => 1 } qw(align valign) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 3 | $allowed{td} = { %{ $allowed{td} }, map { $_ => 1 } qw(align colspan headers height nowrap rowspan scope valign width) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 3 | $allowed{tfoot} = $allowed{tbody}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 3 | $allowed{th} = $allowed{td}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 3 | $allowed{tfoot} = $allowed{tbody}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 3 | $allowed{tr} = $allowed{tbody}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 3 | $allowed{time} = { %{ $allowed{time} }, datetime => 1, pubdate => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 3 | $allowed{video} = { %{ $allowed{video} }, map { $_ => 1 } qw(audio height poster src width) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | # We delete all other elements except for these, for which we keep text. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 3 | my %keep_children = map { $_ => 1 } qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | blink | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | center | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | font | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | sub _clean_html_body { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 24 | ▶ | my $top = my $elem = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_html_body: called CC=24 SCAR=31.8
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | # Create an element for the table of contents. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 24 | my $toc = XML::LibXML::Element->new('div'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 24 | $toc->setAttribute(id => 'pgxntoc'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 24 | $toc->appendText("\n "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 24 | my $contents = XML::LibXML::Element->new('h3'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 24 | $contents->appendText('Contents'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 24 | $toc->appendChild($contents); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 24 | $toc->appendText("\n "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 24 | my $topul = my $ul = XML::LibXML::Element->new('ul'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 24 | $ul->setAttribute(class => 'pgxntocroot'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 24 | $toc->addChild($ul); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 24 | my %gen_ids; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 24 | my $level = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 24 | my $pgxnbod; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 24 | ▶ | while ($elem) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 2006 | ▶ | if ($elem->nodeType == XML_ELEMENT_NODE) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 760 | my $name = $elem->nodeName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 760 | ▶ | if ($name eq 'body') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | # Remove all attributes and rewrite it as a div. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 24 | $elem->removeAttribute($_) for map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | $_->nodeName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } $elem->attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 24 | $elem->setNodeName('div'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 24 | $elem->setAttribute(id => 'pgxnbod'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 24 | $pgxnbod = $elem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 24 | ▶ | $elem = $elem->firstChild || last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$elem->firstChild || (last)
MC/DC0%0/1
$elem->firstChild || (last)
$elem->firstChild
Truth table50%1/2
A
A= $elem->firstChild
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 24 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 736 | ▶ | if (my $attrs = $allowed{$name}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | # Keep only allowed attributes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 730 | ▶ | if (!$pgxnbod || !$elem->isSameNode($pgxnbod)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pgxnbod and $elem->isSameNode($pgxnbod)
MC/DC50%1/2
$pgxnbod and $elem->isSameNode($pgxnbod)
$pgxnbod
$elem->isSameNode($pgxnbod)
Truth table66%2/3
A and B
A= $pgxnbodB= $elem->isSameNode($pgxnbod)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 729 | $elem->removeAttribute($_) for grep { !$attrs->{$_} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 167 | map { $_->nodeName } $elem->attributes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 730 | ▶ | if ($name =~ /^h([123])$/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 79 | my $header = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # Create an ID. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | # http://www.w3schools.com/tags/att_standard_id.aps | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 79 | (my $id = $elem->textContent) =~ s{^([^a-zA-Z])}{L$1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 79 | $id =~ s{[^a-zA-Z0-9_:.-]+}{.}g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 79 | ▶ | $id .= $gen_ids{$id}++ || ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$gen_ids{$id}++ || ''
MC/DC100%1/1
$gen_ids{$id}++ || ''
$gen_ids{$id}++
Truth table100%2/2
A
A= $gen_ids{$id}++
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 79 | $elem->setAttribute(id => $id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 79 | ▶ | if ($header != $level) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | # Add and remove unordered lists as needed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 23 | ▶ | while ($header < $level) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 5 | $ul->appendText("\n " . ' ' x (2 * $level - 2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 5 | my $li = $ul->parentNode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 5 | $li->appendText("\n " . ' ' x (2 * $level - 3)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 5 | $ul = $li->parentNode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 5 | $level--; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 23 | ▶ | while ($header > $level) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 21 | my $newul = XML::LibXML::Element->new('ul'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 21 | ▶ | my $li = $ul->find('./li[last()]')->shift || do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ul->find('./li[last()]')->shift || do {
MC/DC0%0/2
$ul->find('./li[last()]')->shift || do {
$ul->appendChild('XML::LibXML::Element'->new('li'))
}
$ul->find('./li[last()]')->shift
do {
$ul->appendChild('XML::LibXML::Element'->new('li'))
}
Truth table66%2/3
A || B
A= $ul->find('./li[last()]')->shiftB= do {
$ul->appendChild('XML::LibXML::Element'->new('li'))
}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 2 | $ul->appendChild( XML::LibXML::Element->new('li') ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 21 | $li->appendText("\n " . ' ' x (2 * $level)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 21 | $li->addChild($newul); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 21 | $ul = $newul; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 21 | $level++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | # Add the item to the TOC. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 79 | my $li = XML::LibXML::Element->new('li'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 79 | my $a = XML::LibXML::Element->new('a'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 79 | $a->setAttribute(href => "#$id"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 79 | $a->appendText($elem->textContent); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 79 | $li->addChild($a); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 79 | $ul->appendText("\n " . ' ' x (2 * $level - 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 79 | $ul->addChild($li); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | # Descend into children. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 730 | ▶ | if (my $next = $elem->firstChild) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 730 | $elem = $next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 730 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | # You are not wanted. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 6 | my $parent = $elem->parentNode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 6 | ▶ | if ($keep_children{$name}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | # Keep the children. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 3 | $parent->insertAfter($_, $elem) for reverse $elem->childNodes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | # Take it out and jump to the next sibling. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 6 | my $next = $elem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | NEXT: { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 6 | ▶ | if (my $sib = $next->nextSibling) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 5 | $next = $sib; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 5 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | # No sibling, try parent's sibling | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 1 | $next = $next->parentNode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 1 | ▶ | redo if $next && !$next->isSameNode($top); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$next and not $next->isSameNode($top)
MC/DC0%0/2
$next and not $next->isSameNode($top)
$next
not $next->isSameNode($top)
Truth table33%1/3
A and not(B)
A= $nextB= not $next->isSameNode($top)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 6 | $parent->removeChild($elem); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 6 | $elem = $next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 6 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | # Find the next node. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | NEXT: { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 1246 | ▶ | if (my $sib = $elem->nextSibling) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 1222 | $elem = $sib; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 1222 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | # No sibling, try parent's sibling | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 825 | $elem = $elem->parentNode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 825 | ▶ | redo if $elem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | # Add the documentation to the overall document and stringify. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 24 | my $doc = XML::LibXML::Element->new('div'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 24 | $doc->setAttribute(id => 'pgxndoc'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 24 | $doc->appendText("\n "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 24 | $doc->addChild($toc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 24 | $topul->appendText("\n "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 24 | $toc->appendText("\n "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 24 | $doc->appendText("\n "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 24 | $doc->addChild($top); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 24 | $top->appendText(""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 24 | $doc->appendText("\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 24 | return $doc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 3 | __PACKAGE__->meta->make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 3 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | __END__ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | =head1 Name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | PGXN::API::Index - PGXN API distribution indexer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | =head1 Synopsis | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | use PGXN::API::Indexer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | my $indexer = PGXN::API::Indexer->new(verbose => $verbosity); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | $indexer->add_distribution({ meta => $dist_meta, zip => $zip }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | =head1 Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | This module does the heavy lifting of indexing a PGXN distribution for the API | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | server. Simply hand off the metadata loaded from a distribution F<META.json> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | file and an L<Archive::Zip> object loaded with the distribution download file | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | and it will: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | =item 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | Copy the distribution files from the local mirror to the API document root. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | =item 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | Merge the distribution metadata between the metadata files matching the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | C<meta> and C<dist> URI templates. The templates are themselves loaded from | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | the F</index.json> file from the mirror root. The two metadata documents each | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | get additional data useful for API calls and become identical, as well. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | =item 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | Searches for any and all C<README> files and documentation files and parses | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | them into HTML. The format of all documentation files may be any recognized by | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | L<Text::Markup>. The parsed HTML is then cleaned up and an table of contents | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | added before being saved to its new home as a partial HTML document. See the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | pgTAP documentation L<on the PGXN API | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | server|http://api.pgxn.org/dist/pgTAP/doc/pgtap.html> for a nice example of | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | the resulting format (generated from a L<Markdown document in the pgTAP | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | distribution|http://github.org/theory/pgtap/doc/pgtap.md>) and the same | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | document used L<on the PGXN | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | site|http://www.pgxn.org/dist/pgTAP/doc/pgtap.html> for how it can be used. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | =item 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | Merges the user, tag, and extension metadata for the distribution, adding | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | extra data points useful for the API. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | =item 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | Adds all documentation as well as, distribution, extension, user, and tag | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | metadata, to full text indexes. These may be queried via the API server | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | (provided by L<pgxn_api_server> or locally with L<PGXN::API::Searcher>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | The result is a robust API with much more information than is provided by the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | spare metadata JSON files on a normal PGXN mirror. The interface offered via | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | L<pgxn_api_server> is then a superset of that offered by a normal mirror. It's | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | a PGXN mirror + more! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | =head1 Class Interface | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | =head2 Constructor | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | =head3 C<new> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | my $indexer = PGXN::API::Indexer->new(verbose => $verbosity); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | Constructs and returns a new PGXN::API::Indexer object. There is only one | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | parameter, C<verbose>, an incremental integer specifying the level of | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | verbosity to use while indexing. Defaults to 0, which is as quiet as possible. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | =head1 Instance Interface | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | =head2 Instance Methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | =head3 C<update_root_json> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | Updates the F<index.json> file at the root of the document root, copying the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | mirror's F</index.json> to the API's F</index.json> and adding three | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | additional templates: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | =item C<source> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | URI for browsing the source of a distribution. Its value is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | /src/{dist}/{dist}-{version}/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | =item C<search> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | The URI for search/ Its value is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | /search/{in}/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | =item C<doc> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | The URI for a documentation file. It's format is copied form the "meta" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | template, with the trailing C<META.json> replaced with `{+doc}.html}`. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | `{+doc}` is the path to a documentation file (without a file extension) and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | may include slashes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | =head3 C<copy_from_mirror> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | $indexer->copy_from_mirror($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | Copies a file from the mirror to the document root. The path argument must be | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | specified using Unix semantics (that is, using slashes for directory | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | separators). Used by L<PGXN::API::Sync> to sync metadata files and stats. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | =head3 C<parse_from_mirror> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | $indexer->parse_from_mirror($path, $format); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | Uses Text::Markup to parse a file at C<$path> on the mirror, sanitizes it and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | generates a table of contents, and saves it to the document root with its | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | suffix changed to F<.html>. Pass an optional C<format> argument to force | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | Text::Markup to parse the document in that format. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | =head3 C<add_distribution> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | $indexer->add_distribution({ meta => $meta, zip => $zip }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | Adds a distribution to the index. This is the main method called to do all the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | work of indexing a distribution. The two required parameters are: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | =item C<meta> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | The metadata file loaded from a distribution F<META.json> file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | =item c<zip> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | An L<Archive::Zip> object loaded up with the distribution download file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | =head3 C<copy_files> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | $indexer->copy_files($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | Copies a distribution download and C<README> files from the mirror to the API | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | document root. The supported parameters are the same as those for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | C<add_distribution()>, by which this method is called internally. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | =head3 C<merge_distmeta> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | $indexer->copy_files($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | Merges the distribution metadata between the C<meta> file and the C<dist> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | file. These are the names of URI templates in the F</index.json> file. The | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | supported parameters are the same as those for C<add_distribution()>, by which | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | this method is called internally. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | Once the merge is complete, the two files will be identical, although the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | C<dist> file will only be updated if the new distribution's release status is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | "stable" (or if there are no stable distributions). In addition to the data | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | they provided via the mirror server, they will also have the following new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | keys: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | =item C<special_files> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | An array of the names of special files in the distribution. These include any | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | files which match the following regular expressions: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | =item C<qr{Change(?:s|Log)(?:[.][^.]+)?}i> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | =item C<qr{README(?:[.][^.]+)?}i> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | =item C<qr{LICENSE(?:[.][^.]+)?}i> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | =item C<qr{META[.]json}> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | =item C<qr{Makefile}> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | =item C<qr{MANIFEST}> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | =item C<docs> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | A hash (dictionary) listing the documentation files found in the distribution. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | These include a C<README> file and any files found under the F<doc> or F<docs> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | directory. The keys are paths to each document (without the file name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | extension) and the values are document titles. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | =item C<provides/$extension/doc> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | Each extension listed under C<provides> will get a new key, C<doc>, if there | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | is a document in the C<docs> hash with the same base name as the extension. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | This is on the assumption that an included extension will have for its | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | documentation a file with the same name (minus the file name extension) as the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | extension itself. The value will be the path to the document, the same as the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | key for the same document in the C<docs> hash. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | Getting all of this documentation information is handled via a call to | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | C<parse_docs()>, which of course also parses any docs it finds. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | And finally, this method updates all other "dist" files for previous versions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | of the distribution with the latest C<releases> information, so that they all | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | have a complete list of all releases of the distribution. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | =head3 C<find_docs> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | my @docs = $indexer->find_docs($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | Finds all the likely documentation files in the zip archive. A file is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | considered to contain documentation if one of the following is true: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | =item * | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | It is identified under the C<doc> key in the C<provides> hash of the metadata | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | and exists in the zip archive. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | =item * | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | It has an extension recognized by L<Text::Markup> and is not excluded by the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | C<no_index> key in the metadata. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | The list of files returned are relative to an unzipped archive root -- that | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | is, they do not include the top-level directory prefix. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | Used internally by C<parse_docs()> to determine what files to parse. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | =head3 C<parse_docs> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | $indexer->parse_docs($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | Searches the distribution download file for a C<README> and for documentation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | files in a F<doc> or F<docs> directory, parses them into HTML (using | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | L<Text::Markup>), and the runs them through L<XML::LibXML> to remove all | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | unsafe HTML, to generate a table of contents, and to save them as partial HTML | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | files. Their contents are also added to the "doc" full text index. Files | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | matching the rules under the C<no_index> key in the metadata (if any) will be | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | ignored. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | Returns a hash reference with information about the documentation, with the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | keys being paths to the documentation (without file name extensions) and the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | values being the titles of the documents. The supported parameters are the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | same as those for C<add_distribution()>; this method is called internally by | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | C<merge_distmeta()>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | =head3 C<update_extensions> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | $indexer->update_extensions($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | Iterates over the list of extensions under the C<provides> key in the metadata | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | and updates their respective metadata files (as specified by the "extension" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | URI template) and updates them with additional information. The supported | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | parameters are the same as those for C<add_distribution()>, by which this | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | method is called internally. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | The additional metadata added to the extension files is: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | =item C<$release_status/doc> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | The path to the documentation (without the file name extension) for the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | extension for the given release status. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | =item C<$release_status/abstract> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | The abstract for the latest release of the given release status. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | =item C<versions/$version/date> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | The date of a given release. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | The contents of the extension, including is name, abstract, distribution, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | distribution version, and doc path are added to the "extension" full text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | index. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | =head3 C<update_tags> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | $indexer->update_tags($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | Iterates over the list of tags under the C<tags> key in the metadata and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | updates their respective metadata files (as specified by the "tag" URI | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | template). The supported parameters are the same as those for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | C<add_distribution()>, by which this method is called internally. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | The data added to each tag metadata file is the list of releases copied from | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | the distribution metadata. A tag metadata file thus ends up with a complete | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | list of all distribution releases associated with the tag. The tag is then | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | added to the "tag" full text index. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | =head3 C<update_user> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | $indexer->update_user($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | Updates the metadata for the user specified under the C<user> key in the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | distribution metadata. The updated file is specified by the "user" URI | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | template. The supported parameters are the same as those for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | C<add_distribution()>, by which this method is called internally. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | The data added to each user metadata file is the list of releases copied from | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | the distribution metadata. A user metadata file thus ends up with a complete | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | list of all distribution releases made by the user. The user is then added to | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | the "user" full text index, where the name, nickname, email address, URI, and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | other metadata are indexed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | =head3 C<merge_user> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | $indexer->merge_user($nickname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | Pass in the nickname of a user file and JSON file for that user on the mirror | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | will be merged with the document index copy. If no document index copy exists, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | one will be created with an empty hash under the C<releases> key. Called by | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | L<PGXN::API::Sync> for each user file seen during the sync. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | =head3 C<finalize> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | $indexer->finalize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | Method to call when a sync completes. At the moment, all it does is call | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | C<update_user_lists()> and commit any remaining index data to the full text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | index. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | =head3 C<update_user_lists> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | $indexer->update_user_lists; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | Updates the user list files for any users seen in the distribution metadata | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | processed by C<merge_distmeta()>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | =head3 C<doc_root_file_for> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | my $doc_root_file = $indexer->doc_root_file_for($tmpl_name, $meta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | Returns the full path to a file in the API document root for the specified URI | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | template, and using the specified distribution metadata to populate the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | variable values in the template. Used internally to figure out what files | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | to write to. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | =head3 C<mirror_file_for> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | my $mirror_file = $indexer->mirror_file_for($tmpl_name, $meta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | Returns the full path to a file in local PGXN mirror directory for the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | specified URI template, and using the specified distribution metadata to | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | populate the variable values in the template. Used internally to figure out | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | what files to read from. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | =head3 C<indexer_for> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | my $ksi = $indexer->indexer_for($index_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | Returns a L<Lucy::Index::Indexer> object for updating named full text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | index. Used internally for updating the appropriate full text index when a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | distribution has been fully updated. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | =head2 Instance Accessors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | =head3 C<verbose> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | my $verbose = $indexer->verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | $indexer->verbose($verbose); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | Get or set an incremental verbosity. The higher the integer specified, the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | more verbose the indexing. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | =head3 C<to_index> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | push @{ $indexer->to_index->{ $index } } => $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | Stores a hash reference of array references of data to be added to full text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | indexes. As a distribution is merged and updated, data for adding to the full | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | text index is added to this hash. Once the updating and merging has completed | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | successfully, the data is read from this attribute and written to the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | appropriate full text indexes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | =head3 C<libxml> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | my $libxml = $indexer->libxml; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | Returns the L<XML::LibXML> object used for parsing and cleaning HTML documents. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | =head3 C<index_dir> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | my $index_dir = $indexer->index_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | Returns the path to the parent directory of all of the full-text indexes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | =head3 C<schemas> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | my $schema = $indexer->schemas->{$index_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | Returns a hash reference of L<Lucy::Plan::Schema> objects used to define | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | the structure of the full text indexes. The keys identify the indexes and the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | values are the corresponding L<Lucy::Plan::Schema> objects. The supported | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | indexes are: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | =item doc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | =item dist | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | =item extension | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | =item tag | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | =item user | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | =head1 Author | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | David E. Wheeler <david.wheeler@pgexperts.com> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | =head1 Copyright and License | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | Copyright (c) 2011-2025 David E. Wheeler. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | This module is free software; you can redistribute it and/or modify it under | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | the L<PostgreSQL License|http://www.opensource.org/licenses/postgresql>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | Permission to use, copy, modify, and distribute this software and its | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | documentation for any purpose, without fee, and without a written agreement is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | hereby granted, provided that the above copyright notice and this paragraph | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | and the following two paragraphs appear in all copies. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | In no event shall David E. Wheeler be liable to any party for direct, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | indirect, special, incidental, or consequential damages, including lost | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | profits, arising out of the use of this software and its documentation, even | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | if David E. Wheeler has been advised of the possibility of such damage. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | David E. Wheeler specifically disclaims any warranties, including, but not | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | limited to, the implied warranties of merchantability and fitness for a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | particular purpose. The software provided hereunder is on an "as is" basis, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | and David E. Wheeler has no obligations to provide maintenance, support, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | updates, enhancements, or modifications. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||