| 1 | |||||||||||||||||||||
| 2 | package SQL::Admin::Driver::Base::Parser; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 3 | our $VERSION = v0.5.0; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | ###################################################################### | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 3 | ▶ | use Parse::RecDescent; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 3 | our $AUTOLOAD; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 3 | my $parser_skip = '([ \t\r\n]*)|((--(.*)\n))*'; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | ###################################################################### | ||||||||||||||||||||
| 18 | ###################################################################### | ||||||||||||||||||||
| 19 | 2 | ▶ | sub new { # ; | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||
| 20 | 2 | my ($class, %param) = @_; | |||||||||||||||||||
| 21 | 2 | ▶ | my $grammar = $class->grammar || return; | ||||||||||||||||||
|
Condition50%1/2
$class->grammar || (return)
MC/DC0%0/1
$class->grammar || (return)
$class->grammar
Truth table50%1/2
A
A= $class->grammar
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 2 | $::RD_HINT = 1; | |||||||||||||||||||
| 24 | 2 | $Parse::RecDescent::skip = '([ \t\r\n]*)|((--(.*)\n))*'; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 2 | ▶ | bless { | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 27 | %param, | ||||||||||||||||||||
| 28 | parser => Parse::RecDescent->new ($grammar), | ||||||||||||||||||||
| 29 | }, ref $class || $class; | ||||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | ###################################################################### | ||||||||||||||||||||
| 34 | ###################################################################### | ||||||||||||||||||||
| 35 | 0 | ▶ | sub configure { # ; | ||||||||||||||||||
|
Subroutine
configure: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 36 | 0 | my ($self, $key, $value) = @_; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | $self->{$key} = $value if @_ == 3; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 0 | $self->{$key}; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | ###################################################################### | ||||||||||||||||||||
| 44 | ###################################################################### | ||||||||||||||||||||
| 45 | 0 | ▶ | sub load { # ; | ||||||||||||||||||
|
Subroutine
load: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 46 | 0 | my ($self) = @_; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | my $data = do { | |||||||||||||||||||
| 49 | 0 | local $/; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | join ('', $self->{file} ? (map { | ||||||||||||||||||||
| 52 | 0 | ▶ | open my $fh, '<', $_ or die "Unable open ${_}: $!\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | <$fh> | ||||||||||||||||||||
| 54 | 0 | ▶ | } @{ $self->{file} } ) : <>); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | $self->parse ($data); | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | ###################################################################### | ||||||||||||||||||||
| 62 | ###################################################################### | ||||||||||||||||||||
| 63 | 817 | ▶ | sub parser { # ; | ||||||||||||||||||
|
Subroutine
parser: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 64 | 817 | shift->{parser}; | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | ###################################################################### | ||||||||||||||||||||
| 69 | ###################################################################### | ||||||||||||||||||||
| 70 | 0 | ▶ | sub parse { # ; | ||||||||||||||||||
|
Subroutine
parse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 71 | 0 | my ($self, $data) = @_; | |||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 0 | $self->postprocess ($self->parser->parse_sql ($data)); | |||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | ###################################################################### | ||||||||||||||||||||
| 78 | ###################################################################### | ||||||||||||||||||||
| 79 | 0 | ▶ | sub postprocess { # ; | ||||||||||||||||||
|
Subroutine
postprocess: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 80 | 0 | shift; @_; | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | ###################################################################### | ||||||||||||||||||||
| 85 | ###################################################################### | ||||||||||||||||||||
| 86 | 0 | ▶ | sub DESTROY { # ; | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | ###################################################################### | ||||||||||||||||||||
| 91 | ###################################################################### | ||||||||||||||||||||
| 92 | 817 | ▶ | sub AUTOLOAD { # ; | ||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 93 | 817 | my ($self, @args) = @_; | |||||||||||||||||||
| 94 | 817 | my $name = substr $AUTOLOAD, 2 + rindex $AUTOLOAD, '::'; | |||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 817 | $self->parser->$name (@args); | |||||||||||||||||||
| 97 | } | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | ###################################################################### | ||||||||||||||||||||
| 101 | ###################################################################### | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | package SQL::Admin::Driver::Base::Parser; | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 3 | 1; | |||||||||||||||||||