echelon 0.0.2 → 0.0.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/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in echelon.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ echelon (0.0.2)
5
+ json_pure (= 1.4.6)
6
+ zip (= 2.0.2)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.1.2)
12
+ json_pure (1.4.6)
13
+ rspec (2.4.0)
14
+ rspec-core (~> 2.4.0)
15
+ rspec-expectations (~> 2.4.0)
16
+ rspec-mocks (~> 2.4.0)
17
+ rspec-core (2.4.0)
18
+ rspec-expectations (2.4.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.4.0)
21
+ zip (2.0.2)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ bundler (>= 1.0.0)
28
+ echelon!
29
+ json_pure (= 1.4.6)
30
+ rspec (>= 2.4.0)
31
+ zip (= 2.0.2)
data/Rakefile CHANGED
@@ -1,24 +1,2 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/echelon'
6
-
7
- Hoe.plugin :newgem
8
- # Hoe.plugin :website
9
- # Hoe.plugin :cucumberfeatures
10
-
11
- # Generate all the Rake tasks
12
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
- $hoe = Hoe.spec 'echelon' do
14
- self.developer 'Lloyd Pick', 'lloydpick@gmail.com'
15
- self.rubyforge_name = self.name
16
- self.extra_deps = [['json_pure','>= 1.4.6']]
17
- end
18
-
19
- require 'newgem/tasks'
20
- Dir['tasks/**/*.rake'].each { |t| load t }
21
-
22
- # TODO - want other tests/tasks run by default? Add them to the list
23
- # remove_task :default
24
- # task :default => [:spec, :features]
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/echelon.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path("../lib/echelon/version", __FILE__)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "echelon"
7
+ s.version = Echelon::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Lloyd Pick"]
10
+ s.email = ["lloydpick@gmail.com"]
11
+ s.homepage = "http://github.com/lloydpick/echelon"
12
+ s.summary = "RubyGem to give quick access to Theme Park queue times"
13
+ s.description = "RubyGem to give quick access to Theme Park queue times (Disneyland Paris and Thorpe Park supported)"
14
+
15
+ s.required_rubygems_version = ">= 1.3.6"
16
+ s.rubyforge_project = "echelon"
17
+
18
+ s.add_development_dependency "bundler", ">= 1.0.0"
19
+ s.add_development_dependency "rspec", ">= 2.4.0"
20
+
21
+ s.add_dependency "json_pure", "1.4.6"
22
+ s.add_dependency "zip", "2.0.2"
23
+
24
+ s.files = `git ls-files`.split("\n")
25
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
26
+ s.require_path = 'lib'
27
+ end
@@ -0,0 +1,24 @@
1
+ module Echelon
2
+ class Park
3
+
4
+ def ride_list
5
+ {}
6
+ end
7
+
8
+ def rides
9
+ ride_list.inject([]) do |r, e| r << create_ride_object(e[0]) end
10
+ end
11
+
12
+ def find_by_name(ride)
13
+ raise ArgumentError, "Unknown ride name" unless ride_list.has_value?(ride)
14
+ ref = ride_list.index(ride)
15
+ create_ride_object(ref)
16
+ end
17
+
18
+ def find_by_id(ref)
19
+ raise ArgumentError, "Unknown ride name" unless ride_list.has_key?(ref)
20
+ create_ride_object(ref)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,103 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'net/http'
4
+ require 'net/https'
5
+ require 'zip/zip'
6
+
7
+ module Echelon
8
+ class DisneylandParis < Park
9
+
10
+ attr_reader :json_data
11
+
12
+ def ride_list
13
+ {
14
+ 'P1AA01' => 'La Cabane des Robinson',
15
+ 'P1AA02' => 'Indiana Jones and the Temple of Peril',
16
+ 'P1AA04' => 'Pirates of the Caribbean',
17
+ 'P1DA03' => 'Autopia',
18
+ 'P1DA04' => 'Buzz Lightyear Laser Blast',
19
+ 'P1DA06' => 'Les Mystères du Nautilus',
20
+ 'P1DA07' => 'Orbitron',
21
+ 'P1DA08' => 'Space Mountain: Mission 2',
22
+ 'P1DA09' => 'Star Tours',
23
+ 'P1DA12' => 'Captain EO',
24
+ 'P1NA00' => 'Alice\'s Curious Labyrinth',
25
+ 'P1NA01' => 'Blanche-Neige et les Sept Nains',
26
+ 'P1NA02' => 'Le Carrousel de Lancelot',
27
+ 'P1NA03' => 'Casey Jr. - le Petit Train du Cirque',
28
+ 'P1NA05' => 'Dumbo the Flying Elephant',
29
+ 'P1NA07' => '"it\'s a small world" Celebration',
30
+ 'P1NA08' => 'Mad Hatter\'s Tea Cups',
31
+ 'P1NA09' => 'Le Pays des Contes de Fées',
32
+ 'P1NA10' => 'Peter Pan\'s Flight',
33
+ 'P1NA13' => 'Les Voyages de Pinocchio',
34
+ 'P1RA00' => 'Big Thunder Mountain',
35
+ 'P1RA03' => 'Phantom Manor',
36
+ 'P1RA04' => 'River Rogue Keelboats',
37
+ 'P2XA00' => 'Studio Tram Tour: Behind the Magic',
38
+ 'P2XA01' => 'CinéMagique',
39
+ 'P2XA02' => 'Cars Quatre Roues Rallye',
40
+ 'P2XA03' => 'Crush\'s Coaster',
41
+ 'P2XA05' => 'Flying Carpets Over Agrabah',
42
+ 'P2XA06' => 'RC Racer',
43
+ 'P2XA07' => 'Toy Soldiers Parachute Drop',
44
+ 'P2XA08' => 'Slinky Dog Zigzag Spin',
45
+ 'P2ZA00' => 'Armageddon : les Effets Spéciaux',
46
+ 'P2ZA01' => 'Rock\'n\'Roller Coaster starring Aerosmith',
47
+ 'P2ZA02' => 'The Twilight Zone Tower of Terror'
48
+ }
49
+ end
50
+
51
+ def initialize
52
+ # fetch the zipped json feed from the same url as the disney iphone app
53
+ # (you have no idea how long this took to work out)
54
+
55
+ http = Net::HTTP.new('disney.cms.pureagency.com', 443)
56
+ http.use_ssl = true
57
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
58
+
59
+ data = 'key=Ajjjsh;Uj'
60
+ headers = {
61
+ 'User-Agent' => 'Disneyland 1.0 (iPhone; iPhone OS 4.1; en_GB)',
62
+ 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
63
+ }
64
+ resp, data = http.post('/cms/ProxyTempsAttente', data, headers)
65
+
66
+ tmp = Tempfile.new('disneyland_paris_zip')
67
+ tmp << resp.body
68
+ tmp.close
69
+
70
+ json_data = nil
71
+ Zip::ZipFile.open(tmp.path) { |zipfile|
72
+ json_data = JSON.parse(zipfile.read("temps_attente.json"))
73
+ json_data = json_data["l"]
74
+ }
75
+
76
+ i = 0
77
+ rides = []
78
+ while i < json_data.count
79
+ ride = []
80
+ ride << json_data[i]
81
+ ride << json_data[i + 1]
82
+ ride << json_data[i + 2]
83
+ ride << json_data[i + 3]
84
+ ride << json_data[i + 4]
85
+ rides << ride
86
+ i += 5
87
+ end
88
+
89
+ @json_data = rides
90
+ end
91
+
92
+ private
93
+
94
+ def create_ride_object(ref)
95
+ self.json_data.each do |ride|
96
+ if ride[0] == ref
97
+ return Ride.new(:name => self.ride_list[ref], :queue_time => ride[4].to_i, :active => ride[3].to_i)
98
+ end
99
+ end
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'net/http'
4
+
5
+ module Echelon
6
+ class ThorpePark < Park
7
+
8
+ attr_reader :json_data
9
+
10
+ def ride_list
11
+ {
12
+ 1 => 'SAW - The Ride',
13
+ 3 => 'Stealth',
14
+ 4 => 'Colossus',
15
+ 5 => 'Detonator',
16
+ 6 => 'Nemesis Inferno',
17
+ 7 => 'Rush',
18
+ 8 => 'Samurai',
19
+ 9 => 'Slammer',
20
+ 10 => 'Tidal Wave',
21
+ 11 => 'Vortex',
22
+ 12 => 'X:\No Way Out',
23
+ 13 => 'Time Voyagers',
24
+ 14 => 'Quantum',
25
+ 15 => 'Loggers Leap',
26
+ 16 => 'Flying Fish',
27
+ 17 => 'Rumba Rapids',
28
+ 18 => 'Zodiac',
29
+ 19 => 'Depth Charge',
30
+ 20 => 'SAW Alive',
31
+ 21 => 'Mr. Monkey\'s Banana Ride',
32
+ 22 => 'Storm in a Teacup',
33
+ 23 => 'Rocky Express',
34
+ 24 => 'Wet Wet Wet',
35
+ 25 => 'Neptune\'s Beach',
36
+ 26 => 'Chief Ranger\'s Carousel'
37
+ }
38
+ end
39
+
40
+ def initialize
41
+ # fetch the json feed from the merlin site
42
+ url = "http://www.merlincms.com/1.php"
43
+ resp = Net::HTTP.get_response(URI.parse(url))
44
+ data = resp.body
45
+
46
+ # were only interested in the ride data, throw everything else away
47
+ json_data = JSON.parse(data)
48
+ @json_data = json_data["Rides"]
49
+ end
50
+
51
+ private
52
+
53
+ def create_ride_object(ref)
54
+ self.json_data.each do |ride|
55
+ if ride["ref"].to_i == ref
56
+ return Ride.new(:name => self.ride_list[ref], :queue_time => ride["queue"].to_i, :active => ride["active"].to_i)
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ module Echelon
2
+ VERSION = '0.0.3'
3
+ end
data/lib/echelon.rb CHANGED
@@ -2,9 +2,10 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  require "#{File.dirname(__FILE__)}/echelon/ride.rb"
5
- require "#{File.dirname(__FILE__)}/echelon/thorpe_park.rb"
6
- require "#{File.dirname(__FILE__)}/echelon/disneyland_paris.rb"
5
+ require "#{File.dirname(__FILE__)}/echelon/park.rb"
6
+
7
+ require "#{File.dirname(__FILE__)}/echelon/parks/thorpe_park.rb"
8
+ require "#{File.dirname(__FILE__)}/echelon/parks/disneyland_paris.rb"
7
9
 
