blib/lib/App/Grok/Resource/u4x.pm

filter: Statementstmt 100% 34 / 34 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 90.9% 50 / 55 CC 7 SCAR 7.9
CC
7
Cov
89%
u4x_fetch
3.1
u4x_locate
3.1
u4x_index
2.1
CRAP 2.2
« blib/lib/App/Grok/Resource/File.pm ↑ Summary blib/lib/App/Grok/Parser/Pod6.pm »
1 package App::Grok::Resource::u4x;
2 40 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 40 $App::Grok::Resource::u4x::AUTHORITY = 'cpan:HINRIK';
4 }
5 {
6 40 $App::Grok::Resource::u4x::VERSION = '0.26';
7 }
8  
9 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 40 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 40 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 40 our @EXPORT_OK = qw(u4x_index u4x_fetch u4x_locate);
14 40 our %EXPORT_TAGS = ( ALL => [@EXPORT_OK] );
15  
16 40 my %index;
17  
18 12 ▶sub u4x_fetch {
Subroutine u4x_fetch: called CC=3 SCAR=11.4
Pod documented
19 12 my ($topic) = @_;
20 12 ▶ _build_index() if !%index;
Branch: 1 branch
BranchTrueFalseTotal
unless %index 12 0 12
21  
22 12 ▶ return $index{$topic} if defined $index{$topic};
Branch: 1 branch
BranchTrueFalseTotal
if defined $index{$topic} 0 12 12
23 12 return;
24 }
25  
26 2 ▶sub u4x_index {
Subroutine u4x_index: called CC=2 SCAR=7.2
Pod documented
27 2 ▶ _build_index() if !%index;
Branch: 1 branch
BranchTrueFalseTotal
unless %index 2 0 2
28 2 return keys %index;
29 }
30  
31 2 ▶sub u4x_locate {
Subroutine u4x_locate: called CC=3 SCAR=11.4
Pod documented
32 2 my ($topic) = @_;
33 2 ▶ _build_index() if !%index;
Branch: 1 branch
BranchTrueFalseTotal
unless %index 2 0 2
34 2 ▶ return __FILE__ if $index{$topic};
Branch: 1 branch
BranchTrueFalseTotal
if $index{$topic} 0 2 2
35 2 return;
36 }
37  
38 16 ▶sub _build_index {
Subroutine _build_index: called CC=2 SCAR=6.9
39 16 my $pod = do { local $/ = undef; scalar <DATA> };
40 16 my @entries = split /[\s\n]*(?==head3)/m, $pod;
41  
42 16 for my $entry (@entries) {
43 96 my ($name) = $entry =~ /=head3\s*(.*)$/m;
44 96 $index{$name} = $entry;
45 }
46 16 return;
47 }
48  
49 40 1;
50  
51 =encoding utf8
52  
53 =head1 NAME
54  
55 App::Grok::Resource::u4x - u4x resource for grok
56  
57 =head1 SYNOPSIS
58  
59 use strict;
60 use warnings;
61 use App::Grok::Resource::u4x qw<:ALL>;
62  
63 # a list of all terms
64 my @index = u4x_index();
65  
66 # documentation for a single term
67 my $pod = u4x_fetch('infix:<+>');
68  
69 =head1 DESCRIPTION
70  
71 This resource looks maintains an index of syntax items that can be looked up.
72 See L<http://svn.pugscode.org/pugs/docs/u4x/README>.
73  
74 =head1 FUNCTIONS
75  
76 =head2 C<u4x_index>
77  
78 Takes no arguments. Lists all syntax items.
79  
80 =head2 C<u4x_fetch>
81  
82 Takes an syntax item as an argument. Returns the documentation for it.
83  
84 =head2 C<u4x_locate>
85  
86 Takes a syntax item as an argument. Returns the file where it was found.
87  
88 =cut
89  
90 __DATA__
« blib/lib/App/Grok/Resource/File.pm ↑ Summary blib/lib/App/Grok/Parser/Pod6.pm »