| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::NationalRail::LiveDepartureBoards; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
27855
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
28
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use SOAP::Lite |
|
7
|
1
|
|
|
1
|
|
396
|
proxy => 'http://www.livedepartureboards.co.uk/ldbws/ldb2.asmx'; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant { |
|
10
|
|
|
|
|
|
|
URI_PREFIX => 'http://thalesgroup.com/RTTI/2008-02-20/ldb/', |
|
11
|
|
|
|
|
|
|
}; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Net::NationalRail::LiveDepartureBoards - Live Departure Boards information |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.02 |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Provides an interface to the National Rail Enquiries Live Departure Boards |
|
29
|
|
|
|
|
|
|
SOAP API, as documented at http://www.livedepartureboards.co.uk/ldbws/. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Net::NationalRail::LiveDepartureBoards; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $ldb = Net::NationalRail::LiveDepartureBoards->new(); |
|
34
|
|
|
|
|
|
|
my $hashref = $ldb->departures(rows => 10, crs => 'RUG'); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Or filter by trains going to another place |
|
37
|
|
|
|
|
|
|
my $hashref = $ldb->departures(rows => 10, crs => 'RUG', filtercrs => 'SOU'); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Or get trains arriving from another place |
|
40
|
|
|
|
|
|
|
my $hashref = $ldb->departures(rows => 10, crs => 'SOU', |
|
41
|
|
|
|
|
|
|
filtercrs => 'RUG', filtertype => 'from'); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 METHODS |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 new |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { |
|
50
|
|
|
|
|
|
|
my $class = shift; |
|
51
|
|
|
|
|
|
|
my %args = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
bless \%args, $class; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 departures |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub departures { |
|
61
|
|
|
|
|
|
|
return _station_board_request('GetDepartureBoard', @_); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 arrivals |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub arrivals { |
|
69
|
|
|
|
|
|
|
return _station_board_request('GetArrivalBoard', @_); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 arrivals_and_departures |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub arrivals_and_departures { |
|
77
|
|
|
|
|
|
|
return _station_board_request('GetArrivalDepartureBoard', @_); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _station_board_request { |
|
81
|
|
|
|
|
|
|
my $method = shift; |
|
82
|
|
|
|
|
|
|
my $self = shift; |
|
83
|
|
|
|
|
|
|
my %arg = @_; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my @opt_args; |
|
86
|
|
|
|
|
|
|
if (exists($arg{filtercrs})) { |
|
87
|
|
|
|
|
|
|
push @opt_args, SOAP::Data->name(filterCrs => $arg{filtercrs}); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $type = (exists $arg{filtertype} ? $arg{filtertype} : 'to'); |
|
90
|
|
|
|
|
|
|
push @opt_args, SOAP::Data->name(filterType => $type); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $result = _soap_request( |
|
94
|
|
|
|
|
|
|
$method, |
|
95
|
|
|
|
|
|
|
URI_PREFIX . 'types', |
|
96
|
|
|
|
|
|
|
SOAP::Data->name(numRows => $arg{'rows'}), |
|
97
|
|
|
|
|
|
|
SOAP::Data->name(crs => $arg{'crs'}), |
|
98
|
|
|
|
|
|
|
@opt_args |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
if ($result->fault) { |
|
102
|
|
|
|
|
|
|
die join ', ', $result->faultcode, $result->faultstring; |
|
103
|
|
|
|
|
|
|
} else { |
|
104
|
|
|
|
|
|
|
return $result->result(); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _soap_request { |
|
109
|
|
|
|
|
|
|
my $method = shift; |
|
110
|
|
|
|
|
|
|
my $target_namespace = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
return SOAP::Lite |
|
113
|
|
|
|
|
|
|
->on_action(sub { URI_PREFIX . $method }) |
|
114
|
|
|
|
|
|
|
->call( SOAP::Data->name($method . 'Request')->attr( |
|
115
|
|
|
|
|
|
|
{xmlns => $target_namespace}), |
|
116
|
|
|
|
|
|
|
@_, |
|
117
|
|
|
|
|
|
|
); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Tim Retout, C<< >> |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 BUGS |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is version 0.02. The API is probably not stable yet. There are |
|
127
|
|
|
|
|
|
|
probably bugs. The module could break at any time at the whim of ATOC. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
131
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
132
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SUPPORT |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
perldoc Net::NationalRail::LiveDepartureBoards |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
You can also look for information at: |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * Search CPAN |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Copyright (C) 2009, 2010 Tim Retout, all rights reserved. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
169
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
L, L |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; # End of Net::NationalRail::LiveDepartureBoards |