weatherzone 0.6.5 → 0.7.0
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/lib/weatherzone/connection.rb +11 -17
- data/lib/weatherzone/finder.rb +25 -27
- data/lib/weatherzone.rb +1 -1
- data/test/test_almanac.rb +1 -1
- data/test/test_almanac_period.rb +1 -1
- data/test/test_buoy_observation.rb +1 -1
- data/test/test_climate_period.rb +1 -1
- data/test/test_conditions.rb +1 -1
- data/test/test_connection.rb +2 -4
- data/test/test_country.rb +6 -2
- data/test/test_daily_observation.rb +1 -1
- data/test/test_district_forecast.rb +1 -1
- data/test/test_exceptions.rb +9 -4
- data/test/test_farenheit_conversion_factor.rb +5 -4
- data/test/test_finder.rb +10 -10
- data/test/test_forecast.rb +1 -1
- data/test/test_helper.rb +5 -1
- data/test/test_historical_observation.rb +1 -1
- data/test/test_image.rb +1 -1
- data/test/test_location.rb +1 -1
- data/test/test_marine_forecast.rb +1 -1
- data/test/test_marine_summary.rb +1 -1
- data/test/test_moon_phase.rb +6 -2
- data/test/test_news_item.rb +6 -2
- data/test/test_point_forecast.rb +1 -1
- data/test/test_snow_report.rb +1 -1
- data/test/test_state_forecast.rb +1 -1
- data/test/test_surf_report.rb +1 -1
- data/test/test_tide.rb +1 -1
- data/test/test_value_and_unit_helpers.rb +5 -4
- data/test/test_warning.rb +6 -2
- data/test/test_weather.rb +6 -2
- metadata +4 -4
@@ -5,7 +5,7 @@ module Weatherzone
|
|
5
5
|
class RequestFailed < Exception
|
6
6
|
attr_reader :message, :original_exception
|
7
7
|
def initialize(url, original_exception)
|
8
|
-
@message
|
8
|
+
@message = "Failed to retreive #{url} and no cached version available"
|
9
9
|
@original_exception = original_exception
|
10
10
|
end
|
11
11
|
end
|
@@ -19,25 +19,19 @@ module Weatherzone
|
|
19
19
|
|
20
20
|
DEFAULT_TIMEOUT_AFTER = 1
|
21
21
|
|
22
|
-
include Singleton
|
23
|
-
|
24
22
|
attr_accessor :username, :password, :url, :keygen, :logger, :timeout_after
|
25
23
|
|
26
|
-
def initialize
|
27
|
-
@logger
|
28
|
-
@logger.level
|
24
|
+
def initialize(username=nil, password=nil, keygen=nil, options={})
|
25
|
+
@logger = Logger.new(STDOUT)
|
26
|
+
@logger.level = Logger::DEBUG
|
27
|
+
@username = username
|
28
|
+
@password = password
|
29
|
+
@url = options[:url]
|
30
|
+
@keygen = keygen
|
31
|
+
@logger = options[:logger]
|
32
|
+
@timeout_after = options[:timeout_after] || DEFAULT_TIMEOUT_AFTER
|
29
33
|
end
|
30
34
|
|
31
|
-
def self.connect(username=nil, password=nil, options={}, &block)
|
32
|
-
connection = Weatherzone::Connection.instance
|
33
|
-
connection.username = username
|
34
|
-
connection.password = password
|
35
|
-
connection.url = options[:url]
|
36
|
-
connection.keygen = block
|
37
|
-
connection.logger = options[:logger]
|
38
|
-
connection.timeout_after = options[:timeout_after] || DEFAULT_TIMEOUT_AFTER
|
39
|
-
end
|
40
|
-
|
41
35
|
def self.settings
|
42
36
|
Weatherzone::Settings.instance
|
43
37
|
end
|
@@ -47,7 +41,7 @@ module Weatherzone
|
|
47
41
|
end
|
48
42
|
|
49
43
|
def key
|
50
|
-
|
44
|
+
instance_eval &@keygen
|
51
45
|
end
|
52
46
|
|
53
47
|
def base_url
|
data/lib/weatherzone/finder.rb
CHANGED
@@ -33,70 +33,68 @@ module Weatherzone
|
|
33
33
|
|
34
34
|
def self.included(klass)
|
35
35
|
klass.class_eval do
|
36
|
-
@@connection = Weatherzone::Connection.instance
|
37
|
-
|
38
36
|
class << self
|
39
37
|
def parse_file(file_name)
|
40
38
|
parse(File.open(file_name))
|
41
39
|
end
|
42
40
|
|
43
|
-
def find(options, location_code=nil)
|
44
|
-
set_options(options)
|
45
|
-
make_request(build_params(location_code, options))
|
41
|
+
def find(connection, options, location_code=nil)
|
42
|
+
set_options(connection, options)
|
43
|
+
make_request(connection, build_params(location_code, options))
|
46
44
|
end
|
47
45
|
|
48
|
-
def find_by_location_code(location_code, options={})
|
46
|
+
def find_by_location_code(connection, location_code, options={})
|
49
47
|
options = options.dup
|
50
|
-
find(options, location_code)
|
48
|
+
find(connection, options, location_code)
|
51
49
|
end
|
52
50
|
|
53
|
-
def find_by_twcid(twcid, options={})
|
51
|
+
def find_by_twcid(connection, twcid, options={})
|
54
52
|
options = options.dup
|
55
53
|
options.merge!(:params => "<=twcid&lc=#{twcid}")
|
56
|
-
find(options)
|
54
|
+
find(connection, options)
|
57
55
|
end
|
58
56
|
|
59
|
-
def find_by_location_name(location_name, options={})
|
57
|
+
def find_by_location_name(connection, location_name, options={})
|
60
58
|
options = options.dup
|
61
59
|
location_name = location_name.gsub(" ", "%20").gsub("-", "%20")
|
62
60
|
options.merge!(:params => "<=aploc&ln=#{location_name}")
|
63
|
-
find(options)
|
61
|
+
find(connection, options)
|
64
62
|
end
|
65
63
|
|
66
|
-
def find_by_swellnet_code(swellnet_code, options={})
|
64
|
+
def find_by_swellnet_code(connection, swellnet_code, options={})
|
67
65
|
options = options.dup
|
68
66
|
options.merge!(:params => "<=swellnet&lc=#{swellnet_code}")
|
69
|
-
find(options)
|
67
|
+
find(connection, options)
|
70
68
|
end
|
71
69
|
|
72
|
-
def find_by_location_filter(filter, options={})
|
70
|
+
def find_by_location_filter(connection, filter, options={})
|
73
71
|
options = options.dup
|
74
72
|
options.merge!(:params => "<=twcid&lf=#{filter}")
|
75
|
-
find(options)
|
73
|
+
find(connection, options)
|
76
74
|
end
|
77
75
|
|
78
|
-
def find_by_district(district_code, options={})
|
76
|
+
def find_by_district(connection, district_code, options={})
|
79
77
|
options = options.dup
|
80
78
|
options.merge!(:params => "<=twcid&dist=#{district_code}")
|
81
|
-
find(options)
|
79
|
+
find(connection, options)
|
82
80
|
end
|
83
81
|
|
84
|
-
def find_districts_by_state(state, options={})
|
82
|
+
def find_districts_by_state(connection, state, options={})
|
85
83
|
options = options.dup
|
86
84
|
options.merge!(:params => "<=dist&state=#{state}")
|
87
|
-
find(options).countries.first.locations
|
85
|
+
find(connection, options).countries.first.locations
|
88
86
|
end
|
89
87
|
|
90
|
-
def find_radars_by_state(state, options={})
|
88
|
+
def find_radars_by_state(connection, state, options={})
|
91
89
|
options = options.dup
|
92
90
|
options.merge!(:params => "<=radar&links=1&ra=1&state=#{state}")
|
93
|
-
find(options).countries.first.locations
|
91
|
+
find(connection, options).countries.first.locations
|
94
92
|
end
|
95
93
|
|
96
|
-
def find_by_radar_code(radar_code, options={})
|
94
|
+
def find_by_radar_code(connection, radar_code, options={})
|
97
95
|
options = options.dup
|
98
96
|
options.merge!(:params => "<=radar&lc=#{radar_code}&links=1&ra=1")
|
99
|
-
find(options)
|
97
|
+
find(connection, options)
|
100
98
|
end
|
101
99
|
|
102
100
|
def build_params(location_code, options)
|
@@ -109,13 +107,13 @@ module Weatherzone
|
|
109
107
|
end
|
110
108
|
|
111
109
|
protected
|
112
|
-
def set_options(options)
|
113
|
-
|
110
|
+
def set_options(connection, options)
|
111
|
+
connection.settings.weather_class ||= self
|
114
112
|
self.temperature_unit = options.delete(:temperature_unit)
|
115
113
|
end
|
116
114
|
|
117
|
-
def make_request(params)
|
118
|
-
response =
|
115
|
+
def make_request(connection, params)
|
116
|
+
response = connection.request(params)
|
119
117
|
parse(response)
|
120
118
|
end
|
121
119
|
|
data/lib/weatherzone.rb
CHANGED
data/test/test_almanac.rb
CHANGED
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestAlmanac < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
super
|
6
|
-
weather = Weather.find_by_location_code("9770")
|
6
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
7
7
|
country = weather.countries.first
|
8
8
|
location = country.locations.first
|
9
9
|
@almanac = location.almanacs.first
|
data/test/test_almanac_period.rb
CHANGED
@@ -4,7 +4,7 @@ class TestAlmanacPeriod < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
almanac = location.almanacs.first
|
@@ -4,7 +4,7 @@ class TestBuoyObservation < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@buoy_observation = location.buoy_observations.first
|
data/test/test_climate_period.rb
CHANGED
@@ -4,7 +4,7 @@ class TestClimatePeriod < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@climate_period = location.climate_periods.first
|
data/test/test_conditions.rb
CHANGED
@@ -4,7 +4,7 @@ class TestConditions < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@conditions = location.conditions.first
|
data/test/test_connection.rb
CHANGED
@@ -3,10 +3,8 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestConnection < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
@connection = Weatherzone::Connection.instance
|
6
|
+
keygen = lambda { "sekret" + password }
|
7
|
+
@connection = Weatherzone::Connection.new("username", "password", keygen, :url => "http://ws1.theweather.com.au/")
|
10
8
|
end
|
11
9
|
|
12
10
|
def test_should_set_username
|
data/test/test_country.rb
CHANGED
@@ -3,8 +3,12 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestCountry < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
6
|
+
keygen = lambda do
|
7
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
8
|
+
end
|
9
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
10
|
+
@connection.stubs(:request).returns( File.open("test/response/everything.xml") )
|
11
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
12
|
@country = weather.countries.first
|
9
13
|
end
|
10
14
|
|
@@ -4,7 +4,7 @@ class TestDailyObservtion < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@daily_observation = location.daily_observations.first
|
@@ -4,7 +4,7 @@ class TestDistrictForecast < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@district_forecast = location.district_forecasts.first
|
data/test/test_exceptions.rb
CHANGED
@@ -2,11 +2,16 @@ require File.dirname(__FILE__) + '/support/dependencies.rb'
|
|
2
2
|
|
3
3
|
class TestExceptions < Test::Unit::TestCase
|
4
4
|
|
5
|
+
# These tests connect to the weatherzone webservice and therefore require your webservice credentials to function as expected.
|
6
|
+
# Set your credentials using the WZ_USER and WZ_PASS environment variables.
|
7
|
+
# Set your web service instance url using the WZ_URL envionment variable.
|
8
|
+
# Create a file .wzkey.rb in the root of this project containing your keygen algorithm.
|
9
|
+
|
5
10
|
def setup
|
6
|
-
|
7
|
-
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
11
|
+
keygen = lambda do
|
12
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
8
13
|
end
|
9
|
-
@connection = Weatherzone::Connection.
|
14
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
10
15
|
end
|
11
16
|
|
12
17
|
def test_should_have_credentials
|
@@ -36,7 +41,7 @@ class TestExceptions < Test::Unit::TestCase
|
|
36
41
|
def test_connection_should_raise_request_failed_on_timeout
|
37
42
|
@connection.timeout_after = 0.1
|
38
43
|
assert_raises Weatherzone::RequestFailed do
|
39
|
-
Weather.find_by_location_name("Sydney")
|
44
|
+
Weather.find_by_location_name(@connection, "Sydney")
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
@@ -6,11 +6,12 @@ class TestFarenheitConversionFactor < Test::Unit::TestCase
|
|
6
6
|
C22P7_AS_F = (BigDecimal("22.7") * BigDecimal("1.8")) + BigDecimal("32")
|
7
7
|
|
8
8
|
def setup
|
9
|
-
|
10
|
-
|
9
|
+
keygen = lambda do
|
10
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
11
11
|
end
|
12
|
-
Weatherzone::Connection.
|
13
|
-
|
12
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
13
|
+
@connection.stubs(:request).returns( File.open("test/response/everything.xml") )
|
14
|
+
weather = Weather.find_by_location_code(@connection, "9770", :temperature_unit => "F")
|
14
15
|
country = weather.countries.first
|
15
16
|
location = country.locations.first
|
16
17
|
@forecast = location.forecasts.first
|
data/test/test_finder.rb
CHANGED
@@ -17,44 +17,44 @@ class TestFinder < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
def test_should_build_parameters
|
19
19
|
SomeResource.expects(:build_params).with(9770, :include => [:forecast])
|
20
|
-
SomeResource.find_by_location_code(9770, :include => [:forecast])
|
20
|
+
SomeResource.find_by_location_code(@connection, 9770, :include => [:forecast])
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_should_make_request
|
24
|
-
|
25
|
-
SomeResource.find_by_location_code(9770, :include => [:forecast])
|
24
|
+
@connection.expects(:request).returns( File.open("test/response/everything.xml") )
|
25
|
+
SomeResource.find_by_location_code(@connection, 9770, :include => [:forecast])
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_should_parse_response
|
29
29
|
f = File.open("test/response/everything.xml")
|
30
|
-
|
30
|
+
@connection.stubs(:request).returns( f )
|
31
31
|
SomeResource.expects(:parse).with(f)
|
32
|
-
SomeResource.find_by_location_code(9770, :include => [:forecast])
|
32
|
+
SomeResource.find_by_location_code(@connection, 9770, :include => [:forecast])
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_should_find_by_location_name
|
36
36
|
SomeResource.expects(:build_params).with(nil, :params => "<=aploc&ln=Sydney%20NSW")
|
37
|
-
SomeResource.find_by_location_name("Sydney NSW")
|
37
|
+
SomeResource.find_by_location_name(@connection, "Sydney NSW")
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_should_find_by_location_filter
|
41
41
|
SomeResource.expects(:build_params).with(nil, :params => "<=twcid&lf=twccapcity")
|
42
|
-
SomeResource.find_by_location_filter("twccapcity")
|
42
|
+
SomeResource.find_by_location_filter(@connection, "twccapcity")
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_should_find_by_district
|
46
46
|
SomeResource.expects(:build_params).with(nil, :params => "<=twcid&dist=N00")
|
47
|
-
SomeResource.find_by_district("N00")
|
47
|
+
SomeResource.find_by_district(@connection, "N00")
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_find_districts_by_state
|
51
51
|
DistrictResource.expects(:build_params).with(nil, :params => "<=dist&state=nsw")
|
52
|
-
DistrictResource.find_districts_by_state("nsw")
|
52
|
+
DistrictResource.find_districts_by_state(@connection, "nsw")
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_should_find_using_arbitrary_include
|
56
56
|
SomeResource.expects(:build_params).with(nil, :include => [:moon_phases])
|
57
|
-
SomeResource.find(:include => [:moon_phases])
|
57
|
+
SomeResource.find(@connection, :include => [:moon_phases])
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_should_include_location_parameter_string
|
data/test/test_forecast.rb
CHANGED
@@ -4,7 +4,7 @@ class TestForecast < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@forecast = location.forecasts.first
|
data/test/test_helper.rb
CHANGED
@@ -2,6 +2,10 @@ require File.dirname(__FILE__) + '/support/dependencies.rb'
|
|
2
2
|
|
3
3
|
class Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
|
5
|
+
keygen = lambda do
|
6
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
7
|
+
end
|
8
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
9
|
+
@connection.stubs(:request).returns( File.open("test/response/everything.xml") )
|
6
10
|
end
|
7
11
|
end
|
@@ -4,7 +4,7 @@ class TestHistoricalObservtion < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@historical_observation = location.historical_observations.first
|
data/test/test_image.rb
CHANGED
@@ -4,7 +4,7 @@ class TestImage < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@image = location.synoptic_charts.first
|
data/test/test_location.rb
CHANGED
@@ -4,7 +4,7 @@ class TestMarineForecast < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@marine_forecast = location.marine_forecasts.first
|
data/test/test_marine_summary.rb
CHANGED
@@ -4,7 +4,7 @@ class TestMarineSummary < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@marine_forecast = location.marine_forecasts.first
|
data/test/test_moon_phase.rb
CHANGED
@@ -3,8 +3,12 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestMoonPhase < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
6
|
+
keygen = lambda do
|
7
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
8
|
+
end
|
9
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
10
|
+
@connection.stubs(:request).returns( File.open("test/response/moon.xml") )
|
11
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
12
|
@moon_phases = weather.moon_phases
|
9
13
|
@moon_phase = @moon_phases.first
|
10
14
|
end
|
data/test/test_news_item.rb
CHANGED
@@ -3,8 +3,12 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestNewsItem < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
6
|
+
keygen = lambda do
|
7
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
8
|
+
end
|
9
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
10
|
+
@connection.stubs(:request).returns( File.open("test/response/news.xml") )
|
11
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
12
|
@news_items = weather.news_items
|
9
13
|
@news_item = @news_items.first
|
10
14
|
end
|
data/test/test_point_forecast.rb
CHANGED
@@ -4,7 +4,7 @@ class TestPointForecast < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
forecast = location.forecasts.first
|
data/test/test_snow_report.rb
CHANGED
@@ -4,7 +4,7 @@ class TestSnowReport < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@snow_report = location.snow_reports.first
|
data/test/test_state_forecast.rb
CHANGED
@@ -4,7 +4,7 @@ class TestStateForecast < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@state_forecast = location.state_forecasts.first
|
data/test/test_surf_report.rb
CHANGED
@@ -4,7 +4,7 @@ class TestSurfReport < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@surf_report = location.surf_reports.first
|
data/test/test_tide.rb
CHANGED
@@ -4,7 +4,7 @@ class TestTide < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
weather = Weather.find_by_location_code("9770")
|
7
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
8
|
country = weather.countries.first
|
9
9
|
location = country.locations.first
|
10
10
|
@tide = location.tides.first
|
@@ -3,11 +3,12 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestValueAndUnitHelpers < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
6
|
+
keygen = lambda do
|
7
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
8
8
|
end
|
9
|
-
Weatherzone::Connection.
|
10
|
-
|
9
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
10
|
+
@connection.stubs(:request).returns( File.open("test/response/everything.xml") )
|
11
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
11
12
|
country = weather.countries.first
|
12
13
|
location = country.locations.first
|
13
14
|
@forecast = location.forecasts.first
|
data/test/test_warning.rb
CHANGED
@@ -3,8 +3,12 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestWarning < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
6
|
+
keygen = lambda do
|
7
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
8
|
+
end
|
9
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
10
|
+
@connection.stubs(:request).returns( File.open("test/response/warnings.xml") )
|
11
|
+
weather = Weather.find_by_location_code(@connection, "9770")
|
8
12
|
country = weather.countries.first
|
9
13
|
location = country.locations.first
|
10
14
|
@warning = location.warnings.first
|
data/test/test_weather.rb
CHANGED
@@ -3,8 +3,12 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestWeather < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
6
|
+
keygen = lambda do
|
7
|
+
eval(File.open(File.dirname(__FILE__) + '/../.wzkey.rb', 'r').read)
|
8
|
+
end
|
9
|
+
@connection = Weatherzone::Connection.new(ENV['WZ_USER'], ENV['WZ_PASS'], keygen, :url => ENV['WZ_URL'], :timeout_after => 10)
|
10
|
+
@connection.stubs(:request).returns( File.open("test/response/everything.xml") )
|
11
|
+
@weather = Weather.find_by_location_code(@connection, "9770")
|
8
12
|
end
|
9
13
|
|
10
14
|
def test_should_be_an_instance_of_weather
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 7
|
8
|
+
- 0
|
9
|
+
version: 0.7.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ben Askins
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-21 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|