yahoo_weatherman 1.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ 0: Ανεμοστρόβιλος
2
+ 1: Τροπική Θύελλα
3
+ 2: Τυφώνας
4
+ 3: Ισχυρές Βροχοπτώσεις
5
+ 4: Βροχοπτώσεις
6
+ 5: Βροχή και χιόνι
7
+ 6: Βροχή και χιονόνερο
8
+ 7: Βροχές και χιόνια
9
+ 8: Ψιλόχροβο
10
+ 9: Ψιχαλίζει
11
+ 10: Κρύα βροχή
12
+ 11: Καταιγίδες
13
+ 12: Καταιγίδες
14
+ 13: Νιφάδες χιονιού
15
+ 14: Χιονοπτώσεις
16
+ 15: Χιόνι κι άνεμοι
17
+ 16: Χιόνι
18
+ 17: Χαλάζι
19
+ 18: Χαλάζι
20
+ 19: Σκόνη
21
+ 20: Ομιχλώδης
22
+ 21: Ομίχλη
23
+ 22: Ομίχλη
24
+ 23: Θυελλώδης
25
+ 24: Ανεμώδης
26
+ 25: Κρύο
27
+ 26: Συννεφιασμένος
28
+ 27: Νεφελώδης (νύχτα)
29
+ 28: Νεφελώδης (ημέρα)
30
+ 29: Πυκνή συννεφιά (νύχτα)
31
+ 30: Πυκνή συννεφιά (ημέρα)
32
+ 31: Hλιοφάνεια
33
+ 32: Hλιοφάνεια
34
+ 33: Ξαστεριά
35
+ 34: Hλιοφάνεια χωρίς σύννεφα
36
+ 35: Μείγμα χιόνι και χαλάζι
37
+ 36: Καύσωνας
38
+ 37: Καταιγίδες
39
+ 38: Περιοδικές καταιγίδες
40
+ 39: Περιοδικές καταιγίδες
41
+ 40: Βροχή
42
+ 41: Χιονοθέλλα
43
+ 42: Χιόνι περιοδικά
44
+ 43: Πολύ χιόνι
45
+ 44: Αίθριος
46
+ 45: Καταιγίδες
47
+ 46: Καταιγίδα χιονιού
48
+ 47: Καταιγίδες
49
+ 3200: Χωρίς περιγραφή
50
+
51
+ locations:
52
+ Greece:
53
+
54
+ forecasts:
55
+ days:
56
+ Mon: Δευτέρα
57
+ Tue: Τρίτη
58
+ Wed: Τετάρτη
59
+ Thu: Πέμπτη
60
+ Fri: Παρασκευή
61
+ Sat: Σάββατο
62
+ Sun: Κυριακή
@@ -13,7 +13,7 @@ require 'yahoo_weatherman/response'
13
13
 
14
14
  module Weatherman
15
15
 
16
- VERSION = '1.2.2'
16
+ VERSION = '2.0.0'
17
17
 
18
18
  URI = 'http://weather.yahooapis.com/forecastrss'
19
19
 
@@ -35,12 +35,9 @@ module Weatherman
35
35
  #
36
36
  # +lang+: the language used in the response
37
37
  #
38
- # +app_id+: your yahoo app id (necessary for searching by location).
39
- #
40
38
  def initialize(options = {})
41
39
  @options = options
42
40
  @uri = options[:url] || URI
43
- @app_id = options[:app_id]
44
41
  end
45
42
 
46
43
  #
@@ -55,7 +52,7 @@ module Weatherman
55
52
  # Looks up weather by location.
56
53
  #
57
54
  def lookup_by_location(location)
58
- lookup = WoeidLookup.new(@app_id)
55
+ lookup = WoeidLookup.new
59
56
  woeid = lookup.get_woeid(location)
60
57
  lookup_by_woeid(woeid)
61
58
  end
@@ -3,21 +3,17 @@ require 'cgi'
3
3
  module Weatherman
4
4
  class WoeidLookup
5
5
 
6
- def initialize(app_id)
7
- @app_id = app_id
8
- end
9
-
10
6
  def get_woeid(location)
11
7
  raw = get query_string(location)
12
8
  Nokogiri::HTML(raw).at_xpath('.//woeid').content
13
9
  rescue
14
10
  nil
15
11
  end