8
10
  module Echelon
9
- VERSION = '0.0.2'
10
11
  end
@@ -0,0 +1,34 @@
1
+ require 'echelon/park'
2
+ require 'echelon/parks/disneyland_paris'
3
+
4
+ # Mosts of the test here are pretty generic, although you can test for specific
5
+ # cases, such as the active states may differ between parks, and queue times may
6
+ # not exceed a certain value etc etc.
7
+
8
+ describe Echelon::DisneylandParis do
9
+
10
+ before do
11
+ @park = Echelon::DisneylandParis.new()
12
+ end
13
+
14
+ it "should inherit from Park" do
15
+ @park.should be_kind_of(Echelon::DisneylandParis)
16
+ end
17
+
18
+ it "should have some rides" do
19
+ @park.ride_list.count.should satisfy { |v| v > 1 && v < 40 }
20
+ end
21
+
22
+ it "should return ride objects" do
23
+ @park.find_by_name("Pirates of the Caribbean").should be_kind_of(Echelon::Ride)
24
+ @park.find_by_id('P1AA04').should be_kind_of(Echelon::Ride)
25
+ end
26
+
27
+ it "should return ride object values correctly" do
28
+ stealth = @park.find_by_id("P1AA04")
29
+ stealth.name.should eql("Pirates of the Caribbean")
30
+ stealth.queue_time.should satisfy { |v| v >= 0 && v < 500 }
31
+ stealth.active.should satisfy { |v| v >= -1 && v < 3 }
32
+ end
33
+
34
+ end
@@ -0,0 +1,54 @@
1
+ require 'echelon/ride'
2
+ require 'echelon/park'
3
+
4
+ describe Echelon::Ride do
5
+
6
+ before do
7
+ @ride = Echelon::Ride.new(:name => 'Ride', :queue_time => 10, :active => 1)
8
+ end
9
+
10
+ it "should return the name of the ride" do
11
+ @ride.name.should eql('Ride')
12
+ end
13
+
14
+ it "should return the queue time" do
15
+ @ride.queue_time.should eql(10)
16
+ end
17
+
18
+ it "should return the ride status" do
19
+ @ride.active.should eql(1)
20
+ end
21
+
22
+ end
23
+
24
+ describe Echelon::Park do
25
+
26
+ before do
27
+ @park = Echelon::Park.new
28
+ end
29
+
30
+ it "should provide a set of methods" do
31
+ @park.should respond_to(:ride_list)
32
+ @park.should respond_to(:rides)
33
+ @park.should respond_to(:find_by_name)
34
+ @park.should respond_to(:find_by_id)
35
+ end
36
+
37
+ it "should contain a blank ride list" do
38
+ @park.ride_list.should eql({})
39
+ @park.rides.should eql([])
40
+ end
41
+
42
+ describe 'find_by_name' do
43
+ it "should raise if ride isn't available" do
44
+ lambda { @park.find_by_name('Unknown Ride') }.should raise_error(ArgumentError)
45
+ end
46
+ end
47
+
48
+ describe 'find_by_id' do
49
+ it "should raise if ride isn't available" do
50
+ lambda { @park.find_by_id(1) }.should raise_error(ArgumentError)
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,34 @@
1
+ require 'echelon/park'
2
+ require 'echelon/parks/thorpe_park'
3
+
4
+ # Mosts of the test here are pretty generic, although you can test for specific
5
+ # cases, such as the active states may differ between parks, and queue times may
6
+ # not exceed a certain value etc etc.
7
+
8
+ describe Echelon::ThorpePark do
9
+
10
+ before do
11
+ @park = Echelon::ThorpePark.new()
12
+ end
13
+
14
+ it "should inherit from Park" do
15
+ @park.should be_kind_of(Echelon::ThorpePark)
16
+ end
17
+
18
+ it "should have some rides" do
19
+ @park.ride_list.count.should satisfy { |v| v > 1 && v < 30 }
20
+ end
21
+
22
+ it "should return ride objects" do
23
+ @park.find_by_name("Stealth").should be_kind_of(Echelon::Ride)
24
+ @park.find_by_id(3).should be_kind_of(Echelon::Ride)
25
+ end
26
+
27
+ it "should return ride object values correctly" do
28
+ stealth = @park.find_by_id(3)
29
+ stealth.name.should eql("Stealth")
30
+ stealth.queue_time.should satisfy { |v| v >= 0 && v < 1000 }
31
+ stealth.active.should satisfy { |v| v == 0 || v == 1 }
32
+ end
33
+
34
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: echelon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: 25
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lloyd Pick
@@ -15,86 +15,107 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-27 00:00:00 +00:00
18
+ date: 2011-01-11 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: json_pure
22
+ name: bundler
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 11
29
+ hash: 23
30
30
  segments:
31
31
  - 1
32
- - 4
33
- - 6
34
- version: 1.4.6
35
- type: :runtime
32
+ - 0
33
+ - 0
34
+ version: 1.0.0
35
+ type: :development
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: rubyforge
38
+ name: rspec
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 7
45
+ hash: 31
46
46
  segments:
47
47
  - 2
48
- - 0
49
48
  - 4
50
- version: 2.0.4
49
+ - 0
50
+ version: 2.4.0
51
51
  type: :development
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- name: hoe
54
+ name: json_pure
55
55
  prerelease: false
56
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ">="
59
+ - - "="
60
60
  - !ruby/object:Gem::Version
61
- hash: 19
61
+ hash: 11
62
+ segments:
63
+ - 1
64
+ - 4
65
+ - 6
66
+ version: 1.4.6
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: zip
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - "="
76
+ - !ruby/object:Gem::Version
77
+ hash: 11
62
78
  segments:
63
79
  - 2
64
- - 7
65
80
  - 0
66
- version: 2.7.0
67
- type: :development
68
- version_requirements: *id003
69
- description: RubyGem to give quick access to Theme Park queue times
81
+ - 2
82
+ version: 2.0.2
83
+ type: :runtime
84
+ version_requirements: *id004
85
+ description: RubyGem to give quick access to Theme Park queue times (Disneyland Paris and Thorpe Park supported)
70
86
  email:
71
87
  - lloydpick@gmail.com
72
88
  executables: []
73
89
 
74
90
  extensions: []
75
91
 
76
- extra_rdoc_files:
77
- - History.txt
78
- - Manifest.txt
92
+ extra_rdoc_files: []
93
+
79
94
  files:
95
+ - .gitignore
96
+ - Gemfile
97
+ - Gemfile.lock
80
98
  - History.txt
81
99
  - Manifest.txt
82
100
  - README.rdoc
83
101
  - Rakefile
102
+ - echelon.gemspec
84
103
  - lib/echelon.rb
104
+ - lib/echelon/park.rb
105
+ - lib/echelon/parks/disneyland_paris.rb
106
+ - lib/echelon/parks/thorpe_park.rb
85
107
  - lib/echelon/ride.rb
86
- - lib/echelon/thorpe_park.rb
87
- - lib/echelon/disneyland_paris.rb
88
- - test/test_echelon.rb
89
- - test/test_helper.rb
108
+ - lib/echelon/version.rb
109
+ - spec/disneyland_paris_spec.rb
110
+ - spec/echelon_spec.rb
111
+ - spec/thorpe_park_spec.rb
90
112
  has_rdoc: true
91
113
  homepage: http://github.com/lloydpick/echelon
92
114
  licenses: []
