tfl_journey_planner 0.1.2 → 0.1.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -6,17 +6,34 @@ class TflJourneyPlanner
6
6
  JOURNEY_PLANNER_URL = 'http://m.tfl.gov.uk/mt/journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2?language=en'
7
7
  JOURNEY_PLANNER_ACTION = '/mt/journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2'
8
8
 
9
- def self.submit_form(from, to)
10
- tfl = Mechanize.new
9
+ class << self
10
+
11
+ def submit_form(from, to)
12
+ tfl = Mechanize.new
13
+
14
+ tfl.get(JOURNEY_PLANNER_URL) do |page|
15
+ page.form_with(:action => JOURNEY_PLANNER_ACTION) do |f|
16
+ f.name_origin = from
17
+ f.name_destination = to
18
+ end.submit
19
+ end
20
+
21
+ tfl.page.body
22
+ end
23
+
24
+ def get_journeys(from, to)
25
+ output = Nokogiri::HTML.parse(submit_form(from, to)).css('.un_space_top_bottom')
26
+ output.map do |o|
27
+ o.css('div').map do |d|
28
+ if d.css('img').empty?
29
+ d.text.strip
30
+ else
31
+ d.text.strip + d.css('img').map{ |i| CGI.unescape(i.attr('src')).split(/\=|\&/)[1] }.inspect
32
+ end
33
+ end
34
+ end
35
+ end
11
36
 
12
- tfl.get(JOURNEY_PLANNER_URL) do |page|
13
- page.form_with(:action => JOURNEY_PLANNER_ACTION) do |f|
14
- f.name_origin = from
15
- f.name_destination = to
16
- end.submit
17
- end
18
-
19
- Nokogiri::HTML.parse(tfl.page.body).css('.un_space_top_bottom').map(&:inner_html)
20
37
  end
21
38
 
22
39
  end
Binary file
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tfl_journey_planner}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jordi Noguera"]
12
- s.date = %q{2010-11-07}
12
+ s.date = %q{2010-11-12}
13
13
  s.description = %q{Tfl Journey Planner}
14
14
  s.email = %q{jordinoguera83@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "spec/spec.opts",
28
28
  "spec/spec_helper.rb",
29
29
  "spec/tfl_journey_planner_spec.rb",
30
+ "tfl_journey_planner-0.1.1.gem",
30
31
  "tfl_journey_planner.gemspec",
31
32
  "tools/console"
32
33
  ]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tfl_journey_planner
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordi Noguera
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-07 00:00:00 +00:00
18
+ date: 2010-11-12 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -68,6 +68,7 @@ files:
68
68
  - spec/spec.opts
69
69
  - spec/spec_helper.rb
70
70
  - spec/tfl_journey_planner_spec.rb
71
+ - tfl_journey_planner-0.1.1.gem
71
72
  - tfl_journey_planner.gemspec
72
73
  - tools/console
73
74
  has_rdoc: true