16
-
12
+
17
13
  private
18
14
 
19
15
  def query_string(location)
20
- "http://where.yahooapis.com/v1/places.q('#{::CGI.escape(location)}')?appid=#{@app_id}"
16
+ "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22#{::CGI.escape(location)}%22%20and%20gflags%3D%22R%22"
21
17
  end
22
18
 
23
19
  def get(url)
@@ -43,11 +43,17 @@ module WoeidHelper
43
43
  File.open(File.dirname(__FILE__) + "/files/#{file}.xml").read
44
44
  end
45
45
 
46
- def self.register_this_woeid_lookup_result(result, app_id, location)
47
- FakeWeb.register_uri(:get, "http://where.yahooapis.com/v1/places.q('#{location}')?appid=#{app_id}", :body => result)
46
+ def self.register_this_woeid_lookup_result(result, location)
47
+ FakeWeb.register_uri(:get, lookup_uri(location), :body => result)
48
48
  end
49
49
 
50
- def self.register_this_woeid_lookup_to_fail(app_id, location)
51
- FakeWeb.register_uri(:get, "http://where.yahooapis.com/v1/places.q('#{location}')?appid=#{app_id}", :exception => Net::HTTPError)
50
+ def self.register_this_woeid_lookup_to_fail(location)
51
+ FakeWeb.register_uri(:get, lookup_uri(location), :exception => Net::HTTPError)
52
+ end
53
+
54
+ private
55
+
56
+ def self.lookup_uri(location)
57
+ "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22#{location}%22%20and%20gflags%3D%22R%22"
52
58
  end
53
59
  end
@@ -2,14 +2,13 @@ require 'spec_helper'
2
2
  Dir[File.dirname(__FILE__) + '/directory/*.rb'].each {|file| require file }
3
3
 
4
4
  describe Weatherman::WoeidLookup do
5
- describe "example with test_api_id and 66061" do
5
+ describe "example with 66061" do
6
6
  before do
7
- @app_id = 'test_api_id'
8
7
  @location = '66061'
9
- @lookup = Weatherman::WoeidLookup.new(@app_id)
8
+ @lookup = Weatherman::WoeidLookup.new
10
9
 
11
10
  xml_result = WoeidHelper.open_test_file('woeid_result_that_returns_12786745')
12
- WoeidHelper.register_this_woeid_lookup_result(xml_result, @app_id, @location)
11
+ WoeidHelper.register_this_woeid_lookup_result(xml_result, @location)
13
12
  end
14
13
 
15
14
  it "should retrieve the woeid" do
@@ -20,12 +19,11 @@ describe Weatherman::WoeidLookup do
20
19
 
21
20
  describe "example with another_api and 90210" do
22
21
  before do
23
- @app_id = 'another_api'
24
22
  @location = '90210'
25
- @lookup = Weatherman::WoeidLookup.new(@app_id)
23
+ @lookup = Weatherman::WoeidLookup.new
26
24
 
27
25
  xml_result = WoeidHelper.open_test_file('woeid_result_that_returns_4729347')
28
- WoeidHelper.register_this_woeid_lookup_result(xml_result, @app_id, @location)
26
+ WoeidHelper.register_this_woeid_lookup_result(xml_result, @location)
29
27
  end
30
28
 
31
29
  it "should retrieve the woeid" do
@@ -34,28 +32,11 @@ describe Weatherman::WoeidLookup do
34
32
  end
35
33
  end
36
34
 
37
- describe "invalid api key" do
38
- before do
39
- @app_id = 'invalid_api'
40
- @location = '12345'
41
- @lookup = Weatherman::WoeidLookup.new(@app_id)
42
-
43
- xml_result = WoeidHelper.open_test_file('woeid_result_for_invalid_app_id')
44
- WoeidHelper.register_this_woeid_lookup_result(xml_result, @app_id, @location)
45
- end
46
-
47
- it "should return nil" do
48
- response = @lookup.get_woeid(@location)
49
- response.should == nil
50
- end
51
- end
52
-
53
35
  describe "failed net request" do
54
36
  before do
55
- @app_id = 'net_failure'
56
37
  @location = '78902'
