open-weather-ruby-client 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +67 -16
- data/lib/open_weather/client.rb +2 -0
- data/lib/open_weather/endpoints/five_day_forecast.rb +12 -0
- data/lib/open_weather/endpoints/stations.rb +1 -1
- data/lib/open_weather/endpoints/thirty_day_forecast.rb +16 -0
- data/lib/open_weather/endpoints.rb +2 -0
- data/lib/open_weather/logger.rb +1 -1
- data/lib/open_weather/models/forecast/city.rb +1 -0
- data/lib/open_weather/models/forecast/five_day/five_day.rb +24 -0
- data/lib/open_weather/models/forecast/five_day/forecast.rb +35 -0
- data/lib/open_weather/models/forecast/five_day.rb +4 -0
- data/lib/open_weather/models/forecast/forecast.rb +1 -1
- data/lib/open_weather/models/forecast/thirty_day/forecast.rb +33 -0
- data/lib/open_weather/models/forecast/thirty_day/temp.rb +18 -0
- data/lib/open_weather/models/forecast/thirty_day/thirty_day.rb +26 -0
- data/lib/open_weather/models/forecast/thirty_day.rb +5 -0
- data/lib/open_weather/models/forecast.rb +2 -0
- data/lib/open_weather/models/mixins/temp.rb +2 -2
- data/lib/open_weather/models/one_call/current_weather.rb +3 -1
- data/lib/open_weather/models/one_call/daily_weather.rb +3 -1
- data/lib/open_weather/models/one_call/hourly_weather.rb +3 -1
- data/lib/open_weather/models/one_call/weather.rb +2 -0
- data/lib/open_weather/models/stations/measurement.rb +1 -1
- data/lib/open_weather/models/wind.rb +1 -0
- data/lib/open_weather/version.rb +1 -1
- metadata +30 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ae98694e49ce5daa921935652931c2ef63892907641f17634cab2b16f044283
|
|
4
|
+
data.tar.gz: d318548404776897b45598a4ee1b0bf7c6b2cbda28c39758df96aece5c2c447b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27f5329a0d98d2e5db78bad49e5724b0358827c98478cc83f4e5ddf87e7fefdcd3028e26753402e338f4616c836a05c17aecf4a9d8f05fa211d5f903d606e96c
|
|
7
|
+
data.tar.gz: a5e387ce420b0c24f51e5ba8168e7d8a5c29aaa74543af82565aa320dc0873165e99fb01b2cfb587fc5427544b5ff2dfa6edd0f11bae6ebb44097d698acaaf3f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
### 0.7.0 (8/23/2026)
|
|
2
|
+
|
|
3
|
+
* [#49](https://github.com/dblock/open-weather-ruby-client/pull/49): Migrate Danger to use the `danger-pr-comment` reusable workflow - [@dblock](https://github.com/dblock), [@Copilot](https://github.com/apps/copilot-swe-agent).
|
|
4
|
+
* [#49](https://github.com/dblock/open-weather-ruby-client/pull/49): Upgrade danger-changelog to 0.8.0 and danger-toc to 0.2.0 - [@dblock](https://github.com/dblock), [@Copilot](https://github.com/apps/copilot-swe-agent).
|
|
5
|
+
* [#46](https://github.com/dblock/open-weather-ruby-client/pull/46): Added support for the five day forecast API - [@mgm702](https://github.com/mgm702).
|
|
6
|
+
* [#48](https://github.com/dblock/open-weather-ruby-client/pull/48): Modernized CI: dropped EOL Ruby 2.7/3.0, added Ruby 3.3/3.4 to the test matrix, bumped `actions/checkout` to v7, and fixed the Tests badge link in the README - [@dblock](https://github.com/dblock), [@Copilot](https://github.com/apps/copilot-swe-agent).
|
|
7
|
+
|
|
8
|
+
### 0.6.0 (2024/10/19)
|
|
9
|
+
|
|
10
|
+
* [#40](https://github.com/dblock/open-weather-ruby-client/pull/40): Fixing rubocop violations and improved .rubocop.yml - [@troya2](https://github.com/troya2).
|
|
11
|
+
* [#41](https://github.com/dblock/open-weather-ruby-client/pull/41): Added additional tests for hourly forecast that include all data types - i.e. rain and snow - [@troya2](https://github.com/troya2).
|
|
12
|
+
* [#42](https://github.com/dblock/open-weather-ruby-client/pull/42): Added support for the thirty day forecast in the pro 2.5 API - [@troya2](https://github.com/troya2).
|
|
13
|
+
* [#45](https://github.com/dblock/open-weather-ruby-client/pull/45): Added support for One Call 3.0 API on base plan - [@dblock](https://github.com/dblock).
|
|
14
|
+
|
|
1
15
|
### 0.5.0 (2024/07/03)
|
|
2
16
|
|
|
3
17
|
* [#25](https://github.com/dblock/open-weather-ruby-client/pull/25): Exposed the national weather alerts response in the One Call API - [@troya2](https://github.com/troya2).
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@ OpenWeather Ruby Client
|
|
|
2
2
|
=======================
|
|
3
3
|
|
|
4
4
|
[](https://badge.fury.io/rb/open-weather-ruby-client)
|
|
5
|
-
[](https://github.com/dblock/open-weather-ruby-client/actions)
|
|
5
|
+
[](https://github.com/dblock/open-weather-ruby-client/actions/workflows/test.yml)
|
|
6
6
|
|
|
7
7
|
A Ruby client for the [OpenWeather API v2.5 and v3.0](https://openweathermap.org/api).
|
|
8
8
|
|
|
@@ -21,6 +21,8 @@ Unlike other clients, including [open-weather](https://github.com/coderhs/ruby_o
|
|
|
21
21
|
- [Current and Forecast Weather](#current-and-forecast-weather)
|
|
22
22
|
- [Historical Weather](#historical-weather)
|
|
23
23
|
- [Hourly Forecast (Pro)](#hourly-forecast-pro)
|
|
24
|
+
- [30 Day Forecast (Pro)](#30-day-forecast-pro)
|
|
25
|
+
- [5 Day Forecast](#5-day-forecast)
|
|
24
26
|
- [Stations](#stations)
|
|
25
27
|
- [Register a Station](#register-a-station)
|
|
26
28
|
- [List Stations](#list-stations)
|
|
@@ -192,6 +194,7 @@ data.lat # => 33.44
|
|
|
192
194
|
data.lon # => -94.04
|
|
193
195
|
data.timezone # => 'America/Chicago'
|
|
194
196
|
data.current # => OpenWeather::Models::OneCall::CurrentWeather
|
|
197
|
+
data.data # => Array]OpenWeather::Models::OneCall::CurrentWeather] (on base plan)
|
|
195
198
|
data.minutely # => Array[OpenWeather::Models::OneCall::MinutelyWeather]
|
|
196
199
|
data.hourly # => Array[OpenWeather::Models::OneCall::HourlyWeather]
|
|
197
200
|
data.daily # => Array[OpenWeather::Models::OneCall::DailyWeather]
|
|
@@ -218,12 +221,13 @@ data.hourly # => Array[OpenWeather::Models::OneCall::HourlyWeather]
|
|
|
218
221
|
|
|
219
222
|
### Hourly Forecast (Pro)
|
|
220
223
|
|
|
221
|
-
The [Hourly Forecast API](https://openweathermap.org/api/hourly-forecast) provides hourly weather forecast for 4 days. Note: This API requires a
|
|
224
|
+
The [Hourly Forecast API](https://openweathermap.org/api/hourly-forecast) provides hourly weather forecast for 4 days. Note: This API requires a paid api-key from [OpenWeather.org](https://openweathermap.org/full-price#current).
|
|
222
225
|
|
|
223
226
|
```ruby
|
|
224
|
-
data = client.client.hourly(lat: 33.5312, lon: -111.9426) # => OpenWeather::Models::Forecast::Hourly
|
|
227
|
+
data = client.client.hourly(lat: 33.5312, lon: -111.9426, appid: "<your api key>") # => OpenWeather::Models::Forecast::Hourly
|
|
225
228
|
|
|
226
229
|
data.cnt # => 96 (number of entries)
|
|
230
|
+
data.city # => OpenWeather::Models::Forecast::City
|
|
227
231
|
data.list.first # => OpenWeather::Models::Forecast::Forecast
|
|
228
232
|
data.list.first.dt # => Time
|
|
229
233
|
data.list.first.main # => OpenWeather::Models::Forecast::Main
|
|
@@ -238,6 +242,53 @@ data.list.first.sys # => OpenWeather::Models::Forecast::Sys or nil
|
|
|
238
242
|
data.list.first.dt_txt # => String (Time of data forecasted, ISO, UTC)
|
|
239
243
|
```
|
|
240
244
|
|
|
245
|
+
### 30 Day Forecast (Pro)
|
|
246
|
+
|
|
247
|
+
The [30 Day Forecast API](https://openweathermap.org/api/forecast30) provides daily weather forecast for 30 days. Note: This API requires a paid api-key from [OpenWeather.org](https://openweathermap.org/full-price#current).
|
|
248
|
+
|
|
249
|
+
```ruby
|
|
250
|
+
data = client.client.forecast(lat: 33.5312, lon: -111.9426, appid: "<your api key>") # => OpenWeather::Models::Forecast::ThirtyDay::ThirtyDay
|
|
251
|
+
|
|
252
|
+
data.cnt # => 30 (number of entries - sometimes this is 29)
|
|
253
|
+
data.city # => OpenWeather::Models::Forecast::City
|
|
254
|
+
data.list.first # => OpenWeather::Models::Forecast::ThirtyDay::Forecast
|
|
255
|
+
data.list.first.dt # => Time - time of data forcasted, UTC
|
|
256
|
+
data.list.first.sunrise # => Time - Sunrise time, UTC
|
|
257
|
+
data.list.first.sunset # => Time - Sunset time, UTC
|
|
258
|
+
data.list.first.temp # => OpenWeather::Models::Forecast::ThirtyDay::Temp
|
|
259
|
+
data.list.first.feels_like # => OpenWeather::Models::OneCall::FeelsLike
|
|
260
|
+
data.list.first.pressure # => int - Atmospheric pressure on the sea level, hPa
|
|
261
|
+
data.list.first.humidity # => int - Humidity, % (e.g. integer 24 means 24% cloudiness)
|
|
262
|
+
data.list.first.weather # => Array[OpenWeather::Models::Weather]
|
|
263
|
+
data.list.first.speed # => double - Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour
|
|
264
|
+
data.list.first.deg # => int - Wind direction, degrees (meteorological)
|
|
265
|
+
data.list.first.clouds # => int - Cloudiness, % (e.g. integer 78 means 78% cloudiness)
|
|
266
|
+
data.list.first.rain # => double or nil - Precipitation volume, mm. Please note that only mm as units of measurement are available for this parameter
|
|
267
|
+
data.list.first.snow # => double or nil - Snow volume, mm. Please note that only mm as units of measurement are available for this parameter
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 5 Day Forecast
|
|
271
|
+
|
|
272
|
+
The [5 Day Forecast API](https://openweathermap.org/forecast5) provides weather forecast for 5 days with data every 3 hours by geographic coordinates.
|
|
273
|
+
|
|
274
|
+
```ruby
|
|
275
|
+
data = client.client.five_day_forecast(lat: 33.5312, lon: -111.9426, appid: "<your api key>") # => OpenWeather::Models::Forecast::FiveDay
|
|
276
|
+
|
|
277
|
+
data.cnt # => 40 (number of entries)
|
|
278
|
+
data.list.first # => OpenWeather::Models::Forecast::FiveDay::Forecast
|
|
279
|
+
data.list.first.dt # => Time
|
|
280
|
+
data.list.first.main # => OpenWeather::Models::Main
|
|
281
|
+
data.list.first.weather # => Array[OpenWeather::Models::Weather]
|
|
282
|
+
data.list.first.clouds # => OpenWeather::Models::Clouds or nil
|
|
283
|
+
data.list.first.wind # => OpenWeather::Models::Wind or nil
|
|
284
|
+
data.list.first.visibility # => 10000
|
|
285
|
+
data.list.first.pop # => 0.1 (probability of precipitation from 0.0 to 1.0 (0% to 100%))
|
|
286
|
+
data.list.first.rain # => OpenWeather::Models::Rain or nil
|
|
287
|
+
data.list.first.snow # => OpenWeather::Models::Snow or nil
|
|
288
|
+
data.list.first.sys # => OpenWeather::Models::Sys or nil
|
|
289
|
+
data.list.first.dt_txt # => String (Time of data forecasted, ISO, UTC)
|
|
290
|
+
```
|
|
291
|
+
|
|
241
292
|
### Stations
|
|
242
293
|
|
|
243
294
|
The [Stations API](https://openweathermap.org/stations) lets your manage personal weather stations and measurements.
|
|
@@ -341,19 +392,19 @@ end
|
|
|
341
392
|
|
|
342
393
|
The following settings are supported.
|
|
343
394
|
|
|
344
|
-
setting
|
|
345
|
-
|
|
346
|
-
api_key
|
|
347
|
-
lang
|
|
348
|
-
units
|
|
349
|
-
endpoint
|
|
350
|
-
user_agent
|
|
351
|
-
proxy
|
|
352
|
-
ca_path
|
|
353
|
-
ca_file
|
|
354
|
-
logger
|
|
355
|
-
timeout
|
|
356
|
-
open_timeout
|
|
395
|
+
| setting | description |
|
|
396
|
+
| ------------ | ---------------------------------------------------------- |
|
|
397
|
+
| api_key | Required API key. |
|
|
398
|
+
| lang | Default language in API responses. |
|
|
399
|
+
| units | Default units in API responses. |
|
|
400
|
+
| endpoint | Defaults to `https://api.openweathermap.org/data`. |
|
|
401
|
+
| user_agent | User-agent, defaults to _OpenWeather Ruby Client/version_. |
|
|
402
|
+
| proxy | Optional HTTP proxy. |
|
|
403
|
+
| ca_path | Optional SSL certificates path. |
|
|
404
|
+
| ca_file | Optional SSL certificates file. |
|
|
405
|
+
| logger | Optional `Logger` instance that logs HTTP requests. |
|
|
406
|
+
| timeout | Optional open/read timeout in seconds. |
|
|
407
|
+
| open_timeout | Optional connection open timeout in seconds. |
|
|
357
408
|
|
|
358
409
|
### Units
|
|
359
410
|
|
data/lib/open_weather/client.rb
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Endpoints
|
|
5
|
+
module FiveDayForecast
|
|
6
|
+
def five_day_forecast(lat, lon = nil, options = {})
|
|
7
|
+
options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat: lat, lon: lon)
|
|
8
|
+
OpenWeather::Models::Forecast::FiveDay::FiveDay.new(get('2.5/forecast', options), options)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Endpoints
|
|
5
|
+
module ThirtyDayForecast
|
|
6
|
+
def thirty_day_forecast(lat, lon = nil, options = {})
|
|
7
|
+
# default to the pro endpoint if not specified
|
|
8
|
+
endpoint = options.delete(:endpoint) || pro_endpoint
|
|
9
|
+
options = options.merge(endpoint: endpoint)
|
|
10
|
+
|
|
11
|
+
options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat: lat, lon: lon)
|
|
12
|
+
OpenWeather::Models::Forecast::ThirtyDay::ThirtyDay.new(get('2.5/forecast/climate', options), options)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/open_weather/logger.rb
CHANGED
|
@@ -11,6 +11,7 @@ module OpenWeather
|
|
|
11
11
|
property 'timezone' # shift in seconds from UTC
|
|
12
12
|
property 'sunrise', transform_with: ->(v) { Time.at(v).utc } # Sunrise time, UTC
|
|
13
13
|
property 'sunset', transform_with: ->(v) { Time.at(v).utc } # Sunset time, UTC
|
|
14
|
+
property 'population' # City population
|
|
14
15
|
end
|
|
15
16
|
end
|
|
16
17
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Models
|
|
5
|
+
module Forecast
|
|
6
|
+
module FiveDay
|
|
7
|
+
class FiveDay < Model
|
|
8
|
+
include Enumerable
|
|
9
|
+
|
|
10
|
+
property 'cod'
|
|
11
|
+
property 'message'
|
|
12
|
+
property 'cnt'
|
|
13
|
+
property 'list'
|
|
14
|
+
|
|
15
|
+
def initialize(args = nil, options = {})
|
|
16
|
+
super args, options
|
|
17
|
+
|
|
18
|
+
self.list = list.map { |forecast| Forecast.new(forecast, options) } if list
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Models
|
|
5
|
+
module Forecast
|
|
6
|
+
module FiveDay
|
|
7
|
+
class Forecast < Model
|
|
8
|
+
property 'dt', transform_with: ->(v) { Time.at(v).utc } # time of data forcasted, UTC
|
|
9
|
+
property 'main' # Main weather data
|
|
10
|
+
property 'weather' # Array of OpenWeather::Models::Weather
|
|
11
|
+
property 'clouds' # Cloudiness data
|
|
12
|
+
property 'wind' # Wind data
|
|
13
|
+
property 'visibility' # Visibility, meter
|
|
14
|
+
property 'pop' # Probability of precipitation
|
|
15
|
+
property 'rain' # Rain data
|
|
16
|
+
property 'snow' # Snow data
|
|
17
|
+
property 'sys' # System data
|
|
18
|
+
property 'dt_txt' # Date and time of calculation, UTC
|
|
19
|
+
|
|
20
|
+
def initialize(args = nil, options = {})
|
|
21
|
+
super args, options
|
|
22
|
+
|
|
23
|
+
self.main = OpenWeather::Models::Main.new(main, options) if main
|
|
24
|
+
self.weather = weather.map { |w| OpenWeather::Models::Weather.new(w, options) } if weather
|
|
25
|
+
self.clouds = OpenWeather::Models::Clouds.new(clouds, options) if clouds
|
|
26
|
+
self.wind = OpenWeather::Models::Wind.new(wind, options) if wind
|
|
27
|
+
self.rain = OpenWeather::Models::Rain.new(rain, options) if rain
|
|
28
|
+
self.snow = OpenWeather::Models::Snow.new(snow, options) if snow
|
|
29
|
+
self.sys = OpenWeather::Models::Sys.new(sys, options) if sys
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -13,7 +13,7 @@ module OpenWeather
|
|
|
13
13
|
property 'rain'
|
|
14
14
|
property 'snow'
|
|
15
15
|
property 'visibility' # Average visibility, metres. The maximum value of the visibility is 10km
|
|
16
|
-
property 'pop' # Probability of precipitation.
|
|
16
|
+
property 'pop' # Probability of precipitation. Varies from 0 and 1, where 0 is equal to 0%, 1 is equal to 100%
|
|
17
17
|
property 'sys'
|
|
18
18
|
|
|
19
19
|
def initialize(args = nil, options = {})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Models
|
|
5
|
+
module Forecast
|
|
6
|
+
module ThirtyDay
|
|
7
|
+
class Forecast < Model
|
|
8
|
+
property 'dt', transform_with: ->(v) { Time.at(v).utc } # time of data forcasted, UTC
|
|
9
|
+
property 'sunrise', transform_with: ->(v) { Time.at(v).utc } # Sunrise time, UTC
|
|
10
|
+
property 'sunset', transform_with: ->(v) { Time.at(v).utc } # Sunset time, UTC
|
|
11
|
+
property 'temp' # Array of OpenWeather::Models::Forecast::ThirtyDay::Temp
|
|
12
|
+
property 'feels_like' # OpenWeather::Models::OneCall::FeelsLike
|
|
13
|
+
property 'pressure' # Atmospheric pressure on the sea level, hPa
|
|
14
|
+
property 'humidity' # Humidity, % (e.g. integer 24 means 24% cloudiness)
|
|
15
|
+
property 'weather' # Array of OpenWeather::Models::Weather
|
|
16
|
+
property 'speed' # Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour
|
|
17
|
+
property 'deg' # Wind direction, degrees (meteorological)
|
|
18
|
+
property 'clouds' # Cloudiness, % (e.g. integer 78 means 78% cloudiness)
|
|
19
|
+
property 'rain' # Precipitation volume, mm. Unit will only be in mm
|
|
20
|
+
property 'snow' # Snow volume, mm. Unit will only be in mm
|
|
21
|
+
|
|
22
|
+
def initialize(args = nil, options = {})
|
|
23
|
+
super args, options
|
|
24
|
+
|
|
25
|
+
self.temp = Temp.new(temp, options) if temp
|
|
26
|
+
self.feels_like = OpenWeather::Models::OneCall::FeelsLike.new(feels_like, options) if feels_like
|
|
27
|
+
self.weather = weather.map { |w| OpenWeather::Models::Weather.new(w, options) } if weather
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Models
|
|
5
|
+
module Forecast
|
|
6
|
+
module ThirtyDay
|
|
7
|
+
class Temp < Model
|
|
8
|
+
temperature_property 'day' # Day temperature. Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit
|
|
9
|
+
temperature_property 'min' # Min daily temperature. Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit
|
|
10
|
+
temperature_property 'max' # Max daily temperature. Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit
|
|
11
|
+
temperature_property 'night' # Night temperature. Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit
|
|
12
|
+
temperature_property 'eve' # Evening temperature. Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit
|
|
13
|
+
temperature_property 'morn' # Morning temperature. Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Models
|
|
5
|
+
module Forecast
|
|
6
|
+
module ThirtyDay
|
|
7
|
+
class ThirtyDay < Model
|
|
8
|
+
include Enumerable
|
|
9
|
+
|
|
10
|
+
property 'cod' # Internal parameter
|
|
11
|
+
property 'message' # Internal parameter
|
|
12
|
+
property 'city'
|
|
13
|
+
property 'cnt' # Number of items in list
|
|
14
|
+
property 'list' # List of ??? objects
|
|
15
|
+
|
|
16
|
+
def initialize(args = nil, options = {})
|
|
17
|
+
super args, options
|
|
18
|
+
|
|
19
|
+
self.list = list.map { |forecast| Forecast.new(forecast, options) } if list
|
|
20
|
+
self.city = OpenWeather::Models::Forecast::City.new(city, options) if city
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -31,7 +31,7 @@ module OpenWeather
|
|
|
31
31
|
when :metric
|
|
32
32
|
(value.to_f + 273.15).round(2)
|
|
33
33
|
when :imperial
|
|
34
|
-
((value.to_f - 32) * 5 / 9 + 273.15).round(2)
|
|
34
|
+
(((value.to_f - 32) * 5 / 9) + 273.15).round(2)
|
|
35
35
|
else
|
|
36
36
|
value
|
|
37
37
|
end
|
|
@@ -55,7 +55,7 @@ module OpenWeather
|
|
|
55
55
|
when :imperial
|
|
56
56
|
value
|
|
57
57
|
else
|
|
58
|
-
((value.to_f - 273.15) * 9 / 5 + 32).round(2)
|
|
58
|
+
(((value.to_f - 273.15) * 9 / 5) + 32).round(2)
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
end
|
|
@@ -11,7 +11,9 @@ module OpenWeather
|
|
|
11
11
|
temperature_property 'feels_like' # temperature, accounts for the human perception of weather
|
|
12
12
|
property 'pressure' # atmospheric pressure on the sea level, hPa
|
|
13
13
|
property 'humidity' # humidity, %
|
|
14
|
-
|
|
14
|
+
# atmospheric temperature (varying according to pressure and humidity)
|
|
15
|
+
# below which water droplets begin to condense and dew can form
|
|
16
|
+
temperature_property 'dew_point'
|
|
15
17
|
property 'clouds' # cloudiness, %
|
|
16
18
|
property 'uvi' # UV index
|
|
17
19
|
property 'visibility' # average visibility, meters
|
|
@@ -11,7 +11,9 @@ module OpenWeather
|
|
|
11
11
|
property 'feels_like'
|
|
12
12
|
property 'pressure' # atmospheric pressure on the sea level, hPa
|
|
13
13
|
property 'humidity' # humidity, %
|
|
14
|
-
|
|
14
|
+
# atmospheric temperature (varying according to pressure and humidity)
|
|
15
|
+
# below which water droplets begin to condense and dew can form
|
|
16
|
+
temperature_property 'dew_point'
|
|
15
17
|
speed_property 'wind_speed' # wind speed
|
|
16
18
|
speed_property 'wind_gust' # wind gust
|
|
17
19
|
property 'wind_deg' # wind direction, degrees (meteorological)
|
|
@@ -9,7 +9,9 @@ module OpenWeather
|
|
|
9
9
|
temperature_property 'feels_like'
|
|
10
10
|
property 'pressure' # atmospheric pressure on the sea level, hPa
|
|
11
11
|
property 'humidity' # humidity, %
|
|
12
|
-
|
|
12
|
+
# atmospheric temperature (varying according to pressure and humidity)
|
|
13
|
+
# below which water droplets begin to condense and dew can form
|
|
14
|
+
temperature_property 'dew_point'
|
|
13
15
|
property 'clouds' # cloudiness, %
|
|
14
16
|
property 'visibility' # average visibility, meters
|
|
15
17
|
speed_property 'wind_speed' # wind speed.
|
|
@@ -12,11 +12,13 @@ module OpenWeather
|
|
|
12
12
|
property 'hourly' # hourly forecast weather
|
|
13
13
|
property 'daily' # daily forecast weather
|
|
14
14
|
property 'alerts' # weather alerts for the location
|
|
15
|
+
property 'data' # weather data
|
|
15
16
|
|
|
16
17
|
def initialize(args = nil, options = {})
|
|
17
18
|
super args, options
|
|
18
19
|
|
|
19
20
|
self.current = OpenWeather::Models::OneCall::CurrentWeather.new(current, options) if current
|
|
21
|
+
self.data = data.map { |i| OpenWeather::Models::OneCall::CurrentWeather.new(i, options) } if data
|
|
20
22
|
self.minutely = minutely.map { |i| OpenWeather::Models::OneCall::MinutelyWeather.new(i, options) } if minutely
|
|
21
23
|
self.hourly = hourly.map { |i| OpenWeather::Models::OneCall::HourlyWeather.new(i, options) } if hourly
|
|
22
24
|
self.daily = daily.map { |i| OpenWeather::Models::OneCall::DailyWeather.new(i, options) } if daily
|
|
@@ -5,7 +5,7 @@ module OpenWeather
|
|
|
5
5
|
module Stations
|
|
6
6
|
class Measurement < Model
|
|
7
7
|
property 'station_id' # The internal ID of the station
|
|
8
|
-
property 'type' # Type of the aggregated data - minute, hour or day
|
|
8
|
+
property 'type' # Type of the aggregated data - minute, hour or day - the letters m, h or d respectively
|
|
9
9
|
property 'date' # Time of measurement
|
|
10
10
|
property 'temp'
|
|
11
11
|
property 'humidity'
|
data/lib/open_weather/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: open-weather-ruby-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Doubrovkine
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -72,28 +71,42 @@ dependencies:
|
|
|
72
71
|
requirements:
|
|
73
72
|
- - "~>"
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
74
|
+
version: 0.8.0
|
|
76
75
|
type: :development
|
|
77
76
|
prerelease: false
|
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements:
|
|
80
79
|
- - "~>"
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
81
|
+
version: 0.8.0
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: danger-pr-comment
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
83
96
|
- !ruby/object:Gem::Dependency
|
|
84
97
|
name: danger-toc
|
|
85
98
|
requirement: !ruby/object:Gem::Requirement
|
|
86
99
|
requirements:
|
|
87
100
|
- - "~>"
|
|
88
101
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.
|
|
102
|
+
version: 0.2.0
|
|
90
103
|
type: :development
|
|
91
104
|
prerelease: false
|
|
92
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
106
|
requirements:
|
|
94
107
|
- - "~>"
|
|
95
108
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 0.
|
|
109
|
+
version: 0.2.0
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
|
98
111
|
name: dotenv
|
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -192,7 +205,6 @@ dependencies:
|
|
|
192
205
|
- - ">="
|
|
193
206
|
- !ruby/object:Gem::Version
|
|
194
207
|
version: '0'
|
|
195
|
-
description:
|
|
196
208
|
email: dblock@dblock.org
|
|
197
209
|
executables: []
|
|
198
210
|
extensions: []
|
|
@@ -207,9 +219,11 @@ files:
|
|
|
207
219
|
- lib/open_weather/connection.rb
|
|
208
220
|
- lib/open_weather/endpoints.rb
|
|
209
221
|
- lib/open_weather/endpoints/current.rb
|
|
222
|
+
- lib/open_weather/endpoints/five_day_forecast.rb
|
|
210
223
|
- lib/open_weather/endpoints/hourly.rb
|
|
211
224
|
- lib/open_weather/endpoints/one_call.rb
|
|
212
225
|
- lib/open_weather/endpoints/stations.rb
|
|
226
|
+
- lib/open_weather/endpoints/thirty_day_forecast.rb
|
|
213
227
|
- lib/open_weather/errors.rb
|
|
214
228
|
- lib/open_weather/errors/fault.rb
|
|
215
229
|
- lib/open_weather/logger.rb
|
|
@@ -220,8 +234,15 @@ files:
|
|
|
220
234
|
- lib/open_weather/models/coord.rb
|
|
221
235
|
- lib/open_weather/models/forecast.rb
|
|
222
236
|
- lib/open_weather/models/forecast/city.rb
|
|
237
|
+
- lib/open_weather/models/forecast/five_day.rb
|
|
238
|
+
- lib/open_weather/models/forecast/five_day/five_day.rb
|
|
239
|
+
- lib/open_weather/models/forecast/five_day/forecast.rb
|
|
223
240
|
- lib/open_weather/models/forecast/forecast.rb
|
|
224
241
|
- lib/open_weather/models/forecast/hourly.rb
|
|
242
|
+
- lib/open_weather/models/forecast/thirty_day.rb
|
|
243
|
+
- lib/open_weather/models/forecast/thirty_day/forecast.rb
|
|
244
|
+
- lib/open_weather/models/forecast/thirty_day/temp.rb
|
|
245
|
+
- lib/open_weather/models/forecast/thirty_day/thirty_day.rb
|
|
225
246
|
- lib/open_weather/models/list.rb
|
|
226
247
|
- lib/open_weather/models/main.rb
|
|
227
248
|
- lib/open_weather/models/mixins.rb
|
|
@@ -255,7 +276,6 @@ homepage: http://github.com/dblock/open-weather-ruby-client
|
|
|
255
276
|
licenses:
|
|
256
277
|
- MIT
|
|
257
278
|
metadata: {}
|
|
258
|
-
post_install_message:
|
|
259
279
|
rdoc_options: []
|
|
260
280
|
require_paths:
|
|
261
281
|
- lib
|
|
@@ -270,8 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
270
290
|
- !ruby/object:Gem::Version
|
|
271
291
|
version: 1.3.6
|
|
272
292
|
requirements: []
|
|
273
|
-
rubygems_version:
|
|
274
|
-
signing_key:
|
|
293
|
+
rubygems_version: 4.0.16
|
|
275
294
|
specification_version: 4
|
|
276
295
|
summary: OpenWeather API Ruby client.
|
|
277
296
|
test_files: []
|