lpp 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +124 -0
- data/Rakefile +10 -0
- data/lib/lpp.rb +70 -0
- data/lib/lpp/version.rb +3 -0
- data/lpp.gemspec +28 -0
- data/test/response.html +99 -0
- data/test/response_not_found.html +16 -0
- data/test/test_helper.rb +1 -0
- data/test/test_lpp.rb +592 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: cb1739cd18e257f19749f3fce7a91c028041136e
|
4
|
+
data.tar.gz: 1c809827fbd3f903282a2bfad738fef1932e4eeb
|
5
|
+
!binary "U0hBNTEy":
|
6
|
+
metadata.gz: 6d123acc7935cf2ad5c7b5443161fbe1a949c38ff5a6c9522c1096d26742b8e8b1e0ae1ff2f5ae9baac015672c716e10f3cdde31e3861e998a89b1e29f44cedb
|
7
|
+
data.tar.gz: b6d619e0e866f1f88bd518c28d72fa35edfc0403ee5842d7837f468ef3f26c5132ec7b32788c27b0d04cf71989dc2ef0435674c28f36dadf228192277579ee93
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jure Triglav
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# Lpp
|
2
|
+
|
3
|
+
Lpp is a simple gem for getting bus arrivals in Ljubljana. It uses the wbus.talktrack.com website.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'lpp'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install lpp
|
18
|
+
|
19
|
+
## Usage examples
|
20
|
+
|
21
|
+
If you query Lpp to get arrivals from the main bus station in Ljubljana, Bavarski dvor:
|
22
|
+
Lpp.arrivals('bavarski')
|
23
|
+
|
24
|
+
You'll be returned a hash similar to this:
|
25
|
+
{"600012"=>
|
26
|
+
{:name=>"BAVARSKI DVOR",
|
27
|
+
:buses=>
|
28
|
+
{"1N BROD - BAVARSKI DVOR"=>
|
29
|
+
{:route=>"BROD - BAVARSKI DVOR",
|
30
|
+
:bus_number=>"1N",
|
31
|
+
:arrivals=>
|
32
|
+
[{:time=>"02:59", :easy=>false},
|
33
|
+
{:time=>"03:24", :easy=>false},
|
34
|
+
{:time=>"04:05", :easy=>false}]},
|
35
|
+
"3 LITOSTROJ - RUDNIK"=>
|
36
|
+
{:route=>"LITOSTROJ - RUDNIK",
|
37
|
+
:bus_number=>"3",
|
38
|
+
:arrivals=>[{:time=>"21:01", :easy=>false}]},
|
39
|
+
"3L BAVARSKI DVOR - TOVARNA LEK"=>
|
40
|
+
{:route=>"BAVARSKI DVOR - TOVARNA LEK",
|
41
|
+
:bus_number=>"3L",
|
42
|
+
:arrivals=>[{:time=>"21:25", :easy=>false}]},
|
43
|
+
"3N KOFLJICA - BAVARSKI DVOR"=>
|
44
|
+
{:route=>"KOFLJICA - BAVARSKI DVOR",
|
45
|
+
:bus_number=>"3N",
|
46
|
+
:arrivals=>[{:time=>"21:37", :easy=>false}]}}},
|
47
|
+
"600011"=>
|
48
|
+
{:name=>"BAVARSKI DVOR",
|
49
|
+
:buses=>
|
50
|
+
{"1N VIMARJE - BAVARSKI DVOR"=>
|
51
|
+
{:route=>"VIMARJE - BAVARSKI DVOR",
|
52
|
+
:bus_number=>"1N",
|
53
|
+
:arrivals=>[{:time=>"22:55", :easy=>false}]},
|
54
|
+
"2 NOVE JARE - ZELENA JAMA"=>
|
55
|
+
{:route=>"NOVE JARE - ZELENA JAMA",
|
56
|
+
:bus_number=>"2",
|
57
|
+
:arrivals=>
|
58
|
+
[{:time=>"21:30", :easy=>true},
|
59
|
+
{:time=>"21:47", :easy=>false},
|
60
|
+
{:time=>"21:58", :easy=>false}]}}}}
|
61
|
+
|
62
|
+
You can also get arrivals only for a specific bus number:
|
63
|
+
Lpp.arrivals_for_bus('bavarski', 6)
|
64
|
+
|
65
|
+
And you'll get only the arrivals that match bus number 6 (6, 6B, etc.)
|
66
|
+
{"600012"=>
|
67
|
+
{:name=>"BAVARSKI DVOR",
|
68
|
+
:buses=>
|
69
|
+
{"6 ČRNUČE - DOLGI MOST"=>
|
70
|
+
{:route=>"ČRNUČE - DOLGI MOST",
|
71
|
+
:bus_number=>"6",
|
72
|
+
:arrivals=>
|
73
|
+
[{:time=>"21:25", :easy=>true},
|
74
|
+
{:time=>"21:48", :easy=>false},
|
75
|
+
{:time=>"22:00", :easy=>false}]},
|
76
|
+
"6 ČRNUČE - GARAŽA"=>
|
77
|
+
{:route=>"ČRNUČE - GARAŽA",
|
78
|
+
:bus_number=>"6",
|
79
|
+
:arrivals=>[{:time=>"00:53", :easy=>false}]},
|
80
|
+
"6B ČRNUČE - NOTRANJE GORICE"=>
|
81
|
+
{:route=>"ČRNUČE - NOTRANJE GORICE",
|
82
|
+
:bus_number=>"6B",
|
83
|
+
:arrivals=>
|
84
|
+
[{:time=>"21:41", :easy=>false},
|
85
|
+
{:time=>"22:28", :easy=>true},
|
86
|
+
{:time=>"04:47", :easy=>false}]}}},
|
87
|
+
"600011"=>
|
88
|
+
{:name=>"BAVARSKI DVOR",
|
89
|
+
:buses=>
|
90
|
+
{"6B NOTRANJE GORICE - GARAŽA"=>
|
91
|
+
{:route=>"NOTRANJE GORICE - GARAŽA",
|
92
|
+
:bus_number=>"6B",
|
93
|
+
:arrivals=>[{:time=>"23:30", :easy=>true}]},
|
94
|
+
"6 DOLGI MOST - ČRNUČE"=>
|
95
|
+
{:route=>"DOLGI MOST - ČRNUČE",
|
96
|
+
:bus_number=>"6",
|
97
|
+
:arrivals=>
|
98
|
+
[{:time=>"21:45", :easy=>true},
|
99
|
+
{:time=>"22:16", :easy=>false},
|
100
|
+
{:time=>"23:40", :easy=>false}]},
|
101
|
+
"6 DOLGI MOST - GARAŽA"=>
|
102
|
+
{:route=>"DOLGI MOST - GARAŽA",
|
103
|
+
:bus_number=>"6",
|
104
|
+
:arrivals=>
|
105
|
+
[{:time=>"22:44", :easy=>false},
|
106
|
+
{:time=>"00:52", :easy=>false},
|
107
|
+
{:time=>"09:24", :easy=>false}]},
|
108
|
+
"6B NOTRANJE GORICE - ČRNUČE"=>
|
109
|
+
{:route=>"NOTRANJE GORICE - ČRNUČE",
|
110
|
+
:bus_number=>"6B",
|
111
|
+
:arrivals=>
|
112
|
+
[{:time=>"21:28", :easy=>false},
|
113
|
+
{:time=>"21:58", :easy=>true},
|
114
|
+
{:time=>"22:31", :easy=>true}]}}}}
|
115
|
+
|
116
|
+
That's it.
|
117
|
+
|
118
|
+
## Contributing
|
119
|
+
|
120
|
+
1. Fork it
|
121
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
122
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
123
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
124
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/lpp.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require "lpp/version"
|
4
|
+
require 'net/http'
|
5
|
+
require 'nokogiri'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
module Lpp
|
10
|
+
REGEX = /NAPOVED PRIHODOV ZA (.+?) \((.+?)\)(.+?)(?:NAPOVED PRIHODOV ZA (.+?) \((.+?)\)(.+?))?Napovedi/m
|
11
|
+
|
12
|
+
def self.arrivals(station)
|
13
|
+
uri = URI('http://wbus.talktrack.com/wap.aspx')
|
14
|
+
res = Net::HTTP.post_form(uri,
|
15
|
+
'__EVENTTARGET' => '',
|
16
|
+
'__EVENTARGUMENT' => '',
|
17
|
+
'tb_postaja' => station,
|
18
|
+
'b_send' => 'Prika%C5%BEi')
|
19
|
+
|
20
|
+
text = Nokogiri::HTML(res.body).text
|
21
|
+
|
22
|
+
raise 'Station not found' if /Postaje s tem imenom nismo našli/.match(text)
|
23
|
+
|
24
|
+
matches = REGEX.match(text)
|
25
|
+
result = Hash.new
|
26
|
+
|
27
|
+
result[matches[2]] = {name: matches[1], buses: parse(matches[3])}
|
28
|
+
|
29
|
+
# Twice if there are two statons
|
30
|
+
if matches[4]
|
31
|
+
result[matches[5]] = {name: matches[4], buses: parse(matches[6])}
|
32
|
+
end
|
33
|
+
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.arrivals_for_bus(station, bus)
|
38
|
+
arrivals = arrivals(station)
|
39
|
+
result = Hash.new
|
40
|
+
arrivals.each do |station_key, station_value|
|
41
|
+
buses = station_value[:buses].select do |bus_entry|
|
42
|
+
bus_entry =~ /^#{bus}/
|
43
|
+
end
|
44
|
+
if !buses.empty?
|
45
|
+
result[station_key] = {name: station_value[:name], buses: buses}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
result
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.parse(buses)
|
52
|
+
result = Hash.new
|
53
|
+
buses.strip.split("\r\n").each do |bus|
|
54
|
+
matches = /(\d+)(?:\s+(.))? (.*?)\:(?:\s(n))? (\d+\:\d+)(?:,(?:\s(n))? (\d+\:\d+))?(?:,(?:\s(n))? (\d+\:\d+))?/.match(bus)
|
55
|
+
if matches
|
56
|
+
times = ([matches[5]] + [matches[7]] + [matches[9]]).compact
|
57
|
+
easy = ([matches[4]] + [matches[6]] + [matches[8]])
|
58
|
+
bus_number = matches[1]+matches[2].to_s
|
59
|
+
result[bus_number + " " + matches[3]] = {
|
60
|
+
route: matches[3],
|
61
|
+
bus_number: bus_number,
|
62
|
+
arrivals: times.each_with_index.map do |time, index|
|
63
|
+
{time: time, easy: easy[index] == 'n'}
|
64
|
+
end
|
65
|
+
}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
result
|
69
|
+
end
|
70
|
+
end
|
data/lib/lpp/version.rb
ADDED
data/lpp.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lpp/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lpp"
|
8
|
+
spec.version = Lpp::VERSION
|
9
|
+
spec.authors = ["Jure Triglav"]
|
10
|
+
spec.email = ["juretriglav@gmail.com"]
|
11
|
+
spec.description = %q{LPP is a simple gem for getting bus arrivals in Ljubljana. It uses the wbus.talktrack.com website.}
|
12
|
+
spec.summary = %q{Ljubljana bus arrivals gem}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "pry"
|
23
|
+
# Tests
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "webmock"
|
26
|
+
|
27
|
+
spec.add_dependency "nokogiri", "~> 1.5"
|
28
|
+
end
|
data/test/response.html
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
<html><body>
|
2
|
+
<form id="Form1" name="Form1" method="post" action="wap.aspx?__ufps=369864">
|
3
|
+
<input type="hidden" name="__EVENTTARGET" value="">
|
4
|
+
<input type="hidden" name="__EVENTARGUMENT" value="">
|
5
|
+
<script language=javascript><!--
|
6
|
+
function __doPostBack(target, argument){
|
7
|
+
var theform = document.Form1
|
8
|
+
theform.__EVENTTARGET.value = target
|
9
|
+
theform.__EVENTARGUMENT.value = argument
|
10
|
+
theform.submit()
|
11
|
+
}
|
12
|
+
// -->
|
13
|
+
</script>
|
14
|
+
NAPOVED PRIHODOV ZA BAVARSKI DVOR (600012)<br>
|
15
|
+
1 N BROD - BAVARSKI DVOR: 02:59, 03:24, 04:05<br>
|
16
|
+
1 N BAVARSKI DVOR - BROD: 23:40, 00:20, 02:50<br>
|
17
|
+
1 N BAVARSKI DVOR - VIŽMARJE: 04:50<br>
|
18
|
+
1 N MESTNI LOG - BAVARSKI DVOR - GAMELJNE: 22:28, 22:58<br>
|
19
|
+
1 N GAMELJNE - BAVARSKI DVOR: 23:34, 00:14<br>
|
20
|
+
2 ZELENA JAMA - GARAŽA: n 00:42<br>
|
21
|
+
2 ZELENA JAMA - NOVE JARŠE: n 21:28, n 21:44, 21:59<br>
|
22
|
+
3 L TOVARNA LEK - BAVARSKI DVOR: 22:16<br>
|
23
|
+
3 N BAVARSKI DVOR - RUDNIK: 21:40, n 22:00, 22:20<br>
|
24
|
+
3 N BAVARSKI DVOR - ŠKOFLJICA: 04:50, 21:20<br>
|
25
|
+
3 LITOSTROJ - RUDNIK: 21:01<br>
|
26
|
+
3 L BAVARSKI DVOR - TOVARNA LEK: 21:25<br>
|
27
|
+
3 N ŠKOFLJICA - BAVARSKI DVOR: 21:37<br>
|
28
|
+
3 G BEŽIGRAD - GROSUPLJE: 21:35, 22:35, 23:44<br>
|
29
|
+
5 N ŠTEPANJSKO NAS. - PODUTIK: 21:30, 22:00, n 22:29<br>
|
30
|
+
6 ČRNUČE - DOLGI MOST: n 21:25, 21:48, 22:00<br>
|
31
|
+
6 ČRNUČE - GARAŽA: 00:53<br>
|
32
|
+
6 B ČRNUČE - NOTRANJE GORICE: 21:41, n 22:28, 04:47<br>
|
33
|
+
7 NOVE JARŠE - PRŽAN: n 21:23, 21:43, 05:13<br>
|
34
|
+
7 NOVE JARŠE - GARAŽA: n 22:38, 23:00, 08:22<br>
|
35
|
+
7 L LETALIŠKA - PRŽAN: 22:04, n 22:28, 05:55<br>
|
36
|
+
8 BRNČIČEVA - GAMELJNE: 21:40, n 22:00, 05:18<br>
|
37
|
+
8 BRNČIČEVA - GARAŽA: 22:22, n 22:42<br>
|
38
|
+
9 ŠTEPANJSKO NAS. - GARAŽA: 22:44, 23:02, 11:16<br>
|
39
|
+
9 ŠTEPANJSKO NAS. - TRNOVO: 21:30, 21:47, n 22:09<br>
|
40
|
+
11 BEŽIGRAD - ZALOG: 21:44, n 22:19, 22:59<br>
|
41
|
+
11 JEŽICA - ZALOG: 05:06, 05:08, 05:24<br>
|
42
|
+
14 SAVLJE - VRHOVCI: n 21:43, 22:04, 22:29<br>
|
43
|
+
14 B SAVLJE - BOKALCE: 05:28, 05:55, 06:07<br>
|
44
|
+
14 SAVLJE - GARAŽA: n 22:34, n 22:58, 09:23<br>
|
45
|
+
19 I TOMAČEVO - IG: 10:48<br>
|
46
|
+
19 I TOMAČEVO - GARAŽA: 08:03, 08:28, 08:53<br>
|
47
|
+
19 B TOMAČEVO - JEZERO: n 21:58, n 22:44, 04:34<br>
|
48
|
+
19 I TOMAČEVO - IŠKA VAS: 21:38, 22:18, 22:57<br>
|
49
|
+
20 NOVE STOŽICE - GARAŽA: 22:52<br>
|
50
|
+
20 NOVE STOŽICE - FUŽINE: 21:34, n 21:54, n 22:13<br>
|
51
|
+
23 KOLODVOR - ZOO: 09:02, 10:02, 12:02<br>
|
52
|
+
25 ZADOBROVA - MEDVODE: n 21:36, 22:36, 05:04<br>
|
53
|
+
25 ZADOBROVA - GARAŽA: n 23:34<br>
|
54
|
+
27 LETALIŠKA - GARAŽA: n 22:28, 22:48, 00:15<br>
|
55
|
+
27 LETALIŠKA - BTC - NS RUDNIK: n 21:28, 21:48, 22:08<br>
|
56
|
+
27 B LETALIŠKA - BTC - BLEIWEISOVA: 23:23<br>
|
57
|
+
51 LJUBLJANA-POLHOV GRADEC: 22:46, 05:36, 06:27<br>
|
58
|
+
56 LJUBLJANA-ŠENTJOŠT: 22:36, 05:21, 06:41<br>
|
59
|
+
NAPOVED PRIHODOV ZA BAVARSKI DVOR (600011)<br>
|
60
|
+
1 N VIŽMARJE - BAVARSKI DVOR: 22:55<br>
|
61
|
+
2 NOVE JARŠE - ZELENA JAMA: n 21:30, 21:47, 21:58<br>
|
62
|
+
2 NOVE JARŠE - GARAŽA: 00:31, n 01:06<br>
|
63
|
+
3 G GROSUPLJE - BEŽIGRAD : 22:24, 23:25, 05:04<br>
|
64
|
+
5 N PODUTIK - ŠTEPANJSKO NAS.: n 21:32, 21:59, 22:29<br>
|
65
|
+
6 B NOTRANJE GORICE - GARAŽA: n 23:30<br>
|
66
|
+
6 DOLGI MOST - ČRNUČE: n 21:45, 22:16, 23:40<br>
|
67
|
+
6 DOLGI MOST - GARAŽA: 22:44, 00:52, 09:24<br>
|
68
|
+
6 B NOTRANJE GORICE - ČRNUČE: 21:28, n 21:58, n 22:31<br>
|
69
|
+
7 L PRŽAN - LETALIŠKA: 21:24, n 21:45, 05:14<br>
|
70
|
+
7 PRŽAN - NOVE JARŠE: n 22:04, 22:28, 07:41<br>
|
71
|
+
8 GAMELJNE - BRNČIČEVA: 21:38, n 22:01, 05:27<br>
|
72
|
+
9 TRNOVO - GARAŽA: n 22:33, n 22:53<br>
|
73
|
+
9 TRNOVO - ŠTEPANJSKO NAS.: n 21:27, n 21:49, 22:09<br>
|
74
|
+
11 ZALOG - GARAŽA: n 00:40, 01:20<br>
|
75
|
+
11 ZALOG - JEŽICA: 05:29, 05:44, 05:57<br>
|
76
|
+
11 ZALOG - BEŽIGRAD: n 21:47, n 22:00, 22:20<br>
|
77
|
+
13 SOSTRO - GARAŽA: 21:31, n 22:29, n 23:19<br>
|
78
|
+
13 SOSTRO - CENTER STOŽICE: n 21:26, n 22:01, 05:16<br>
|
79
|
+
14 VRHOVCI - SAVLJE: n 22:29, 05:15, 05:29<br>
|
80
|
+
14 VRHOVCI - GARAŽA: 21:43, 22:36, 23:01<br>
|
81
|
+
14 B BOKALCE - SAVLJE: 21:44, n 22:04, 05:44<br>
|
82
|
+
19 IG AP - GARAŽA: 08:21<br>
|
83
|
+
19 B JEZERO - GARAŽA: n 22:59, 23:34, n 23:39<br>
|
84
|
+
19 B JEZERO - TOMAČEVO: 21:42, 22:26, 05:21<br>
|
85
|
+
19 I IŠKA VAS - TOMAČEVO: n 22:08, 05:12, 05:44<br>
|
86
|
+
19 I IŠKA VAS - GARAŽA: 22:41, 23:21, 23:56<br>
|
87
|
+
20 FUŽINE - NOVE STOŽICE: n 21:34, n 21:56, n 22:16<br>
|
88
|
+
20 FUŽINE - GARAŽA: n 22:58, n 23:16<br>
|
89
|
+
23 ZOO - KOLODVOR: 10:30, 12:30, 16:31<br>
|
90
|
+
25 MEDVODE - ZADOBROVA: 21:35, n 22:49, 05:28<br>
|
91
|
+
27 NS RUDNIK - BTC - LETALIŠKA: 21:24, n 21:45, 22:05<br>
|
92
|
+
27 NS RUDNIK - GARAŽA: 22:43, 17:54<br>
|
93
|
+
27 B BLEIWEISOVA - BTC - LETALIŠKA: 23:40<br>
|
94
|
+
51 POLHOV GRADEC-LJUBLJANA: 21:33, 05:31, 06:19<br>
|
95
|
+
56 ŠENTJOŠT-LJUBLJANA: 22:06, 05:15, 06:26<br>
|
96
|
+
Napovedi so bile izračunane ob 21:23.<br>
|
97
|
+
Časi, označeni s črko n , pomenijo prihode nizkopodnih avtobusov, na katere je lažje vstopiti.<br>
|
98
|
+
<a href="wap.aspx?culture=sl-SI">Nazaj</a><br>
|
99
|
+
</form></body></html>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<html><body>
|
2
|
+
<form id="Form1" name="Form1" method="post" action="wap.aspx?__ufps=712679">
|
3
|
+
<input type="hidden" name="__EVENTTARGET" value="">
|
4
|
+
<input type="hidden" name="__EVENTARGUMENT" value="">
|
5
|
+
<script language=javascript><!--
|
6
|
+
function __doPostBack(target, argument){
|
7
|
+
var theform = document.Form1
|
8
|
+
theform.__EVENTTARGET.value = target
|
9
|
+
theform.__EVENTARGUMENT.value = argument
|
10
|
+
theform.submit()
|
11
|
+
}
|
12
|
+
// -->
|
13
|
+
</script>
|
14
|
+
Postaje s tem imenom nismo našli, poizkusite znova!<br>
|
15
|
+
<a href="wap.aspx?culture=sl-SI">Nazaj</a><br>
|
16
|
+
</form></body></html>
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'webmock/test_unit'
|
data/test/test_lpp.rb
ADDED
@@ -0,0 +1,592 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'lpp'
|
5
|
+
require 'test_helper'
|
6
|
+
|
7
|
+
class LppTest < Test::Unit::TestCase
|
8
|
+
def test_parsing
|
9
|
+
response = File.read(File.join(File.dirname(__FILE__), 'response.html'))
|
10
|
+
stub_request(:any, /wbus.talktrack.com\/.*/).
|
11
|
+
to_return(:body => response, :status => 200, :headers => { 'Content-Length' => response.length } )
|
12
|
+
|
13
|
+
arrivals = Lpp.arrivals('bavarski')
|
14
|
+
|
15
|
+
result_hash = {"600012"=>
|
16
|
+
{:name=>"BAVARSKI DVOR",
|
17
|
+
:buses=>
|
18
|
+
{"1N BROD - BAVARSKI DVOR"=>
|
19
|
+
{:route=>"BROD - BAVARSKI DVOR",
|
20
|
+
:bus_number=>"1N",
|
21
|
+
:arrivals=>
|
22
|
+
[{:time=>"02:59", :easy=>false},
|
23
|
+
{:time=>"03:24", :easy=>false},
|
24
|
+
{:time=>"04:05", :easy=>false}]},
|
25
|
+
"1N BAVARSKI DVOR - BROD"=>
|
26
|
+
{:route=>"BAVARSKI DVOR - BROD",
|
27
|
+
:bus_number=>"1N",
|
28
|
+
:arrivals=>
|
29
|
+
[{:time=>"23:40", :easy=>false},
|
30
|
+
{:time=>"00:20", :easy=>false},
|
31
|
+
{:time=>"02:50", :easy=>false}]},
|
32
|
+
"1N BAVARSKI DVOR - VIŽMARJE"=>
|
33
|
+
{:route=>"BAVARSKI DVOR - VIŽMARJE",
|
34
|
+
:bus_number=>"1N",
|
35
|
+
:arrivals=>[{:time=>"04:50", :easy=>false}]},
|
36
|
+
"1N MESTNI LOG - BAVARSKI DVOR - GAMELJNE"=>
|
37
|
+
{:route=>"MESTNI LOG - BAVARSKI DVOR - GAMELJNE",
|
38
|
+
:bus_number=>"1N",
|
39
|
+
:arrivals=>
|
40
|
+
[{:time=>"22:28", :easy=>false}, {:time=>"22:58", :easy=>false}]},
|
41
|
+
"1N GAMELJNE - BAVARSKI DVOR"=>
|
42
|
+
{:route=>"GAMELJNE - BAVARSKI DVOR",
|
43
|
+
:bus_number=>"1N",
|
44
|
+
:arrivals=>
|
45
|
+
[{:time=>"23:34", :easy=>false}, {:time=>"00:14", :easy=>false}]},
|
46
|
+
"2 ZELENA JAMA - GARAŽA"=>
|
47
|
+
{:route=>"ZELENA JAMA - GARAŽA",
|
48
|
+
:bus_number=>"2",
|
49
|
+
:arrivals=>[{:time=>"00:42", :easy=>true}]},
|
50
|
+
"2 ZELENA JAMA - NOVE JARŠE"=>
|
51
|
+
{:route=>"ZELENA JAMA - NOVE JARŠE",
|
52
|
+
:bus_number=>"2",
|
53
|
+
:arrivals=>
|
54
|
+
[{:time=>"21:28", :easy=>true},
|
55
|
+
{:time=>"21:44", :easy=>true},
|
56
|
+
{:time=>"21:59", :easy=>false}]},
|
57
|
+
"3L TOVARNA LEK - BAVARSKI DVOR"=>
|
58
|
+
{:route=>"TOVARNA LEK - BAVARSKI DVOR",
|
59
|
+
:bus_number=>"3L",
|
60
|
+
:arrivals=>[{:time=>"22:16", :easy=>false}]},
|
61
|
+
"3N BAVARSKI DVOR - RUDNIK"=>
|
62
|
+
{:route=>"BAVARSKI DVOR - RUDNIK",
|
63
|
+
:bus_number=>"3N",
|
64
|
+
:arrivals=>
|
65
|
+
[{:time=>"21:40", :easy=>false},
|
66
|
+
{:time=>"22:00", :easy=>true},
|
67
|
+
{:time=>"22:20", :easy=>false}]},
|
68
|
+
"3N BAVARSKI DVOR - ŠKOFLJICA"=>
|
69
|
+
{:route=>"BAVARSKI DVOR - ŠKOFLJICA",
|
70
|
+
:bus_number=>"3N",
|
71
|
+
:arrivals=>
|
72
|
+
[{:time=>"04:50", :easy=>false}, {:time=>"21:20", :easy=>false}]},
|
73
|
+
"3 LITOSTROJ - RUDNIK"=>
|
74
|
+
{:route=>"LITOSTROJ - RUDNIK",
|
75
|
+
:bus_number=>"3",
|
76
|
+
:arrivals=>[{:time=>"21:01", :easy=>false}]},
|
77
|
+
"3L BAVARSKI DVOR - TOVARNA LEK"=>
|
78
|
+
{:route=>"BAVARSKI DVOR - TOVARNA LEK",
|
79
|
+
:bus_number=>"3L",
|
80
|
+
:arrivals=>[{:time=>"21:25", :easy=>false}]},
|
81
|
+
"3N ŠKOFLJICA - BAVARSKI DVOR"=>
|
82
|
+
{:route=>"ŠKOFLJICA - BAVARSKI DVOR",
|
83
|
+
:bus_number=>"3N",
|
84
|
+
:arrivals=>[{:time=>"21:37", :easy=>false}]},
|
85
|
+
"3G BEŽIGRAD - GROSUPLJE"=>
|
86
|
+
{:route=>"BEŽIGRAD - GROSUPLJE",
|
87
|
+
:bus_number=>"3G",
|
88
|
+
:arrivals=>
|
89
|
+
[{:time=>"21:35", :easy=>false},
|
90
|
+
{:time=>"22:35", :easy=>false},
|
91
|
+
{:time=>"23:44", :easy=>false}]},
|
92
|
+
"5N ŠTEPANJSKO NAS. - PODUTIK"=>
|
93
|
+
{:route=>"ŠTEPANJSKO NAS. - PODUTIK",
|
94
|
+
:bus_number=>"5N",
|
95
|
+
:arrivals=>
|
96
|
+
[{:time=>"21:30", :easy=>false},
|
97
|
+
{:time=>"22:00", :easy=>false},
|
98
|
+
{:time=>"22:29", :easy=>true}]},
|
99
|
+
"6 ČRNUČE - DOLGI MOST"=>
|
100
|
+
{:route=>"ČRNUČE - DOLGI MOST",
|
101
|
+
:bus_number=>"6",
|
102
|
+
:arrivals=>
|
103
|
+
[{:time=>"21:25", :easy=>true},
|
104
|
+
{:time=>"21:48", :easy=>false},
|
105
|
+
{:time=>"22:00", :easy=>false}]},
|
106
|
+
"6 ČRNUČE - GARAŽA"=>
|
107
|
+
{:route=>"ČRNUČE - GARAŽA",
|
108
|
+
:bus_number=>"6",
|
109
|
+
:arrivals=>[{:time=>"00:53", :easy=>false}]},
|
110
|
+
"6B ČRNUČE - NOTRANJE GORICE"=>
|
111
|
+
{:route=>"ČRNUČE - NOTRANJE GORICE",
|
112
|
+
:bus_number=>"6B",
|
113
|
+
:arrivals=>
|
114
|
+
[{:time=>"21:41", :easy=>false},
|
115
|
+
{:time=>"22:28", :easy=>true},
|
116
|
+
{:time=>"04:47", :easy=>false}]},
|
117
|
+
"7 NOVE JARŠE - PRŽAN"=>
|
118
|
+
{:route=>"NOVE JARŠE - PRŽAN",
|
119
|
+
:bus_number=>"7",
|
120
|
+
:arrivals=>
|
121
|
+
[{:time=>"21:23", :easy=>true},
|
122
|
+
{:time=>"21:43", :easy=>false},
|
123
|
+
{:time=>"05:13", :easy=>false}]},
|
124
|
+
"7 NOVE JARŠE - GARAŽA"=>
|
125
|
+
{:route=>"NOVE JARŠE - GARAŽA",
|
126
|
+
:bus_number=>"7",
|
127
|
+
:arrivals=>
|
128
|
+
[{:time=>"22:38", :easy=>true},
|
129
|
+
{:time=>"23:00", :easy=>false},
|
130
|
+
{:time=>"08:22", :easy=>false}]},
|
131
|
+
"7L LETALIŠKA - PRŽAN"=>
|
132
|
+
{:route=>"LETALIŠKA - PRŽAN",
|
133
|
+
:bus_number=>"7L",
|
134
|
+
:arrivals=>
|
135
|
+
[{:time=>"22:04", :easy=>false},
|
136
|
+
{:time=>"22:28", :easy=>true},
|
137
|
+
{:time=>"05:55", :easy=>false}]},
|
138
|
+
"8 BRNČIČEVA - GAMELJNE"=>
|
139
|
+
{:route=>"BRNČIČEVA - GAMELJNE",
|
140
|
+
:bus_number=>"8",
|
141
|
+
:arrivals=>
|
142
|
+
[{:time=>"21:40", :easy=>false},
|
143
|
+
{:time=>"22:00", :easy=>true},
|
144
|
+
{:time=>"05:18", :easy=>false}]},
|
145
|
+
"8 BRNČIČEVA - GARAŽA"=>
|
146
|
+
{:route=>"BRNČIČEVA - GARAŽA",
|
147
|
+
:bus_number=>"8",
|
148
|
+
:arrivals=>
|
149
|
+
[{:time=>"22:22", :easy=>false}, {:time=>"22:42", :easy=>true}]},
|
150
|
+
"9 ŠTEPANJSKO NAS. - GARAŽA"=>
|
151
|
+
{:route=>"ŠTEPANJSKO NAS. - GARAŽA",
|
152
|
+
:bus_number=>"9",
|
153
|
+
:arrivals=>
|
154
|
+
[{:time=>"22:44", :easy=>false},
|
155
|
+
{:time=>"23:02", :easy=>false},
|
156
|
+
{:time=>"11:16", :easy=>false}]},
|
157
|
+
"9 ŠTEPANJSKO NAS. - TRNOVO"=>
|
158
|
+
{:route=>"ŠTEPANJSKO NAS. - TRNOVO",
|
159
|
+
:bus_number=>"9",
|
160
|
+
:arrivals=>
|
161
|
+
[{:time=>"21:30", :easy=>false},
|
162
|
+
{:time=>"21:47", :easy=>false},
|
163
|
+
{:time=>"22:09", :easy=>true}]},
|
164
|
+
"11 BEŽIGRAD - ZALOG"=>
|
165
|
+
{:route=>"BEŽIGRAD - ZALOG",
|
166
|
+
:bus_number=>"11",
|
167
|
+
:arrivals=>
|
168
|
+
[{:time=>"21:44", :easy=>false},
|
169
|
+
{:time=>"22:19", :easy=>true},
|
170
|
+
{:time=>"22:59", :easy=>false}]},
|
171
|
+
"11 JEŽICA - ZALOG"=>
|
172
|
+
{:route=>"JEŽICA - ZALOG",
|
173
|
+
:bus_number=>"11",
|
174
|
+
:arrivals=>
|
175
|
+
[{:time=>"05:06", :easy=>false},
|
176
|
+
{:time=>"05:08", :easy=>false},
|
177
|
+
{:time=>"05:24", :easy=>false}]},
|
178
|
+
"14 SAVLJE - VRHOVCI"=>
|
179
|
+
{:route=>"SAVLJE - VRHOVCI",
|
180
|
+
:bus_number=>"14",
|
181
|
+
:arrivals=>
|
182
|
+
[{:time=>"21:43", :easy=>true},
|
183
|
+
{:time=>"22:04", :easy=>false},
|
184
|
+
{:time=>"22:29", :easy=>false}]},
|
185
|
+
"14B SAVLJE - BOKALCE"=>
|
186
|
+
{:route=>"SAVLJE - BOKALCE",
|
187
|
+
:bus_number=>"14B",
|
188
|
+
:arrivals=>
|
189
|
+
[{:time=>"05:28", :easy=>false},
|
190
|
+
{:time=>"05:55", :easy=>false},
|
191
|
+
{:time=>"06:07", :easy=>false}]},
|
192
|
+
"14 SAVLJE - GARAŽA"=>
|
193
|
+
{:route=>"SAVLJE - GARAŽA",
|
194
|
+
:bus_number=>"14",
|
195
|
+
:arrivals=>
|
196
|
+
[{:time=>"22:34", :easy=>true},
|
197
|
+
{:time=>"22:58", :easy=>true},
|
198
|
+
{:time=>"09:23", :easy=>false}]},
|
199
|
+
"19I TOMAČEVO - IG"=>
|
200
|
+
{:route=>"TOMAČEVO - IG",
|
201
|
+
:bus_number=>"19I",
|
202
|
+
:arrivals=>[{:time=>"10:48", :easy=>false}]},
|
203
|
+
"19I TOMAČEVO - GARAŽA"=>
|
204
|
+
{:route=>"TOMAČEVO - GARAŽA",
|
205
|
+
:bus_number=>"19I",
|
206
|
+
:arrivals=>
|
207
|
+
[{:time=>"08:03", :easy=>false},
|
208
|
+
{:time=>"08:28", :easy=>false},
|
209
|
+
{:time=>"08:53", :easy=>false}]},
|
210
|
+
"19B TOMAČEVO - JEZERO"=>
|
211
|
+
{:route=>"TOMAČEVO - JEZERO",
|
212
|
+
:bus_number=>"19B",
|
213
|
+
:arrivals=>
|
214
|
+
[{:time=>"21:58", :easy=>true},
|
215
|
+
{:time=>"22:44", :easy=>true},
|
216
|
+
{:time=>"04:34", :easy=>false}]},
|
217
|
+
"19I TOMAČEVO - IŠKA VAS"=>
|
218
|
+
{:route=>"TOMAČEVO - IŠKA VAS",
|
219
|
+
:bus_number=>"19I",
|
220
|
+
:arrivals=>
|
221
|
+
[{:time=>"21:38", :easy=>false},
|
222
|
+
{:time=>"22:18", :easy=>false},
|
223
|
+
{:time=>"22:57", :easy=>false}]},
|
224
|
+
"20 NOVE STOŽICE - GARAŽA"=>
|
225
|
+
{:route=>"NOVE STOŽICE - GARAŽA",
|
226
|
+
:bus_number=>"20",
|
227
|
+
:arrivals=>[{:time=>"22:52", :easy=>false}]},
|
228
|
+
"20 NOVE STOŽICE - FUŽINE"=>
|
229
|
+
{:route=>"NOVE STOŽICE - FUŽINE",
|
230
|
+
:bus_number=>"20",
|
231
|
+
:arrivals=>
|
232
|
+
[{:time=>"21:34", :easy=>false},
|
233
|
+
{:time=>"21:54", :easy=>true},
|
234
|
+
{:time=>"22:13", :easy=>true}]},
|
235
|
+
"23 KOLODVOR - ZOO"=>
|
236
|
+
{:route=>"KOLODVOR - ZOO",
|
237
|
+
:bus_number=>"23",
|
238
|
+
:arrivals=>
|
239
|
+
[{:time=>"09:02", :easy=>false},
|
240
|
+
{:time=>"10:02", :easy=>false},
|
241
|
+
{:time=>"12:02", :easy=>false}]},
|
242
|
+
"25 ZADOBROVA - MEDVODE"=>
|
243
|
+
{:route=>"ZADOBROVA - MEDVODE",
|
244
|
+
:bus_number=>"25",
|
245
|
+
:arrivals=>
|
246
|
+
[{:time=>"21:36", :easy=>true},
|
247
|
+
{:time=>"22:36", :easy=>false},
|
248
|
+
{:time=>"05:04", :easy=>false}]},
|
249
|
+
"25 ZADOBROVA - GARAŽA"=>
|
250
|
+
{:route=>"ZADOBROVA - GARAŽA",
|
251
|
+
:bus_number=>"25",
|
252
|
+
:arrivals=>[{:time=>"23:34", :easy=>true}]},
|
253
|
+
"27 LETALIŠKA - GARAŽA"=>
|
254
|
+
{:route=>"LETALIŠKA - GARAŽA",
|
255
|
+
:bus_number=>"27",
|
256
|
+
:arrivals=>
|
257
|
+
[{:time=>"22:28", :easy=>true},
|
258
|
+
{:time=>"22:48", :easy=>false},
|
259
|
+
{:time=>"00:15", :easy=>false}]},
|
260
|
+
"27 LETALIŠKA - BTC - NS RUDNIK"=>
|
261
|
+
{:route=>"LETALIŠKA - BTC - NS RUDNIK",
|
262
|
+
:bus_number=>"27",
|
263
|
+
:arrivals=>
|
264
|
+
[{:time=>"21:28", :easy=>true},
|
265
|
+
{:time=>"21:48", :easy=>false},
|
266
|
+
{:time=>"22:08", :easy=>false}]},
|
267
|
+
"27B LETALIŠKA - BTC - BLEIWEISOVA"=>
|
268
|
+
{:route=>"LETALIŠKA - BTC - BLEIWEISOVA",
|
269
|
+
:bus_number=>"27B",
|
270
|
+
:arrivals=>[{:time=>"23:23", :easy=>false}]},
|
271
|
+
"51 LJUBLJANA-POLHOV GRADEC"=>
|
272
|
+
{:route=>"LJUBLJANA-POLHOV GRADEC",
|
273
|
+
:bus_number=>"51",
|
274
|
+
:arrivals=>
|
275
|
+
[{:time=>"22:46", :easy=>false},
|
276
|
+
{:time=>"05:36", :easy=>false},
|
277
|
+
{:time=>"06:27", :easy=>false}]},
|
278
|
+
"56 LJUBLJANA-ŠENTJOŠT"=>
|
279
|
+
{:route=>"LJUBLJANA-ŠENTJOŠT",
|
280
|
+
:bus_number=>"56",
|
281
|
+
:arrivals=>
|
282
|
+
[{:time=>"22:36", :easy=>false},
|
283
|
+
{:time=>"05:21", :easy=>false},
|
284
|
+
{:time=>"06:41", :easy=>false}]}}},
|
285
|
+
"600011"=>
|
286
|
+
{:name=>"BAVARSKI DVOR",
|
287
|
+
:buses=>
|
288
|
+
{"1N VIŽMARJE - BAVARSKI DVOR"=>
|
289
|
+
{:route=>"VIŽMARJE - BAVARSKI DVOR",
|
290
|
+
:bus_number=>"1N",
|
291
|
+
:arrivals=>[{:time=>"22:55", :easy=>false}]},
|
292
|
+
"2 NOVE JARŠE - ZELENA JAMA"=>
|
293
|
+
{:route=>"NOVE JARŠE - ZELENA JAMA",
|
294
|
+
:bus_number=>"2",
|
295
|
+
:arrivals=>
|
296
|
+
[{:time=>"21:30", :easy=>true},
|
297
|
+
{:time=>"21:47", :easy=>false},
|
298
|
+
{:time=>"21:58", :easy=>false}]},
|
299
|
+
"2 NOVE JARŠE - GARAŽA"=>
|
300
|
+
{:route=>"NOVE JARŠE - GARAŽA",
|
301
|
+
:bus_number=>"2",
|
302
|
+
:arrivals=>
|
303
|
+
[{:time=>"00:31", :easy=>false}, {:time=>"01:06", :easy=>true}]},
|
304
|
+
"3G GROSUPLJE - BEŽIGRAD "=>
|
305
|
+
{:route=>"GROSUPLJE - BEŽIGRAD ",
|
306
|
+
:bus_number=>"3G",
|
307
|
+
:arrivals=>
|
308
|
+
[{:time=>"22:24", :easy=>false},
|
309
|
+
{:time=>"23:25", :easy=>false},
|
310
|
+
{:time=>"05:04", :easy=>false}]},
|
311
|
+
"5N PODUTIK - ŠTEPANJSKO NAS."=>
|
312
|
+
{:route=>"PODUTIK - ŠTEPANJSKO NAS.",
|
313
|
+
:bus_number=>"5N",
|
314
|
+
:arrivals=>
|
315
|
+
[{:time=>"21:32", :easy=>true},
|
316
|
+
{:time=>"21:59", :easy=>false},
|
317
|
+
{:time=>"22:29", :easy=>false}]},
|
318
|
+
"6B NOTRANJE GORICE - GARAŽA"=>
|
319
|
+
{:route=>"NOTRANJE GORICE - GARAŽA",
|
320
|
+
:bus_number=>"6B",
|
321
|
+
:arrivals=>[{:time=>"23:30", :easy=>true}]},
|
322
|
+
"6 DOLGI MOST - ČRNUČE"=>
|
323
|
+
{:route=>"DOLGI MOST - ČRNUČE",
|
324
|
+
:bus_number=>"6",
|
325
|
+
:arrivals=>
|
326
|
+
[{:time=>"21:45", :easy=>true},
|
327
|
+
{:time=>"22:16", :easy=>false},
|
328
|
+
{:time=>"23:40", :easy=>false}]},
|
329
|
+
"6 DOLGI MOST - GARAŽA"=>
|
330
|
+
{:route=>"DOLGI MOST - GARAŽA",
|
331
|
+
:bus_number=>"6",
|
332
|
+
:arrivals=>
|
333
|
+
[{:time=>"22:44", :easy=>false},
|
334
|
+
{:time=>"00:52", :easy=>false},
|
335
|
+
{:time=>"09:24", :easy=>false}]},
|
336
|
+
"6B NOTRANJE GORICE - ČRNUČE"=>
|
337
|
+
{:route=>"NOTRANJE GORICE - ČRNUČE",
|
338
|
+
:bus_number=>"6B",
|
339
|
+
:arrivals=>
|
340
|
+
[{:time=>"21:28", :easy=>false},
|
341
|
+
{:time=>"21:58", :easy=>true},
|
342
|
+
{:time=>"22:31", :easy=>true}]},
|
343
|
+
"7L PRŽAN - LETALIŠKA"=>
|
344
|
+
{:route=>"PRŽAN - LETALIŠKA",
|
345
|
+
:bus_number=>"7L",
|
346
|
+
:arrivals=>
|
347
|
+
[{:time=>"21:24", :easy=>false},
|
348
|
+
{:time=>"21:45", :easy=>true},
|
349
|
+
{:time=>"05:14", :easy=>false}]},
|
350
|
+
"7 PRŽAN - NOVE JARŠE"=>
|
351
|
+
{:route=>"PRŽAN - NOVE JARŠE",
|
352
|
+
:bus_number=>"7",
|
353
|
+
:arrivals=>
|
354
|
+
[{:time=>"22:04", :easy=>true},
|
355
|
+
{:time=>"22:28", :easy=>false},
|
356
|
+
{:time=>"07:41", :easy=>false}]},
|
357
|
+
"8 GAMELJNE - BRNČIČEVA"=>
|
358
|
+
{:route=>"GAMELJNE - BRNČIČEVA",
|
359
|
+
:bus_number=>"8",
|
360
|
+
:arrivals=>
|
361
|
+
[{:time=>"21:38", :easy=>false},
|
362
|
+
{:time=>"22:01", :easy=>true},
|
363
|
+
{:time=>"05:27", :easy=>false}]},
|
364
|
+
"9 TRNOVO - GARAŽA"=>
|
365
|
+
{:route=>"TRNOVO - GARAŽA",
|
366
|
+
:bus_number=>"9",
|
367
|
+
:arrivals=>
|
368
|
+
[{:time=>"22:33", :easy=>true}, {:time=>"22:53", :easy=>true}]},
|
369
|
+
"9 TRNOVO - ŠTEPANJSKO NAS."=>
|
370
|
+
{:route=>"TRNOVO - ŠTEPANJSKO NAS.",
|
371
|
+
:bus_number=>"9",
|
372
|
+
:arrivals=>
|
373
|
+
[{:time=>"21:27", :easy=>true},
|
374
|
+
{:time=>"21:49", :easy=>true},
|
375
|
+
{:time=>"22:09", :easy=>false}]},
|
376
|
+
"11 ZALOG - GARAŽA"=>
|
377
|
+
{:route=>"ZALOG - GARAŽA",
|
378
|
+
:bus_number=>"11",
|
379
|
+
:arrivals=>
|
380
|
+
[{:time=>"00:40", :easy=>true}, {:time=>"01:20", :easy=>false}]},
|
381
|
+
"11 ZALOG - JEŽICA"=>
|
382
|
+
{:route=>"ZALOG - JEŽICA",
|
383
|
+
:bus_number=>"11",
|
384
|
+
:arrivals=>
|
385
|
+
[{:time=>"05:29", :easy=>false},
|
386
|
+
{:time=>"05:44", :easy=>false},
|
387
|
+
{:time=>"05:57", :easy=>false}]},
|
388
|
+
"11 ZALOG - BEŽIGRAD"=>
|
389
|
+
{:route=>"ZALOG - BEŽIGRAD",
|
390
|
+
:bus_number=>"11",
|
391
|
+
:arrivals=>
|
392
|
+
[{:time=>"21:47", :easy=>true},
|
393
|
+
{:time=>"22:00", :easy=>true},
|
394
|
+
{:time=>"22:20", :easy=>false}]},
|
395
|
+
"13 SOSTRO - GARAŽA"=>
|
396
|
+
{:route=>"SOSTRO - GARAŽA",
|
397
|
+
:bus_number=>"13",
|
398
|
+
:arrivals=>
|
399
|
+
[{:time=>"21:31", :easy=>false},
|
400
|
+
{:time=>"22:29", :easy=>true},
|
401
|
+
{:time=>"23:19", :easy=>true}]},
|
402
|
+
"13 SOSTRO - CENTER STOŽICE"=>
|
403
|
+
{:route=>"SOSTRO - CENTER STOŽICE",
|
404
|
+
:bus_number=>"13",
|
405
|
+
:arrivals=>
|
406
|
+
[{:time=>"21:26", :easy=>true},
|
407
|
+
{:time=>"22:01", :easy=>true},
|
408
|
+
{:time=>"05:16", :easy=>false}]},
|
409
|
+
"14 VRHOVCI - SAVLJE"=>
|
410
|
+
{:route=>"VRHOVCI - SAVLJE",
|
411
|
+
:bus_number=>"14",
|
412
|
+
:arrivals=>
|
413
|
+
[{:time=>"22:29", :easy=>true},
|
414
|
+
{:time=>"05:15", :easy=>false},
|
415
|
+
{:time=>"05:29", :easy=>false}]},
|
416
|
+
"14 VRHOVCI - GARAŽA"=>
|
417
|
+
{:route=>"VRHOVCI - GARAŽA",
|
418
|
+
:bus_number=>"14",
|
419
|
+
:arrivals=>
|
420
|
+
[{:time=>"21:43", :easy=>false},
|
421
|
+
{:time=>"22:36", :easy=>false},
|
422
|
+
{:time=>"23:01", :easy=>false}]},
|
423
|
+
"14B BOKALCE - SAVLJE"=>
|
424
|
+
{:route=>"BOKALCE - SAVLJE",
|
425
|
+
:bus_number=>"14B",
|
426
|
+
:arrivals=>
|
427
|
+
[{:time=>"21:44", :easy=>false},
|
428
|
+
{:time=>"22:04", :easy=>true},
|
429
|
+
{:time=>"05:44", :easy=>false}]},
|
430
|
+
"19 IG AP - GARAŽA"=>
|
431
|
+
{:route=>"IG AP - GARAŽA",
|
432
|
+
:bus_number=>"19",
|
433
|
+
:arrivals=>[{:time=>"08:21", :easy=>false}]},
|
434
|
+
"19B JEZERO - GARAŽA"=>
|
435
|
+
{:route=>"JEZERO - GARAŽA",
|
436
|
+
:bus_number=>"19B",
|
437
|
+
:arrivals=>
|
438
|
+
[{:time=>"22:59", :easy=>true},
|
439
|
+
{:time=>"23:34", :easy=>false},
|
440
|
+
{:time=>"23:39", :easy=>true}]},
|
441
|
+
"19B JEZERO - TOMAČEVO"=>
|
442
|
+
{:route=>"JEZERO - TOMAČEVO",
|
443
|
+
:bus_number=>"19B",
|
444
|
+
:arrivals=>
|
445
|
+
[{:time=>"21:42", :easy=>false},
|
446
|
+
{:time=>"22:26", :easy=>false},
|
447
|
+
{:time=>"05:21", :easy=>false}]},
|
448
|
+
"19I IŠKA VAS - TOMAČEVO"=>
|
449
|
+
{:route=>"IŠKA VAS - TOMAČEVO",
|
450
|
+
:bus_number=>"19I",
|
451
|
+
:arrivals=>
|
452
|
+
[{:time=>"22:08", :easy=>true},
|
453
|
+
{:time=>"05:12", :easy=>false},
|
454
|
+
{:time=>"05:44", :easy=>false}]},
|
455
|
+
"19I IŠKA VAS - GARAŽA"=>
|
456
|
+
{:route=>"IŠKA VAS - GARAŽA",
|
457
|
+
:bus_number=>"19I",
|
458
|
+
:arrivals=>
|
459
|
+
[{:time=>"22:41", :easy=>false},
|
460
|
+
{:time=>"23:21", :easy=>false},
|
461
|
+
{:time=>"23:56", :easy=>false}]},
|
462
|
+
"20 FUŽINE - NOVE STOŽICE"=>
|
463
|
+
{:route=>"FUŽINE - NOVE STOŽICE",
|
464
|
+
:bus_number=>"20",
|
465
|
+
:arrivals=>
|
466
|
+
[{:time=>"21:34", :easy=>true},
|
467
|
+
{:time=>"21:56", :easy=>true},
|
468
|
+
{:time=>"22:16", :easy=>true}]},
|
469
|
+
"20 FUŽINE - GARAŽA"=>
|
470
|
+
{:route=>"FUŽINE - GARAŽA",
|
471
|
+
:bus_number=>"20",
|
472
|
+
:arrivals=>
|
473
|
+
[{:time=>"22:58", :easy=>true}, {:time=>"23:16", :easy=>true}]},
|
474
|
+
"23 ZOO - KOLODVOR"=>
|
475
|
+
{:route=>"ZOO - KOLODVOR",
|
476
|
+
:bus_number=>"23",
|
477
|
+
:arrivals=>
|
478
|
+
[{:time=>"10:30", :easy=>false},
|
479
|
+
{:time=>"12:30", :easy=>false},
|
480
|
+
{:time=>"16:31", :easy=>false}]},
|
481
|
+
"25 MEDVODE - ZADOBROVA"=>
|
482
|
+
{:route=>"MEDVODE - ZADOBROVA",
|
483
|
+
:bus_number=>"25",
|
484
|
+
:arrivals=>
|
485
|
+
[{:time=>"21:35", :easy=>false},
|
486
|
+
{:time=>"22:49", :easy=>true},
|
487
|
+
{:time=>"05:28", :easy=>false}]},
|
488
|
+
"27 NS RUDNIK - BTC - LETALIŠKA"=>
|
489
|
+
{:route=>"NS RUDNIK - BTC - LETALIŠKA",
|
490
|
+
:bus_number=>"27",
|
491
|
+
:arrivals=>
|
492
|
+
[{:time=>"21:24", :easy=>false},
|
493
|
+
{:time=>"21:45", :easy=>true},
|
494
|
+
{:time=>"22:05", :easy=>false}]},
|
495
|
+
"27 NS RUDNIK - GARAŽA"=>
|
496
|
+
{:route=>"NS RUDNIK - GARAŽA",
|
497
|
+
:bus_number=>"27",
|
498
|
+
:arrivals=>
|
499
|
+
[{:time=>"22:43", :easy=>false}, {:time=>"17:54", :easy=>false}]},
|
500
|
+
"27B BLEIWEISOVA - BTC - LETALIŠKA"=>
|
501
|
+
{:route=>"BLEIWEISOVA - BTC - LETALIŠKA",
|
502
|
+
:bus_number=>"27B",
|
503
|
+
:arrivals=>[{:time=>"23:40", :easy=>false}]},
|
504
|
+
"51 POLHOV GRADEC-LJUBLJANA"=>
|
505
|
+
{:route=>"POLHOV GRADEC-LJUBLJANA",
|
506
|
+
:bus_number=>"51",
|
507
|
+
:arrivals=>
|
508
|
+
[{:time=>"21:33", :easy=>false},
|
509
|
+
{:time=>"05:31", :easy=>false},
|
510
|
+
{:time=>"06:19", :easy=>false}]},
|
511
|
+
"56 ŠENTJOŠT-LJUBLJANA"=>
|
512
|
+
{:route=>"ŠENTJOŠT-LJUBLJANA",
|
513
|
+
:bus_number=>"56",
|
514
|
+
:arrivals=>
|
515
|
+
[{:time=>"22:06", :easy=>false},
|
516
|
+
{:time=>"05:15", :easy=>false},
|
517
|
+
{:time=>"06:26", :easy=>false}]}}}}
|
518
|
+
|
519
|
+
assert_equal result_hash,
|
520
|
+
arrivals
|
521
|
+
end
|
522
|
+
|
523
|
+
def test_parsing_single_bus
|
524
|
+
response = File.read(File.join(File.dirname(__FILE__), 'response.html'))
|
525
|
+
stub_request(:any, /wbus.talktrack.com\/.*/).
|
526
|
+
to_return(:body => response, :status => 200, :headers => { 'Content-Length' => response.length } )
|
527
|
+
|
528
|
+
arrivals = Lpp.arrivals_for_bus('bavarski', 6)
|
529
|
+
result_hash = {"600012"=>
|
530
|
+
{:name=>"BAVARSKI DVOR",
|
531
|
+
:buses=>
|
532
|
+
{"6 ČRNUČE - DOLGI MOST"=>
|
533
|
+
{:route=>"ČRNUČE - DOLGI MOST",
|
534
|
+
:bus_number=>"6",
|
535
|
+
:arrivals=>
|
536
|
+
[{:time=>"21:25", :easy=>true},
|
537
|
+
{:time=>"21:48", :easy=>false},
|
538
|
+
{:time=>"22:00", :easy=>false}]},
|
539
|
+
"6 ČRNUČE - GARAŽA"=>
|
540
|
+
{:route=>"ČRNUČE - GARAŽA",
|
541
|
+
:bus_number=>"6",
|
542
|
+
:arrivals=>[{:time=>"00:53", :easy=>false}]},
|
543
|
+
"6B ČRNUČE - NOTRANJE GORICE"=>
|
544
|
+
{:route=>"ČRNUČE - NOTRANJE GORICE",
|
545
|
+
:bus_number=>"6B",
|
546
|
+
:arrivals=>
|
547
|
+
[{:time=>"21:41", :easy=>false},
|
548
|
+
{:time=>"22:28", :easy=>true},
|
549
|
+
{:time=>"04:47", :easy=>false}]}}},
|
550
|
+
"600011"=>
|
551
|
+
{:name=>"BAVARSKI DVOR",
|
552
|
+
:buses=>
|
553
|
+
{"6B NOTRANJE GORICE - GARAŽA"=>
|
554
|
+
{:route=>"NOTRANJE GORICE - GARAŽA",
|
555
|
+
:bus_number=>"6B",
|
556
|
+
:arrivals=>[{:time=>"23:30", :easy=>true}]},
|
557
|
+
"6 DOLGI MOST - ČRNUČE"=>
|
558
|
+
{:route=>"DOLGI MOST - ČRNUČE",
|
559
|
+
:bus_number=>"6",
|
560
|
+
:arrivals=>
|
561
|
+
[{:time=>"21:45", :easy=>true},
|
562
|
+
{:time=>"22:16", :easy=>false},
|
563
|
+
{:time=>"23:40", :easy=>false}]},
|
564
|
+
"6 DOLGI MOST - GARAŽA"=>
|
565
|
+
{:route=>"DOLGI MOST - GARAŽA",
|
566
|
+
:bus_number=>"6",
|
567
|
+
:arrivals=>
|
568
|
+
[{:time=>"22:44", :easy=>false},
|
569
|
+
{:time=>"00:52", :easy=>false},
|
570
|
+
{:time=>"09:24", :easy=>false}]},
|
571
|
+
"6B NOTRANJE GORICE - ČRNUČE"=>
|
572
|
+
{:route=>"NOTRANJE GORICE - ČRNUČE",
|
573
|
+
:bus_number=>"6B",
|
574
|
+
:arrivals=>
|
575
|
+
[{:time=>"21:28", :easy=>false},
|
576
|
+
{:time=>"21:58", :easy=>true},
|
577
|
+
{:time=>"22:31", :easy=>true}]}}}}
|
578
|
+
|
579
|
+
assert_equal result_hash,
|
580
|
+
arrivals
|
581
|
+
end
|
582
|
+
|
583
|
+
def test_no_station_found
|
584
|
+
response = File.read(File.join(File.dirname(__FILE__), 'response_not_found.html'))
|
585
|
+
stub_request(:any, /wbus.talktrack.com\/.*/).
|
586
|
+
to_return(:body => response, :status => 200, :headers => { 'Content-Length' => response.length } )
|
587
|
+
|
588
|
+
assert_raise RuntimeError do
|
589
|
+
Lpp.arrivals('non-existing-station')
|
590
|
+
end
|
591
|
+
end
|
592
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lpp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jure Triglav
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.5'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.5'
|
83
|
+
description: LPP is a simple gem for getting bus arrivals in Ljubljana. It uses the
|
84
|
+
wbus.talktrack.com website.
|
85
|
+
email:
|
86
|
+
- juretriglav@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .gitignore
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/lpp.rb
|
97
|
+
- lib/lpp/version.rb
|
98
|
+
- lpp.gemspec
|
99
|
+
- test/response.html
|
100
|
+
- test/response_not_found.html
|
101
|
+
- test/test_helper.rb
|
102
|
+
- test/test_lpp.rb
|
103
|
+
homepage: ''
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.0.0
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Ljubljana bus arrivals gem
|
127
|
+
test_files:
|
128
|
+
- test/response.html
|
129
|
+
- test/response_not_found.html
|
130
|
+
- test/test_helper.rb
|
131
|
+
- test/test_lpp.rb
|