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,61 +1,55 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe "Query::Icao" do
4
-
3
+ describe Barometer::Query::Format::Icao do
5
4
  before(:each) do
6
5
  @valid = "KSFO"
7
6
  @invalid = "invalid"
8
7
  end
9
-
8
+
10
9
  describe "and class methods" do
11
-
12
10
  it "returns a format" do
13
- Query::Format::Icao.format.should == :icao
11
+ Barometer::Query::Format::Icao.format.should == :icao
14
12
  end
15
-
13
+
16
14
  it "returns a country" do
17
- Query::Format::Icao.country_code.should be_nil
18
- Query::Format::Icao.country_code("KSFO").should == "US"
19
- Query::Format::Icao.country_code("CYYC").should == "CA"
20
- Query::Format::Icao.country_code("ETAA").should == "DE"
15
+ Barometer::Query::Format::Icao.country_code.should be_nil
16
+ Barometer::Query::Format::Icao.country_code("KSFO").should == "US"
17
+ Barometer::Query::Format::Icao.country_code("CYYC").should == "CA"
18
+ Barometer::Query::Format::Icao.country_code("ETAA").should == "DE"
21
19
  end
22
-
20
+
23
21
  it "returns a regex" do
24
- Query::Format::Icao.regex.should_not be_nil
25
- Query::Format::Icao.regex.is_a?(Regexp).should be_true
22
+ Barometer::Query::Format::Icao.regex.should_not be_nil
23
+ Barometer::Query::Format::Icao.regex.is_a?(Regexp).should be_true
26
24
  end
27
-
25
+
28
26
  it "returns the convertable_formats" do
29
- Query::Format::Icao.convertable_formats.should_not be_nil
30
- Query::Format::Icao.convertable_formats.is_a?(Array).should be_true
31
- Query::Format::Icao.convertable_formats.should == []
27
+ Barometer::Query::Format::Icao.convertable_formats.should_not be_nil
28
+ Barometer::Query::Format::Icao.convertable_formats.is_a?(Array).should be_true
29
+ Barometer::Query::Format::Icao.convertable_formats.should == []
32
30
  end
33
-
31
+
34
32
  describe "is?," do
35
-
36
33
  it "recognizes a valid format" do
37
- Query::Format::Icao.is?(@valid).should be_true
34
+ Barometer::Query::Format::Icao.is?(@valid).should be_true
38
35
  end
39
-
36
+
40
37
  it "recognizes non-valid format" do
41
- Query::Format::Icao.is?(@invalid).should be_false
38
+ Barometer::Query::Format::Icao.is?(@invalid).should be_false
42
39
  end
43
-
44
40
  end
45
-
41
+
46
42
  it "stubs to" do
47
- Query::Format::Icao.to.should be_nil
43
+ Barometer::Query::Format::Icao.to.should be_nil
48
44
  end
49
-
45
+
50
46
  it "stubs convertable_formats" do
51
- Query::Format::Icao.convertable_formats.should == []
47
+ Barometer::Query::Format::Icao.convertable_formats.should == []
52
48
  end
53
-
49
+
54
50
  it "doesn't convert" do
55
51
  query = Barometer::Query.new(@valid)
56
- Query::Format::Icao.converts?(query).should be_false
52
+ Barometer::Query::Format::Icao.converts?(query).should be_false
57
53
  end
58
-
59
54
  end
60
-
61
- end
55
+ end
@@ -1,59 +1,53 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe "Query::Postalcode" do
4
-
3
+ describe Barometer::Query::Format::Postalcode do
5
4
  before(:each) do
6
5
  @valid = "T5B 4M9"
7
6
  @invalid = "90210"
8
7
  end
9
-
8
+
10
9
  describe "and class methods" do
11
-
12
10
  it "returns a format" do
13
- Query::Format::Postalcode.format.should == :postalcode
11
+ Barometer::Query::Format::Postalcode.format.should == :postalcode
14
12
  end
15
-
13
+
16
14
  it "returns a country" do
17
- Query::Format::Postalcode.country_code.should == "CA"
18
- Query::Format::Postalcode.country_code("ignored").should == "CA"
15
+ Barometer::Query::Format::Postalcode.country_code.should == "CA"
16
+ Barometer::Query::Format::Postalcode.country_code("ignored").should == "CA"
19
17
  end
