weatherzone 0.5.8

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.
Files changed (79) hide show
  1. data/History.txt +6 -0
  2. data/Manifest.txt +51 -0
  3. data/README.txt +30 -0
  4. data/Rakefile +7 -0
  5. data/bin/weatherzone +0 -0
  6. data/lib/ext/class.rb +175 -0
  7. data/lib/ext/object.rb +74 -0
  8. data/lib/tzinfo/definitions/Australia/CDT.rb +13 -0
  9. data/lib/tzinfo/definitions/Australia/CST.rb +13 -0
  10. data/lib/tzinfo/definitions/Australia/EDT.rb +13 -0
  11. data/lib/tzinfo/definitions/Australia/EST.rb +13 -0
  12. data/lib/tzinfo/definitions/Australia/WDT.rb +13 -0
  13. data/lib/tzinfo/definitions/Australia/WST.rb +13 -0
  14. data/lib/vendor/openuri_memcached/History.txt +18 -0
  15. data/lib/vendor/openuri_memcached/License.txt +20 -0
  16. data/lib/vendor/openuri_memcached/README.markdown +48 -0
  17. data/lib/vendor/openuri_memcached/lib/openuri/common.rb +117 -0
  18. data/lib/vendor/openuri_memcached/lib/openuri/memcached.rb +36 -0
  19. data/lib/vendor/openuri_memcached/lib/openuri/rails-cache.rb +21 -0
  20. data/lib/vendor/openuri_memcached/lib/openuri_memcached.rb +1 -0
  21. data/lib/weatherzone.rb +39 -0
  22. data/lib/weatherzone/connection.rb +85 -0
  23. data/lib/weatherzone/finder.rb +129 -0
  24. data/lib/weatherzone/helpers/almanac_element.rb +28 -0
  25. data/lib/weatherzone/helpers/date_parser.rb +33 -0
  26. data/lib/weatherzone/helpers/units.rb +76 -0
  27. data/lib/weatherzone/resource.rb +46 -0
  28. data/lib/weatherzone/resources/almanac.rb +18 -0
  29. data/lib/weatherzone/resources/almanac_period.rb +51 -0
  30. data/lib/weatherzone/resources/climate_period.rb +8 -0
  31. data/lib/weatherzone/resources/conditions.rb +19 -0
  32. data/lib/weatherzone/resources/country.rb +4 -0
  33. data/lib/weatherzone/resources/daily_observation.rb +10 -0
  34. data/lib/weatherzone/resources/district_forecast.rb +5 -0
  35. data/lib/weatherzone/resources/forecast.rb +47 -0
  36. data/lib/weatherzone/resources/historical_observation.rb +57 -0
  37. data/lib/weatherzone/resources/image.rb +9 -0
  38. data/lib/weatherzone/resources/lift.rb +3 -0
  39. data/lib/weatherzone/resources/location.rb +100 -0
  40. data/lib/weatherzone/resources/marine_forecast.rb +9 -0
  41. data/lib/weatherzone/resources/marine_summary.rb +8 -0
  42. data/lib/weatherzone/resources/moon_phase.rb +23 -0
  43. data/lib/weatherzone/resources/news_item.rb +18 -0
  44. data/lib/weatherzone/resources/point_forecast.rb +40 -0
  45. data/lib/weatherzone/resources/snow_report.rb +5 -0
  46. data/lib/weatherzone/resources/state_forecast.rb +4 -0
  47. data/lib/weatherzone/resources/surf_report.rb +5 -0
  48. data/lib/weatherzone/resources/tide.rb +9 -0
  49. data/lib/weatherzone/resources/warning.rb +21 -0
  50. data/lib/weatherzone/resources/weather.rb +14 -0
  51. data/test/test_almanac.rb +25 -0
  52. data/test/test_almanac_period.rb +33 -0
  53. data/test/test_buoy_observation.rb +24 -0
  54. data/test/test_climate_period.rb +29 -0
  55. data/test/test_conditions.rb +32 -0
  56. data/test/test_connection.rb +28 -0
  57. data/test/test_country.rb +29 -0
  58. data/test/test_daily_observation.rb +29 -0
  59. data/test/test_district_forecast.rb +23 -0
  60. data/test/test_farenheit_conversion_factor.rb +48 -0
  61. data/test/test_finder.rb +148 -0
  62. data/test/test_forecast.rb +30 -0
  63. data/test/test_helper.rb +38 -0
  64. data/test/test_historical_observation.rb +32 -0
  65. data/test/test_image.rb +23 -0
  66. data/test/test_location.rb +70 -0
  67. data/test/test_marine_forecast.rb +27 -0
  68. data/test/test_marine_summary.rb +24 -0
  69. data/test/test_moon_phase.rb +33 -0
  70. data/test/test_news_item.rb +22 -0
  71. data/test/test_point_forecast.rb +24 -0
  72. data/test/test_snow_report.rb +27 -0
  73. data/test/test_state_forecast.rb +23 -0
  74. data/test/test_surf_report.rb +22 -0
  75. data/test/test_tide.rb +23 -0
  76. data/test/test_value_and_unit_helpers.rb +45 -0
  77. data/test/test_warning.rb +23 -0
  78. data/test/test_weather.rb +22 -0
  79. metadata +146 -0
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestMoonPhase < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Weatherzone::Connection.instance.stubs(:request).returns( File.open("test/response/moon.xml") )
7
+ weather = Weather.find_by_location_code("9770")
8
+ @moon_phases = weather.moon_phases
9
+ @moon_phase = @moon_phases.first
10
+ end
11
+
12
+ def test_should_be_a_moon_phase
13
+ assert_kind_of MoonPhase, @moon_phase
14
+ end
15
+
16
+ def test_should_not_have_nil_attributes
17
+ [:day, :day_name, :date, :moon_phase_phase_text, :moon_phase_phase_num, :moon_phase_image_name].each do |attr_name|
18
+ assert_not_nil @moon_phase.send(attr_name), "@moon_phase should respond to #{attr_name}"
19
+ end
20
+ end
21
+
22
+ def test_should_be_four_phases
23
+ assert_equal 4, @moon_phases.length
24
+ end
25
+
26
+ def test_should_translate_phase_text
27
+ assert_equal "New moon", @moon_phases[0].phase_text
28
+ assert_equal "First quarter", @moon_phases[1].phase_text
29
+ assert_equal "Full moon", @moon_phases[2].phase_text
30
+ assert_equal "Last quarter", @moon_phases[3].phase_text
31
+ end
32
+
33
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestNewsItem < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Weatherzone::Connection.instance.stubs(:request).returns( File.open("test/response/news.xml") )
7
+ weather = Weather.find_by_location_code("9770")
8
+ @news_items = weather.news_items
9
+ @news_item = @news_items.first
10
+ end
11
+
12
+ def test_should_be_a_news_item
13
+ assert_kind_of NewsItem, @news_item
14
+ end
15
+
16
+ def test_should_not_have_nil_attributes
17
+ [:link_url, :title, :byline, :dateline, :creditline, :copyright, :text, :dateline_date, :copyright_date, :link_type, :link_description].each do |attr_name|
18
+ assert_not_nil @news_item.send(attr_name), "@news_item should respond to #{attr_name}"
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestPointForecast < Test::Unit::TestCase
4
+
5
+ def setup
6
+ super
7
+ weather = Weather.find_by_location_code("9770")
8
+ country = weather.countries.first
9
+ location = country.locations.first
10
+ forecast = location.forecasts.first
11
+ @point_forecast = forecast.point_forecasts.first
12
+ end
13
+
14
+ def test_should_be_a_point_forecast
15
+ assert_kind_of PointForecast, @point_forecast
16
+ end
17
+
18
+ def test_should_not_have_nil_attributes
19
+ [:dp_c, :rh, :wind_dir_degrees, :wind_dir_compass, :wind_speed_kph].each do |attr_name|
20
+ assert_not_nil @point_forecast.send(attr_name), "@point_forecast should respond to #{attr_name}"
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestSnowReport < Test::Unit::TestCase
4
+
5
+ def setup
6
+ super
7
+ weather = Weather.find_by_location_code("9770")
8
+ country = weather.countries.first
9
+ location = country.locations.first
10
+ @snow_report = location.snow_reports.first
11
+ end
12
+
13
+ def test_should_be_a_snow_report
14
+ assert_kind_of SnowReport, @snow_report
15
+ end
16
+
17
+ def test_should_have_many_lifts
18
+ assert @snow_report.lifts.any?
19
+ end
20
+
21
+ def test_should_not_have_nil_attributes
22
+ [:day_name, :issue_time_local, :visibility_text, :road_conditions, :primary_surface, :snow_conditions, :snow_cover, :snow_depth_avg_cm, :snow_depth_new_cm,
23
+ :snow_making, :grooming, :last_snowfall_date, :resort_summary, :lifts_open].each do |attr_name|
24
+ assert_not_nil @snow_report.send(attr_name), "@snow_report should respond to #{attr_name}"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestStateForecast < Test::Unit::TestCase
4
+
5
+ def setup
6
+ super
7
+ weather = Weather.find_by_location_code("9770")
8
+ country = weather.countries.first
9
+ location = country.locations.first
10
+ @state_forecast = location.state_forecasts.first
11
+ end
12
+
13
+ def test_should_be_a_state_forecast
14
+ assert_kind_of StateForecast, @state_forecast
15
+ end
16
+
17
+ def test_should_not_have_nil_attributes
18
+ [:period, :period_name, :precis].each do |attr_name|
19
+ assert_not_nil @state_forecast.send(attr_name), "@state_forecast should respond to #{attr_name}"
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestSurfReport < Test::Unit::TestCase
4
+
5
+ def setup
6
+ super
7
+ weather = Weather.find_by_location_code("9770")
8
+ country = weather.countries.first
9
+ location = country.locations.first
10
+ @surf_report = location.surf_reports.first
11
+ end
12
+
13
+ def test_should_be_a_surf_report
14
+ assert_kind_of SurfReport, @surf_report
15
+ end
16
+
17
+ def test_should_not_have_nil_attributes
18
+ [:issue_day_name, :issue_time_local, :report_day_name, :report_time_local, :image_url, :surf_summary_text, :wind_text, :weather_text, :summary].each do |attr_name|
19
+ assert_not_nil @surf_report.send(attr_name), "@surf_report should respond to #{attr_name}"
20
+ end
21
+ end
22
+ end
data/test/test_tide.rb ADDED
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTide < Test::Unit::TestCase
4
+
5
+ def setup
6
+ super
7
+ weather = Weather.find_by_location_code("9770")
8
+ country = weather.countries.first
9
+ location = country.locations.first
10
+ @tide = location.tides.first
11
+ end
12
+
13
+ def test_should_be_a_tide
14
+ assert_kind_of Tide, @tide
15
+ end
16
+
17
+ def test_should_not_have_nil_attributes
18
+ [:day_name, :time, :tide_type, :tide_height_m, :tide_height_m_units, :time_tz].each do |attr_name|
19
+ assert_not_nil @tide.send(attr_name), "@tide should respond to #{attr_name}"
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestValueAndUnitHelpers < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Weatherzone::Connection.connect("username", "password") do
7
+ "sekret" + Weatherzone::Connection.instance.password
8
+ end
9
+ Weatherzone::Connection.instance.stubs(:request).returns( File.open("test/response/everything.xml") )
10
+ weather = Weather.find_by_location_code("9770")
11
+ country = weather.countries.first
12
+ location = country.locations.first
13
+ @forecast = location.forecasts.first
14
+ @conditions = location.conditions.first
15
+ end
16
+
17
+ def test_forecast_should_have_min_temp_value
18
+ assert_equal "21", @forecast.temp_min_c_value
19
+ end
20
+
21
+ def test_forecast_should_have_min_temp_value_with_units
22
+ assert_equal "21°C", @forecast.temp_min_c
23
+ end
24
+
25
+ def test_forecast_should_have_min_temp_units
26
+ assert_equal "°C", @forecast.temp_min_c_units
27
+ end
28
+
29
+ def test_conditions_should_have_temp_value
30
+ assert_equal "22.7", @conditions.temp_c_value
31
+ end
32
+
33
+ def test_conditions_should_have_rainfall_value
34
+ assert_equal "0.0", @conditions.rainfall_mm_value
35
+ end
36
+
37
+ def test_conditions_should_have_rainfall_value_with_units
38
+ assert_equal "0.0mm", @conditions.rainfall_mm
39
+ end
40
+
41
+ def test_conditions_should_have_rainfall_units
42
+ assert_equal "mm", @conditions.rainfall_mm_units
43
+ end
44
+
45
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestWarning < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Weatherzone::Connection.instance.stubs(:request).returns( File.open("test/response/warnings.xml") )
7
+ weather = Weather.find_by_location_code("9770")
8
+ country = weather.countries.first
9
+ location = country.locations.first
10
+ @warning = location.warnings.first
11
+ end
12
+
13
+ def test_should_be_a_warning
14
+ assert_kind_of Warning, @warning
15
+ end
16
+
17
+ def test_should_not_have_nil_attributes
18
+ [:id, :type, :issue_day_name, :issue_time_local, :expire_time_local, :short_text, :url].each do |attr_name|
19
+ assert_not_nil @warning.send(attr_name), "@warning should respond to #{attr_name}"
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestWeather < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Weatherzone::Connection.instance.stubs(:request).returns( File.open("test/response/everything.xml") )
7
+ @weather = Weather.find_by_location_code("9770")
8
+ end
9
+
10
+ def test_should_be_an_instance_of_weather
11
+ assert_kind_of Weather, @weather
12
+ end
13
+
14
+ def test_should_have_countries
15
+ assert @weather.countries.any?
16
+ end
17
+
18
+ def test_countries_should_be_countries
19
+ assert_kind_of Country, @weather.countries.first
20
+ end
21
+
22
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: weatherzone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.8
5
+ platform: ruby
6
+ authors:
7
+ - Ben Askins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-17 00:00:00 +11:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.0
24
+ version:
25
+ description: Ruby client for the weatherzone webservice.
26
+ email:
27
+ - ben.askins@gmail.com
28
+ executables:
29
+ - weatherzone
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ - Manifest.txt
35
+ - README.txt
36
+ - lib/vendor/openuri_memcached/History.txt
37
+ - lib/vendor/openuri_memcached/License.txt
38
+ files:
39
+ - History.txt
40
+ - Manifest.txt
41
+ - README.txt
42
+ - Rakefile
43
+ - bin/weatherzone
44
+ - lib/ext/class.rb
45
+ - lib/ext/object.rb
46
+ - lib/weatherzone.rb
47
+ - lib/weatherzone/connection.rb
48
+ - lib/weatherzone/resource.rb
49
+ - lib/weatherzone/finder.rb
50
+ - lib/weatherzone/helpers/almanac_element.rb
51
+ - lib/weatherzone/helpers/date_parser.rb
52
+ - lib/weatherzone/helpers/units.rb
53
+ - lib/weatherzone/resources/almanac.rb
54
+ - lib/weatherzone/resources/almanac_period.rb
55
+ - lib/weatherzone/resources/conditions.rb
56
+ - lib/weatherzone/resources/country.rb
57
+ - lib/weatherzone/resources/daily_observation.rb
58
+ - lib/weatherzone/resources/district_forecast.rb
59
+ - lib/weatherzone/resources/forecast.rb
60
+ - lib/weatherzone/resources/historical_observation.rb
61
+ - lib/weatherzone/resources/climate_period.rb
62
+ - lib/weatherzone/resources/image.rb
63
+ - lib/weatherzone/resources/tide.rb
64
+ - lib/weatherzone/resources/location.rb
65
+ - lib/weatherzone/resources/moon_phase.rb
66
+ - lib/weatherzone/resources/news_item.rb
67
+ - lib/weatherzone/resources/point_forecast.rb
68
+ - lib/weatherzone/resources/state_forecast.rb
69
+ - lib/weatherzone/resources/marine_forecast.rb
70
+ - lib/weatherzone/resources/marine_summary.rb
71
+ - lib/weatherzone/resources/lift.rb
72
+ - lib/weatherzone/resources/snow_report.rb
73
+ - lib/weatherzone/resources/surf_report.rb
74
+ - lib/weatherzone/resources/warning.rb
75
+ - lib/weatherzone/resources/weather.rb
76
+ - lib/vendor/openuri_memcached/History.txt
77
+ - lib/vendor/openuri_memcached/License.txt
78
+ - lib/vendor/openuri_memcached/README.markdown
79
+ - lib/vendor/openuri_memcached/lib/openuri_memcached.rb
80
+ - lib/vendor/openuri_memcached/lib/openuri/common.rb
81
+ - lib/vendor/openuri_memcached/lib/openuri/memcached.rb
82
+ - lib/vendor/openuri_memcached/lib/openuri/rails-cache.rb
83
+ - lib/tzinfo/definitions/Australia/CDT.rb
84
+ - lib/tzinfo/definitions/Australia/CST.rb
85
+ - lib/tzinfo/definitions/Australia/EDT.rb
86
+ - lib/tzinfo/definitions/Australia/EST.rb
87
+ - lib/tzinfo/definitions/Australia/WDT.rb
88
+ - lib/tzinfo/definitions/Australia/WST.rb
89
+ has_rdoc: true
90
+ homepage: http://github.com/benaskins/weatherzone/
91
+ licenses: []
92
+
93
+ post_install_message:
94
+ rdoc_options:
95
+ - --main
96
+ - README.txt
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: "0"
104
+ version:
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: "0"
110
+ version:
111
+ requirements: []
112
+
113
+ rubyforge_project: weatherzone
114
+ rubygems_version: 1.3.4
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Ruby client for the weatherzone webservice.
118
+ test_files:
119
+ - test/test_almanac.rb
120
+ - test/test_almanac_period.rb
121
+ - test/test_buoy_observation.rb
122
+ - test/test_climate_period.rb
123
+ - test/test_conditions.rb
124
+ - test/test_connection.rb
125
+ - test/test_country.rb
126
+ - test/test_daily_observation.rb
127
+ - test/test_district_forecast.rb
128
+ - test/test_farenheit_conversion_factor.rb
129
+ - test/test_finder.rb
130
+ - test/test_forecast.rb
131
+ - test/test_helper.rb
132
+ - test/test_historical_observation.rb
133
+ - test/test_image.rb
134
+ - test/test_location.rb
135
+ - test/test_marine_forecast.rb
136
+ - test/test_marine_summary.rb
137
+ - test/test_moon_phase.rb
138
+ - test/test_news_item.rb
139
+ - test/test_point_forecast.rb
140
+ - test/test_snow_report.rb
141
+ - test/test_state_forecast.rb
142
+ - test/test_surf_report.rb
143
+ - test/test_tide.rb
144
+ - test/test_value_and_unit_helpers.rb
145
+ - test/test_warning.rb
146
+ - test/test_weather.rb