line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zeal; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
16302
|
use 5.014000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
58
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
3
|
use re '/s'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
79
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.001001'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
485
|
use File::Spec::Functions qw/catfile/; |
|
1
|
|
|
|
|
660
|
|
|
1
|
|
|
|
|
71
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
315
|
use Zeal::Docset; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Zeal::Document; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
my ($class, $path) = @_; |
17
|
|
|
|
|
|
|
$path //= $ENV{ZEAL_PATH}; |
18
|
|
|
|
|
|
|
my $self = bless {sets => {}}, $class; |
19
|
|
|
|
|
|
|
if ($path) { |
20
|
|
|
|
|
|
|
$self->add($_) for split /:/, $path; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
$self |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub add { |
26
|
|
|
|
|
|
|
my ($self, $path) = @_; |
27
|
|
|
|
|
|
|
return unless -d $path; |
28
|
|
|
|
|
|
|
if ($path =~ /[.]docset$/) { |
29
|
|
|
|
|
|
|
my $ds = Zeal::Docset->new($path); |
30
|
|
|
|
|
|
|
$self->{sets}{$ds->family} //= []; |
31
|
|
|
|
|
|
|
push @{$self->{sets}{$ds->family}}, $ds; |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
my $dir; |
34
|
|
|
|
|
|
|
opendir $dir, $path; |
35
|
|
|
|
|
|
|
my @entries = grep { !/^[.]{1,2}$/ } readdir $dir; |
36
|
|
|
|
|
|
|
closedir $dir; |
37
|
|
|
|
|
|
|
$self->add(catfile $path, $_) for @entries |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub sets { |
42
|
|
|
|
|
|
|
my ($self, $family) = @_; |
43
|
|
|
|
|
|
|
return map { @$_ } values %{$self->{sets}} unless $family; |
44
|
|
|
|
|
|
|
die "No docsets in family '$family'\n" unless $self->{sets}{$family}; |
45
|
|
|
|
|
|
|
@{$self->{sets}{$family}} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub query { |
49
|
|
|
|
|
|
|
my ($self, $query, $family) = @_; |
50
|
|
|
|
|
|
|
($family, $query) = split /:/, $query, 2 if !$family && $query =~ /^\w+:[^:]/; |
51
|
|
|
|
|
|
|
my @res = map { $_->query($query) } $self->sets($family); |
52
|
|
|
|
|
|
|
wantarray ? @res : $res[0] |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
__END__ |