open-weather 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1ad59e52bf16b188c02fa811012230dc6745c74b
4
+ data.tar.gz: 225b8e3c265dd023669705c1e496807562a47ded
5
+ SHA512:
6
+ metadata.gz: 3c3452fe71b08b2a3d5a910c435d51e70742da0e97f5fafaf02a71fea498ad4b24b528f3a83075830c18c32dab52edb9433d229cc75ebe54106f0cbc00fa8e7b
7
+ data.tar.gz: e8b09324d7fbbffab0f5683a3693507cea4b47ef0be4c4cad06deec5ea1799931a86c7e90357cfae20412baa36d3c5b8fc098afda3c267b97c31a3dc5794fd0f
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Installation
4
4
 
5
+ Latest version `0.11.0`
6
+
5
7
  Add the following to your **Gemfile**
6
8
 
7
9
  gem 'open-weather'
@@ -51,6 +53,21 @@ OpenWeather::Forecast.city_id("1273874")
51
53
 
52
54
  # get weather forecast by geocode. (lat, lon)
53
55
  OpenWeather::Forecast.geocode(9.94, 76.26)
56
+
57
+ # get daily weather forecast by city name
58
+ OpenWeather::ForecastDaily.city("Cochin, IN")
59
+
60
+ # get daily weather forecast by city name in fahrenheit
61
+ OpenWeather::ForecastDaily.city("Cochin, IN", units: 'imperial')
62
+
63
+ # get daily weather forecast by city id
64
+ OpenWeather::ForecastDaily.city_id("1273874")
65
+
66
+ # get daily weather forecast by geocode. (lat, lon)
67
+ OpenWeather::ForecastDaily.geocode(9.94, 76.26)
68
+
69
+ # get daily weather forecast for 6 days
70
+ OpenWeather::ForecastDaily.city_id("1273874", cnt: 6)
54
71
  ```
55
72
 
56
73
  Doucumentation about the weather forecast end-point:
@@ -67,19 +84,29 @@ OpenWeather::Current.city("Berlin, DE", options)
67
84
  How to get an API key and tips for an effective usage of the API:
68
85
  http://openweathermap.org/appid
69
86
 
70
-
71
- ## Contributing
87
+ #### Multilingual support
88
+
89
+ ```ruby
90
+ # get current weather in german
91
+ OpenWeather::Current.city("Berlin, DE", lang: "de")
92
+ ```
93
+
94
+ Available languages are listed at:
95
+ http://openweathermap.org/current#multi
96
+
97
+
98
+ ## Contributing
72
99
 
73
100
  Fork it
74
-
101
+
75
102
  Create your feature branch (git checkout -b my-new-feature)
76
-
103
+
77
104
  Commit your changes (git commit -am 'Added some feature')
78
-
105
+
79
106
  Push to the branch (git push origin my-new-feature)
80
-
107
+
81
108
  Create new Pull Request
82
-
109
+
83
110
  --------
84
-
85
- **Created during the Hacker Saturdays hosted by Kerala/Kochi Ruby Users Group**
111
+
112
+ **This gem was created during the Hacker Saturdays hosted by [Kerala/Kochi Ruby Users Group](https://krug.github.io)**
@@ -4,6 +4,7 @@ module OpenWeather
4
4
  autoload :Base, "open_weather/base"
5
5
  autoload :Current, "open_weather/current"
6
6
  autoload :Forecast, "open_weather/forecast"
7
+ autoload :ForecastDaily, "open_weather/forecast_daily"
7
8
  autoload :VERSION, "open_weather/version"
8
9
 
9
10
  require "open_weather/api.rb"
@@ -24,7 +24,7 @@ module OpenWeather
24
24
  private
25
25
 
26
26
  def extract_options!(options)
27
- valid_options = [:lat, :lon, :city, :country, :id, :units, :APPID]
27
+ valid_options = [:lat, :lon, :city, :country, :id, :units, :cnt, :APPID, :lang]
28
28
  options.keys.each { |k| options.delete(k) unless valid_options.include?(k) }
29
29
 
30
30
  if options[:city] || options[:country]
@@ -0,0 +1,7 @@
1
+ module OpenWeather
2
+ class ForecastDaily < Base
3
+ def initialize options = {}
4
+ super('http://api.openweathermap.org/data/2.5/forecast/daily', options)
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module OpenWeather
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -4,7 +4,7 @@ require 'open_weather/version'
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "open-weather"
6
6
  gem.version = OpenWeather::VERSION
7
- gem.authors = ["HsPS <mailme@hsps.in>", "Deepak <deepakkumarnd@gmail.com>"]
7
+ gem.authors = ["HsPS mailme@hsps.in", "Deepak deepakkumarnd@gmail.com"]
8
8
  gem.email = ['mailme@hsps.in']
9
9
  gem.homepage = "https://github.com/coderhs/ruby_open_weather_map"
10
10
  gem.summary = %q{ A ruby wrapper for Open Weather Map API. }
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?q=,invalidid
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:13 GMT
27
+ Content-Type:
28
+ - text/html
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - redis
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"message":"","cod":"404"}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:13 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?id=1273874
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:12 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - redis
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"cod":"200","message":0.0138,"city":{"id":1273874,"name":"Cochin","coord":{"lon":76.260223,"lat":9.93988},"country":"IN","population":604696},"cnt":7,"list":[{"dt":1419400800,"temp":{"day":297.85,"min":297.85,"max":297.85,"night":297.85,"eve":297.85,"morn":297.85},"pressure":1021.02,"humidity":95,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"speed":1.32,"deg":253,"clouds":36},{"dt":1419487200,"temp":{"day":303.36,"min":296.48,"max":305.05,"night":298.14,"eve":303.08,"morn":296.48},"pressure":1020,"humidity":67,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":2.19,"deg":46,"clouds":0},{"dt":1419573600,"temp":{"day":303.52,"min":297.32,"max":305.08,"night":299.32,"eve":302.99,"morn":297.32},"pressure":1017.68,"humidity":59,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":3.57,"deg":58,"clouds":0},{"dt":1419660000,"temp":{"day":298.63,"min":296.19,"max":301.16,"night":298.48,"eve":301.16,"morn":297.25},"pressure":1018.07,"humidity":82,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"speed":5.26,"deg":26,"clouds":88},{"dt":1419746400,"temp":{"day":298.68,"min":298.68,"max":299.72,"night":299.25,"eve":299.72,"morn":299.57},"pressure":1020.98,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":3.12,"deg":175,"clouds":68,"rain":40.09},{"dt":1419832800,"temp":{"day":299.33,"min":299.08,"max":300.85,"night":300.67,"eve":300.85,"morn":299.08},"pressure":1017.96,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":4.96,"deg":310,"clouds":51,"rain":20.77},{"dt":1419919200,"temp":{"day":301.41,"min":300.2,"max":301.49,"night":300.2,"eve":301.49,"morn":300.57},"pressure":1017.8,"humidity":0,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"speed":4.62,"deg":337,"clouds":0,"rain":0.58}]}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:13 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?q=,Cochin,%20In&units=imperial
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:15 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - redis
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"cod":"200","message":0.1394,"city":{"id":"1273874","name":"Kochi","coord":{"lon":76.2615,"lat":9.93606},"country":"India","population":0},"cnt":7,"list":[{"dt":1419400800,"temp":{"day":76.46,"min":76.46,"max":76.46,"night":76.46,"eve":76.46,"morn":76.46},"pressure":1021.02,"humidity":95,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"speed":2.85,"deg":253,"clouds":36},{"dt":1419487200,"temp":{"day":86.38,"min":73.99,"max":89.42,"night":76.98,"eve":85.87,"morn":73.99},"pressure":1020,"humidity":67,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":4.73,"deg":46,"clouds":0},{"dt":1419573600,"temp":{"day":86.67,"min":75.51,"max":89.47,"night":79.11,"eve":85.71,"morn":75.51},"pressure":1017.68,"humidity":59,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":7.71,"deg":58,"clouds":0},{"dt":1419660000,"temp":{"day":77.86,"min":73.47,"max":82.42,"night":77.59,"eve":82.42,"morn":75.38},"pressure":1018.07,"humidity":82,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"speed":11.36,"deg":26,"clouds":88},{"dt":1419746400,"temp":{"day":77.95,"min":77.95,"max":79.83,"night":78.98,"eve":79.83,"morn":79.56},"pressure":1020.98,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":6.74,"deg":175,"clouds":68,"rain":40.09},{"dt":1419832800,"temp":{"day":79.12,"min":78.67,"max":81.86,"night":81.54,"eve":81.86,"morn":78.67},"pressure":1017.96,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":10.71,"deg":310,"clouds":51,"rain":20.77},{"dt":1419919200,"temp":{"day":82.87,"min":80.69,"max":83.01,"night":80.69,"eve":83.01,"morn":81.36},"pressure":1017.8,"humidity":0,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"speed":9.98,"deg":337,"clouds":0,"rain":0.58}]}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:16 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?q=,Cochin,%20In&units=metric
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:15 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - back
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"cod":"200","message":0.0484,"city":{"id":"1273874","name":"Kochi","coord":{"lon":76.2615,"lat":9.93606},"country":"India","population":0},"cnt":7,"list":[{"dt":1419400800,"temp":{"day":26.44,"min":26.44,"max":26.44,"night":26.44,"eve":26.44,"morn":26.44},"pressure":1023.99,"humidity":100,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"speed":1.22,"deg":179,"clouds":88},{"dt":1419487200,"temp":{"day":25.82,"min":23.55,"max":27.32,"night":26.64,"eve":27.32,"morn":23.87},"pressure":1025.89,"humidity":100,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":3.32,"deg":202,"clouds":0,"rain":5},{"dt":1419573600,"temp":{"day":27.24,"min":26.27,"max":27.98,"night":26.79,"eve":27.7,"morn":26.27},"pressure":1023.35,"humidity":99,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"speed":2.37,"deg":136,"clouds":48},{"dt":1419660000,"temp":{"day":27.51,"min":24.2,"max":28.34,"night":24.24,"eve":28.34,"morn":26.24},"pressure":1021.68,"humidity":94,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"speed":5.21,"deg":357,"clouds":48},{"dt":1419746400,"temp":{"day":27.92,"min":25.04,"max":28.89,"night":27.85,"eve":28.84,"morn":25.04},"pressure":1021.79,"humidity":94,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"02d"}],"speed":2.82,"deg":352,"clouds":8},{"dt":1419832800,"temp":{"day":29.64,"min":29.44,"max":29.64,"night":29.44,"eve":29.54,"morn":29.53},"pressure":1020.3,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":5.4,"deg":337,"clouds":2},{"dt":1419919200,"temp":{"day":29.32,"min":29.16,"max":29.43,"night":29.29,"eve":29.16,"morn":29.43},"pressure":1018.74,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":7.94,"deg":329,"clouds":20}]}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:16 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?q=,Cochin,%20In
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:12 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - redis
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"cod":"200","message":0.146,"city":{"id":"1273874","name":"Kochi","coord":{"lon":76.2615,"lat":9.93606},"country":"India","population":0},"cnt":7,"list":[{"dt":1419400800,"temp":{"day":297.44,"min":297.44,"max":297.44,"night":297.44,"eve":297.44,"morn":297.44},"pressure":1021.02,"humidity":95,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"speed":1.32,"deg":253,"clouds":36},{"dt":1419487200,"temp":{"day":301.24,"min":296.09,"max":303.23,"night":296.49,"eve":302.64,"morn":296.09},"pressure":1020.05,"humidity":74,"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"speed":1.97,"deg":87,"clouds":64},{"dt":1419573600,"temp":{"day":303.36,"min":296.29,"max":304.94,"night":299.24,"eve":302.87,"morn":296.29},"pressure":1017.68,"humidity":59,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":3.57,"deg":58,"clouds":0},{"dt":1419660000,"temp":{"day":300.11,"min":294.95,"max":302.01,"night":295.44,"eve":297.64,"morn":297.21},"pressure":1016.74,"humidity":76,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":2.41,"deg":22,"clouds":68,"rain":4},{"dt":1419746400,"temp":{"day":303.14,"min":297.29,"max":303.14,"night":299.4,"eve":301.99,"morn":297.29},"pressure":1016.12,"humidity":68,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"02d"}],"speed":4.82,"deg":16,"clouds":8},{"dt":1419832800,"temp":{"day":303.24,"min":301.13,"max":303.24,"night":301.99,"eve":303.07,"morn":301.13},"pressure":1018.28,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":5,"deg":329,"clouds":7},{"dt":1419919200,"temp":{"day":302.32,"min":300.79,"max":302.32,"night":300.79,"eve":301.74,"morn":301.23},"pressure":1016.31,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":8.04,"deg":328,"clouds":6}]}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:13 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?cnt=6&q=,Cochin,%20In
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:16 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - redis
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"cod":"200","message":0.0208,"city":{"id":"1273874","name":"Kochi","coord":{"lon":76.2615,"lat":9.93606},"country":"India","population":0},"cnt":6,"list":[{"dt":1419400800,"temp":{"day":297.85,"min":297.85,"max":297.85,"night":297.85,"eve":297.85,"morn":297.85},"pressure":1021.02,"humidity":95,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"speed":1.32,"deg":253,"clouds":36},{"dt":1419487200,"temp":{"day":303.36,"min":296.48,"max":305.05,"night":298.14,"eve":303.08,"morn":296.48},"pressure":1020,"humidity":67,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":2.19,"deg":46,"clouds":0},{"dt":1419573600,"temp":{"day":303.52,"min":297.32,"max":305.08,"night":299.32,"eve":302.99,"morn":297.32},"pressure":1017.68,"humidity":59,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":3.57,"deg":58,"clouds":0},{"dt":1419660000,"temp":{"day":298.63,"min":296.19,"max":301.16,"night":298.48,"eve":301.16,"morn":297.25},"pressure":1018.07,"humidity":82,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"speed":5.26,"deg":26,"clouds":88},{"dt":1419746400,"temp":{"day":298.68,"min":298.68,"max":299.72,"night":299.25,"eve":299.72,"morn":299.57},"pressure":1020.98,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":3.12,"deg":175,"clouds":68,"rain":40.09},{"dt":1419832800,"temp":{"day":299.33,"min":299.08,"max":300.85,"night":300.67,"eve":300.85,"morn":299.08},"pressure":1017.96,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":4.96,"deg":310,"clouds":51,"rain":20.77}]}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:16 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?q=,Cochin,%20In
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:15 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - redis
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"cod":"200","message":0.146,"city":{"id":"1273874","name":"Kochi","coord":{"lon":76.2615,"lat":9.93606},"country":"India","population":0},"cnt":7,"list":[{"dt":1419400800,"temp":{"day":297.44,"min":297.44,"max":297.44,"night":297.44,"eve":297.44,"morn":297.44},"pressure":1021.02,"humidity":95,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"speed":1.32,"deg":253,"clouds":36},{"dt":1419487200,"temp":{"day":301.24,"min":296.09,"max":303.23,"night":296.49,"eve":302.64,"morn":296.09},"pressure":1020.05,"humidity":74,"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"speed":1.97,"deg":87,"clouds":64},{"dt":1419573600,"temp":{"day":303.36,"min":296.29,"max":304.94,"night":299.24,"eve":302.87,"morn":296.29},"pressure":1017.68,"humidity":59,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":3.57,"deg":58,"clouds":0},{"dt":1419660000,"temp":{"day":300.11,"min":294.95,"max":302.01,"night":295.44,"eve":297.64,"morn":297.21},"pressure":1016.74,"humidity":76,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":2.41,"deg":22,"clouds":68,"rain":4},{"dt":1419746400,"temp":{"day":303.14,"min":297.29,"max":303.14,"night":299.4,"eve":301.99,"morn":297.29},"pressure":1016.12,"humidity":68,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"02d"}],"speed":4.82,"deg":16,"clouds":8},{"dt":1419832800,"temp":{"day":303.24,"min":301.13,"max":303.24,"night":301.99,"eve":303.07,"morn":301.13},"pressure":1018.28,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":5,"deg":329,"clouds":7},{"dt":1419919200,"temp":{"day":302.32,"min":300.79,"max":302.32,"night":300.79,"eve":301.74,"morn":301.23},"pressure":1016.31,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":8.04,"deg":328,"clouds":6}]}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:16 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?lat=181&lon=181
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:14 GMT
27
+ Content-Type:
28
+ - text/html
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - redis
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"message":"","cod":"404"}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:15 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?lat=9.94&lon=76.26
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:13 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - redis
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"cod":"200","message":0.0021,"city":{"id":1278345,"name":"Arukutti","coord":{"lon":76.349998,"lat":9.86667},"country":"IN","population":0},"cnt":7,"list":[{"dt":1419400800,"temp":{"day":297.85,"min":297.85,"max":297.85,"night":297.85,"eve":297.85,"morn":297.85},"pressure":1021.02,"humidity":95,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"speed":1.32,"deg":253,"clouds":36},{"dt":1419487200,"temp":{"day":303.36,"min":296.48,"max":305.05,"night":298.14,"eve":303.08,"morn":296.48},"pressure":1020,"humidity":67,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":2.19,"deg":46,"clouds":0},{"dt":1419573600,"temp":{"day":303.52,"min":297.32,"max":305.08,"night":299.32,"eve":302.99,"morn":297.32},"pressure":1017.68,"humidity":59,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":3.57,"deg":58,"clouds":0},{"dt":1419660000,"temp":{"day":298.63,"min":296.19,"max":301.16,"night":298.48,"eve":301.16,"morn":297.25},"pressure":1018.07,"humidity":82,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"speed":5.26,"deg":26,"clouds":88},{"dt":1419746400,"temp":{"day":298.68,"min":298.68,"max":299.72,"night":299.25,"eve":299.72,"morn":299.57},"pressure":1020.98,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":3.12,"deg":175,"clouds":68,"rain":40.09},{"dt":1419832800,"temp":{"day":299.33,"min":299.08,"max":300.85,"night":300.67,"eve":300.85,"morn":299.08},"pressure":1017.96,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":4.96,"deg":310,"clouds":51,"rain":20.77},{"dt":1419919200,"temp":{"day":301.41,"min":300.2,"max":301.49,"night":300.2,"eve":301.49,"morn":300.57},"pressure":1017.8,"humidity":0,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"speed":4.62,"deg":337,"clouds":0,"rain":0.58}]}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:14 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/forecast/daily?q=,Cochiiiiiin,%20In
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.openweathermap.org
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 24 Dec 2014 21:15:12 GMT
27
+ Content-Type:
28
+ - text/html
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Source:
34
+ - back
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Allow-Credentials:
38
+ - 'true'
39
+ Access-Control-Allow-Methods:
40
+ - GET, POST
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {"message":"","cod":"404"}
45
+ http_version:
46
+ recorded_at: Wed, 24 Dec 2014 21:15:13 GMT
47
+ recorded_with: VCR 2.9.2
@@ -131,3 +131,84 @@ describe 'Open weather Forecast API' do
131
131
  end
132
132
  end
133
133
  end
134
+
135
+ describe 'Open weather Forecast Daily API' do
136
+ context '.city' do
137
+ it 'return forecast weather for cochi' do
138
+ response = VCR.use_cassette("api/forecast_daily_city_valid") do
139
+ OpenWeather::ForecastDaily.city('Cochin, In')
140
+ end
141
+ response['cod'].to_s.should eq("200")
142
+ end
143
+
144
+ it 'returns error if the city is invalid' do
145
+ response = VCR.use_cassette("api/forecast_daily_invalid") do
146
+ OpenWeather::ForecastDaily.city('Cochiiiiiin, In')
147
+ end
148
+ response['cod'].to_s.should eq("404")
149
+ end
150
+ end
151
+
152
+ context '.city_id' do
153
+ it 'return forecast weather for city id of cochi' do
154
+ response = VCR.use_cassette("api/forecast_daily_city_id_valid") do
155
+ OpenWeather::ForecastDaily.city_id('1273874')
156
+ end
157
+ response['cod'].to_s.should eq("200")
158
+ end
159
+
160
+ it 'returns error if the city id is invalid' do
161
+ response = VCR.use_cassette("api/forecast_daily_city_id_invalid") do
162
+ OpenWeather::ForecastDaily.city('invalidid')
163
+ end
164
+ response['cod'].to_s.should eq("404")
165
+ end
166
+ end
167
+
168
+ context '.geocode' do
169
+ it 'return forecast weather for geocode of cochi' do
170
+ response = VCR.use_cassette("api/forecast_daily_geocode_valid") do
171
+ OpenWeather::ForecastDaily.geocode('9.94', '76.26')
172
+ end
173
+ response['cod'].to_s.should eq("200")
174
+ end
175
+
176
+ it 'returns error if the geocode is invalid' do
177
+ response = VCR.use_cassette("api/forecast_daily_geocode_invalid") do
178
+ OpenWeather::ForecastDaily.geocode('181', '181')
179
+ end
180
+ response['cod'].to_s.should eq("404")
181
+ end
182
+ end
183
+
184
+ context 'units option' do
185
+ it 'returns the forecast in requested units' do
186
+ response = VCR.use_cassette("api/forecast_daily_city_metric_valid") do
187
+ OpenWeather::ForecastDaily.city('Cochin, In', units: 'metric')
188
+ end
189
+ temp_metric = response['list'].first['temp']['day']
190
+
191
+ response = VCR.use_cassette("api/forecast_daily_city_imperial_valid") do
192
+ OpenWeather::ForecastDaily.city('Cochin, In', units: 'imperial')
193
+ end
194
+ temp_imperial = response['list'].first['temp']['day']
195
+ farenheit_to_celsius = ((temp_imperial - 32) / 1.8000)
196
+
197
+ expect(farenheit_to_celsius).to be_within(temp_metric-1).of(temp_metric+1)
198
+ end
199
+ end
200
+
201
+ context 'cnt option' do
202
+ it 'returns the forecast for N days' do
203
+ response = VCR.use_cassette("api/forecast_daily_cnt_default") do
204
+ OpenWeather::ForecastDaily.city('Cochin, In')
205
+ end
206
+ response['list'].count.should eq(7)
207
+
208
+ response = VCR.use_cassette("api/forecast_daily_cnt_6") do
209
+ OpenWeather::ForecastDaily.city('Cochin, In', cnt: 6)
210
+ end
211
+ response['list'].count.should eq(6)
212
+ end
213
+ end
214
+ end
metadata CHANGED
@@ -1,90 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open-weather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
5
- prerelease:
4
+ version: 0.11.0
6
5
  platform: ruby
7
6
  authors:
8
- - HsPS <mailme@hsps.in>
9
- - Deepak <deepakkumarnd@gmail.com>
7
+ - HsPS mailme@hsps.in
8
+ - Deepak deepakkumarnd@gmail.com
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-09-01 00:00:00.000000000 Z
12
+ date: 2015-04-17 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: vcr
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: webmock
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - ">="
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - ">="
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: json
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - ">="
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :runtime
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - ">="
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
- description: ! ' A ruby wrapper for Open Weather Map API. '
70
+ description: " A ruby wrapper for Open Weather Map API. "
80
71
  email:
81
72
  - mailme@hsps.in
82
73
  executables: []
83
74
  extensions: []
84
75
  extra_rdoc_files: []
85
76
  files:
86
- - .gitignore
87
- - .rspec
77
+ - ".gitignore"
78
+ - ".rspec"
88
79
  - Gemfile
89
80
  - Gemfile.lock
90
81
  - LICENSE
@@ -94,6 +85,7 @@ files:
94
85
  - lib/open_weather/base.rb
95
86
  - lib/open_weather/current.rb
96
87
  - lib/open_weather/forecast.rb
88
+ - lib/open_weather/forecast_daily.rb
97
89
  - lib/open_weather/version.rb
98
90
  - open_weather.gemspec
99
91
  - spec/fixtures/cassettes/api/current_city_id_invalid.yml
@@ -110,6 +102,16 @@ files:
110
102
  - spec/fixtures/cassettes/api/forecast_city_metric_invalid.yml
111
103
  - spec/fixtures/cassettes/api/forecast_city_metric_valid.yml
112
104
  - spec/fixtures/cassettes/api/forecast_city_valid.yml
105
+ - spec/fixtures/cassettes/api/forecast_daily_city_id_invalid.yml
106
+ - spec/fixtures/cassettes/api/forecast_daily_city_id_valid.yml
107
+ - spec/fixtures/cassettes/api/forecast_daily_city_imperial_valid.yml
108
+ - spec/fixtures/cassettes/api/forecast_daily_city_metric_valid.yml
109
+ - spec/fixtures/cassettes/api/forecast_daily_city_valid.yml
110
+ - spec/fixtures/cassettes/api/forecast_daily_cnt_6.yml
111
+ - spec/fixtures/cassettes/api/forecast_daily_cnt_default.yml
112
+ - spec/fixtures/cassettes/api/forecast_daily_geocode_invalid.yml
113
+ - spec/fixtures/cassettes/api/forecast_daily_geocode_valid.yml
114
+ - spec/fixtures/cassettes/api/forecast_daily_invalid.yml
113
115
  - spec/fixtures/cassettes/api/forecast_geocode_invalid.yml
114
116
  - spec/fixtures/cassettes/api/forecast_geocode_valid.yml
115
117
  - spec/fixtures/cassettes/api/forecast_invalid.yml
@@ -123,27 +125,26 @@ files:
123
125
  - spec/spec_helper.rb
124
126
  homepage: https://github.com/coderhs/ruby_open_weather_map
125
127
  licenses: []
128
+ metadata: {}
126
129
  post_install_message:
127
130
  rdoc_options: []
128
131
  require_paths:
129
132
  - lib
130
133
  required_ruby_version: !ruby/object:Gem::Requirement
131
- none: false
132
134
  requirements:
133
- - - ! '>='
135
+ - - ">="
134
136
  - !ruby/object:Gem::Version
135
137
  version: '0'
136
138
  required_rubygems_version: !ruby/object:Gem::Requirement
137
- none: false
138
139
  requirements:
139
- - - ! '>='
140
+ - - ">="
140
141
  - !ruby/object:Gem::Version
141
142
  version: '0'
142
143
  requirements: []
143
144
  rubyforge_project:
144
- rubygems_version: 1.8.23
145
+ rubygems_version: 2.4.6
145
146
  signing_key:
146
- specification_version: 3
147
+ specification_version: 4
147
148
  summary: A ruby wrapper for Open Weather Map API.
148
149
  test_files:
149
150
  - spec/fixtures/cassettes/api/current_city_id_invalid.yml
@@ -160,6 +161,16 @@ test_files:
160
161
  - spec/fixtures/cassettes/api/forecast_city_metric_invalid.yml
161
162
  - spec/fixtures/cassettes/api/forecast_city_metric_valid.yml
162
163
  - spec/fixtures/cassettes/api/forecast_city_valid.yml
164
+ - spec/fixtures/cassettes/api/forecast_daily_city_id_invalid.yml
165
+ - spec/fixtures/cassettes/api/forecast_daily_city_id_valid.yml
166
+ - spec/fixtures/cassettes/api/forecast_daily_city_imperial_valid.yml
167
+ - spec/fixtures/cassettes/api/forecast_daily_city_metric_valid.yml
168
+ - spec/fixtures/cassettes/api/forecast_daily_city_valid.yml
169
+ - spec/fixtures/cassettes/api/forecast_daily_cnt_6.yml
170
+ - spec/fixtures/cassettes/api/forecast_daily_cnt_default.yml
171
+ - spec/fixtures/cassettes/api/forecast_daily_geocode_invalid.yml
172
+ - spec/fixtures/cassettes/api/forecast_daily_geocode_valid.yml
173
+ - spec/fixtures/cassettes/api/forecast_daily_invalid.yml
163
174
  - spec/fixtures/cassettes/api/forecast_geocode_invalid.yml
164
175
  - spec/fixtures/cassettes/api/forecast_geocode_valid.yml
165
176
  - spec/fixtures/cassettes/api/forecast_invalid.yml
@@ -171,4 +182,3 @@ test_files:
171
182
  - spec/open_weather/api_spec.rb
172
183
  - spec/open_weather/version_spec.rb
173
184
  - spec/spec_helper.rb
174
- has_rdoc: