echelon 0.0.3 → 0.0.4
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/Gemfile.lock +4 -1
- data/History.txt +10 -0
- data/echelon.gemspec +2 -1
- data/lib/echelon.rb +1 -0
- data/lib/echelon/parks/alton_towers.rb +40 -0
- data/lib/echelon/parks/disneyland_paris.rb +1 -1
- data/lib/echelon/parks/seaworld_san_antonio.rb +64 -0
- data/lib/echelon/ride.rb +1 -1
- data/lib/echelon/version.rb +1 -1
- data/spec/alton_towers_spec.rb +34 -0
- data/spec/disneyland_paris_spec.rb +4 -4
- data/spec/echelon_spec.rb +6 -1
- data/spec/seaworld_san_antonio_spec.rb +45 -0
- data/spec/thorpe_park_spec.rb +4 -4
- metadata +25 -5
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
echelon (0.0.
|
4
|
+
echelon (0.0.3)
|
5
5
|
json_pure (= 1.4.6)
|
6
|
+
xml-simple (= 1.0.12)
|
6
7
|
zip (= 2.0.2)
|
7
8
|
|
8
9
|
GEM
|
@@ -18,6 +19,7 @@ GEM
|
|
18
19
|
rspec-expectations (2.4.0)
|
19
20
|
diff-lcs (~> 1.1.2)
|
20
21
|
rspec-mocks (2.4.0)
|
22
|
+
xml-simple (1.0.12)
|
21
23
|
zip (2.0.2)
|
22
24
|
|
23
25
|
PLATFORMS
|
@@ -28,4 +30,5 @@ DEPENDENCIES
|
|
28
30
|
echelon!
|
29
31
|
json_pure (= 1.4.6)
|
30
32
|
rspec (>= 2.4.0)
|
33
|
+
xml-simple (= 1.0.12)
|
31
34
|
zip (= 2.0.2)
|
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 0.0.4 2011-01-12
|
2
|
+
|
3
|
+
* Added Seaworld San Antonio
|
4
|
+
* Added Alton Towers (not enabled, remote server not operational yet)
|
5
|
+
|
6
|
+
=== 0.0.3 2011-01-10
|
7
|
+
|
8
|
+
* Added rSpec tests
|
9
|
+
* Refactored how parks work
|
10
|
+
|
1
11
|
=== 0.0.2 2010-11-27
|
2
12
|
|
3
13
|
* Added Disneyland Paris
|
data/echelon.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["lloydpick@gmail.com"]
|
11
11
|
s.homepage = "http://github.com/lloydpick/echelon"
|
12
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
|
13
|
+
s.description = "RubyGem to give quick access to Theme Park queue times (Disneyland Paris, Thorpe Park, Seaworld San Antonio supported)"
|
14
14
|
|
15
15
|
s.required_rubygems_version = ">= 1.3.6"
|
16
16
|
s.rubyforge_project = "echelon"
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.add_dependency "json_pure", "1.4.6"
|
22
22
|
s.add_dependency "zip", "2.0.2"
|
23
|
+
s.add_dependency "xml-simple", "1.0.12"
|
23
24
|
|
24
25
|
s.files = `git ls-files`.split("\n")
|
25
26
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
data/lib/echelon.rb
CHANGED
@@ -6,6 +6,7 @@ require "#{File.dirname(__FILE__)}/echelon/park.rb"
|
|
6
6
|
|
7
7
|
require "#{File.dirname(__FILE__)}/echelon/parks/thorpe_park.rb"
|
8
8
|
require "#{File.dirname(__FILE__)}/echelon/parks/disneyland_paris.rb"
|
9
|
+
require "#{File.dirname(__FILE__)}/echelon/parks/seaworld_san_antonio.rb"
|
9
10
|
|
10
11
|
module Echelon
|
11
12
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Echelon
|
6
|
+
class AltonTowers < Park
|
7
|
+
|
8
|
+
attr_reader :json_data
|
9
|
+
|
10
|
+
def ride_list
|
11
|
+
{
|
12
|
+
1 => 'Air',
|
13
|
+
2 => 'Enterprise',
|
14
|
+
3 => 'Rita'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
# fetch the json feed from the merlin site
|
20
|
+
url = "http://www.merlincms.com/2.php"
|
21
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
22
|
+
data = resp.body
|
23
|
+
|
24
|
+
# were only interested in the ride data, throw everything else away
|
25
|
+
json_data = JSON.parse(data)
|
26
|
+
@json_data = json_data["Rides"]
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def create_ride_object(ref)
|
32
|
+
self.json_data.each do |ride|
|
33
|
+
if ride["ref"].to_i == ref
|
34
|
+
return Ride.new(:name => self.ride_list[ref], :queue_time => ride["queue"].to_i, :active => ride["active"].to_i)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -94,7 +94,7 @@ module Echelon
|
|
94
94
|
def create_ride_object(ref)
|
95
95
|
self.json_data.each do |ride|
|
96
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)
|
97
|
+
return Ride.new(:name => self.ride_list[ref], :queue_time => ride[4].to_i, :active => ride[3].to_i, :updated_at => DateTime.now)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'xmlsimple'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Echelon
|
6
|
+
class SeaworldSanAntonio < Park
|
7
|
+
|
8
|
+
attr_reader :xml_data
|
9
|
+
|
10
|
+
def ride_list
|
11
|
+
{
|
12
|
+
10 => 'Shamu Express',
|
13
|
+
11 => 'Steel Eel',
|
14
|
+
12 => 'Texas Splashdown',
|
15
|
+
13 => 'Great White',
|
16
|
+
14 => 'Rio Loco',
|
17
|
+
15 => 'Journey to Atlantis',
|
18
|
+
164 => 'Lost Lagoon'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
# fetch the xml file
|
24
|
+
http = Net::HTTP.new('lab.defimobile.com', 443)
|
25
|
+
http.use_ssl = true
|
26
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
27
|
+
resp, data = http.get('/seaworld/rides')
|
28
|
+
|
29
|
+
# were only interested in the ride data, throw everything else away
|
30
|
+
xml_data = XmlSimple.xml_in(data)
|
31
|
+
@xml_data = xml_data['ride']
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def create_ride_object(ref)
|
37
|
+
self.xml_data.each do |ride|
|
38
|
+
if ride["id"].to_s.to_i == ref
|
39
|
+
active, queue_time = parse_wait_time(ride["waitTime"].to_s)
|
40
|
+
updated_at = DateTime.parse(ride["lastModified"].to_s)
|
41
|
+
return Ride.new(:name => self.ride_list[ref], :queue_time => queue_time, :active => active, :updated_at => updated_at)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def parse_wait_time(wait)
|
47
|
+
if wait == "Closed"
|
48
|
+
queue_time = 0
|
49
|
+
active = 0
|
50
|
+
elsif wait == "No Wait"
|
51
|
+
queue_time = 0
|
52
|
+
active = 1
|
53
|
+
elsif wait =~ /(\d*) min/
|
54
|
+
queue_time = $1.to_i
|
55
|
+
active = 1
|
56
|
+
else
|
57
|
+
queue_time = 0
|
58
|
+
active = 0
|
59
|
+
end
|
60
|
+
return active, queue_time
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
data/lib/echelon/ride.rb
CHANGED
data/lib/echelon/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'echelon/park'
|
2
|
+
require 'echelon/parks/alton_towers'
|
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::AltonTowers do
|
9
|
+
|
10
|
+
before do
|
11
|
+
@park = Echelon::AltonTowers.new()
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should inherit from Park" do
|
15
|
+
@park.should be_kind_of(Echelon::AltonTowers)
|
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("Rita").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
|
+
ride = @park.find_by_id(3)
|
29
|
+
ride.name.should eql("Rita")
|
30
|
+
ride.queue_time.should satisfy { |v| v >= 0 && v < 1000 }
|
31
|
+
ride.active.should satisfy { |v| v == 0 || v == 1 }
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -25,10 +25,10 @@ describe Echelon::DisneylandParis do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should return ride object values correctly" do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
ride = @park.find_by_id("P1AA04")
|
29
|
+
ride.name.should eql("Pirates of the Caribbean")
|
30
|
+
ride.queue_time.should satisfy { |v| v >= 0 && v < 500 }
|
31
|
+
ride.active.should satisfy { |v| v >= -1 && v < 3 }
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
data/spec/echelon_spec.rb
CHANGED
@@ -4,7 +4,8 @@ require 'echelon/park'
|
|
4
4
|
describe Echelon::Ride do
|
5
5
|
|
6
6
|
before do
|
7
|
-
@
|
7
|
+
@datetime = DateTime.now
|
8
|
+
@ride = Echelon::Ride.new(:name => 'Ride', :queue_time => 10, :active => 1, :updated_at => @datetime)
|
8
9
|
end
|
9
10
|
|
10
11
|
it "should return the name of the ride" do
|
@@ -19,6 +20,10 @@ describe Echelon::Ride do
|
|
19
20
|
@ride.active.should eql(1)
|
20
21
|
end
|
21
22
|
|
23
|
+
it "should return the ride updated at datetime" do
|
24
|
+
@ride.updated_at.should eql(@datetime)
|
25
|
+
end
|
26
|
+
|
22
27
|
end
|
23
28
|
|
24
29
|
describe Echelon::Park do
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'echelon/park'
|
2
|
+
require 'echelon/parks/seaworld_san_antonio'
|
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::SeaworldSanAntonio do
|
9
|
+
|
10
|
+
before do
|
11
|
+
@park = Echelon::SeaworldSanAntonio.new()
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should inherit from Park" do
|
15
|
+
@park.should be_kind_of(Echelon::SeaworldSanAntonio)
|
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("Steel Eel").should be_kind_of(Echelon::Ride)
|
24
|
+
@park.find_by_id(11).should be_kind_of(Echelon::Ride)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return ride object values correctly" do
|
28
|
+
ride = @park.find_by_id(11)
|
29
|
+
ride.name.should eql("Steel Eel")
|
30
|
+
ride.queue_time.should satisfy { |v| v >= 0 && v < 1000 }
|
31
|
+
ride.active.should satisfy { |v| v == 0 || v == 1 }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "parse_wait_time" do
|
35
|
+
|
36
|
+
it "should return a wait time and active state correctly" do
|
37
|
+
@park.send(:parse_wait_time, "15 mins").should eql([1, 15])
|
38
|
+
@park.send(:parse_wait_time, "Closed").should eql([0, 0])
|
39
|
+
@park.send(:parse_wait_time, "No Wait").should eql([1, 0])
|
40
|
+
@park.send(:parse_wait_time, "30 mins").should eql([1, 30])
|
41
|
+
@park.send(:parse_wait_time, "Invalid").should eql([0, 0])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/spec/thorpe_park_spec.rb
CHANGED
@@ -25,10 +25,10 @@ describe Echelon::ThorpePark do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should return ride object values correctly" do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
ride = @park.find_by_id(3)
|
29
|
+
ride.name.should eql("Stealth")
|
30
|
+
ride.queue_time.should satisfy { |v| v >= 0 && v < 1000 }
|
31
|
+
ride.active.should satisfy { |v| v == 0 || v == 1 }
|
32
32
|
end
|
33
33
|
|
34
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
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: 2011-01-
|
18
|
+
date: 2011-01-12 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -82,7 +82,23 @@ dependencies:
|
|
82
82
|
version: 2.0.2
|
83
83
|
type: :runtime
|
84
84
|
version_requirements: *id004
|
85
|
-
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: xml-simple
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - "="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 15
|
94
|
+
segments:
|
95
|
+
- 1
|
96
|
+
- 0
|
97
|
+
- 12
|
98
|
+
version: 1.0.12
|
99
|
+
type: :runtime
|
100
|
+
version_requirements: *id005
|
101
|
+
description: RubyGem to give quick access to Theme Park queue times (Disneyland Paris, Thorpe Park, Seaworld San Antonio supported)
|
86
102
|
email:
|
87
103
|
- lloydpick@gmail.com
|
88
104
|
executables: []
|
@@ -102,12 +118,16 @@ files:
|
|
102
118
|
- echelon.gemspec
|
103
119
|
- lib/echelon.rb
|
104
120
|
- lib/echelon/park.rb
|
121
|
+
- lib/echelon/parks/alton_towers.rb
|
105
122
|
- lib/echelon/parks/disneyland_paris.rb
|
123
|
+
- lib/echelon/parks/seaworld_san_antonio.rb
|
106
124
|
- lib/echelon/parks/thorpe_park.rb
|
107
125
|
- lib/echelon/ride.rb
|
108
126
|
- lib/echelon/version.rb
|
127
|
+
- spec/alton_towers_spec.rb
|
109
128
|
- spec/disneyland_paris_spec.rb
|
110
129
|
- spec/echelon_spec.rb
|
130
|
+
- spec/seaworld_san_antonio_spec.rb
|
111
131
|
- spec/thorpe_park_spec.rb
|
112
132
|
has_rdoc: true
|
113
133
|
homepage: http://github.com/lloydpick/echelon
|