20
-
18
+
21
19
  it "returns a regex" do
22
- Query::Format::Postalcode.regex.should_not be_nil
23
- Query::Format::Postalcode.regex.is_a?(Regexp).should be_true
20
+ Barometer::Query::Format::Postalcode.regex.should_not be_nil
21
+ Barometer::Query::Format::Postalcode.regex.is_a?(Regexp).should be_true
24
22
  end
25
-
23
+
26
24
  it "returns the convertable_formats" do
27
- Query::Format::Postalcode.convertable_formats.should_not be_nil
28
- Query::Format::Postalcode.convertable_formats.is_a?(Array).should be_true
29
- Query::Format::Postalcode.convertable_formats.should == []
25
+ Barometer::Query::Format::Postalcode.convertable_formats.should_not be_nil
26
+ Barometer::Query::Format::Postalcode.convertable_formats.is_a?(Array).should be_true
27
+ Barometer::Query::Format::Postalcode.convertable_formats.should == []
30
28
  end
31
-
29
+
32
30
  describe "is?," do
33
-
34
31
  it "recognizes a valid format" do
35
- Query::Format::Postalcode.is?(@valid).should be_true
32
+ Barometer::Query::Format::Postalcode.is?(@valid).should be_true
36
33
  end
37
-
34
+
38
35
  it "recognizes non-valid format" do
39
- Query::Format::Postalcode.is?(@invalid).should be_false
36
+ Barometer::Query::Format::Postalcode.is?(@invalid).should be_false
40
37
  end
41
-
42
38
  end
43
-
39
+
44
40
  it "stubs to" do
45
- Query::Format::Postalcode.to.should be_nil
41
+ Barometer::Query::Format::Postalcode.to.should be_nil
46
42
  end
47
43
 
48
44
  it "stubs convertable_formats" do
49
- Query::Format::Postalcode.convertable_formats.should == []
45
+ Barometer::Query::Format::Postalcode.convertable_formats.should == []
50
46
  end
51
47
 
52
48
  it "doesn't convert" do
53
49
  query = Barometer::Query.new(@valid)
54
- Query::Format::Postalcode.converts?(query).should be_false
50
+ Barometer::Query::Format::Postalcode.converts?(query).should be_false
55
51
  end
56
-
57
52
  end
58
-
59
- end
53
+ end
@@ -1,53 +1,47 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe "Query::ShortZipcode" do
4
-
3
+ describe Barometer::Query::Format::ShortZipcode do
5
4
  before(:each) do
6
5
  @valid = "90210"
7
6
  @invalid = "90210-5555"
8
7
  end
9
-
8
+
10
9
  describe "and class methods" do
11
-
12
10
  it "returns a format" do
13
- Query::Format::ShortZipcode.format.should == :short_zipcode
11
+ Barometer::Query::Format::ShortZipcode.format.should == :short_zipcode
14
12
  end
15
-
13
+
16
14
  it "returns a country" do
17
- Query::Format::ShortZipcode.country_code.should == "US"
18
- Query::Format::ShortZipcode.country_code("ignored").should == "US"
15
+ Barometer::Query::Format::ShortZipcode.country_code.should == "US"
16
+ Barometer::Query::Format::ShortZipcode.country_code("ignored").should == "US"
19
17
  end
20
-
18
+
21
19
  it "returns a regex" do
22
- Query::Format::ShortZipcode.regex.should_not be_nil
23
- Query::Format::ShortZipcode.regex.is_a?(Regexp).should be_true
20
+ Barometer::Query::Format::ShortZipcode.regex.should_not be_nil
21
+ Barometer::Query::Format::ShortZipcode.regex.is_a?(Regexp).should be_true
24
22
  end
25
-
23
+
26
24
  describe "is?," do
27
-
28
25
  it "recognizes a valid format" do
29
- Query::Format::ShortZipcode.is?(@valid).should be_true
26
+ Barometer::Query::Format::ShortZipcode.is?(@valid).should be_true
30
27
  end
31
-
28
+
32
29
  it "recognizes non-valid format" do