57
- @lookup = Weatherman::WoeidLookup.new(@app_id)
58
- WoeidHelper.register_this_woeid_lookup_to_fail @app_id, @location
38
+ @lookup = Weatherman::WoeidLookup.new
39
+ WoeidHelper.register_this_woeid_lookup_to_fail @location
59
40
  end
60
41
 
61
42
  it "should return nil" do
@@ -66,11 +47,10 @@ describe Weatherman::WoeidLookup do
66
47
 
67
48
  describe "request with spaces" do
68
49
  before do
69
- @app_id = 'test_api_id'
70
- @lookup = Weatherman::WoeidLookup.new(@app_id)
50
+ @lookup = Weatherman::WoeidLookup.new
71
51
 
72
52
  xml_result = WoeidHelper.open_test_file('woeid_result_that_returns_12786745')
73
- WoeidHelper.register_this_woeid_lookup_result(xml_result, @app_id, "San+Francisco%2C+CA")
53
+ WoeidHelper.register_this_woeid_lookup_result(xml_result, "San+Francisco%2C+CA")
74
54
  end
75
55
 
76
56
  it "should retrieve the woeid" do
@@ -15,13 +15,12 @@ describe Weatherman::Client do
15
15
  describe "#lookup_by_location" do
16
16
  describe "4729347 example" do
17
17
  it "should lookup by location" do
18
- app_id = 'test_id'
19
18
  location = '78923'
20
19
 
21
20
  xml_result = WoeidHelper.open_test_file 'woeid_result_that_returns_4729347'
22
- WoeidHelper.register_this_woeid_lookup_result xml_result, app_id, location
21
+ WoeidHelper.register_this_woeid_lookup_result xml_result, location
23
22
 
24
- @client = Weatherman::Client.new( { :app_id => app_id } )
23
+ @client = Weatherman::Client.new()
25
24
  response = @client.lookup_by_location location
26
25
 
27
26
  response.should be_instance_of(Weatherman::Response)
@@ -30,13 +29,12 @@ describe Weatherman::Client do
30
29
 
31
30
  describe "12786745 example" do
32
31
  it "should lookup by location" do
33
- app_id = 'apple'
34
32
  location = 'orange'
35
33
 
36
34
  xml_result = WoeidHelper.open_test_file 'woeid_result_that_returns_12786745'
37
- WoeidHelper.register_this_woeid_lookup_result xml_result, app_id, location
35
+ WoeidHelper.register_this_woeid_lookup_result xml_result, location
38
36
 
39
- @client = Weatherman::Client.new( { :app_id => app_id } )
37
+ @client = Weatherman::Client.new()
40
38
  response = @client.lookup_by_location location
41
39
 
42
40
  response.should be_instance_of(Weatherman::Response)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "yahoo_weatherman"
3
- gem.version = "1.2.2"
3
+ gem.version = "2.0.0"
4
4
  gem.authors = ["Dalto Curvelano Junior"]
5
5
  gem.description = "A ruby wrapper to the Yahoo! Weather feed with i18n support."
6
6
  gem.summary = "A ruby wrapper to the Yahoo! Weather feed with i18n support."
@@ -11,9 +11,10 @@ Gem::Specification.new do |gem|
11
11
  "lib/yahoo_weatherman/i18n.rb",
12
12
  "lib/yahoo_weatherman/woeid_lookup.rb",
13
13
  "lib/yahoo_weatherman.rb",
14
+ "i18n/es.yml",
15
+ "i18n/gr.yml",
14
16
  "i18n/pt-br.yml",
15
17
  "i18n/ru.yml",
16
- "i18n/es.yml",
17
18
  "i18n/zh-cn.yml",
18
19
  "spec/files/belo_horizonte_c.rss",
19
20
  "spec/files/belo_horizonte_f.rss",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo_weatherman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-20 00:00:00.000000000 Z
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -71,9 +71,10 @@ files:
71
71
  - lib/yahoo_weatherman/i18n.rb
72
72
  - lib/yahoo_weatherman/woeid_lookup.rb
73
73
  - lib/yahoo_weatherman.rb
74
+ - i18n/es.yml
75
+ - i18n/gr.yml
74
76
  - i18n/pt-br.yml
75
77
  - i18n/ru.yml
76
- - i18n/es.yml
77
78
  - i18n/zh-cn.yml
78
79
  - spec/files/belo_horizonte_c.rss
79
80
  - spec/files/belo_horizonte_f.rss