| 1 | package Finance::Bank::Bankwest::Parser::TransactionSearch; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: transaction search page parser | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | $Finance::Bank::Bankwest::Parser::TransactionSearch::VERSION = '1.2.8'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## no critic (RequireUseStrict, RequireUseWarnings, RequireEndWithOne) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use MooseX::Declare; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use HTTP::Response::Switch::Handler 1.000000; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | class Finance::Bank::Bankwest::Parser::TransactionSearch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | with HTTP::Response::Switch::Handler | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use Finance::Bank::Bankwest::Error::ExportFailed (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use Finance::Bank::Bankwest::Error::ExportFailed::UnknownReason (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use Web::Scraper qw{ scraper process }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 14 | ▶ | my $scraper = scraper { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | process '#headingBar', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 'heading' => 'TEXT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 14 | process '#_ctl0_valSummary ul li', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 'errors[]' => 'TEXT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 14 | process '#_ctl0_ContentMain_valAccount_custom1', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 'acct_style' => '@style'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | process '#_ctl0_ContentMain_dpFromDate_valCheck_custom1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 14 | ▶ | 'from_date_err' => sub { 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | process '#_ctl0_ContentMain_dpFromDate_valCheck_custom2', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 14 | ▶ | 'from_date_err' => sub { 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | process '#_ctl0_ContentMain_dpToDate_valCheck_custom1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 14 | ▶ | 'to_date_has_err' => sub { 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 14 | process '#_ctl0_ContentMain_valToDate', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 'tdate_style' => '@style'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 10 | ▶ | method handle { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=13 SCAR=26.1
Subroutine
handle: called CC=13 SCAR=26.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | my $scrape = $scraper->scrape($self->response); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | $self->decline if not $scrape->{'heading'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 10 | ▶ | or $scrape->{'heading'} !~ /^\s*Transaction\s+Search\s*$/x; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$scrape->{"heading"} and $scrape->{"heading"} =~ /^\s*Transaction\s+Search\s*$/x
$scrape->{"heading"} and $scrape->{"heading"} =~ /^\s*Transaction\s+Search\s*$/x
MC/DC50%1/2
$scrape->{"heading"} and $scrape->{"heading"} =~ /^\s*Transaction\s+Search\s*$/x
$scrape->{"heading"}
$scrape->{"heading"} =~ /^\s*Transaction\s+Search\s*$/x
MC/DC50%1/2
$scrape->{"heading"} and $scrape->{"heading"} =~ /^\s*Transaction\s+Search\s*$/x
$scrape->{"heading"}
$scrape->{"heading"} =~ /^\s*Transaction\s+Search\s*$/x
Truth table66%2/3
A and B
A= $scrape->{"heading"}B= $scrape->{"heading"} =~ /^\s*Transaction\s+Search\s*$/x
Truth table66%2/3
A and B
A= $scrape->{"heading"}B= $scrape->{"heading"} =~ /^\s*Transaction\s+Search\s*$/x
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | my %ef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $ef{'account'}++ if defined $scrape->{'acct_style'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 9 | ▶ | and index($scrape->{'acct_style'}, ';display:none;') < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
defined $scrape->{"acct_style"} and index($scrape->{"acct_style"}, ";display:none;") == -1
defined $scrape->{"acct_style"} and index($scrape->{"acct_style"}, ";display:none;") == -1
MC/DC50%1/2
defined $scrape->{"acct_style"} and index($scrape->{"acct_style"}, ";display:none;") == -1
defined $scrape->{"acct_style"}
index($scrape->{"acct_style"}, ";display:none;") == -1
MC/DC50%1/2
defined $scrape->{"acct_style"} and index($scrape->{"acct_style"}, ";display:none;") == -1
defined $scrape->{"acct_style"}
index($scrape->{"acct_style"}, ";display:none;") == -1
Truth table66%2/3
A and B
A= defined $scrape->{"acct_style"}B= index($scrape->{"acct_style"}, ";display:none;") == -1
Truth table66%2/3
A and B
A= defined $scrape->{"acct_style"}B= index($scrape->{"acct_style"}, ";display:none;") == -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 9 | ▶ | $ef{'from_date'}++ if $scrape->{'from_date_err'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | ▶ | $ef{'to_date'}++ if $scrape->{'to_date_has_err'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | $ef{'to_date'}++ if defined $scrape->{'tdate_style'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 9 | ▶ | and index($scrape->{'tdate_style'}, ';display:none;') < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
defined $scrape->{"tdate_style"} and index($scrape->{"tdate_style"}, ";display:none;") == -1
defined $scrape->{"tdate_style"} and index($scrape->{"tdate_style"}, ";display:none;") == -1
MC/DC50%1/2
defined $scrape->{"tdate_style"} and index($scrape->{"tdate_style"}, ";display:none;") == -1
defined $scrape->{"tdate_style"}
index($scrape->{"tdate_style"}, ";display:none;") == -1
MC/DC0%0/2
defined $scrape->{"tdate_style"} and index($scrape->{"tdate_style"}, ";display:none;") == -1
defined $scrape->{"tdate_style"}
index($scrape->{"tdate_style"}, ";display:none;") == -1
Truth table66%2/3
A and B
A= defined $scrape->{"tdate_style"}B= index($scrape->{"tdate_style"}, ";display:none;") == -1
Truth table33%1/3
A and B
A= defined $scrape->{"tdate_style"}B= index($scrape->{"tdate_style"}, ";display:none;") == -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 9 | ▶ | if ($scrape->{'errors'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 8 | s{ ^ \s+ }{}x for @{ $scrape->{'errors'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | ▶ | if ($scrape->{'errors'} or keys %ef) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$scrape->{"errors"} or keys %ef
$scrape->{"errors"} or keys %ef
MC/DC50%1/2
$scrape->{"errors"} or keys %ef
$scrape->{"errors"}
keys %ef
MC/DC50%1/2
$scrape->{"errors"} or keys %ef
$scrape->{"errors"}
keys %ef
Truth table66%2/3
A or B
A= $scrape->{"errors"}B= keys %ef
Truth table66%2/3
A or B
A= $scrape->{"errors"}B= keys %ef
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Finance::Bank::Bankwest::Error::ExportFailed->throw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | errors => $scrape->{'errors'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | params => [keys %ef], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # We have a transaction search page with no apparent errors. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # Not a problem if the caller is expecting it, but very bad | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # news otherwise--so throw an exception just in case. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | Finance::Bank::Bankwest::Error::ExportFailed::UnknownReason | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ->throw($self->response); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 10 | } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 10 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||