33
- Query::Format::ShortZipcode.is?(@invalid).should be_false
30
+ Barometer::Query::Format::ShortZipcode.is?(@invalid).should be_false
34
31
  end
35
-
36
32
  end
37
-
33
+
38
34
  it "stubs to" do
39
- Query::Format::ShortZipcode.to.should be_nil
35
+ Barometer::Query::Format::ShortZipcode.to.should be_nil
40
36
  end
41
-
37
+
42
38
  it "stubs convertable_formats" do
43
- Query::Format::ShortZipcode.convertable_formats.should == []
39
+ Barometer::Query::Format::ShortZipcode.convertable_formats.should == []
44
40
  end
45
-
41
+
46
42
  it "doesn't convert" do
47
43
  query = Barometer::Query.new(@valid)
48
- Query::Format::ShortZipcode.converts?(query).should be_false
44
+ Barometer::Query::Format::ShortZipcode.converts?(query).should be_false
49
45
  end
50
-
51
46
  end
52
-
53
- end
47
+ end
@@ -1,7 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe "Query::WeatherID" do
4
-
3
+ describe Barometer::Query::Format::WeatherID, :vcr => {
4
+ :cassette_name => "Query::Format::WeatherID"
5
+ } do
5
6
  before(:each) do
6
7
  @short_zipcode = "90210"
7
8
  @zipcode = @short_zipcode
@@ -12,120 +13,112 @@ describe "Query::WeatherID" do
12
13
  @geocode = "New York, NY"
13
14
  @icao = "KSFO"
14
15
  end
15
-
16
+
16
17
  describe "and class methods" do
17
-
18
18
  before(:each) do
19
19
  @us_query = "USGA0000"
20
20
  @ca_query = "CAAB0000"
21
21
  @es_query = "SPXX0000"
22
22
  end
23
-
23
+
24
24
  it "returns a format" do
25
- Query::Format::WeatherID.format.should == :weather_id
25
+ Barometer::Query::Format::WeatherID.format.should == :weather_id
26
26
  end
27
-
27
+
28
28
  it "returns a country" do
29
- Query::Format::WeatherID.country_code.should be_nil
30
- Query::Format::WeatherID.country_code("i").should be_nil
31
- Query::Format::WeatherID.country_code(@us_query).should == "US"
32
- Query::Format::WeatherID.country_code(@ca_query).should == "CA"
33
- Query::Format::WeatherID.country_code(@es_query).should == "ES"
29
+ Barometer::Query::Format::WeatherID.country_code.should be_nil
30
+ Barometer::Query::Format::WeatherID.country_code("i").should be_nil
31
+ Barometer::Query::Format::WeatherID.country_code(@us_query).should == "US"
32
+ Barometer::Query::Format::WeatherID.country_code(@ca_query).should == "CA"
33
+ Barometer::Query::Format::WeatherID.country_code(@es_query).should == "ES"
34
34
  end
35
-
35
+
36
36
  it "returns a regex" do
37
- Query::Format::WeatherID.regex.should_not be_nil
38
- Query::Format::WeatherID.regex.is_a?(Regexp).should be_true
37
+ Barometer::Query::Format::WeatherID.regex.should_not be_nil
38
+ Barometer::Query::Format::WeatherID.regex.is_a?(Regexp).should be_true
39
39
  end
40
-
40
+
41
41
  it "returns the convertable_formats" do
42
- Query::Format::WeatherID.convertable_formats.should_not be_nil
43
- Query::Format::WeatherID.convertable_formats.is_a?(Array).should be_true
44
- Query::Format::WeatherID.convertable_formats.include?(:short_zipcode).should be_true
45
- Query::Format::WeatherID.convertable_formats.include?(:zipcode).should be_true
46
- Query::Format::WeatherID.convertable_formats.include?(:coordinates).should be_true
47
- Query::Format::WeatherID.convertable_formats.include?(:geocode).should be_true
42
+ Barometer::Query::Format::WeatherID.convertable_formats.should_not be_nil
43
+ Barometer::Query::Format::WeatherID.convertable_formats.is_a?(Array).should be_true
44
+ Barometer::Query::Format::WeatherID.convertable_formats.include?(:short_zipcode).should be_true
45
+ Barometer::Query::Format::WeatherID.convertable_formats.include?(:zipcode).should be_true
46
+ Barometer::Query::Format::WeatherID.convertable_formats.include?(:coordinates).should be_true
47
+ Barometer::Query::Format::WeatherID.convertable_formats.include?(:geocode).should be_true
48
48
  end
49
-
49
+
50
50
  describe "is?," do
51
-
52
51
  before(:each) do
53
52
  @valid = "USGA0028"
54
53
  @invalid = "invalid"
55
54
  end
56
-
55
+
57
56
  it "recognizes a valid format" do
58
- Query::Format::WeatherID.is?(@valid).should be_true
57
+ Barometer::Query::Format::WeatherID.is?(@valid).should be_true
59
58
  end
60
-
59
+
61
60
  it "recognizes non-valid format" do
62
- Query::Format::WeatherID.is?(@invalid).should be_false
61
+ Barometer::Query::Format::WeatherID.is?(@invalid).should be_false
63
62
  end
64
-
65
63
  end
66
-
64
+
67
65
  describe "fixing country codes" do
68
-
69
66
  it "doesn't fix a correct code" do
70
- Query::Format::WeatherID.send("_fix_country", "CA").should == "CA"
67
+ Barometer::Query::Format::WeatherID.send("_fix_country", "CA").should == "CA"
71
68
  end
72
-
69
+
73
70
  it "fixes an incorrect code" do
74
- Query::Format::WeatherID.send("_fix_country", "SP").should == "ES"
71
+ Barometer::Query::Format::WeatherID.send("_fix_country", "SP").should == "ES"
75
72
  end
76
-
77
73
  end
78
-
74
+
79
75
  describe "when reversing lookup" do
80
-
81
76
  it "requires a Barometer::Query object" do
82
- lambda { Query::Format::WeatherID.reverse }.should raise_error(ArgumentError)
83
- lambda { Query::Format::WeatherID.reverse("invalid") }.should raise_error(ArgumentError)
77
+ lambda { Barometer::Query::Format::WeatherID.reverse }.should raise_error(ArgumentError)
78
+ lambda { Barometer::Query::Format::WeatherID.reverse("invalid") }.should raise_error(ArgumentError)
84
79
  query = Barometer::Query.new(@weather_id)
85
80
  query.is_a?(Barometer::Query).should be_true
86
- lambda { Query::Format::WeatherID.reverse(original_query) }.should_not raise_error(ArgumentError)
81
+ lambda { Barometer::Query::Format::WeatherID.reverse(original_query) }.should_not raise_error(ArgumentError)
87
82
  end
88
-
83
+
89
84
  it "returns a Barometer::Query" do
90
85
  query = Barometer::Query.new(@weather_id)
91
- Query::Format::WeatherID.reverse(query).is_a?(Barometer::Query).should be_true
86
+ Barometer::Query::Format::WeatherID.reverse(query).is_a?(Barometer::Query).should be_true
92
87
  end
93
-
88
+
94
89
  it "reverses a valid weather_id (US)" do
95
90
  query = Barometer::Query.new(@weather_id)
96
- new_query = Query::Format::WeatherID.reverse(query)
91
+ new_query = Barometer::Query::Format::WeatherID.reverse(query)
97
92
  new_query.q.should == "Atlanta, GA, US"
98
93
  new_query.country_code.should be_nil
99
94
  new_query.format.should == :geocode
100
95
  new_query.geo.should be_nil
101
96
  end
102
-
97
+
103
98
  it "doesn't reverse an invalid weather_id" do
104
99
  query = Barometer::Query.new(@zipcode)
105
- Query::Format::WeatherID.reverse(query).should be_nil
100
+ Barometer::Query::Format::WeatherID.reverse(query).should be_nil
106
101
  end
107
-
108
102
  end
109
-
103
+
110
104
  describe "when converting using 'to'," do
111
-
112
105
  it "requires a Barometer::Query object" do
