powered_wunderground 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d321857421d8651732072a87beb863afba9f3ee5
4
- data.tar.gz: 028461c9f6baef784794606596de32e0df82443c
3
+ metadata.gz: afc0a814a57bb9bbebde58adddc8815000deef44
4
+ data.tar.gz: 66863b460785851543b4c35cdb15e7079dd7f3b9
5
5
  SHA512:
6
- metadata.gz: afc48bac85430678b0eab078ebe6816be9cc1aef6aaad6c9375dfffd467f71df0f735d8372157365f8230458305a4ba3c53437f16a618073da774357e0632b4c
7
- data.tar.gz: e09719742238c235720b241f0ec2eda141ab8ec1164524c8520cb595dab6a9bba90f98d62b9d56cbfd14b16f33547811772982cb3dcb53f8cbae1d53321d9152
6
+ metadata.gz: 768ee510d6b838b6170d43878f13053245d1e74f3e3883fae53db93cd3bc0897a6fa59ef711612fa61fc067f7687070a8d711f37b027f4fd5755baaab0d0f5b2
7
+ data.tar.gz: 18c29f44f450a11ca25bf4e60e622ddc5242156b25e603b44c827c34263d0e001eeef6588fb090634c1fc95710575c342f4e60e7026c6f1bb0598e803ba9756f
data/README.md CHANGED
@@ -22,14 +22,20 @@ Or install it yourself as:
22
22
 
23
23
  by coords
24
24
  ```ruby
25
- pw = PoweredWunderground.new(api_key: api_key, language: 'pt')
26
- response = pw.coord(37.77, -122.39)
27
- response.powered_output
28
- => {
29
- :text=>"Nuvens matinais seguidas de sol da parte da tarde. Máxima de 68°F. Ventos O a 10 a 20 mph.",
30
- :city=>"San Francisco",
31
- :country=>"US"
32
- }
25
+ pw = PoweredWunderground.new(api_key: api_key, language: 'en')
26
+ resp = pw.coord(41.16, -8.6)
27
+
28
+ resp.to_s # "Partly cloudy. Low 16C."
29
+ resp.powered_output # {text: "Partly cloudy. Low 16C.", city: "Porto", country: "PT", language_code: 'pt'}
30
+ ```
31
+
32
+ by city
33
+ ```ruby
34
+ pw = PoweredWunderground.new(api_key: api_key, language: 'en')
35
+ resp = pw.city('PT', 'Porto')
36
+
37
+ resp.to_s # "Partly cloudy. Low 16C."
38
+ resp.powered_output # {text: "Partly cloudy. Low 16C.", city: "Porto", country: "PT", language_code: 'pt'}
33
39
  ```
34
40
 
35
41
  ## Development
@@ -5,11 +5,11 @@ module PoweredWunderground
5
5
  include LanguageMapper
6
6
 
7
7
  attr_reader :api_key
8
- attr_accessor :language
9
- attr_accessor :units
8
+ attr_accessor :original_language, :language, :units
10
9
 
11
10
  def initialize(api_key)
12
11
  @api_key = api_key
12
+ @original_language = 'en'
13
13
  @language = 'en'
14
14
  end
15
15
 
@@ -19,17 +19,18 @@ module PoweredWunderground
19
19
 
20
20
  def coord(latitude, longitude)
21
21
  geo_response = wunderground_geolookup(latitude, longitude)
22
+ fail geo_response['response']['error']['description'] if geo_response['response']['error']
22
23
  city = geo_response['location']['city']
23
- country = geo_response['location']['country']
24
+ country = geo_response['location']['country_iso3166']
24
25
  w_response = wunderground_coord_forecast(latitude, longitude)
25
26
  hash = w_response['forecast']['txt_forecast']['forecastday'].first
26
- Response.new(country, city, hash)
27
+ Response.new(country, city, original_language, hash)
27
28
  end
28
29
 
29
30
  def city(country, city)
30
31
  w_response = wunderground_city_forecast(country, city)
31
32
  hash = w_response['forecast']['txt_forecast']['forecastday'].first
32
- Response.new(country, city, hash)
33
+ Response.new(country, city, original_language, hash)
33
34
  end
34
35
 
35
36
  def forecast(country, city)
@@ -42,6 +43,7 @@ module PoweredWunderground
42
43
  end
43
44
 
44
45
  def language=(code)
46
+ @original_language = code.downcase
45
47
  @language = fetch_language(code)
46
48
  end
47
49
 
@@ -4,8 +4,11 @@ module PoweredWunderground
4
4
  language_map[code.upcase] || code.upcase
5
5
  end
6
6
 
7
+ # The weather underground language codes are here:
8
+ # http://www.wunderground.com/weather/api/d/docs?d=language-support&MR=1
7
9
  def language_map
8
10
  {
11
+ 'ES' => 'SP',
9
12
  'PT' => 'BR', # this makes me sad
10
13
  }
11
14
  end
@@ -1,10 +1,11 @@
1
1
  module PoweredWunderground
2
2
  class Response
3
- attr_reader :country, :city, :properties
3
+ attr_reader :country, :city, :language_code, :properties
4
4
 
5
- def initialize(country, city, properties)
5
+ def initialize(country, city, language_code, properties)
6
6
  @country = country
7
7
  @city = city
8
+ @language_code = language_code
8
9
  @properties = properties
9
10
  end
10
11
 
@@ -14,6 +15,7 @@ module PoweredWunderground
14
15
 
15
16
  def powered_output
16
17
  {
18
+ language_code: language_code,
17
19
  text: to_s,
18
20
  city: city,
19
21
  country: country
@@ -1,3 +1,3 @@
1
1
  module PoweredWunderground
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: powered_wunderground
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Carneiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-23 00:00:00.000000000 Z
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest