echelon 0.0.1 → 0.0.2
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/History.txt +4 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +1 -0
- data/lib/echelon.rb +2 -1
- data/lib/echelon/disneyland_paris.rb +118 -0
- metadata +8 -7
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
data/lib/echelon.rb
CHANGED
@@ -3,7 +3,8 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
3
3
|
|
4
4
|
require "#{File.dirname(__FILE__)}/echelon/ride.rb"
|
5
5
|
require "#{File.dirname(__FILE__)}/echelon/thorpe_park.rb"
|
6
|
+
require "#{File.dirname(__FILE__)}/echelon/disneyland_paris.rb"
|
6
7
|
|
7
8
|
module Echelon
|
8
|
-
VERSION = '0.0.
|
9
|
+
VERSION = '0.0.2'
|
9
10
|
end
|
@@ -0,0 +1,118 @@
|
|
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
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lloyd Pick
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-27 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -61,9 +61,9 @@ dependencies:
|
|
61
61
|
hash: 19
|
62
62
|
segments:
|
63
63
|
- 2
|
64
|
-
-
|
65
|
-
-
|
66
|
-
version: 2.
|
64
|
+
- 7
|
65
|
+
- 0
|
66
|
+
version: 2.7.0
|
67
67
|
type: :development
|
68
68
|
version_requirements: *id003
|
69
69
|
description: RubyGem to give quick access to Theme Park queue times
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/echelon.rb
|
85
85
|
- lib/echelon/ride.rb
|
86
86
|
- lib/echelon/thorpe_park.rb
|
87
|
+
- lib/echelon/disneyland_paris.rb
|
87
88
|
- test/test_echelon.rb
|
88
89
|
- test/test_helper.rb
|
89
90
|
has_rdoc: true
|