echelon 0.0.1

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 ADDED
@@ -0,0 +1,3 @@
1
+ === 0.0.1 2010-10-20
2
+
3
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,9 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/echelon.rb
6
+ lib/echelon/ride.rb
7
+ lib/echelon/thorpe_park.rb
8
+ test/test_echelon.rb
9
+ test/test_helper.rb
data/README.rdoc ADDED
@@ -0,0 +1,52 @@
1
+ = echelon
2
+
3
+ * http://github.com/lloydpick/echelon
4
+
5
+ == DESCRIPTION:
6
+
7
+ RubyGem to give quick access to Theme Park queue times
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ Currently only the following parks are supported...
12
+
13
+ * Thorpe Park
14
+
15
+ == SYNOPSIS:
16
+
17
+ require 'echelon'
18
+ tp = Echelon::ThorpePark.new()
19
+ tp.find_by_name("SAW - The Ride")
20
+
21
+ == REQUIREMENTS:
22
+
23
+ * FIX (list of requirements)
24
+
25
+ == INSTALL:
26
+
27
+ gem install echelon
28
+
29
+ == LICENSE:
30
+
31
+ (The MIT License)
32
+
33
+ Copyright (c) 2010 Lloyd Pick
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining
36
+ a copy of this software and associated documentation files (the
37
+ 'Software'), to deal in the Software without restriction, including
38
+ without limitation the rights to use, copy, modify, merge, publish,
39
+ distribute, sublicense, and/or sell copies of the Software, and to
40
+ permit persons to whom the Software is furnished to do so, subject to
41
+ the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be
44
+ included in all copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
47
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
49
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
50
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
51
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
52
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
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]
data/lib/echelon.rb ADDED
@@ -0,0 +1,9 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require "#{File.dirname(__FILE__)}/echelon/ride.rb"
5
+ require "#{File.dirname(__FILE__)}/echelon/thorpe_park.rb"
6
+
7
+ module Echelon
8
+ VERSION = '0.0.1'
9
+ end
@@ -0,0 +1,11 @@
1
+ module Echelon
2
+ class Ride
3
+ attr_reader :name, :queue_time, :active
4
+
5
+ def initialize(*params)
6
+ params.each do |key|
7
+ key.each { |k, v| instance_variable_set("@#{k}", v) }
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,77 @@
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
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/echelon'
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: echelon
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Lloyd Pick
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-20 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: json_pure
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 11
30
+ segments:
31
+ - 1
32
+ - 4
33
+ - 6
34
+ version: 1.4.6
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rubyforge
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 7
46
+ segments:
47
+ - 2
48
+ - 0
49
+ - 4
50
+ version: 2.0.4
51
+ type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: hoe
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 19
62
+ segments:
63
+ - 2
64
+ - 6
65
+ - 2
66
+ version: 2.6.2
67
+ type: :development
68
+ version_requirements: *id003
69
+ description: RubyGem to give quick access to Theme Park queue times
70
+ email:
71
+ - lloydpick@gmail.com
72
+ executables: []
73
+
74
+ extensions: []
75
+
76
+ extra_rdoc_files:
77
+ - History.txt
78
+ - Manifest.txt
79
+ files:
80
+ - History.txt
81
+ - Manifest.txt
82
+ - README.rdoc
83
+ - Rakefile
84
+ - lib/echelon.rb
85
+ - lib/echelon/ride.rb
86
+ - lib/echelon/thorpe_park.rb
87
+ - test/test_echelon.rb
88
+ - test/test_helper.rb
89
+ has_rdoc: true
90
+ homepage: http://github.com/lloydpick/echelon
91
+ licenses: []
92
+
93
+ post_install_message:
94
+ rdoc_options:
95
+ - --main
96
+ - README.rdoc
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ hash: 3
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ requirements: []
118
+
119
+ rubyforge_project: echelon
120
+ rubygems_version: 1.3.7
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: RubyGem to give quick access to Theme Park queue times
124
+ test_files:
125
+ - test/test_helper.rb
126
+ - test/test_echelon.rb