national-rail 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ module NationalRail
|
|
15
15
|
@date = date
|
16
16
|
end
|
17
17
|
def parse(value)
|
18
|
-
value = value.gsub(%r{\*+$}, '')
|
18
|
+
value = value.gsub(%r{&#\d+;}, '').gsub(%r{\*+$}, '')
|
19
19
|
return value if ['On time', 'Starts here', 'No report'].include?(value)
|
20
20
|
parts = value.scan(%r{\d{2}})
|
21
21
|
return nil unless parts.length == 2
|
@@ -67,10 +67,10 @@ module NationalRail
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
class
|
70
|
+
class NokogiriParser < Mechanize::Page
|
71
71
|
attr_reader :doc
|
72
72
|
def initialize(uri = nil, response = nil, body = nil, code = nil)
|
73
|
-
@doc =
|
73
|
+
@doc = Nokogiri(TidyFFI::Tidy.new(body).clean)
|
74
74
|
super(uri, response, body, code)
|
75
75
|
end
|
76
76
|
end
|
@@ -79,7 +79,7 @@ module NationalRail
|
|
79
79
|
|
80
80
|
def initialize
|
81
81
|
@agent = Mechanize.new
|
82
|
-
@agent.pluggable_parser.html =
|
82
|
+
@agent.pluggable_parser.html = NokogiriParser
|
83
83
|
@agent.user_agent_alias = "Mac FireFox"
|
84
84
|
end
|
85
85
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: national-rail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Mead
|