« App/lcpan/Cmd/rdeps_from_other_author.pm
↑ Summary
App/lcpan/Cmd/authors_by_mod_mention_count.pm »
| 1 | package App::lcpan::PodParser; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Log::ger; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use parent qw(Pod::Simple::Methody); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||
| 13 | 1 | our $DATE = '2023-09-26'; # DATE | |||||||||||||||||||||||||||
| 14 | 1 | our $DIST = 'App-lcpan'; # DIST | |||||||||||||||||||||||||||
| 15 | 1 | our $VERSION = '1.074'; # VERSION | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub handle_text { | ||||||||||||||||||||||||||
|
Subroutine
handle_text: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # to reduce false positive with regular words, in naked text we only look | ||||||||||||||||||||||||||||
| 21 | # for modules that have namespaces, e.g. 'Foo::Bar' and not top-level | ||||||||||||||||||||||||||||
| 22 | # modules like 'strict' or 'warnings'. we also don't look for scripts | ||||||||||||||||||||||||||||
| 23 | # because script names might be regular words or proper nouns too like 'yes' | ||||||||||||||||||||||||||||
| 24 | # or 'wikipedia'. | ||||||||||||||||||||||||||||
| 25 | 0 | ▶ | while ($_[0] =~ /\b([A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z0-9_]+)+)\b/g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | my ($module_id, $module_name); | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ($self->{module_ids}{$1}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # skip if mention target is in the same release | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | next if $self->{module_file_ids}{$1} == $self->{file_id}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | log_trace(" found a mention in naked text to known module: %s", $1); | |||||||||||||||||||||||||||
| 33 | 0 | $module_id = $self->{module_ids}{$1}; | |||||||||||||||||||||||||||
| 34 | } else { | ||||||||||||||||||||||||||||
| 35 | 0 | log_trace(" found a mention in naked text to unknown module: %s", $1); | |||||||||||||||||||||||||||
| 36 | 0 | $module_name = $1; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 0 | my $now = time(); | |||||||||||||||||||||||||||
| 39 | $self->{sth_ins_mention}->execute( | ||||||||||||||||||||||||||||
| 40 | 0 | $self->{content_id}, $self->{file_id}, $module_id, $module_name, undef, | |||||||||||||||||||||||||||
| 41 | $now,$now, | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub start_L { | ||||||||||||||||||||||||||
|
Subroutine
start_L: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | return unless $_[0]{type} eq 'pod' && $_[0]{to}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0]{"type"} eq "pod" and $_[0]{"to"}
MC/DC0%0/2
$_[0]{"type"} eq "pod" and $_[0]{"to"}
$_[0]{"type"} eq "pod"
$_[0]{"to"}
Truth table0%0/3
A and B
A= $_[0]{"type"} eq "pod"B= $_[0]{"to"}
| |||||||||||||||||||||||||||||
| 50 | 0 | my $to = "" . $_[0]{to}; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | my ($module_id, $module_name, $script_name); | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($self->{module_ids}{$to}) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # skip if mention target is in the same release | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | return if $self->{module_file_ids}{$to} == $self->{file_id}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | log_trace(" found a mention in POD link to known module: %s", $to); | |||||||||||||||||||||||||||
| 59 | 0 | $module_id = $self->{module_ids}{$to}; | |||||||||||||||||||||||||||
| 60 | } elsif ($to =~ $self->{scripts_re}) { | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | # skip if mention target is in the same release | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return if first { $_==$self->{file_id} } @{ $self->{script_file_ids}{$to} }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | log_trace(" found a mention in POD link to known script: %s", $to); | |||||||||||||||||||||||||||
| 66 | 0 | $script_name = $to; | |||||||||||||||||||||||||||
| 67 | } elsif ($to =~ /\A([A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z0-9_]+)*)\z/) { | ||||||||||||||||||||||||||||
| 68 | 0 | log_trace(" found a mention in POD link to unknown module: %s", $to); | |||||||||||||||||||||||||||
| 69 | 0 | $module_name = $to; | |||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||
| 71 | # name doesn't look like a module name, skip | ||||||||||||||||||||||||||||
| 72 | 0 | return; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 0 | my $now = time(); | |||||||||||||||||||||||||||
| 75 | $self->{sth_ins_mention}->execute( | ||||||||||||||||||||||||||||
| 76 | 0 | $self->{content_id}, $self->{file_id}, $module_id, $module_name, $script_name, | |||||||||||||||||||||||||||
| 77 | $now,$now, | ||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | 1; | |||||||||||||||||||||||||||
| 82 | # ABSTRACT: Pod parser for use in App::lcpan | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||