open-weather-ruby-client 0.6.0 → 0.8.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 +74 -9
- data/lib/open_weather/client.rb +2 -0
- data/lib/open_weather/config.rb +2 -0
- data/lib/open_weather/endpoints/five_day_forecast.rb +12 -0
- data/lib/open_weather/endpoints/geocoding.rb +37 -0
- data/lib/open_weather/endpoints.rb +2 -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/thirty_day/forecast.rb +1 -1
- data/lib/open_weather/models/forecast.rb +1 -0
- data/lib/open_weather/models/geo_location.rb +14 -0
- data/lib/open_weather/models/geo_location_zip.rb +13 -0
- data/lib/open_weather/models/mixins/temp.rb +4 -4
- data/lib/open_weather/models/wind.rb +1 -0
- data/lib/open_weather/models.rb +2 -0
- data/lib/open_weather/version.rb +1 -1
- metadata +28 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f58c9713754c10d3b49e6b5798db270924130a6b40cc96df49f1530cdff68bf4
|
|
4
|
+
data.tar.gz: 8e05928fde71a02d177df35ae3b6f1ab78f19f756e21b1f6a766133de6c37fee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f047b48bec6d1f0b5b8391c1c9f7ac7896383c169253cd0cb2096d4532bb2801309a0c68ede79b87853068aecf6090939e507cb6e2f520b5091dc22cb1fbff80
|
|
7
|
+
data.tar.gz: 12c3e088084c4457e28659f4b82dca9b18d8926aea70eb87588a847a6523bb60c893b14919c3ce25a9ecc5458b33fb983a8af33ec62381d254a9a9c3ba5d8ffc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
### 0.8.0 (2026/10/09)
|
|
2
|
+
|
|
3
|
+
* [#54](https://github.com/dblock/open-weather-ruby-client/pull/54): Add support for the Geocoding API (`geo_direct`, `geo_reverse`, `geo_zip`) - [@dblock](https://github.com/dblock).
|
|
4
|
+
* [#50](https://github.com/dblock/open-weather-ruby-client/pull/50): Fixes `Danger Comment` workflow failing with a `contents: none` permissions error - [@dblock](https://github.com/dblock).
|
|
5
|
+
* [#51](https://github.com/dblock/open-weather-ruby-client/pull/51): Adds test coverage reporting with [coveralls.io](https://coveralls.io) - [@dblock](https://github.com/dblock).
|
|
6
|
+
* [#53](https://github.com/dblock/open-weather-ruby-client/pull/53): Fixed coverage reporting to Coveralls not running on pull requests by switching from `coveralls_reborn`/`COVERALLS_REPO_TOKEN` to `coverallsapp/github-action`/`GITHUB_TOKEN` - [@dblock](https://github.com/dblock).
|
|
7
|
+
* [#56](https://github.com/dblock/open-weather-ruby-client/pull/56): Correct spelling of Celsius and Fahrenheit - [@dblock](https://github.com/dblock).
|
|
8
|
+
### 0.7.0 (2026/8/23)
|
|
9
|
+
|
|
10
|
+
* [#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).
|
|
11
|
+
* [#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).
|
|
12
|
+
* [#46](https://github.com/dblock/open-weather-ruby-client/pull/46): Added support for the five day forecast API - [@mgm702](https://github.com/mgm702).
|
|
13
|
+
* [#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).
|
|
14
|
+
|
|
1
15
|
### 0.6.0 (2024/10/19)
|
|
2
16
|
|
|
3
17
|
* [#40](https://github.com/dblock/open-weather-ruby-client/pull/40): Fixing rubocop violations and improved .rubocop.yml - [@troya2](https://github.com/troya2).
|
data/README.md
CHANGED
|
@@ -2,7 +2,8 @@ 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
|
+
[](https://coveralls.io/github/dblock/open-weather-ruby-client?branch=master)
|
|
6
7
|
|
|
7
8
|
A Ruby client for the [OpenWeather API v2.5 and v3.0](https://openweathermap.org/api).
|
|
8
9
|
|
|
@@ -22,6 +23,7 @@ Unlike other clients, including [open-weather](https://github.com/coderhs/ruby_o
|
|
|
22
23
|
- [Historical Weather](#historical-weather)
|
|
23
24
|
- [Hourly Forecast (Pro)](#hourly-forecast-pro)
|
|
24
25
|
- [30 Day Forecast (Pro)](#30-day-forecast-pro)
|
|
26
|
+
- [5 Day Forecast](#5-day-forecast)
|
|
25
27
|
- [Stations](#stations)
|
|
26
28
|
- [Register a Station](#register-a-station)
|
|
27
29
|
- [List Stations](#list-stations)
|
|
@@ -30,6 +32,10 @@ Unlike other clients, including [open-weather](https://github.com/coderhs/ruby_o
|
|
|
30
32
|
- [Delete Station](#delete-station)
|
|
31
33
|
- [Create Measurements](#create-measurements)
|
|
32
34
|
- [Get Measurements](#get-measurements)
|
|
35
|
+
- [Geocoding](#geocoding)
|
|
36
|
+
- [Direct Geocoding](#direct-geocoding)
|
|
37
|
+
- [Reverse Geocoding](#reverse-geocoding)
|
|
38
|
+
- [Zip Code Geocoding](#zip-code-geocoding)
|
|
33
39
|
- [Configuration](#configuration)
|
|
34
40
|
- [Units](#units)
|
|
35
41
|
- [Converting Temperature](#converting-temperature)
|
|
@@ -74,8 +80,8 @@ data.main.humidity # => 81
|
|
|
74
80
|
data.main.pressure # => 1005
|
|
75
81
|
data.main.temp # => 282.57
|
|
76
82
|
data.main.temp_max # => 283.15, degrees Kelvin
|
|
77
|
-
data.main.temp_max_c # => 10, degrees
|
|
78
|
-
data.main.temp_max_f # => 50.0, degrees
|
|
83
|
+
data.main.temp_max_c # => 10, degrees Celsius
|
|
84
|
+
data.main.temp_max_f # => 50.0, degrees Fahrenheit
|
|
79
85
|
data.main.temp_min # => 281.48
|
|
80
86
|
```
|
|
81
87
|
|
|
@@ -266,6 +272,28 @@ data.list.first.rain # => double or nil - Precipitation volume, mm. Please note
|
|
|
266
272
|
data.list.first.snow # => double or nil - Snow volume, mm. Please note that only mm as units of measurement are available for this parameter
|
|
267
273
|
```
|
|
268
274
|
|
|
275
|
+
### 5 Day Forecast
|
|
276
|
+
|
|
277
|
+
The [5 Day Forecast API](https://openweathermap.org/forecast5) provides weather forecast for 5 days with data every 3 hours by geographic coordinates.
|
|
278
|
+
|
|
279
|
+
```ruby
|
|
280
|
+
data = client.client.five_day_forecast(lat: 33.5312, lon: -111.9426, appid: "<your api key>") # => OpenWeather::Models::Forecast::FiveDay
|
|
281
|
+
|
|
282
|
+
data.cnt # => 40 (number of entries)
|
|
283
|
+
data.list.first # => OpenWeather::Models::Forecast::FiveDay::Forecast
|
|
284
|
+
data.list.first.dt # => Time
|
|
285
|
+
data.list.first.main # => OpenWeather::Models::Main
|
|
286
|
+
data.list.first.weather # => Array[OpenWeather::Models::Weather]
|
|
287
|
+
data.list.first.clouds # => OpenWeather::Models::Clouds or nil
|
|
288
|
+
data.list.first.wind # => OpenWeather::Models::Wind or nil
|
|
289
|
+
data.list.first.visibility # => 10000
|
|
290
|
+
data.list.first.pop # => 0.1 (probability of precipitation from 0.0 to 1.0 (0% to 100%))
|
|
291
|
+
data.list.first.rain # => OpenWeather::Models::Rain or nil
|
|
292
|
+
data.list.first.snow # => OpenWeather::Models::Snow or nil
|
|
293
|
+
data.list.first.sys # => OpenWeather::Models::Sys or nil
|
|
294
|
+
data.list.first.dt_txt # => String (Time of data forecasted, ISO, UTC)
|
|
295
|
+
```
|
|
296
|
+
|
|
269
297
|
### Stations
|
|
270
298
|
|
|
271
299
|
The [Stations API](https://openweathermap.org/stations) lets your manage personal weather stations and measurements.
|
|
@@ -356,6 +384,43 @@ client.get_measurements(
|
|
|
356
384
|
) # => Array[OpenWeather::Models::Stations::Measurement]
|
|
357
385
|
```
|
|
358
386
|
|
|
387
|
+
### Geocoding
|
|
388
|
+
|
|
389
|
+
The [Geocoding API](https://openweathermap.org/api/geocoding-api) converts city names and zip/post codes to geographical coordinates, and vice versa.
|
|
390
|
+
|
|
391
|
+
#### Direct Geocoding
|
|
392
|
+
|
|
393
|
+
To get geographical coordinates for a city name, call the client method:
|
|
394
|
+
```ruby
|
|
395
|
+
client.geo_direct('London', nil, 'GB') # => Array[OpenWeather::Models::GeoLocation]
|
|
396
|
+
```
|
|
397
|
+
Or pass a hash of options.
|
|
398
|
+
```ruby
|
|
399
|
+
client.geo_direct(city: 'London', state: nil, country: 'GB', limit: 5) # => Array[OpenWeather::Models::GeoLocation]
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
#### Reverse Geocoding
|
|
403
|
+
|
|
404
|
+
To get a location name for geographical coordinates, call the client method:
|
|
405
|
+
```ruby
|
|
406
|
+
client.geo_reverse(51.5074456, -0.1277653) # => Array[OpenWeather::Models::GeoLocation]
|
|
407
|
+
```
|
|
408
|
+
Or pass a hash of options.
|
|
409
|
+
```ruby
|
|
410
|
+
client.geo_reverse(lat: 51.5074456, lon: -0.1277653, limit: 5) # => Array[OpenWeather::Models::GeoLocation]
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### Zip Code Geocoding
|
|
414
|
+
|
|
415
|
+
To get geographical coordinates for a zip/post code, call the client method:
|
|
416
|
+
```ruby
|
|
417
|
+
client.geo_zip('94040', 'US') # => OpenWeather::Models::GeoLocationZip
|
|
418
|
+
```
|
|
419
|
+
Or pass a hash of options.
|
|
420
|
+
```ruby
|
|
421
|
+
client.geo_zip(zip: '94040', country: 'US') # => OpenWeather::Models::GeoLocationZip
|
|
422
|
+
```
|
|
423
|
+
|
|
359
424
|
## Configuration
|
|
360
425
|
|
|
361
426
|
You can configure client options, globally.
|
|
@@ -390,7 +455,7 @@ The OpenWeather API returns responses in `standard`, `metric`, and `imperial` un
|
|
|
390
455
|
```ruby
|
|
391
456
|
data = client.weather(id: 2643743, units: 'metric')
|
|
392
457
|
data.name # => 'London'
|
|
393
|
-
data.main.temp # => 12, degrees
|
|
458
|
+
data.main.temp # => 12, degrees Celsius
|
|
394
459
|
```
|
|
395
460
|
|
|
396
461
|
```ruby
|
|
@@ -400,20 +465,20 @@ end
|
|
|
400
465
|
|
|
401
466
|
data = client.weather(id: 2643743)
|
|
402
467
|
data.name # => 'London'
|
|
403
|
-
data.main.temp # => 12, degrees
|
|
468
|
+
data.main.temp # => 12, degrees Celsius
|
|
404
469
|
```
|
|
405
470
|
|
|
406
471
|
#### Converting Temperature
|
|
407
472
|
|
|
408
|
-
APIs that return temperature support conversion between default, metric and imperial units, regardless of what units were requested. The following example requests current weather in metric units in Moscow. Use `_k` for Kelvin, `_c` for
|
|
473
|
+
APIs that return temperature support conversion between default, metric and imperial units, regardless of what units were requested. The following example requests current weather in metric units in Moscow. Use `_k` for Kelvin, `_c` for Celsius and `_f` for Fahrenheit.
|
|
409
474
|
|
|
410
475
|
```ruby
|
|
411
476
|
data = client.current_weather(city: 'Moscow', units: 'metric') # => OpenWeather::Models::City::Weather
|
|
412
477
|
|
|
413
|
-
data.main.temp_max # => 12, degrees
|
|
414
|
-
data.main.temp_max_c # => 12, degrees
|
|
478
|
+
data.main.temp_max # => 12, degrees Celsius, metric as requested
|
|
479
|
+
data.main.temp_max_c # => 12, degrees Celsius
|
|
415
480
|
data.main.temp_max_k # => 285.15, degrees Kelvin
|
|
416
|
-
data.main.temp_max_f # => 53.6, degrees
|
|
481
|
+
data.main.temp_max_f # => 53.6, degrees Fahrenheit
|
|
417
482
|
```
|
|
418
483
|
|
|
419
484
|
#### Converting Wind Speed
|
data/lib/open_weather/client.rb
CHANGED
|
@@ -7,8 +7,10 @@ module OpenWeather
|
|
|
7
7
|
include Endpoints::Current
|
|
8
8
|
include Endpoints::Hourly
|
|
9
9
|
include Endpoints::ThirtyDayForecast
|
|
10
|
+
include Endpoints::FiveDayForecast
|
|
10
11
|
include Endpoints::OneCall
|
|
11
12
|
include Endpoints::Stations
|
|
13
|
+
include Endpoints::Geocoding
|
|
12
14
|
|
|
13
15
|
attr_accessor(*Config::ATTRIBUTES)
|
|
14
16
|
|
data/lib/open_weather/config.rb
CHANGED
|
@@ -7,6 +7,7 @@ module OpenWeather
|
|
|
7
7
|
ATTRIBUTES = %i[
|
|
8
8
|
endpoint
|
|
9
9
|
pro_endpoint
|
|
10
|
+
geo_endpoint
|
|
10
11
|
api_key
|
|
11
12
|
proxy
|
|
12
13
|
user_agent
|
|
@@ -24,6 +25,7 @@ module OpenWeather
|
|
|
24
25
|
def reset
|
|
25
26
|
self.endpoint = 'https://api.openweathermap.org/data'
|
|
26
27
|
self.pro_endpoint = 'https://pro.openweathermap.org/data'
|
|
28
|
+
self.geo_endpoint = 'https://api.openweathermap.org/geo'
|
|
27
29
|
self.api_key = nil
|
|
28
30
|
self.user_agent = "OpenWeather Ruby Client/#{OpenWeather::VERSION}"
|
|
29
31
|
self.ca_path = nil
|
|
@@ -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,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Geocoding
|
|
6
|
+
def geo_direct(name, state = nil, country = nil, options = {})
|
|
7
|
+
options = name.is_a?(Hash) ? options.merge(name) : options.merge(city: name, state: state, country: country)
|
|
8
|
+
options[:q] = [
|
|
9
|
+
options.delete(:city),
|
|
10
|
+
options.delete(:state),
|
|
11
|
+
options.delete(:country)
|
|
12
|
+
].compact.join(',')
|
|
13
|
+
options[:endpoint] ||= geo_endpoint
|
|
14
|
+
|
|
15
|
+
get('1.0/direct', options).map { |data| OpenWeather::Models::GeoLocation.new(data) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def geo_reverse(lat, lon = nil, options = {})
|
|
19
|
+
options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat: lat, lon: lon)
|
|
20
|
+
options[:endpoint] ||= geo_endpoint
|
|
21
|
+
|
|
22
|
+
get('1.0/reverse', options).map { |data| OpenWeather::Models::GeoLocation.new(data) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def geo_zip(code, country = nil, options = {})
|
|
26
|
+
options = code.is_a?(Hash) ? options.merge(code) : options.merge(zip: code, country: country)
|
|
27
|
+
options[:zip] = [
|
|
28
|
+
options.delete(:zip),
|
|
29
|
+
options.delete(:country)
|
|
30
|
+
].compact.join(',')
|
|
31
|
+
options[:endpoint] ||= geo_endpoint
|
|
32
|
+
|
|
33
|
+
OpenWeather::Models::GeoLocationZip.new(get('1.0/zip', options))
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
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
|
|
@@ -8,7 +8,7 @@ module OpenWeather
|
|
|
8
8
|
property 'dt', transform_with: ->(v) { Time.at(v).utc } # time of data forcasted, UTC
|
|
9
9
|
property 'sunrise', transform_with: ->(v) { Time.at(v).utc } # Sunrise time, UTC
|
|
10
10
|
property 'sunset', transform_with: ->(v) { Time.at(v).utc } # Sunset time, UTC
|
|
11
|
-
property 'temp' # Array of OpenWeather::Models::Forecast::
|
|
11
|
+
property 'temp' # Array of OpenWeather::Models::Forecast::ThirtyDay::Temp
|
|
12
12
|
property 'feels_like' # OpenWeather::Models::OneCall::FeelsLike
|
|
13
13
|
property 'pressure' # Atmospheric pressure on the sea level, hPa
|
|
14
14
|
property 'humidity' # Humidity, % (e.g. integer 24 means 24% cloudiness)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Models
|
|
5
|
+
class GeoLocation < Model
|
|
6
|
+
property 'name' # name of the found location
|
|
7
|
+
property 'local_names' # name of the found location in different languages
|
|
8
|
+
property 'lat' # geo location, latitude
|
|
9
|
+
property 'lon' # geo location, longitude
|
|
10
|
+
property 'country' # country of the found location
|
|
11
|
+
property 'state' # state of the found location
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenWeather
|
|
4
|
+
module Models
|
|
5
|
+
class GeoLocationZip < Model
|
|
6
|
+
property 'zip' # zip/post code
|
|
7
|
+
property 'name' # name of the found location
|
|
8
|
+
property 'lat' # geo location, latitude
|
|
9
|
+
property 'lon' # geo location, longitude
|
|
10
|
+
property 'country' # country of the found location
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -15,11 +15,11 @@ module OpenWeather
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
define_method "#{field}_c" do
|
|
18
|
-
|
|
18
|
+
to_celsius(send(field))
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
define_method "#{field}_f" do
|
|
22
|
-
|
|
22
|
+
to_fahrenheit(send(field))
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -37,7 +37,7 @@ module OpenWeather
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def
|
|
40
|
+
def to_celsius(value)
|
|
41
41
|
case units
|
|
42
42
|
when :metric
|
|
43
43
|
value
|
|
@@ -48,7 +48,7 @@ module OpenWeather
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def
|
|
51
|
+
def to_fahrenheit(value)
|
|
52
52
|
case units
|
|
53
53
|
when :metric
|
|
54
54
|
((value.to_f * 9 / 5) + 32).round(2)
|
data/lib/open_weather/models.rb
CHANGED
|
@@ -15,6 +15,8 @@ require_relative 'models/city'
|
|
|
15
15
|
require_relative 'models/one_call'
|
|
16
16
|
require_relative 'models/forecast'
|
|
17
17
|
require_relative 'models/station'
|
|
18
|
+
require_relative 'models/geo_location'
|
|
19
|
+
require_relative 'models/geo_location_zip'
|
|
18
20
|
require_relative 'models/stations/measurement'
|
|
19
21
|
require_relative 'models/stations/temp'
|
|
20
22
|
require_relative 'models/stations/humidity'
|
data/lib/open_weather/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Doubrovkine
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -72,28 +72,42 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
75
|
+
version: 0.8.0
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
82
|
+
version: 0.8.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: danger-pr-comment
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: danger-toc
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
86
100
|
requirements:
|
|
87
101
|
- - "~>"
|
|
88
102
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.
|
|
103
|
+
version: 0.2.0
|
|
90
104
|
type: :development
|
|
91
105
|
prerelease: false
|
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
107
|
requirements:
|
|
94
108
|
- - "~>"
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 0.
|
|
110
|
+
version: 0.2.0
|
|
97
111
|
- !ruby/object:Gem::Dependency
|
|
98
112
|
name: dotenv
|
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -207,6 +221,8 @@ files:
|
|
|
207
221
|
- lib/open_weather/connection.rb
|
|
208
222
|
- lib/open_weather/endpoints.rb
|
|
209
223
|
- lib/open_weather/endpoints/current.rb
|
|
224
|
+
- lib/open_weather/endpoints/five_day_forecast.rb
|
|
225
|
+
- lib/open_weather/endpoints/geocoding.rb
|
|
210
226
|
- lib/open_weather/endpoints/hourly.rb
|
|
211
227
|
- lib/open_weather/endpoints/one_call.rb
|
|
212
228
|
- lib/open_weather/endpoints/stations.rb
|
|
@@ -221,12 +237,17 @@ files:
|
|
|
221
237
|
- lib/open_weather/models/coord.rb
|
|
222
238
|
- lib/open_weather/models/forecast.rb
|
|
223
239
|
- lib/open_weather/models/forecast/city.rb
|
|
240
|
+
- lib/open_weather/models/forecast/five_day.rb
|
|
241
|
+
- lib/open_weather/models/forecast/five_day/five_day.rb
|
|
242
|
+
- lib/open_weather/models/forecast/five_day/forecast.rb
|
|
224
243
|
- lib/open_weather/models/forecast/forecast.rb
|
|
225
244
|
- lib/open_weather/models/forecast/hourly.rb
|
|
226
245
|
- lib/open_weather/models/forecast/thirty_day.rb
|
|
227
246
|
- lib/open_weather/models/forecast/thirty_day/forecast.rb
|
|
228
247
|
- lib/open_weather/models/forecast/thirty_day/temp.rb
|
|
229
248
|
- lib/open_weather/models/forecast/thirty_day/thirty_day.rb
|
|
249
|
+
- lib/open_weather/models/geo_location.rb
|
|
250
|
+
- lib/open_weather/models/geo_location_zip.rb
|
|
230
251
|
- lib/open_weather/models/list.rb
|
|
231
252
|
- lib/open_weather/models/main.rb
|
|
232
253
|
- lib/open_weather/models/mixins.rb
|
|
@@ -275,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
275
296
|
- !ruby/object:Gem::Version
|
|
276
297
|
version: 1.3.6
|
|
277
298
|
requirements: []
|
|
278
|
-
rubygems_version: 3.
|
|
299
|
+
rubygems_version: 3.5.16
|
|
279
300
|
signing_key:
|
|
280
301
|
specification_version: 4
|
|
281
302
|
summary: OpenWeather API Ruby client.
|