weather_fetcher 0.1.2 → 0.1.3

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: 0e0b42eb8b3a0472d8eec2d0fdeb5340c2e6fd37
4
- data.tar.gz: 136957f386ec94ab93299c6baddf994de4fe2eb3
3
+ metadata.gz: 270dcf5030313ef8855cb98e01873a13a110004c
4
+ data.tar.gz: d4a32c91a82362b69e1e318f39e34730f392c8ce
5
5
  SHA512:
6
- metadata.gz: 762ff6dd9c0277023a6e2ef8bb23bafd0d643dd7501902bc64cec51e2dcd3f2906db9c84d18575274367b387396f6645756c5b25bc3ad7e4d5bebdf9d78da96d
7
- data.tar.gz: 114cd0b9e17def27edbce62bfab09139a1da064fd6616c28c860ff0054ce1a88c51ca0500fc9954217b63d4bfacaba7464dba18bac59c21241e8ce0b03fb5c0b
6
+ metadata.gz: b8f33ac89ec4949b7041f8df0cfe9f0f7ff9591ebc8195664c6ad150f130b30afea4d6c81d5436f8630f4e46219349ff3d96d11c5406f7b0aeb54ce88c9a21da
7
+ data.tar.gz: f47cc17506b562bb5cf8d4afc1ead3f69e64a27319bca37e83d29e085a9d4805c52316ac2c52b77809d3ef4dcb1e6ecb2b203e7559b7d90f68984fd715cedc0f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -20,7 +20,7 @@ module WeatherFetcher
20
20
  puts result.inspect
21
21
  data = result.sort{|r,s| r.time_from <=> s.time_from}
22
22
  data.each do |d|
23
- puts "#{d.time_from} #{d.temperature} #{d.wind}"
23
+ puts "#{d.provider} #{d.time_from} #{d.temperature} #{d.wind}"
24
24
  end
25
25
  end
26
26
 
@@ -15,7 +15,7 @@ module WeatherFetcher
15
15
 
16
16
  # This provider required API key
17
17
  def self.api=(_api)
18
- @@api = _api
18
+ @@api = _api unless _api.to_s == ""
19
19
  end
20
20
 
21
21
  def self.api
@@ -23,6 +23,18 @@ module WeatherFetcher
23
23
  @@api
24
24
  end
25
25
 
26
+ # Create an instance, definitions can be set here
27
+ def initialize(*args)
28
+ super(*args)
29
+
30
+ # set api key if exists
31
+ self.defs.each do |d|
32
+ if d and d[:classes] and d[:classes][self.class.provider_name] and d[:classes][self.class.provider_name][:key]
33
+ self.class.api = d[:classes][self.class.provider_name][:key]
34
+ end
35
+ end
36
+ end
37
+
26
38
  # Url for current provider
27
39
  def url(p)
28
40
  "http://api.worldweatheronline.com/free/v1/weather.ashx?q=#{p[:coords][:lat]},#{p[:coords][:lon]}&format=json&num_of_days=5&key=#{@@api}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weather_fetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksander Kwiatkowski