line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zeal; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
16127
|
use 5.014000; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
6
|
1
|
|
|
1
|
|
4
|
use re '/s'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.000_003'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
513
|
use File::Spec::Functions qw/catfile/; |
|
1
|
|
|
|
|
680
|
|
|
1
|
|
|
|
|
100
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
338
|
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__ |