barometer 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +7 -0
  3. data/LICENSE +1 -1
  4. data/{README.rdoc → README.md} +124 -110
  5. data/Rakefile +1 -21
  6. data/TODO +8 -9
  7. data/barometer.gemspec +20 -19
  8. data/bin/barometer +36 -83
  9. data/lib/barometer.rb +13 -11
  10. data/lib/barometer/base.rb +10 -10
  11. data/lib/barometer/data.rb +1 -1
  12. data/lib/barometer/data/distance.rb +25 -25
  13. data/lib/barometer/data/geo.rb +9 -9
  14. data/lib/barometer/data/local_datetime.rb +24 -20
  15. data/lib/barometer/data/local_time.rb +13 -13
  16. data/lib/barometer/data/location.rb +6 -6
  17. data/lib/barometer/data/pressure.rb +24 -24
  18. data/lib/barometer/data/speed.rb +28 -28
  19. data/lib/barometer/data/sun.rb +7 -7
  20. data/lib/barometer/data/temperature.rb +29 -29
  21. data/lib/barometer/data/units.rb +9 -9
  22. data/lib/barometer/data/zone.rb +19 -19
  23. data/lib/barometer/formats.rb +1 -1
  24. data/lib/barometer/formats/coordinates.rb +7 -7
  25. data/lib/barometer/formats/format.rb +6 -6
  26. data/lib/barometer/formats/geocode.rb +5 -5
  27. data/lib/barometer/formats/icao.rb +6 -6
  28. data/lib/barometer/formats/postalcode.rb +3 -3
  29. data/lib/barometer/formats/short_zipcode.rb +2 -2
  30. data/lib/barometer/formats/weather_id.rb +10 -10
  31. data/lib/barometer/formats/woe_id.rb +20 -20
  32. data/lib/barometer/formats/zipcode.rb +3 -3
  33. data/lib/barometer/key_file_parser.rb +20 -0
  34. data/lib/barometer/measurements/measurement.rb +32 -32
  35. data/lib/barometer/measurements/result.rb +39 -39
  36. data/lib/barometer/measurements/result_array.rb +12 -12
  37. data/lib/barometer/query.rb +15 -15
  38. data/lib/barometer/services.rb +3 -3
  39. data/lib/barometer/translations/icao_country_codes.yml +20 -20
  40. data/lib/barometer/translations/weather_country_codes.yml +1 -1
  41. data/lib/barometer/translations/zone_codes.yml +2 -2
  42. data/lib/barometer/version.rb +3 -0
  43. data/lib/barometer/weather.rb +27 -27
  44. data/lib/barometer/weather_services/noaa.rb +314 -3
  45. data/lib/barometer/weather_services/service.rb +32 -30
  46. data/lib/barometer/weather_services/weather_bug.rb +35 -33
  47. data/lib/barometer/weather_services/wunderground.rb +31 -29
  48. data/lib/barometer/weather_services/yahoo.rb +36 -35
  49. data/lib/barometer/web_services/geocode.rb +5 -7
  50. data/lib/barometer/web_services/noaa_station_id.rb +53 -0
  51. data/lib/barometer/web_services/placemaker.rb +11 -13
  52. data/lib/barometer/web_services/timezone.rb +5 -7
  53. data/lib/barometer/web_services/weather_id.rb +4 -6
  54. data/lib/barometer/web_services/web_service.rb +4 -4
  55. data/spec/barometer_spec.rb +25 -27
  56. data/spec/cassettes/Barometer.json +1 -0
  57. data/spec/cassettes/Query.json +1 -0
  58. data/spec/cassettes/Query_Format_Coordinates.json +1 -0
  59. data/spec/cassettes/Query_Format_Geocode.json +1 -0
  60. data/spec/cassettes/Query_Format_WeatherID.json +1 -0
  61. data/spec/cassettes/Query_Format_WoeID.json +1 -0
  62. data/spec/cassettes/WeatherService.json +1 -0
  63. data/spec/cassettes/WeatherService_Noaa.json +1 -0
  64. data/spec/cassettes/WeatherService_WeatherBug.json +1 -0
  65. data/spec/cassettes/WeatherService_Wunderground.json +1 -0
  66. data/spec/cassettes/WeatherService_Yahoo.json +1 -0
  67. data/spec/cassettes/WebService_Geocode.json +1 -0
  68. data/spec/cassettes/WebService_NoaaStation.json +1 -0
  69. data/spec/data/distance_spec.rb +60 -60
  70. data/spec/data/geo_spec.rb +23 -23
  71. data/spec/data/local_datetime_spec.rb +44 -44
  72. data/spec/data/local_time_spec.rb +47 -47
  73. data/spec/data/location_spec.rb +16 -16
  74. data/spec/data/pressure_spec.rb +61 -61
  75. data/spec/data/speed_spec.rb +69 -69
  76. data/spec/data/sun_spec.rb +25 -25
  77. data/spec/data/temperature_spec.rb +68 -68
  78. data/spec/data/units_spec.rb +21 -21
  79. data/spec/data/zone_spec.rb +35 -35
  80. data/spec/formats/coordinates_spec.rb +27 -27
  81. data/spec/formats/format_spec.rb +17 -25
  82. data/spec/formats/geocode_spec.rb +23 -31
  83. data/spec/formats/icao_spec.rb +26 -32
  84. data/spec/formats/postalcode_spec.rb +22 -28
  85. data/spec/formats/short_zipcode_spec.rb +20 -26
  86. data/spec/formats/weather_id_spec.rb +57 -67
  87. data/spec/formats/woe_id_spec.rb +59 -59
  88. data/spec/formats/zipcode_spec.rb +39 -47
  89. data/spec/key_file_parser_spec.rb +28 -0
  90. data/spec/measurements/measurement_spec.rb +79 -133
  91. data/spec/measurements/result_array_spec.rb +23 -38
  92. data/spec/measurements/result_spec.rb +100 -128
  93. data/spec/query_spec.rb +83 -100
  94. data/spec/spec_helper.rb +24 -6
  95. data/spec/weather_services/noaa_spec.rb +179 -0
  96. data/spec/weather_services/services_spec.rb +28 -36
  97. data/spec/weather_services/weather_bug_spec.rb +57 -77
  98. data/spec/weather_services/wunderground_spec.rb +36 -65
  99. data/spec/weather_services/yahoo_spec.rb +38 -60
  100. data/spec/weather_spec.rb +79 -79
  101. data/spec/web_services/geocode_spec.rb +7 -11
  102. data/spec/web_services/noaa_station_id_spec.rb +33 -0
  103. data/spec/web_services/placemaker_spec.rb +7 -12
  104. data/spec/web_services/web_services_spec.rb +3 -9
  105. metadata +214 -163
  106. data/VERSION.yml +0 -5
  107. data/lib/barometer/weather_services/google.rb +0 -142
  108. data/lib/barometer/weather_services/weather_dot_com.rb +0 -279
  109. data/spec/fakeweb_helper.rb +0 -179
  110. data/spec/fixtures/formats/weather_id/90210.xml +0 -7
  111. data/spec/fixtures/formats/weather_id/from_USGA0028.xml +0 -3
  112. data/spec/fixtures/formats/weather_id/ksfo.xml +0 -1
  113. data/spec/fixtures/formats/weather_id/manhattan.xml +0 -7
  114. data/spec/fixtures/formats/weather_id/new_york.xml +0 -1
  115. data/spec/fixtures/formats/weather_id/the_hills.xml +0 -1
  116. data/spec/fixtures/geocode/40_73_v3.json +0 -497
  117. data/spec/fixtures/geocode/90210_v3.json +0 -63
  118. data/spec/fixtures/geocode/T5B4M9_v3.json +0 -68
  119. data/spec/fixtures/geocode/atlanta_v3.json +0 -58
  120. data/spec/fixtures/geocode/calgary_ab_v3.json +0 -58
  121. data/spec/fixtures/geocode/ksfo_v3.json +0 -73
  122. data/spec/fixtures/geocode/newyork_ny_v3.json +0 -58
  123. data/spec/fixtures/services/google/calgary_ab.xml +0 -1
  124. data/spec/fixtures/services/placemaker/T5B4M9.xml +0 -65
  125. data/spec/fixtures/services/placemaker/atlanta.xml +0 -65
  126. data/spec/fixtures/services/placemaker/coords.xml +0 -65
  127. data/spec/fixtures/services/placemaker/ksfo.xml +0 -65
  128. data/spec/fixtures/services/placemaker/new_york.xml +0 -65
  129. data/spec/fixtures/services/placemaker/the_hills.xml +0 -65
  130. data/spec/fixtures/services/placemaker/w615702.xml +0 -47
  131. data/spec/fixtures/services/weather_bug/90210_current.xml +0 -93
  132. data/spec/fixtures/services/weather_bug/90210_forecast.xml +0 -76
  133. data/spec/fixtures/services/weather_dot_com/90210.xml +0 -1
  134. data/spec/fixtures/services/wunderground/current_calgary_ab.xml +0 -9
  135. data/spec/fixtures/services/wunderground/forecast_calgary_ab.xml +0 -13
  136. data/spec/fixtures/services/yahoo/90210.xml +0 -3
  137. data/spec/weather_services/google_spec.rb +0 -181
  138. data/spec/weather_services/weather_dot_com_spec.rb +0 -224
