lothianbusestimetable 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/lothianbusestimetable.rb +39 -16
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3bf2af622eaa822e7a296b7cea1bbdb8680c7a8
|
4
|
+
data.tar.gz: bc2f0e8851c2333a28196598ba339373dd61a2f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86524dc73bc3fdc147c83f38ce5353a3fa2689cdd7bc998617d88122321150b346a68ea6b45bfca6357bb23661da7821463bd8a27619cbd81b8d5cd72e8c51ef
|
7
|
+
data.tar.gz: d03b438eca70aef97dc79b0fa012e64f27ce965903042c6f25024034c3295d24ec5babdcbddc05ba3d663572f5f321a8eb6b89905ef49f531a2f7657ebaeb8fe
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -46,6 +46,8 @@ class LothianBusesTimetable
|
|
46
46
|
|
47
47
|
# get the name
|
48
48
|
a = tr.xpath('td//text()').map(&:unescape)
|
49
|
+
|
50
|
+
next unless a.any?
|
49
51
|
|
50
52
|
col1 = a.shift.strip
|
51
53
|
|
@@ -54,7 +56,8 @@ class LothianBusesTimetable
|
|
54
56
|
a0 << {service: $1}
|
55
57
|
|
56
58
|
elsif col1.empty? or col1.length <= 1
|
57
|
-
|
59
|
+
|
60
|
+
#next if a.length < 1
|
58
61
|
if prev_col.empty? or prev_col.length <= 1 and a0.last.any? then
|
59
62
|
|
60
63
|
a0 << {}
|
@@ -70,7 +73,7 @@ class LothianBusesTimetable
|
|
70
73
|
|
71
74
|
else
|
72
75
|
|
73
|
-
if a.any? then
|
76
|
+
if a.any? and a.length > 1 then
|
74
77
|
|
75
78
|
h = a0.last
|
76
79
|
|
@@ -81,6 +84,7 @@ class LothianBusesTimetable
|
|
81
84
|
end
|
82
85
|
|
83
86
|
else
|
87
|
+
|
84
88
|
a0.pop if a0.last.empty?
|
85
89
|
end
|
86
90
|
end
|
@@ -114,28 +118,40 @@ class LothianBusesTimetable
|
|
114
118
|
h = a0.shift
|
115
119
|
master[:saturday][:outbound] = h
|
116
120
|
|
117
|
-
h = a0.shift
|
118
|
-
h = a0.shift until h.any?
|
119
|
-
master[:sunday][:desc] = h[:timetable]
|
120
121
|
h = a0.shift
|
121
|
-
|
122
|
-
h
|
123
|
-
|
124
|
-
|
122
|
+
|
123
|
+
if h then
|
124
|
+
|
125
|
+
h = a0.shift until h.any?
|
126
|
+
master[:sunday][:desc] = h[:timetable]
|
127
|
+
h = a0.shift
|
128
|
+
master[:sunday][:inbound] = h
|
129
|
+
h = a0.shift
|
130
|
+
master[:sunday][:outbound] = h
|
131
|
+
|
132
|
+
end
|
125
133
|
|
126
134
|
master.to_a[1..-1].each do |key, timetable|
|
127
135
|
|
128
136
|
timetable.to_a[1..-1].each do |direction, printed_rows|
|
129
137
|
|
138
|
+
next unless printed_rows
|
139
|
+
|
130
140
|
# find the interval gaps
|
131
141
|
|
132
142
|
a = printed_rows.to_a
|
133
|
-
index = a.index a.detect {|x| x.last.grep(/^ $/).any? }
|
134
|
-
|
143
|
+
index = a.index a.detect {|x| x.last.grep(/^ |then$/).any? }
|
144
|
+
|
145
|
+
if index then
|
146
|
+
a2 = a[index].last
|
135
147
|
|
136
|
-
|
148
|
+
gaps = a2.map.with_index.select {|x,i| x == " " \
|
149
|
+
or x == 'then'}.map(&:last)
|
137
150
|
|
138
|
-
|
151
|
+
gaps.delete_at -1 if gaps.last >= a2.length - 1
|
152
|
+
else
|
153
|
+
gaps = []
|
154
|
+
end
|
139
155
|
|
140
156
|
# sanitise the times (where short hand times are
|
141
157
|
# given i.e. minutes only)
|
@@ -143,7 +159,7 @@ class LothianBusesTimetable
|
|
143
159
|
printed_rows.each do |name, row|
|
144
160
|
|
145
161
|
prev_time = nil
|
146
|
-
printed_rows[name] = row.map.with_index do |col,i|
|
162
|
+
printed_rows[name] = row.map.with_index do |col,i|
|
147
163
|
|
148
164
|
if gaps.include? i then
|
149
165
|
col
|
@@ -173,15 +189,22 @@ class LothianBusesTimetable
|
|
173
189
|
|
174
190
|
# fill in the gaps
|
175
191
|
|
176
|
-
periods = gaps.map {|i| a.map {|k,v| v[i].to_s.gsub(/\W/,'')}
|
192
|
+
periods = gaps.map {|i| a.map {|k,v| v[i].to_s.gsub(/\W/,' ')}
|
177
193
|
.compact.join(' ').strip }
|
178
194
|
|
179
195
|
gap_times = gaps.zip(periods)
|
180
196
|
|
181
197
|
|
182
198
|
intervaltimes = gap_times.map do |i, desc|
|
199
|
+
|
200
|
+
interval = if desc =~
|
201
|
+
/^then at these mins past each hour(?: until)?/ then
|
202
|
+
60
|
203
|
+
else
|
204
|
+
interval = desc[/then (?:at least )?every (\d+) mins(?: until)?/,1].to_i
|
205
|
+
end
|
183
206
|
|
184
|
-
|
207
|
+
next if interval == 0
|
185
208
|
|
186
209
|
new_rows = printed_rows.map do |k,v|
|
187
210
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lothianbusestimetable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
K7yWGJq+eGl34xrLaucvTbO8Ua3rHayCkBzgfx5LVcch22Axj8quw+YGsPnhuosr
|
32
32
|
BHdCmx9eUF/TKg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-08-
|
34
|
+
date: 2017-08-26 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: nokorexi
|
metadata.gz.sig
CHANGED
Binary file
|