echelon 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db14024c0e3222ac1c609300cbae0f50b895aa5c
4
- data.tar.gz: a6862271c7b5f01885e74d3bb5f2e6a79d3ed22b
3
+ metadata.gz: 789453d3c1948d753eb0f627a6363aa148a39cb8
4
+ data.tar.gz: ba0f22e5483e7831ccd493e26d593ee81c39fa91
5
5
  SHA512:
6
- metadata.gz: 6e40449b0b6d65d6f737378f0348d828cc63466af9e2a5a050ce9a36d5f5adedcfeba78de2761967d906541cf91dcf1ec8b18e5397d3d41eba691a82a18fae70
7
- data.tar.gz: f309887fde0eede1b840699ee106eb4d9949806b97104fb7501d4d5b31e84d7e8739ff0ec98e33ed003f1cf641a58875d5992bca9222968bb9363376c42a1dd9
6
+ metadata.gz: dc3524b85a8dc6b557193ab299b541e485c7e52cf67317d1732afa53706460a461d80738587cce68ce655e092dba348c9c5a53474aaa22b0f9ab9e1f47a5e37b
7
+ data.tar.gz: 5777892598010cd75ed452bc14296c8868478831967197f3d6756d2aac074ea85e5d03e98a0f3de55cc25a9a78d829eed87595a50ad07bfa663e8d8c90c2b2b7
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.1.2
data/Gemfile CHANGED
@@ -4,6 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- # for travis-ci.org
8
- gem "rake"
9
- end
7
+ gem 'rake'
8
+ end
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- echelon (1.0.2)
5
- json_pure (= 1.4.6)
4
+ echelon (1.0.4)
5
+ json_pure (= 1.8.1)
6
6
  nokogiri (~> 1.5)
7
7
  zip (= 2.0.2)
8
8
 
@@ -10,10 +10,10 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  diff-lcs (1.1.2)
13
- json_pure (1.4.6)
14
- mini_portile (0.5.2)
15
- nokogiri (1.6.1)
16
- mini_portile (~> 0.5.0)
13
+ json_pure (1.8.1)
14
+ mini_portile (0.6.1)
15
+ nokogiri (1.6.5)
16
+ mini_portile (~> 0.6.0)
17
17
  rake (0.9.2.2)
18
18
  rspec (2.4.0)
19
19
  rspec-core (~> 2.4.0)
@@ -32,12 +32,14 @@ Currently only the following parks are supported...
32
32
  * Seaworld Orlando
33
33
  * Seaworld San Antonio
34
34
  * Seaworld San Diego
35
+ * Universal Studios Orlando
36
+ * Universal Studios Islands of Adventure
35
37
 
36
38
 
37
39
  == SYNOPSIS:
38
40
 
39
41
  require 'echelon'
40
- seaworld = Echelon::Seaworld::SanAntonio.new()
42
+ seaworld = Echelon::Seaworld::SanAntonio.new
41
43
  seaworld.find_by_name("Steel Eel")
42
44
  => #<Echelon::Ride:0xb7179ca8 @updated_at=#<DateTime>, @name="Steel Eel", @active=1, @queue_time=30>
43
45
  seaworld.rides
@@ -52,27 +54,32 @@ Currently only the following parks are supported...
52
54
  == PARK LISTS
53
55
 
54
56
  # Seaworld
55
- Echelon::Seaworld::SanAntonio.new()
56
- Echelon::Seaworld::Orlando.new()
57
- Echelon::Seaworld::SanDiego.new()
58
-
57
+ Echelon::Seaworld::SanAntonio.new
58
+ Echelon::Seaworld::Orlando.new
59
+ Echelon::Seaworld::SanDiego.new
60
+
59
61
  # Disney World
60
- wdw = Echelon::DisneyWorld.new()
62
+ wdw = Echelon::DisneyWorld.new
61
63
  wdw.animal_kingdom
62
64
  wdw.epcot
63
65
  wdw.hollywood_studios
64
66
  wdw.magic_kingdom
65
67
 
66
68
  # Disneyland California
67
- Echelon::Disneyland::Disneyland.new()
68
- Echelon::Disneyland::CaliforniaAdventure.new()
69
-
69
+ Echelon::Disneyland::Disneyland.new
70
+ Echelon::Disneyland::CaliforniaAdventure.new
71
+
70
72
  # Disneyland Paris
71
- Echelon::DisneylandParis.new()
73
+ Echelon::DisneylandParis.new
72
74
 
73
75
  # UK Parks
