onthesnow 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/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/CHANGELOG +3 -0
- data/Gemfile +4 -0
- data/README.md +55 -0
- data/Rakefile +6 -0
- data/lib/onthesnow/api.rb +22 -0
- data/lib/onthesnow/config.rb +29 -0
- data/lib/onthesnow/helper.rb +37 -0
- data/lib/onthesnow/region/region.rb +31 -0
- data/lib/onthesnow/region.rb +1 -0
- data/lib/onthesnow/resort/elevation.rb +23 -0
- data/lib/onthesnow/resort/info.rb +23 -0
- data/lib/onthesnow/resort/lifts.rb +43 -0
- data/lib/onthesnow/resort/resort.rb +65 -0
- data/lib/onthesnow/resort/slopes.rb +27 -0
- data/lib/onthesnow/resort/snow.rb +23 -0
- data/lib/onthesnow/resort/weather.rb +31 -0
- data/lib/onthesnow/resort.rb +7 -0
- data/lib/onthesnow/state/state.rb +45 -0
- data/lib/onthesnow/state.rb +1 -0
- data/lib/onthesnow/version.rb +3 -0
- data/lib/onthesnow.rb +26 -0
- data/onthesnow.gemspec +28 -0
- data/spec/fixtures/alaska_snow.rss +63 -0
- data/spec/fixtures/alyska_profile.html +2310 -0
- data/spec/fixtures/site_map_rss.html +1528 -0
- data/spec/onthesnow_parser_spec.rb +209 -0
- data/spec/spec_helper.rb +6 -0
- metadata +163 -0
@@ -0,0 +1,209 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
|
+
|
3
|
+
describe "OnTheSnow" do
|
4
|
+
describe "API" do
|
5
|
+
it "should initialize a OnTheSnow::API" do
|
6
|
+
api.should be_kind_of OnTheSnow::API
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "private methods" do
|
10
|
+
it "should return url" do
|
11
|
+
api.send(:url).should == "http://www.onthesnow.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return site map rss url" do
|
15
|
+
api.send(:site_map_rss_url).should == "http://www.onthesnow.com/site_map_rss.html"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return rss url" do
|
19
|
+
api.send(:rss_url, "AK").should == "http://www.onthesnow.com/AK/snow.rss"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#regions" do
|
24
|
+
it "should return a Hash of regions" do
|
25
|
+
api.regions().should be_kind_of Hash
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should contain USA and Europe" do
|
29
|
+
api.regions["1"]["name"].should == "USA"
|
30
|
+
api.regions["2"]["name"].should == "Europe"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#states" do
|
35
|
+
it "should return a Hash of states" do
|
36
|
+
api.states.should be_kind_of Hash
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "first state" do
|
40
|
+
it "should contain name Alaska" do
|
41
|
+
api.states["1"]["name"].should == "Alaska"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should contain region USA" do
|
45
|
+
api.states["1"]["region"].should == "USA"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should contrain rss url" do
|
49
|
+
api.states["1"]["rss"].should == "http://www.onthesnow.com/AK/snow.rss"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#resorts" do
|
55
|
+
it "should return a Hash of resorts" do
|
56
|
+
api.resorts.should be_kind_of Hash
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "first resort" do
|
60
|
+
it "should return a hash" do
|
61
|
+
api.resorts["1"].to_hash.should be_kind_of Hash
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should contain name Alyeska" do
|
65
|
+
api.resorts["1"]["info"]["name"].should == "Alyeska"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should contain state Alaska" do
|
69
|
+
api.resorts["1"]["info"]["states"].first.should == "Alaska"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should contain right profile url" do
|
73
|
+
api.resorts["1"]["info"]["url"].should == "http://www.onthesnow.com/alaska/alyeska-resort/profile.html"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should contain peak height" do
|
77
|
+
api.resorts["1"]["elevation"]["peak"].should == "2750Ft."
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should contrain valley height" do
|
81
|
+
api.resorts["1"]["elevation"]["valley"].should == "250Ft."
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should contain height difference between peak and valley" do
|
85
|
+
api.resorts["1"]["elevation"]["height_difference"].should == "2500Ft."
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "lifts" do
|
89
|
+
it "should contain 9 total lifts" do
|
90
|
+
api.resorts["1"]["lifts"]["total"].should == "9"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should contain 1 tram lifts" do
|
94
|
+
api.resorts["1"]["lifts"]["trams"].should == "1"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should contain 0 fast sixes lifts" do
|
98
|
+
api.resorts["1"]["lifts"]["fast_sixes"].should == "0"
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should contain 1 fast quads lifts" do
|
102
|
+
api.resorts["1"]["lifts"]["fast_quads"].should == "1"
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should contain 3 quad lifts" do
|
106
|
+
api.resorts["1"]["lifts"]["quad"].should == "3"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should contain 0 triple lifts" do
|
110
|
+
api.resorts["1"]["lifts"]["triple"].should == "0"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should contain 2 double lifts" do
|
114
|
+
api.resorts["1"]["lifts"]["double"].should == "2"
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should contain 2 surface lifts" do
|
118
|
+
api.resorts["1"]["lifts"]["surface"].should == "2"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "slopes" do
|
123
|
+
it "should contain 10% beginner terrain" do
|
124
|
+
api.resorts["1"]["slopes"]["beginner"].should == "10%"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should contain 30% intermediate terrain" do
|
128
|
+
api.resorts["1"]["slopes"]["intermediate"].should == "30%"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should contain 20% advanced terrain" do
|
132
|
+
api.resorts["1"]["slopes"]["advanced"].should == "20%"
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should contain 40% expert terrain" do
|
136
|
+
api.resorts["1"]["slopes"]["expert"].should == "40%"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "snow" do
|
141
|
+
it "should contain 1 in. in the last 24 hours" do
|
142
|
+
api.resorts["1"]["snow"]["last_24"].should == "1in."
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should contain 2 in. in the last 48 hours" do
|
146
|
+
api.resorts["1"]["snow"]["last_48"].should == "2in."
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should contain 3 in. in the last 72 hours" do
|
150
|
+
api.resorts["1"]["snow"]["last_72"].should == "3in."
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "weather" do
|
155
|
+
it "should contain Jan 21" do
|
156
|
+
api.resorts["1"]["weather"]["date"].should == "Jan 21"
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should contain temperature -17" do
|
160
|
+
api.resorts["1"]["weather"]["temperature"]["f"].should match(/-17/)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should contain temperature -27" do
|
164
|
+
api.resorts["1"]["weather"]["temperature"]["c"].should match(/-27/)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should contain clear" do
|
168
|
+
api.resorts["1"]["weather"]["condition"].should == "Clear"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe "Spec helper" do
|
176
|
+
it "should return site_map_rss.html" do
|
177
|
+
site_map_rss_html == File.read("spec/fixtures/site_map_rss.html")
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should return alaska_snow_rss" do
|
181
|
+
alaska_snow_rss == File.read("spec/fixtures/alaska_snow.rss")
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should return alyska_profile_html" do
|
185
|
+
alyska_profile_html == File.read("spec/fixtures/alyska_profile.html")
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
private
|
190
|
+
def api
|
191
|
+
api = OnTheSnow::API.instance
|
192
|
+
FakeWeb.register_uri(:get, api.send(:site_map_rss_url), :body => site_map_rss_html)
|
193
|
+
FakeWeb.register_uri(:get, %r|http:\/\/www.onthesnow.com\/[A-Z-]+\/snow.rss|, :body => alaska_snow_rss)
|
194
|
+
FakeWeb.register_uri(:get, %r|http:\/\/www.onthesnow.com\/[a-z-]+\/[a-z-]+\/profile.html|, :body => alyska_profile_html)
|
195
|
+
api
|
196
|
+
end
|
197
|
+
|
198
|
+
def site_map_rss_html
|
199
|
+
File.read("spec/fixtures/site_map_rss.html")
|
200
|
+
end
|
201
|
+
|
202
|
+
def alaska_snow_rss
|
203
|
+
File.read("spec/fixtures/alaska_snow.rss")
|
204
|
+
end
|
205
|
+
|
206
|
+
def alyska_profile_html
|
207
|
+
File.read("spec/fixtures/alyska_profile.html")
|
208
|
+
end
|
209
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: onthesnow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jan Owiesniak
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-01-22 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: fakeweb
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mocha
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: nokogiri
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: simple-rss
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :runtime
|
89
|
+
version_requirements: *id005
|
90
|
+
description: "\"\""
|
91
|
+
email:
|
92
|
+
- jowiesniak@gmail.com
|
93
|
+
executables: []
|
94
|
+
|
95
|
+
extensions: []
|
96
|
+
|
97
|
+
extra_rdoc_files: []
|
98
|
+
|
99
|
+
files:
|
100
|
+
- .gitignore
|
101
|
+
- .rvmrc
|
102
|
+
- CHANGELOG
|
103
|
+
- Gemfile
|
104
|
+
- README.md
|
105
|
+
- Rakefile
|
106
|
+
- lib/onthesnow.rb
|
107
|
+
- lib/onthesnow/api.rb
|
108
|
+
- lib/onthesnow/config.rb
|
109
|
+
- lib/onthesnow/helper.rb
|
110
|
+
- lib/onthesnow/region.rb
|
111
|
+
- lib/onthesnow/region/region.rb
|
112
|
+
- lib/onthesnow/resort.rb
|
113
|
+
- lib/onthesnow/resort/elevation.rb
|
114
|
+
- lib/onthesnow/resort/info.rb
|
115
|
+
- lib/onthesnow/resort/lifts.rb
|
116
|
+
- lib/onthesnow/resort/resort.rb
|
117
|
+
- lib/onthesnow/resort/slopes.rb
|
118
|
+
- lib/onthesnow/resort/snow.rb
|
119
|
+
- lib/onthesnow/resort/weather.rb
|
120
|
+
- lib/onthesnow/state.rb
|
121
|
+
- lib/onthesnow/state/state.rb
|
122
|
+
- lib/onthesnow/version.rb
|
123
|
+
- onthesnow.gemspec
|
124
|
+
- spec/fixtures/alaska_snow.rss
|
125
|
+
- spec/fixtures/alyska_profile.html
|
126
|
+
- spec/fixtures/site_map_rss.html
|
127
|
+
- spec/onthesnow_parser_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: ""
|
130
|
+
licenses: []
|
131
|
+
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
version: "0"
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 3
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
version: "0"
|
155
|
+
requirements: []
|
156
|
+
|
157
|
+
rubyforge_project: onthesnow
|
158
|
+
rubygems_version: 1.8.10
|
159
|
+
signing_key:
|
160
|
+
specification_version: 3
|
161
|
+
summary: "\"Small API to communicate with http://www.onthesnow.com\""
|
162
|
+
test_files: []
|
163
|
+
|