@@ -1,63 +0,0 @@
1
- {
2
- "results" : [
3
- {
4
- "address_components" : [
5
- {
6
- "long_name" : "90210",
7
- "short_name" : "90210",
8
- "types" : [ "postal_code" ]
9
- },
10
- {
11
- "long_name" : "Beverly Hills",
12
- "short_name" : "Beverly Hills",
13
- "types" : [ "locality", "political" ]
14
- },
15
- {
16
- "long_name" : "Los Angeles",
17
- "short_name" : "Los Angeles",
18
- "types" : [ "administrative_area_level_2", "political" ]
19
- },
20
- {
21
- "long_name" : "California",
22
- "short_name" : "CA",
23
- "types" : [ "administrative_area_level_1", "political" ]
24
- },
25
- {
26
- "long_name" : "United States",
27
- "short_name" : "US",
28
- "types" : [ "country", "political" ]
29
- }
30
- ],
31
- "formatted_address" : "Beverly Hills, CA 90210, USA",
32
- "geometry" : {
33
- "bounds" : {
34
- "northeast" : {
35
- "lat" : 34.13775590,
36
- "lng" : -118.3896720
37
- },
38
- "southwest" : {
39
- "lat" : 34.0642330,
40
- "lng" : -118.4467160
41
- }
42
- },
43
- "location" : {
44
- "lat" : 34.10300320,
45
- "lng" : -118.41046840
46
- },
47
- "location_type" : "APPROXIMATE",
48
- "viewport" : {
49
- "northeast" : {
50
- "lat" : 34.13775590,
51
- "lng" : -118.3896720
52
- },
53
- "southwest" : {
54
- "lat" : 34.0642330,
55
- "lng" : -118.4467160
56
- }
57
- }
58
- },
59
- "types" : [ "postal_code" ]
60
- }
61
- ],
62
- "status" : "OK"
63
- }
@@ -1,68 +0,0 @@
1
- {
2
- "results" : [
3
- {
4
- "address_components" : [
5
- {
6
- "long_name" : "T5B 4M9",
7
- "short_name" : "T5B 4M9",
8
- "types" : [ "postal_code" ]
9
- },
10
- {
11
- "long_name" : "Montrose",
12
- "short_name" : "Montrose",
13
- "types" : [ "sublocality", "political" ]
14
- },
15
- {
16
- "long_name" : "Edmonton",
17
- "short_name" : "Edmonton",
18
- "types" : [ "locality", "political" ]
19
- },
20
- {
21
- "long_name" : "Division No. 11",
22
- "short_name" : "Division No. 11",
23
- "types" : [ "administrative_area_level_2", "political" ]
24
- },
25
- {
26
- "long_name" : "Alberta",
27
- "short_name" : "AB",
28
- "types" : [ "administrative_area_level_1", "political" ]
29
- },
30
- {
31
- "long_name" : "Canada",
32
- "short_name" : "CA",
33
- "types" : [ "country", "political" ]
34
- }
35
- ],
36
- "formatted_address" : "Edmonton, AB T5B 4M9, Canada",
37
- "geometry" : {
38
- "bounds" : {
39
- "northeast" : {
40
- "lat" : 53.57536850,
41
- "lng" : -113.4531120
42
- },
43
- "southwest" : {
44
- "lat" : 53.57041430,
45
- "lng" : -113.45893970
46
- }
47
- },
48
- "location" : {
49
- "lat" : 53.5705160,
50
- "lng" : -113.457840
51
- },
52
- "location_type" : "APPROXIMATE",
53
- "viewport" : {
54
- "northeast" : {
55
- "lat" : 53.57603902068017,
56
- "lng" : -113.4528782293198
57
- },
58
- "southwest" : {
59
- "lat" : 53.56974377931983,
60
- "lng" : -113.4591734706802
61
- }
62
- }
63
- },
64
- "types" : [ "postal_code" ]
65
- }
66
- ],
67
- "status" : "OK"
68
- }
@@ -1,58 +0,0 @@
1
- {
2
- "results" : [
3
- {
4
- "address_components" : [
5
- {
6
- "long_name" : "Atlanta",
7
- "short_name" : "Atlanta",
8
- "types" : [ "locality", "political" ]
9
- },
10
- {
11
- "long_name" : "Fulton",
12
- "short_name" : "Fulton",
13
- "types" : [ "administrative_area_level_2", "political" ]
14
- },
15
- {
16
- "long_name" : "Georgia",
17
- "short_name" : "GA",
18
- "types" : [ "administrative_area_level_1", "political" ]
19
- },
20
- {
21
- "long_name" : "United States",
22
- "short_name" : "US",
23
- "types" : [ "country", "political" ]
24
- }
25
- ],
26
- "formatted_address" : "Atlanta, GA, USA",
27
- "geometry" : {
28
- "bounds" : {
29
- "northeast" : {
30
- "lat" : 33.88761790,
31
- "lng" : -84.2893890
32
- },
33
- "southwest" : {
34
- "lat" : 33.6478080,
35
- "lng" : -84.55181899999999
36
- }
37
- },
38
- "location" : {
39
- "lat" : 33.74899540,
40
- "lng" : -84.38798240
41
- },
42
- "location_type" : "APPROXIMATE",
43
- "viewport" : {
44
- "northeast" : {
45
- "lat" : 33.82318440,
46
- "lng" : -84.2599230
47
- },
48
- "southwest" : {
49
- "lat" : 33.67474220,
50
- "lng" : -84.51604180
51
- }
52
- }
53
- },
54
- "types" : [ "locality", "political" ]
55
- }
56
- ],
57
- "status" : "OK"
58
- }
@@ -1,58 +0,0 @@
1
- {
2
- "results" : [
3
- {
4
- "address_components" : [
5
- {
6
- "long_name" : "Calgary",
7
- "short_name" : "Calgary",
8
- "types" : [ "locality", "political" ]
9
- },
10
- {
11
- "long_name" : "Division No. 6",
12
- "short_name" : "Division No. 6",
13
- "types" : [ "administrative_area_level_2", "political" ]
14
- },
15
- {
16
- "long_name" : "Alberta",
17
- "short_name" : "AB",
18
- "types" : [ "administrative_area_level_1", "political" ]
19
- },
20
- {
21
- "long_name" : "Canada",
22
- "short_name" : "CA",
23
- "types" : [ "country", "political" ]
24
- }
25
- ],
26
- "formatted_address" : "Calgary, AB, Canada",
27
- "geometry" : {
28
- "bounds" : {
29
- "northeast" : {
30
- "lat" : 51.183830,
31
- "lng" : -113.9056380
32
- },
33
- "southwest" : {
34
- "lat" : 50.84240399999999,
35
- "lng" : -114.271360
36
- }
37
- },
38
- "location" : {
39
- "lat" : 51.04499999999999,
40
- "lng" : -114.05722220
41
- },
42
- "location_type" : "APPROXIMATE",
43
- "viewport" : {
44
- "northeast" : {
45
- "lat" : 51.15710630,
46
- "lng" : -113.80110340
47
- },
48
- "southwest" : {
49
- "lat" : 50.93262180,
50
- "lng" : -114.3133410
51
- }
52
- }
53
- },
54
- "types" : [ "locality", "political" ]
55
- }
56
- ],
57
- "status" : "OK"
58
- }
@@ -1,73 +0,0 @@
1
- {
2
- "results" : [
3
- {
4
- "address_components" : [
5
- {
6
- "long_name" : "San Francisco International Airport",
7
- "short_name" : "SFO",
8
- "types" : [ "establishment" ]
9
- },
10
- {
11
- "long_name" : "San Francisco",
12
- "short_name" : "SF",
13
- "types" : [ "locality", "political" ]
14
- },
15
- {
16
- "long_name" : "South San Francisco",
17
- "short_name" : "South San Francisco",
18
- "types" : [ "administrative_area_level_3", "political" ]
19
- },
20
- {
21
- "long_name" : "San Mateo",
22
- "short_name" : "San Mateo",
23
- "types" : [ "administrative_area_level_2", "political" ]
24
- },
25
- {
26
- "long_name" : "California",
27
- "short_name" : "CA",
28
- "types" : [ "administrative_area_level_1", "political" ]
29
- },
30
- {
31
- "long_name" : "United States",
32
- "short_name" : "US",
33
- "types" : [ "country", "political" ]
34
- },
35
- {
36
- "long_name" : "94128",
37
- "short_name" : "94128",
38
- "types" : [ "postal_code" ]
39
- }
40
- ],
41
- "formatted_address" : "San Francisco International Airport, San Francisco, CA 94128, USA",
42
- "geometry" : {
43
- "bounds" : {
44
- "northeast" : {
45
- "lat" : 37.63921040,
46
- "lng" : -122.35491660
47
- },
48
- "southwest" : {
49
- "lat" : 37.60437690,
50
- "lng" : -122.40141080
51
- }
52
- },
53
- "location" : {
54
- "lat" : 37.6152230,
55
- "lng" : -122.3899790
56
- },
57
- "location_type" : "APPROXIMATE",
58
- "viewport" : {
59
- "northeast" : {
60
- "lat" : 37.6328980,
61
- "lng" : -122.35796420
62
- },
63
- "southwest" : {
64
- "lat" : 37.59754380,
65
- "lng" : -122.42199380
66
- }
67
- }
68
- },
69
- "types" : [ "airport", "airport", "establishment" ]
70
- }
71
- ],
72
- "status" : "OK"
73
- }
@@ -1,58 +0,0 @@
1
- {
2
- "results" : [
3
- {
4
- "address_components" : [
5
- {
6
- "long_name" : "New York",
7
- "short_name" : "New York",
8
- "types" : [ "locality", "political" ]
9
- },
10
- {
11
- "long_name" : "New York",
12
- "short_name" : "New York",
13
- "types" : [ "administrative_area_level_2", "political" ]
14
- },
15
- {
16
- "long_name" : "New York",
17
- "short_name" : "NY",
18
- "types" : [ "administrative_area_level_1", "political" ]
19
- },
20
- {
21
- "long_name" : "United States",
22
- "short_name" : "US",
23
- "types" : [ "country", "political" ]
24
- }
25
- ],
26
- "formatted_address" : "New York, NY, USA",
27
- "geometry" : {
28
- "bounds" : {
29
- "northeast" : {
30
- "lat" : 40.9175770,
31
- "lng" : -73.7002720
32
- },
33
- "southwest" : {
34
- "lat" : 40.4773990,
35
- "lng" : -74.259090
36
- }
37
- },
38
- "location" : {
39
- "lat" : 40.71435280,
40
- "lng" : -74.00597309999999
41
- },
42
- "location_type" : "APPROXIMATE",
43
- "viewport" : {
44
- "northeast" : {
45
- "lat" : 40.84953420,
46
- "lng" : -73.74985430
47
- },
48
- "southwest" : {
49
- "lat" : 40.57889640,
50
- "lng" : -74.26209190
51
- }
52
- }
53
- },
54
- "types" : [ "locality", "political" ]
55
- }
56
- ],
57
- "status" : "OK"
58
- }
@@ -1 +0,0 @@
1
- <?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information><city data="Calgary, AB"/><postal_code data="Calgary,AB"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2011-06-01"/><current_date_time data="2011-06-01 21:51:53 +0000"/><unit_system data="SI"/></forecast_information><current_conditions><condition data="Mostly Cloudy"/><temp_f data="63"/><temp_c data="17"/><humidity data="Humidity: 52%"/><icon data="http://g0.gstatic.com/images/icons/onebox/weather_mostlycloudy-40.gif"/><wind_condition data="Wind: SE at 16 km/h"/></current_conditions><forecast_conditions><day_of_week data="Wed"/><low data="5"/><high data="15"/><icon data="http://g0.gstatic.com/images/icons/onebox/weather_scatteredthunderstorms-40.gif"/><condition data="Scattered Thunderstorms"/></forecast_conditions><forecast_conditions><day_of_week data="Thu"/><low data="7"/><high data="18"/><icon data="http://g0.gstatic.com/images/icons/onebox/weather_thunderstorms-40.gif"/><condition data="Isolated Thunderstorms"/></forecast_conditions><forecast_conditions><day_of_week data="Fri"/><low data="5"/><high data="18"/><icon data="http://g0.gstatic.com/images/icons/onebox/weather_scatteredthunderstorms-40.gif"/><condition data="Scattered Thunderstorms"/></forecast_conditions><forecast_conditions><day_of_week data="Sat"/><low data="7"/><high data="18"/><icon data="http://g0.gstatic.com/images/icons/onebox/weather_scatteredshowers-40.gif"/><condition data="Scattered Showers"/></forecast_conditions></weather></xml_api_reply>
@@ -1,65 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <contentlocation xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xmlns="http://wherein.yahooapis.com/v1/schema" xml:lang="en">
3
- <processingTime>0.000986</processingTime>
4
- <version> build 091119</version>
5
- <documentLength>7</documentLength>
6
- <document>
7
- <administrativeScope>
8
- <woeId>8676</woeId>
9
- <type>Town</type>
10
- <name><![CDATA[Edmonton, Alberta, CA]]></name>
11
- <centroid>
12
- <latitude>53.5462</latitude>
13
- <longitude>-113.49</longitude>
14
- </centroid>
15
- </administrativeScope>
16
- <geographicScope>
17
- <woeId>24354344</woeId>
18
- <type>Zip</type>
19
- <name><![CDATA[T5B 4M9, Edmonton, Alberta, CA]]></name>
20
- <centroid>
21
- <latitude>53.5705</latitude>
22
- <longitude>-113.458</longitude>
23
- </centroid>
24
- </geographicScope>
25
- <extents>
26
- <center>
27
- <latitude>53.5705</latitude>
28
- <longitude>-113.458</longitude>
29
- </center>
30
- <southWest>
31
- <latitude>53.5695</latitude>
32
- <longitude>-113.46</longitude>
33
- </southWest>
34
- <northEast>
35
- <latitude>53.5715</latitude>
36
- <longitude>-113.456</longitude>
37
- </northEast>
38
- </extents>
39
- <placeDetails>
40
- <place>
41
- <woeId>24354344</woeId>
42
- <type>Zip</type>
43
- <name><![CDATA[T5B 4M9, Edmonton, Alberta, CA]]></name>
44
- <centroid>
45
- <latitude>53.5705</latitude>
46
- <longitude>-113.458</longitude>
47
- </centroid>
48
- </place>
49
- <matchType>0</matchType>
50
- <weight>1</weight>
51
- <confidence>7</confidence>
52
- </placeDetails>
53
- <referenceList>
54
- <reference>
55
- <woeIds>24354344</woeIds>
56
- <start>0</start>
57
- <end>7</end>
58
- <isPlaintextMarker>1</isPlaintextMarker>
59
- <text><![CDATA[T5B 4M9]]></text>
60
- <type>plaintext</type>
61
- <xpath><![CDATA[]]></xpath>
62
- </reference>
63
- </referenceList>
64
- </document>
65
- </contentlocation>