74
- Echelon::AltonTowers.new()
75
- Echelon::ThorpePark.new()
76
+ Echelon::AltonTowers.new
77
+ Echelon::ThorpePark.new
78
+
79
+ # Universal Studios Orlando Resort
80
+ uo = Echelon::UniversalStudiosOrlando.new
81
+ uo.islands_of_adventure.rides
82
+ uo.universal_studios.rides
76
83
 
77
84
  == INSTALL:
78
85
 
@@ -82,7 +89,7 @@ Currently only the following parks are supported...
82
89
 
83
90
  (The MIT License)
84
91
 
85
- Copyright (c) 2010-2014 Lloyd Pick
92
+ Copyright (c) 2010-2015 Lloyd Pick
86
93
 
87
94
  Permission is hereby granted, free of charge, to any person obtaining
88
95
  a copy of this software and associated documentation files (the
@@ -101,4 +108,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
101
108
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
102
109
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
103
110
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
104
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
111
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
1
  require 'bundler'
2
- Bundler::GemHelper.install_tasks
2
+ Bundler::GemHelper.install_tasks
@@ -1,28 +1,28 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- require File.expand_path("../lib/echelon/version", __FILE__)
3
+ require File.expand_path('../lib/echelon/version', __FILE__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "echelon"
6
+ s.name = 'echelon'
7
7
  s.version = Echelon::VERSION
8
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 (Alton Towers, Disney World Animal Kingdom, Disney World Epcot, Disney World Hollywood Studios, Disney World Magic Kingdom, Disneyland, Disneyland California Adventure, Disneyland Paris, Seaworld San Antonio, Seaworld San Diego, Seaworld Orlando, Thorpe Park)"
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 (Alton Towers, Disney World Animal Kingdom, Disney World Epcot, Disney World Hollywood Studios, Disney World Magic Kingdom, Disneyland, Disneyland California Adventure, Disneyland Paris, Seaworld San Antonio, Seaworld San Diego, Seaworld Orlando, Thorpe Park)'
14
14
 
15
- s.required_rubygems_version = ">= 1.3.6"
16
- s.rubyforge_project = "echelon"
15
+ s.required_rubygems_version = '>= 1.3.6'
16
+ s.rubyforge_project = 'echelon'
17
17
 
18
- s.add_development_dependency "bundler", ">= 1.0.0"
19
- s.add_development_dependency "rspec", ">= 2.4.0"
18
+ s.add_development_dependency 'bundler', '>= 1.0.0'
19
+ s.add_development_dependency 'rspec', '>= 2.4.0'
20
20
 
21
- s.add_dependency "json_pure", "1.4.6"
22
- s.add_dependency "zip", "2.0.2"
23
- s.add_dependency "nokogiri", "~> 1.5"
21
+ s.add_dependency 'json_pure', '1.8.1'
22
+ s.add_dependency 'zip', '2.0.2'
23
+ s.add_dependency 'nokogiri', '~> 1.5'
24
24
 
25
25
  s.files = `git ls-files`.split("\n")
26
- s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
26
+ s.executables = `git ls-files`.split("\n").map { |f| f =~ /^bin\/(.*)/ ? $1 : nil }.compact
27
27
  s.require_path = 'lib'
28
- end
28
+ end
@@ -15,10 +15,6 @@ require "#{File.dirname(__FILE__)}/echelon/parks/seaworld/orlando.rb"
15
15
 
16
16
  # Disney World Resort
17
17
  require "#{File.dirname(__FILE__)}/echelon/parks/disney_world.rb"
18
- # require "#{File.dirname(__FILE__)}/echelon/parks/disney_world/magic_kingdom.rb"
19
- # require "#{File.dirname(__FILE__)}/echelon/parks/disney_world/epcot.rb"
20
- # require "#{File.dirname(__FILE__)}/echelon/parks/disney_world/hollywood_studios.rb"
21
- # require "#{File.dirname(__FILE__)}/echelon/parks/disney_world/animal_kingdom.rb"
22
18
 
23
19
  # Disneyland Resort California
24
20
  require "#{File.dirname(__FILE__)}/echelon/parks/disneyland/disneyland.rb"
@@ -27,10 +23,11 @@ require "#{File.dirname(__FILE__)}/echelon/parks/disneyland/california_adventure
27
23
  # Disneyland Resort Paris
28
24
  require "#{File.dirname(__FILE__)}/echelon/parks/disneyland_paris.rb"
29
25
 
26
+ # Universal Studios Orlando Resort
27
+ require "#{File.dirname(__FILE__)}/echelon/parks/universal_studios_orlando.rb"
28
+
30
29
  module Echelon
31
-
32
30
  def self.parameterize(params)
33
- URI.escape(params.collect{|k,v| "#{k}=#{v}"}.join('&'))
31
+ URI.escape(params.collect { |k, v| "#{k}=#{v}" }.join('&'))
34
32
  end
35
-
36
- end
33
+ end
@@ -1,24 +1,22 @@
1
1
  module Echelon
2
2
  class Park
3
-
4
3
  def ride_list
5
4
  {}
6
5
  end
7
6
 
8
7
  def rides
9
- ride_list.inject([]) do |r, e| r << create_ride_object(e[0]) end
8
+ ride_list.inject([]) { |a, e| a << create_ride_object(e[0]) }
10
9
  end
11
10
 
12
11
  def find_by_name(ride)
13
- raise ArgumentError, "Unknown ride name" unless ride_list.has_value?(ride)
12
+ fail ArgumentError, 'Unknown ride name' unless ride_list.value?(ride)
14
13
  ref = ride_list.respond_to?(:key) ? ride_list.key(ride) : ride_list.index(ride)
15
14
  create_ride_object(ref)
16
15
  end
17
16
 
18
17
  def find_by_id(ref)
19
- raise ArgumentError, "Unknown ride name" unless ride_list.has_key?(ref)
18
+ fail ArgumentError, 'Unknown ride name' unless ride_list.key?(ref)
20
19
  create_ride_object(ref)
21
20
  end
22
-
23
21
  end
24
- end
22
+ end
@@ -24,24 +24,23 @@ module Echelon
24
24
 
25
25
  def initialize
26
26
  # fetch the json feed from the merlin site
27
- url = "http://www.merlincms.com/2.php"
27
+ url = 'http://www.merlincms.com/2.php'
28
28
  resp = Net::HTTP.get_response(URI.parse(url))
29
29
  data = resp.body
30
30
 
31
31
  # were only interested in the ride data, throw everything else away
32
32
  json_data = JSON.parse(data)
33
- @json_data = json_data["Rides"]
33
+ @json_data = json_data['Rides']
34
34
  end
35
35
 
36
36
  private
37
37
 
38
38
  def create_ride_object(ref)
39
- self.json_data.each do |ride|
40
- if ride["ref"].to_i == ref
41
- return Ride.new(:name => self.ride_list[ref], :queue_time => ride["queue"].to_i, :active => ride["active"].to_i)
39
+ json_data.each do |ride|
40
+ if ride['ref'].to_i == ref
41
+ return Ride.new(name: ride_list[ref], queue_time: ride['queue'].to_i, active: ride['active'].to_i)
42
42
  end
43
43
  end
44
44
  end
45
-
46
45
  end
47
- end
46
+ end
@@ -5,118 +5,112 @@ require 'net/https'
5
5
 
6
6
  module Echelon
7
7
  class DisneyWorld
8
-
8
+
9
9
  attr_reader :access_token, :expires_at
10
-
10
+
11
11
  def initialize
12
-
13
- uri = URI.parse("https://authorization.go.com/token")
12
+ uri = URI.parse('https://authorization.go.com/token')
14
13
  http = Net::HTTP.new(uri.host, uri.port)
15
14
  http.use_ssl = true
16
15
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
17
-
18
- params = Echelon::parameterize({ grant_type: 'assertion', assertion_type: 'public', client_id: 'WDPRO-MOBILE.CLIENT-PROD' })
16
+
17
+ params = Echelon::parameterize(grant_type: 'assertion', assertion_type: 'public', client_id: 'WDPRO-MOBILE.CLIENT-PROD')
19
18
  resp = http.post(uri.request_uri, params)
20
-
19
+
21
20
  data = JSON.parse(resp.body)
22
21
  @access_token = data['access_token']
23
22
  @expires_at = Time.now.to_i + data['expires_in'].to_i
24
-
25
23
  end
26
-
24
+
27
25
  def animal_kingdom
28
- @animal_kingdom ||= DisneyWorld::AnimalKingdom.new(self.access_token)
26
+ @animal_kingdom ||= DisneyWorld::AnimalKingdom.new(access_token)
29
27
  end
30
-
28
+
31
29
  def magic_kingdom
32
- @magic_kingdom ||= DisneyWorld::MagicKingdom.new(self.access_token)
30
+ @magic_kingdom ||= DisneyWorld::MagicKingdom.new(access_token)
33
31
  end
34
-
32
+
35
33
  def hollywood_studios
36
- @hollywood_studios ||= DisneyWorld::HollywoodStudios.new(self.access_token)
34
+ @hollywood_studios ||= DisneyWorld::HollywoodStudios.new(access_token)
37
35
  end
38
-
36
+
39
37
  def epcot
40
- @epcot ||= DisneyWorld::Epcot.new(self.access_token)
38
+ @epcot ||= DisneyWorld::Epcot.new(access_token)
41
39
  end
42
-
40
+
43
41
  class Park < Echelon::Park
44
-
45
42
  attr_reader :json_data
46
-
43
+
47
44
  def ride_list
48
- self.json_data['entries'].inject({}) { |r,a| r[a['id'].split(';').first.to_i] = a['name']; r }
45
+ json_data['entries'].inject({}) { |a, r| a[r['id'].split(';').first.to_i] = r['name']; a }
49
46
  end
50
-
47
+
51
48
  def initialize(access_token, park_id)
52
-
53
49
  uri = URI.parse("https://api.wdpro.disney.go.com/facility-service/theme-parks/#{park_id};entityType=theme-park/wait-times")
54
50
  http = Net::HTTP.new(uri.host, uri.port)
55
51
  http.use_ssl = true
56
52
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
57
-
53
+
58
54
  headers = {
59
55
  'Authorization' => "BEARER #{access_token}",
60
56
  'Accept' => 'application/json;apiversion=1',
61
57
  'X-Conversation-Id' => '~WDPRO-MOBILE.CLIENT-PROD'
62
58
  }
63
-
59
+
64
60
  resp = http.get(uri.request_uri, headers)
65
61
  @json_data = JSON.parse(resp.body)
66
-
67
62
  end
68
-
63
+
69
64
  private
70
65
 
71
66
  def create_ride_object(ref)
72
- self.json_data['entries'].each do |ride|
67
+ json_data['entries'].each do |ride|
73
68
  if ride['id'].split(';').first.to_i == ref
74
-
69
+
75
70
  ride_status = ride['waitTime']['status']
76
71
  status = 1 if ride_status == 'Operating'
77
72
  status = 0 if ride_status == 'Closed'
78
73
  status = -1 if ride_status == 'Down'
79
-
80
- queue_times = {
74
+
75
+ queue_times = {
81
76
  actual: ride['waitTime']['actualWaitMinutes'].to_i,
82
77
  posted: ride['waitTime']['postedWaitMinutes'].to_i
83
78
  }
84
-
79
+
85
80
  meta = {
86
81
  fastpass_available: ride['waitTime']['fastPass']['available'],
87
82
  single_rider: ride['waitTime']['singleRider']
88
83
  }
89
-
90
- return Ride.new(:name => self.ride_list[ref], :queue_time => queue_times, :active => status, :meta => meta)
84
+
85
+ return Ride.new(name: ride_list[ref], queue_time: queue_times, active: status, meta: meta)
91
86
  end
92
87
  end
93
88
  end
94
-
89
+
95
90
  end
96
-
91
+
97
92
  class Epcot < Park
98
93
  def initialize(access_token)
99
- super(access_token, 80007838)
94
+ super(access_token, 80_007_838)
100
95
  end
101
96
  end
102
-
97
+
103
98
  class MagicKingdom < Park
104
99
  def initialize(access_token)
105
- super(access_token, 80007944)
100
+ super(access_token, 80_007_944)
106
101
  end
107
102
  end
108
-
103
+
109
104
  class HollywoodStudios < Park
110
105
  def initialize(access_token)
111
- super(access_token, 80007998)
106
+ super(access_token, 80_007_998)
112
107
  end
113
108
  end
114
-
109
+
115
110
  class AnimalKingdom < Park
116
111
  def initialize(access_token)
117
- super(access_token, 80007823)
112
+ super(access_token, 80_007_823)
118
113
  end
119
114
  end
120
-
121
115
  end
122
- end
116
+ end
@@ -5,36 +5,32 @@ require 'net/http'
5
5
  module Echelon
6
6
  module Disneyland
7
7
  class CaliforniaAdventure < Park
8
-
9
8
  attr_reader :json_data
10
9
 
11
10
  def ride_list
12
- self.json_data.keys.inject({}) { |r,k| r[k] = k; r }
11
+ json_data.keys.inject({}) { |a, e| a[e] = e; a }
13
12
  end
14
13
 
15
14
  def initialize
16
15
  # fetch the json feed
17
- url = "http://dparks.uiemedia.net/dmm_v2/jsondata/JsonUpdateData?version=14&p=336894"
16
+ url = 'http://dparks.uiemedia.net/dmm_v2/jsondata/JsonUpdateData?version=14&p=336894'
18
17
  resp = Net::HTTP.get_response(URI.parse(url))
19
18
  data = resp.body
20
19
 
21
20
  # were only interested in the ride data, throw everything else away
22
21
  json_data = JSON.parse(data)
23
- ride_data = json_data["attractions"]["homeLabels"]
24
- queue_data = json_data["attractions"]["homeValues"].map { |v| v.to_i }
25
- @json_data = json_data["attractions"]["homeLabels"].each_with_index.inject({}) { |r,i| r[i.first.gsub("\302\240",'')] = queue_data[i.last]; r }
22
+ ride_data = json_data['attractions']['homeLabels']
23
+ queue_data = json_data['attractions']['homeValues'].map(&:to_i)
24
+ @json_data = ride_data.each_with_index.inject({}) { |a, e| a[e.first.gsub("\302\240", '')] = queue_data[e.last]; a }
26
25
  end
27
26
 
28
27
  private
29
28
 
30
29
  def create_ride_object(ref)
31
- self.json_data.each do |ride|
32
- if ride[0] == ref
33
- return Ride.new(:name => ride[0], :queue_time => ride[1])
34
- end
30
+ json_data.each do |ride|
31
+ return Ride.new(name: ride[0], queue_time: ride[1]) if ride[0] == ref
35
32
  end
36
33
  end
37
-
38
34
  end
39
35
  end
40
- end
36
+ end
@@ -5,36 +5,32 @@ require 'net/http'
5
5
  module Echelon
6
6
  module Disneyland
7
7
  class Disneyland < Park
8
-
9
8
  attr_reader :json_data
10
9
 
11
10
  def ride_list
12
- self.json_data.keys.inject({}) { |r,k| r[k] = k; r }
11
+ json_data.keys.inject({}) { |a, e| a[e] = e; a }
13
12
  end
14
13
 
15
14
  def initialize
16
15
  # fetch the json feed
17
- url = "http://dparks.uiemedia.net/dmm_v2/jsondata/JsonUpdateData?version=14&p=330339"
16
+ url = 'http://dparks.uiemedia.net/dmm_v2/jsondata/JsonUpdateData?version=14&p=330339'
18
17
  resp = Net::HTTP.get_response(URI.parse(url))
19
18
  data = resp.body
20
19
 
21
20
  # were only interested in the ride data, throw everything else away
22
21
  json_data = JSON.parse(data)
23
- ride_data = json_data["attractions"]["homeLabels"]
24
- queue_data = json_data["attractions"]["homeValues"].map { |v| v.to_i }
25
- @json_data = json_data["attractions"]["homeLabels"].each_with_index.inject({}) { |r,i| r[i.first.gsub("\302\240",'')] = queue_data[i.last]; r }
22
+ ride_data = json_data['attractions']['homeLabels']
23
+ queue_data = json_data['attractions']['homeValues'].map(&:to_i)
24
+ @json_data = ride_data.each_with_index.inject({}) { |a, e| a[e.first.gsub("\302\240", '')] = queue_data[e.last]; a }
26
25
  end
27
26
 
28
27
  private
29
28
 
30
29
  def create_ride_object(ref)
31
- self.json_data.each do |ride|
32
- if ride[0] == ref
33
- return Ride.new(:name => ride[0], :queue_time => ride[1])
34
- end
30
+ json_data.each do |ride|
31
+ return Ride.new(name: ride[0], queue_time: ride[1]) if ride[0] == ref
35
32
  end
36
33
  end
37
-
38
34
  end
39
35
  end
40
- end
36
+ end
@@ -63,17 +63,17 @@ module Echelon
63
63
  'User-Agent' => 'Disneyland 1.0 (iPhone; iPhone OS 4.1; en_GB)',
64
64
  'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
65
65
  }
66
- resp, data = http.post('/cms/ProxyTempsAttente', data, headers)
66
+ resp, _data = http.post('/cms/ProxyTempsAttente', data, headers)
67
67
 
68
68
  tmp = Tempfile.new('disneyland_paris_zip')
69
69
  tmp << resp.body
70
70
  tmp.close
71
71
 
72
72
  json_data = nil
73
- Zip::ZipFile.open(tmp.path) { |zipfile|
74
- json_data = JSON.parse(zipfile.read("temps_attente.json"))
75
- json_data = json_data["l"]
76
- }
73
+ Zip::ZipFile.open(tmp.path) do |zipfile|
74
+ json_data = JSON.parse(zipfile.read('temps_attente.json'))
75
+ json_data = json_data['l']
76
+ end
77
77
 
78
78
  i = 0
79
79
  rides = []
@@ -94,12 +94,11 @@ module Echelon
94
94
  private
95
95
 
96
96
  def create_ride_object(ref)
97
- self.json_data.each do |ride|
97
+ json_data.each do |ride|
98
98
  if ride[0] == ref
99
- return Ride.new(:name => self.ride_list[ref], :queue_time => ride[4].to_i, :active => ride[3].to_i, :updated_at => DateTime.now)
99
+ return Ride.new(name: ride_list[ref], queue_time: ride[4].to_i, active: ride[3].to_i)
100
100
  end
101
101
  end
102
102
  end
103
-
104
103
  end
105
- end
104
+ end
@@ -31,7 +31,7 @@ module Echelon
31
31
  http = Net::HTTP.new('lab.defimobile.com', 443)
32
32
  http.use_ssl = true
33
33
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
34
- resp, data = http.get('/orlando/rides')
34
+ _resp, data = http.get('/orlando/rides')
35
35
 
36
36
  # were only interested in the ride data, throw everything else away
37
37
  xml_data = Nokogiri::HTML(data)
@@ -41,20 +41,20 @@ module Echelon
41
41
  private
42
42
 
43
43
  def create_ride_object(ref)
44
- self.xml_data.each do |ride|
44
+ xml_data.each do |ride|
45
45
  if ride.xpath('id').inner_text.to_i == ref
46
46
  active, queue_time = parse_wait_time(ride.xpath('waittime').inner_text)
47
47
  updated_at = DateTime.parse(ride.xpath('lastmodified').inner_text)
48
- return Ride.new(:name => self.ride_list[ref], :queue_time => queue_time, :active => active, :updated_at => updated_at)
48
+ return Ride.new(name: ride_list[ref], queue_time: queue_time, active: active, updated_at: updated_at)
49
49
  end
50
50
  end
51
51
  end
52
52
 
53
53
  def parse_wait_time(wait)
54
- if wait == "Closed"
54
+ if wait == 'Closed'
55
55
  queue_time = 0
56
56
  active = 0
57
- elsif wait == "No Wait"
57
+ elsif wait == 'No Wait'
58
58
  queue_time = 0
59
59
  active = 1
60
60
  elsif wait =~ /(\d*) min/
@@ -64,8 +64,9 @@ module Echelon
64
64
  queue_time = 0
65
65
  active = 0
66
66
  end
67
+
67
68
  return active, queue_time
68
69
  end
69
70
  end
70
71
  end
71
- end
72
+ end
@@ -26,7 +26,7 @@ module Echelon
26
26
  http = Net::HTTP.new('lab.defimobile.com', 443)
27
27
  http.use_ssl = true
28
28
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
29
- resp, data = http.get('/seaworld/rides')
29
+ _resp, data = http.get('/seaworld/rides')
30
30
 
31
31
  # were only interested in the ride data, throw everything else away
32
32
  xml_data = Nokogiri::HTML(data)
@@ -36,20 +36,20 @@ module Echelon
36
36
  private
37
37
 
38
38
  def create_ride_object(ref)
39
- self.xml_data.each do |ride|
39
+ xml_data.each do |ride|
40
40
  if ride.xpath('id').inner_text.to_i == ref
41
41
  active, queue_time = parse_wait_time(ride.xpath('waittime').inner_text)
42
42
  updated_at = DateTime.parse(ride.xpath('lastmodified').inner_text)
43
- return Ride.new(:name => self.ride_list[ref], :queue_time => queue_time, :active => active, :updated_at => updated_at)
43
+ return Ride.new(name: ride_list[ref], queue_time: queue_time, active: active, updated_at: updated_at)
44
44
  end
45
45
  end
46
46
  end
47
47
 
48
48
  def parse_wait_time(wait)
49
- if wait == "Closed"
49
+ if wait == 'Closed'
50
50
  queue_time = 0
51
51
  active = 0
52
- elsif wait == "No Wait"
52
+ elsif wait == 'No Wait'
53
53
  queue_time = 0
54
54
  active = 1
55
55
  elsif wait =~ /(\d*) min/
@@ -59,8 +59,9 @@ module Echelon
59
59
  queue_time = 0
60
60
  active = 0
61
61
  end
62
+
62
63
  return active, queue_time
63
64
  end
64
65
  end
65
66
  end
66
- end
67
+ end
@@ -28,7 +28,7 @@ module Echelon
28
28
  http = Net::HTTP.new('lab.defimobile.com', 443)
29
29
  http.use_ssl = true
30
30
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
31
- resp, data = http.get('/san_diego/rides')
31
+ _resp, data = http.get('/san_diego/rides')
32
32
 
33
33
  # were only interested in the ride data, throw everything else away
34
34
  xml_data = Nokogiri::HTML(data)
@@ -38,20 +38,20 @@ module Echelon
38
38
  private
39
39
 
40
40
  def create_ride_object(ref)
41
- self.xml_data.each do |ride|
41
+ xml_data.each do |ride|
42
42
  if ride.xpath('id').inner_text.to_i == ref
43
43
  active, queue_time = parse_wait_time(ride.xpath('waittime').inner_text)
44
44
  updated_at = DateTime.parse(ride.xpath('lastmodified').inner_text)
45
- return Ride.new(:name => self.ride_list[ref], :queue_time => queue_time, :active => active, :updated_at => updated_at)
45
+ return Ride.new(name: ride_list[ref], queue_time: queue_time, active: active, updated_at: updated_at)
46
46
  end
47
47
  end
48
48
  end
49
49
 
50
50
  def parse_wait_time(wait)
51
- if wait == "Closed"
51
+ if wait == 'Closed'
52
52
  queue_time = 0
53
53
  active = 0
54
- elsif wait == "No Wait"
54
+ elsif wait == 'No Wait'
55
55
  queue_time = 0
56
56
  active = 1
57
57
  elsif wait =~ /(\d*) min/
@@ -61,8 +61,9 @@ module Echelon
61
61
  queue_time = 0
62
62
  active = 0
63
63
  end
64
+
64
65
  return active, queue_time
65
66
  end
66
67
  end
67
68
  end
68
- end
69
+ end
@@ -41,24 +41,23 @@ module Echelon
41
41
 
42
42
  def initialize
43
43
  # fetch the json feed from the merlin site
44
- url = "http://www.merlincms.com/1.php"
44
+ url = 'http://www.merlincms.com/1.php'
45
45
  resp = Net::HTTP.get_response(URI.parse(url))
46
46
  data = resp.body
47
47
 
48
48
  # were only interested in the ride data, throw everything else away
49
49
  json_data = JSON.parse(data)
50
- @json_data = json_data["Rides"]
50
+ @json_data = json_data['Rides']
51
51
  end
52
52
 
53
53
  private
54
54
 
55
55
  def create_ride_object(ref)
56
- self.json_data.each do |ride|
57
- if ride["ref"].to_i == ref
58
- return Ride.new(:name => self.ride_list[ref], :queue_time => ride["queue"].to_i, :active => ride["active"].to_i)
56
+ json_data.each do |ride|
57
+ if ride['ref'].to_i == ref
58
+ return Ride.new(name: self.ride_list[ref], queue_time: ride['queue'].to_i, active: ride['active'].to_i)
59
59
  end
60
60
  end
61
61
  end
62
-
63
62
  end
64
- end
63
+ end
@@ -0,0 +1,108 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'net/http'
4
+ require 'net/https'
5
+ require 'openssl'
6
+ require 'base64'
7
+
8
+ module Echelon
9
+ class UniversalStudiosOrlando
10
+ attr_reader :access_token, :expires_at
11
+
12
+ KEY = 'AndroidMobileApp'.freeze
13
+ SECRET = 'AndroidMobileAppSecretKey182014'.freeze
14
+ SHARED_HEADERS = {
15
+ 'Accept' => 'application/json',
16
+ 'Accept-Language' => 'en-US',
17
+ 'X-UNIWebService-AppVersion' => '1.2.1',
18
+ 'X-UNIWebService-Platform' => 'Android',
19
+ 'X-UNIWebService-PlatformVersion' => '4.4.2',
20
+ 'X-UNIWebService-Device' => 'samsung SM-N9005',
21
+ 'X-UNIWebService-ServiceVersion' => '1',
22
+ 'User-Agent' => 'Dalvik/1.6.0 (Linux; U; Android 4.4.2; SM-N9005 Build/KOT49H)',
23
+ 'Connection' => 'Keep-Alive',
24
+ 'Accept-Encoding' => 'gzip'
25
+ }.freeze
26
+
27
+ def initialize
28
+ uri = URI.parse('https://services.universalorlando.com/api')
29
+ http = Net::HTTP.new(uri.host, uri.port)
30
+ http.use_ssl = true
31
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
32
+
33
+ date = DateTime.now.strftime("%a, %d %b %Y %H:%M:%S #{Time.now.strftime('%Z')}")
34
+ digest = OpenSSL::HMAC.digest('sha256', SECRET, "#{KEY}\n#{date}\n")
35
+ signature = Base64.encode64(digest).strip.gsub(/\=$/, "\u003d")
36
+ params = { apikey: 'AndroidMobileApp', signature: signature }.to_json
37
+
38
+ headers = {
39
+ 'Date' => date,
40
+ 'Content-Type' => 'application/json; charset=UTF-8'
41
+ }.merge(SHARED_HEADERS)
42
+
43
+ resp = http.post(uri.path, params, headers)
44
+ data = JSON.parse(resp.body)
45
+ @access_token = data['Token']
46
+ @expires_at = DateTime.parse(data['TokenExpirationString']).to_time
47
+ end
48
+
49
+ def islands_of_adventure
50
+ @islands_of_adventure ||= UniversalStudiosOrlando::IslandsOfAdventure.new(access_token)
51
+ end
52
+
53
+ def universal_studios
54
+ @universal_studios ||= UniversalStudiosOrlando::UniversalStudios.new(access_token)
55
+ end
56
+
57
+ class Park < Echelon::Park
58
+ attr_reader :json_data, :park_id
59
+
60
+ def ride_list
61
+ park_rides = json_data['Rides'].keep_if { |r| r['VenueId'] == park_id }
62
+ park_rides.inject({}) { |a, e| a[e['Id'].to_i] = e['MblDisplayName']; a }
63
+ end
64
+
65
+ def initialize(access_token, park_id)
66
+ @park_id = park_id
67
+ uri = URI.parse('https://services.universalorlando.com/api/pointsOfInterest')
68
+ http = Net::HTTP.new(uri.host, uri.port)
69
+ http.use_ssl = true
70
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
71
+
72
+ headers = {
73
+ 'X-UNIWebService-ApiKey' => 'AndroidMobileApp',
74
+ 'X-UNIWebService-Token' => access_token
75
+ }.merge(SHARED_HEADERS)
76
+
77
+ resp = http.get(uri.request_uri, headers)
78
+ @json_data = JSON.parse(resp.body)
79
+ end
80
+
81
+ private
82
+
83
+ def create_ride_object(ref)
84
+ ride = json_data['Rides'].find { |k, _v| k['Id'].to_i == ref }
85
+
86
+ meta = {
87
+ express_pass_accepted: ride['ExpressPassAccepted'],
88
+ single_rider: ride['HasSingleRiderLine']
89
+ }
90
+
91
+ Ride.new(name: ride['MblDisplayName'], queue_time: ride['WaitTime'], meta: meta)
92
+ end
93
+
94
+ end
95
+
96
+ class IslandsOfAdventure < Park
97
+ def initialize(access_token)
98
+ super(access_token, 10_000)
99
+ end
100
+ end
101
+
102
+ class UniversalStudios < Park
103
+ def initialize(access_token)
104
+ super(access_token, 10_010)
105
+ end
106
+ end
107
+ end
108
+ end
@@ -8,4 +8,4 @@ module Echelon
8
8
  end
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Echelon
2
- VERSION = '1.0.3'
3
- end
2
+ VERSION = '1.0.4'
3
+ end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: echelon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lloyd Pick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-22 00:00:00.000000000 Z
11
+ date: 2014-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.0.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.4.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.4.0
41
41
  - !ruby/object:Gem::Dependency
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.4.6
47
+ version: 1.8.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 1.4.6
54
+ version: 1.8.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: zip
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +70,14 @@ dependencies:
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.5'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.5'
83
83
  description: RubyGem to give quick access to Theme Park queue times (Alton Towers,
@@ -90,10 +90,10 @@ executables: []
90
90
  extensions: []
91
91
  extra_rdoc_files: []
92
92
  files:
93
- - .gitignore
94
- - .ruby-gemset
95
- - .ruby-version
96
- - .travis.yml
93
+ - ".gitignore"
94
+ - ".ruby-gemset"
95
+ - ".ruby-version"
96
+ - ".travis.yml"
97
97
  - Gemfile
98
98
  - Gemfile.lock
99
99
  - History.txt
@@ -112,6 +112,7 @@ files:
112
112
  - lib/echelon/parks/seaworld/san_antonio.rb
113
113
  - lib/echelon/parks/seaworld/san_diego.rb
114
114
  - lib/echelon/parks/thorpe_park.rb
115
+ - lib/echelon/parks/universal_studios_orlando.rb
115
116
  - lib/echelon/ride.rb
116
117
  - lib/echelon/version.rb
117
118
  - spec/alton_towers_spec.rb
@@ -128,17 +129,17 @@ require_paths:
128
129
  - lib
129
130
  required_ruby_version: !ruby/object:Gem::Requirement
130
131
  requirements:
131
- - - '>='
132
+ - - ">="
132
133
  - !ruby/object:Gem::Version
133
134
  version: '0'
134
135
  required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  requirements:
136
- - - '>='
137
+ - - ">="
137
138
  - !ruby/object:Gem::Version
138
139
  version: 1.3.6
139
140
  requirements: []
140
141
  rubyforge_project: echelon
141
- rubygems_version: 2.0.6
142
+ rubygems_version: 2.2.2
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: RubyGem to give quick access to Theme Park queue times