113
- lambda { Query::Format::WeatherID.to }.should raise_error(ArgumentError)
114
- lambda { Query::Format::WeatherID.to("invalid") }.should raise_error(ArgumentError)
106
+ lambda { Barometer::Query::Format::WeatherID.to }.should raise_error(ArgumentError)
107
+ lambda { Barometer::Query::Format::WeatherID.to("invalid") }.should raise_error(ArgumentError)
115
108
  query = Barometer::Query.new(@zipcode)
116
109
  query.is_a?(Barometer::Query).should be_true
117
- lambda { Query::Format::WeatherID.to(original_query) }.should_not raise_error(ArgumentError)
110
+ lambda { Barometer::Query::Format::WeatherID.to(original_query) }.should_not raise_error(ArgumentError)
118
111
  end
119
-
112
+
120
113
  it "returns a Barometer::Query" do
121
114
  query = Barometer::Query.new(@short_zipcode)
122
- Query::Format::WeatherID.to(query).is_a?(Barometer::Query).should be_true
115
+ Barometer::Query::Format::WeatherID.to(query).is_a?(Barometer::Query).should be_true
123
116
  end
124
-
117
+
125
118
  it "converts from short_zipcode" do
126
119
  query = Barometer::Query.new(@short_zipcode)
127
120
  query.format.should == :short_zipcode
128
- new_query = Query::Format::WeatherID.to(query)
121
+ new_query = Barometer::Query::Format::WeatherID.to(query)
129
122
  new_query.q.should == "USCA0090"
130
123
  new_query.country_code.should == "US"
131
124
  new_query.format.should == :weather_id
@@ -136,7 +129,7 @@ describe "Query::WeatherID" do
136
129
  query = Barometer::Query.new(@zipcode)
137
130
  query.format = :zipcode
138
131
  query.format.should == :zipcode
139
- new_query = Query::Format::WeatherID.to(query)
132
+ new_query = Barometer::Query::Format::WeatherID.to(query)
140
133
  new_query.q.should == "USCA0090"
141
134
  new_query.country_code.should == "US"
142
135
  new_query.format.should == :weather_id
@@ -146,7 +139,7 @@ describe "Query::WeatherID" do
146
139
  it "converts from coordinates" do
147
140
  query = Barometer::Query.new(@coordinates)
148
141
  query.format.should == :coordinates
149
- new_query = Query::Format::WeatherID.to(query)
142
+ new_query = Barometer::Query::Format::WeatherID.to(query)
150
143
  new_query.q.should == "USNY0996"
151
144
  new_query.country_code.should == "US"
152
145
  new_query.format.should == :weather_id
@@ -156,7 +149,7 @@ describe "Query::WeatherID" do
156
149
  it "converts from geocode" do
157
150
  query = Barometer::Query.new(@geocode)
158
151
  query.format.should == :geocode
159
- new_query = Query::Format::WeatherID.to(query)
152
+ new_query = Barometer::Query::Format::WeatherID.to(query)
160
153
  new_query.q.should == "USNY0996"
161
154
  new_query.country_code.should == "US"
162
155
  new_query.format.should == :weather_id
@@ -166,7 +159,7 @@ describe "Query::WeatherID" do
166
159
  it "converts from icao" do
167
160
  query = Barometer::Query.new(@icao)
168
161
  query.format.should == :icao
169
- new_query = Query::Format::WeatherID.to(query)
162
+ new_query = Barometer::Query::Format::WeatherID.to(query)
170
163
  new_query.q.should == "USCA0987"
171
164
  new_query.country_code.should == "US"
172
165
  new_query.format.should == :weather_id
@@ -176,17 +169,14 @@ describe "Query::WeatherID" do
176
169
  it "returns nil for other formats" do
177
170
  query = Barometer::Query.new(@weather_id)
178
171
  query.format.should == :weather_id
179
- new_query = Query::Format::WeatherID.to(query)
172
+ new_query = Barometer::Query::Format::WeatherID.to(query)
180
173
  new_query.should be_nil
181
-
174
+
182
175
  query = Barometer::Query.new(@postal_code)
183
176
  query.format.should == :postalcode
184
- new_query = Query::Format::WeatherID.to(query)
177
+ new_query = Barometer::Query::Format::WeatherID.to(query)
185
178
  new_query.should be_nil
186
179
  end
187
-
188
180
  end
189
-
190
181
  end
191
-
192
- end
182
+ end