93
115
 
94
116
  post_install_message:
95
- rdoc_options:
96
- - --main
97
- - README.rdoc
117
+ rdoc_options: []
118
+
98
119
  require_paths:
99
120
  - lib
100
121
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -111,17 +132,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
132
  requirements:
112
133
  - - ">="
113
134
  - !ruby/object:Gem::Version
114
- hash: 3
135
+ hash: 23
115
136
  segments:
116
- - 0
117
- version: "0"
137
+ - 1
138
+ - 3
139
+ - 6
140
+ version: 1.3.6
118
141
  requirements: []
119
142
 
120
143
  rubyforge_project: echelon
121
- rubygems_version: 1.3.7
144
+ rubygems_version: 1.4.1
122
145
  signing_key:
123
146
  specification_version: 3
124
147
  summary: RubyGem to give quick access to Theme Park queue times
125
- test_files:
126
- - test/test_helper.rb
127
- - test/test_echelon.rb
148
+ test_files: []
149
+
@@ -1,118 +0,0 @@
1
- require 'rubygems'
2
- require 'json'
3
- require 'net/http'
4
- require 'net/https'
5
- require 'zip/zip'
6
-
7
- module Echelon
8
- class DisneylandParis
9
-
10
- attr_reader :json_data
11
-
12
- RIDES = {
13
- 'P1AA01' => 'La Cabane des Robinson',
14
- 'P1AA02' => 'Indiana Jones and the Temple of Peril',
15
- 'P1AA04' => 'Pirates of the Caribbean',
16
- 'P1DA03' => 'Autopia',
17
- 'P1DA04' => 'Buzz Lightyear Laser Blast',
18
- 'P1DA06' => 'Les Mystères du Nautilus',
19
- 'P1DA07' => 'Orbitron',
20
- 'P1DA08' => 'Space Mountain: Mission 2',
21
- 'P1DA09' => 'Star Tours',
22
- 'P1DA12' => 'Captain EO',
23
- 'P1NA00' => 'Alice\'s Curious Labyrinth',
24
- 'P1NA01' => 'Blanche-Neige et les Sept Nains',
25
- 'P1NA02' => 'Le Carrousel de Lancelot',
26
- 'P1NA03' => 'Casey Jr. - le Petit Train du Cirque',
27
- 'P1NA05' => 'Dumbo the Flying Elephant',
28
- 'P1NA07' => '"it\'s a small world" Celebration',
29
- 'P1NA08' => 'Mad Hatter\'s Tea Cups',
30
- 'P1NA09' => 'Le Pays des Contes de Fées',
31
- 'P1NA10' => 'Peter Pan\'s Flight',
32
- 'P1NA13' => 'Les Voyages de Pinocchio',
33
- 'P1RA00' => 'Big Thunder Mountain',
34
- 'P1RA03' => 'Phantom Manor',
35
- 'P1RA04' => 'River Rogue Keelboats',
36
- 'P2XA00' => 'Studio Tram Tour: Behind the Magic',
37
- 'P2XA01' => 'CinéMagique',
38
- 'P2XA02' => 'Cars Quatre Roues Rallye',
39
- 'P2XA03' => 'Crush\'s Coaster',
40
- 'P2XA05' => 'Flying Carpets Over Agrabah',
41
- 'P2XA06' => 'RC Racer',
42
- 'P2XA07' => 'Toy Soldiers Parachute Drop',
43
- 'P2XA08' => 'Slinky Dog Zigzag Spin',
44
- 'P2ZA00' => 'Armageddon : les Effets Spéciaux',
45
- 'P2ZA01' => 'Rock\'n\'Roller Coaster starring Aerosmith',
46
- 'P2ZA02' => 'The Twilight Zone Tower of Terror'
47
- }
48
-
49
- def initialize
50
- # fetch the zipped json feed from the same url as the disney iphone app
51
- # (you have no idea how long this took to work out)
52
-
53
- http = Net::HTTP.new('disney.cms.pureagency.com', 443)
54
- http.use_ssl = true
55
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
56
-
57
- data = 'key=Ajjjsh;Uj'
58
- headers = {
59
- 'User-Agent' => 'Disneyland 1.0 (iPhone; iPhone OS 4.1; en_GB)',
60
- 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
61
- }
62
- resp, data = http.post('/cms/ProxyTempsAttente', data, headers)
63
-
64
- tmp = Tempfile.new('disneyland_paris_zip')
65
- tmp << resp.body
66
- tmp.close
67
-
68
- json_data = nil
69
- Zip::ZipFile.open(tmp.path) { |zipfile|
70
- json_data = JSON.parse(zipfile.read("temps_attente.json"))
71
- json_data = json_data["l"]
72
- }
73
-
74
- i = 0
75
- rides = []
76
- while i < json_data.count
77
- ride = []
78
- ride << json_data[i]
79
- ride << json_data[i + 1]
80
- ride << json_data[i + 2]
81
- ride << json_data[i + 3]
82
- ride << json_data[i + 4]
83
- rides << ride
84
- i += 5
85
- end
86
-
87
- @json_data = rides
88
- end
89
-
90
- def rides
91
- all_rides = []
92
- RIDES.each do |ride| all_rides << create_ride_object(ride[0]) end
93
- all_rides
94
- end
95
-
96
- def find_by_name(ride)
97
- raise ArgumentError, "Unknown ride name" unless RIDES.has_value?(ride)
98
- ref = RIDES.index(ride)
99
- create_ride_object(ref)
100
- end
101
-
102
- def find_by_id(ref)
103
- raise ArgumentError, "Unknown ride name" unless RIDES.has_key?(ref)
104
- create_ride_object(ref)
105
- end
106
-
107
- private
108
-
109
- def create_ride_object(ref)
110
- self.json_data.each do |ride|
111
- if ride[0] == ref
112
- return Ride.new(:name => RIDES[ref], :queue_time => ride[4].to_i, :active => ride[3].to_i)
113
- end
114
- end
115
- end
116
-
117
- end
118
- end
@@ -1,77 +0,0 @@
1
- require 'rubygems'
2
- require 'json'
3
- require 'net/http'
4
-
5
- module Echelon
6
- class ThorpePark
7
-
8
- attr_reader :json_data
9
-
10
- RIDES = {
11
- 1 => 'SAW - The Ride',
12
- 3 => 'Stealth',
13
- 4 => 'Colossus',
14
- 5 => 'Detonator',
15
- 6 => 'Nemesis Inferno',
16
- 7 => 'Rush',
17
- 8 => 'Samurai',
18
- 9 => 'Slammer',
19
- 10 => 'Tidal Wave',
20
- 11 => 'Vortex',
21
- 12 => 'X:\No Way Out',
22
- 13 => 'Time Voyagers',
23
- 14 => 'Quantum',
24
- 15 => 'Loggers Leap',
25
- 16 => 'Flying Fish',
26
- 17 => 'Rumba Rapids',
27
- 18 => 'Zodiac',
28
- 19 => 'Depth Charge',
29
- 20 => 'SAW Alive',
30
- 21 => 'Mr. Monkey\'s Banana Ride',
31
- 22 => 'Storm in a Teacup',
32
- 23 => 'Rocky Express',
33
- 24 => 'Wet Wet Wet',
34
- 25 => 'Neptune\'s Beach',
35
- 26 => 'Chief Ranger\'s Carousel'
36
- }
37
-
38
- def initialize
39
- # fetch the json feed from the merlin site
40
- url = "http://www.merlincms.com/1.php"
41
- resp = Net::HTTP.get_response(URI.parse(url))
42
- data = resp.body
43
-
44
- # were only interested in the ride data, throw everything else away
45
- json_data = JSON.parse(data)
46
- @json_data = json_data["Rides"]
47
- end
48
-
49
- def rides
50
- all_rides = []
51
- RIDES.each do |ride| all_rides << create_ride_object(ride[0]) end
52
- all_rides
53
- end
54
-
55
- def find_by_name(ride)
56
- raise ArgumentError, "Unknown ride name" unless RIDES.has_value?(ride)
57
- ref = RIDES.index(ride)
58
- create_ride_object(ref)
59
- end
60
-
61
- def find_by_id(ref)
62
- raise ArgumentError, "Unknown ride name" unless RIDES.has_key?(ref)
63
- create_ride_object(ref)
64
- end
65
-
66
- private
67
-
68
- def create_ride_object(ref)
69
- self.json_data.each do |ride|
70
- if ride["ref"].to_i == ref
71
- return Ride.new(:name => RIDES[ref], :queue_time => ride["queue"].to_i, :active => ride["active"].to_i)
72
- end
73
- end
74
- end
75
-
76
- end
77
- end
data/test/test_echelon.rb DELETED
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestEchelon < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def test_truth
9
- assert true
10
- end
11
- end
data/test/test_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'stringio'
2
- require 'test/unit'
3
- require File.dirname(__FILE__) + '/../lib/echelon'