lib/Locale/Simple/Scraper/ParserShortcuts.pm

filter: Statementstmt 100% 48 / 48 Branchbran 100% 2 / 2 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 17 / 17 Podpod 0.0% 0 / 8 totaltotal 83.1% 69 / 83 CC 5 SCAR 4.6
CC
5
Cov
95%
warn_failure
3.1
named_token
3.0
BEGIN
1.0
CRAP 1.6
« lib/Locale/Simple/Scraper/Parser.pm ↑ Summary bin/locale_simple_scraper »
1 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Locale::Simple::Scraper::ParserShortcuts;
5 22 our $VERSION = '0.200';
6 # ABSTRACT: LSS::Parser methods that are generic shortcuts to P::MGC functionality
7  
8 22 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 has debug_sub => (
11 is => 'ro',
12 112 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
13 2993 ▶ sub { shift, warn "- " . sprintf shift() . "\n", @_ }
Subroutine __ANON__: called CC=1 SCAR=0.0
14 112 }
15 22 );
16  
17 2993 ▶sub debug { shift->debug_sub->( @_ ) }
Subroutine debug: called CC=1 SCAR=0.0
Pod undocumented
18  
19 880 ▶sub collect_from {
Subroutine collect_from: called CC=1 SCAR=0.0
Pod undocumented
20 880 my ( $self, $methods ) = @_;
21 880 return map { $self->$_ } @{$methods};
22 }
23  
24 1539 ▶sub named_token {
Subroutine named_token: called CC=3 SCAR=11.0
Pod undocumented
25 1539 my ( $self, $name, $type ) = @_;
26 1539 ▶ $type ||= "constant_string";
Condition50%1/2
$type ||= "constant_string"
l!l
01539
MC/DC0%0/1
$type ||= "constant_string"
$type
Truth table50%1/2
A
A= $type
Aresult
11
00
27 1539 ▶ my $token = $self->maybe( sub { $self->$type } );
Subroutine __ANON__: called CC=1 SCAR=0.0
28 1539 ▶ $self->fail( "Expected $name" ) if !defined $token;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $token 141 1398 1539
29 1398 return $token;
30 }
31  
32 301 ▶sub warn_failure {
Subroutine warn_failure: called CC=3 SCAR=11.2
Pod undocumented
33 301 my ( $self, $f ) = @_;
34 301 ▶ my ( $linenum, $col, $text ) = $self->where( $f->{pos} || $self->pos );
Condition33%1/3
$f->{'pos'} || $self->pos
l!l&&r!l&&!r
30100
MC/DC0%0/2
$f->{'pos'} || $self->pos
$f->{'pos'} $self->pos
Truth table33%1/3
A || B
A= $f->{'pos'}B= $self->pos
ABresult
1X1
011
000
35 301 my $indent = substr( $text, 0, $col );
36 301 $_ =~ s/\t/ /g for $text, $indent;
37 301 $indent =~ s/./-/g; # blank out all the non-whitespace
38 301 $text =~ s/\%/%%/g;
39 301 $self->debug( "$f->{message}:\n |$text\n |$indent^" );
40 301 return;
41 }
42  
43 1948 ▶sub c_any_of {
Subroutine c_any_of: called CC=1 SCAR=0.0
Pod undocumented
44 1948 my ( $self, @args ) = @_;
45 4792 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
46 4792 $self->any_of( @args );
47 1948 };
48 }
49  
50 1509 ▶sub c_expect {
Subroutine c_expect: called CC=1 SCAR=0.0
Pod undocumented
51 1509 my ( $self, @args ) = @_;
52 4436 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
53 4436 $self->expect( @args );
54 1509 };
55 }
56  
57 3539 ▶sub c_with_ws {
Subroutine c_with_ws: called CC=1 SCAR=0.0
Pod undocumented
58 3539 my ( $self, $code, @args ) = @_;
59 1785 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
60 1785 local $self->{patterns}{ws} = qr//;
61 1785 local $self->{patterns}{_skip} = qr//;
62 1785 return $self->$code( @args );
63 3539 };
64 }
65  
66 2524 ▶sub with_ws {
Subroutine with_ws: called CC=1 SCAR=0.0
Pod undocumented
67 2524 my ( $self, $code, @args ) = @_;
68 2524 local $self->{patterns}{ws} = qr//;
69 2524 local $self->{patterns}{_skip} = qr//;
70 2524 return $self->$code( @args );
71 }
72  
73 22 1;
74  
75 __END__
« lib/Locale/Simple/Scraper/Parser.pm ↑ Summary bin/locale_simple_scraper »