AzimuthAero/PriceCrawler.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 41 CC 5 SCAR 30.9
CC
5
Cov
0%
prepare_requests
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 22.0
1 package WWW::AzimuthAero::PriceCrawler;
2 $WWW::AzimuthAero::PriceCrawler::VERSION = '0.2';
3  
4 # ABSTRACT: Crawler for https://azimuth.aero/
5  
6 use parent 'WWW::AzimuthAero';
7 use feature 'say';
8  
9  
10 sub prepare_requests {
11 my ( $self, %params ) = @_;
12  
13 my $iata_map = $self->route_map->route_map_iata;
14  
15 my $n = 0;
16 if ( $params{verbose} ) {
17 say 'Cities total: ' . scalar keys %$iata_map;
18 for my $x ( values %$iata_map ) {
19 $n += scalar @$x;
20 }
21 say
22 'Amount of WWW::AzimuthAero::get_schedule_dates HTTP requests will be performed: '
23 . $n;
24 }
25  
26 my @get_requests;
27 while ( ( $from, $cities ) = each(%$iata_map) ) {
28 for my $to (@$cities) {
29 say "$n : get_schedule_dates : $from -> $to" if $params{verbose};
30 $n-- if $params{verbose};
31 my @dates = $self->get_schedule_dates( from => $from, to => $to );
32 for my $date (@dates) {
33 push @get_requests, { from => $from, to => $to, date => $date };
34 }
35 }
36 }
37  
38 if ( $params{verbose} ) {
39 say 'Amount of WWW::AzimuthAero::get HTTP requests will be performed: '
40 . scalar @get_requests;
41 say 'Total HTTP requests: ' . $n + scalar @get_requests;
42 }
43  
44 return @get_requests;
45  
46 }
47  
48 1;
49  
50 __END__
51  
52 =pod
53  
54 =encoding UTF-8
55  
56 =head1 NAME
57  
58 WWW::AzimuthAero::PriceCrawler - Crawler for https://azimuth.aero/
59  
60 =head1 VERSION
61  
62 version 0.2
63  
64 =head1 SYNOPSIS
65  
66 my $azo_price_crawler = WWW::AzimuthAero::PriceCrawler->new();
67 $azo_price_crawler->prepare_requests()
68  
69 =head1 DESCRIPTION
70  
71 Wrappper under L<WWW::AzimuthAero>
72  
73 =head1 new
74  
75 See L<WWW::AzimuthAero/new>
76  
77 =head1 prepare_requests
78  
79 Return arrray of hashes with params (from, to, date) for WWW::AzimuthAero::get method
80  
81 my @l = $azo_price_crawler->prepare_requests( max_date => '18.12.2019', verbose => 1 );
82  
83 In fact, combines L<WWW::AzimuthAero::RouteMap/route_map_iata> and L<WWW::AzimuthAero/get_schedule_dates>
84  
85 =head2 Params
86  
87 max_date - '%d.%m.%Y' format, if no specified will looks forward for 2 months, default max_date of L<WWW::AzimuthAero/get_schedule_dates>
88  
89 verbose - print amount of L<WWW::AzimuthAero/get_schedule_dates> requests and future amount of L<WWW::AzimuthAero/get> requests
90  
91 =head1 AUTHOR
92  
93 Pavel Serikov <pavelsr@cpan.org>
94  
95 =head1 COPYRIGHT AND LICENSE
96  
97 This software is copyright (c) 2019 by Pavel Serikov.
98  
99 This is free software; you can redistribute it and/or modify it under
100 the same terms as the Perl 5 programming language system itself.
101  
102 =cut