open-weather-ruby-client 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ae98694e49ce5daa921935652931c2ef63892907641f17634cab2b16f044283
4
- data.tar.gz: d318548404776897b45598a4ee1b0bf7c6b2cbda28c39758df96aece5c2c447b
3
+ metadata.gz: f58c9713754c10d3b49e6b5798db270924130a6b40cc96df49f1530cdff68bf4
4
+ data.tar.gz: 8e05928fde71a02d177df35ae3b6f1ab78f19f756e21b1f6a766133de6c37fee
5
5
  SHA512:
6
- metadata.gz: 27f5329a0d98d2e5db78bad49e5724b0358827c98478cc83f4e5ddf87e7fefdcd3028e26753402e338f4616c836a05c17aecf4a9d8f05fa211d5f903d606e96c
7
- data.tar.gz: a5e387ce420b0c24f51e5ba8168e7d8a5c29aaa74543af82565aa320dc0873165e99fb01b2cfb587fc5427544b5ff2dfa6edd0f11bae6ebb44097d698acaaf3f
6
+ metadata.gz: f047b48bec6d1f0b5b8391c1c9f7ac7896383c169253cd0cb2096d4532bb2801309a0c68ede79b87853068aecf6090939e507cb6e2f520b5091dc22cb1fbff80
7
+ data.tar.gz: 12c3e088084c4457e28659f4b82dca9b18d8926aea70eb87588a847a6523bb60c893b14919c3ce25a9ecc5458b33fb983a8af33ec62381d254a9a9c3ba5d8ffc
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
- ### 0.7.0 (8/23/2026)
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)
2
9
 
3
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).
4
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).
data/README.md CHANGED
@@ -3,6 +3,7 @@ OpenWeather Ruby Client
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/open-weather-ruby-client.svg)](https://badge.fury.io/rb/open-weather-ruby-client)
5
5
  [![Tests Status](https://github.com/dblock/open-weather-ruby-client/actions/workflows/test.yml/badge.svg)](https://github.com/dblock/open-weather-ruby-client/actions/workflows/test.yml)
6
+ [![Coverage Status](https://coveralls.io/repos/github/dblock/open-weather-ruby-client/badge.svg?branch=master)](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
 
@@ -31,6 +32,10 @@ Unlike other clients, including [open-weather](https://github.com/coderhs/ruby_o
31
32
  - [Delete Station](#delete-station)
32
33
  - [Create Measurements](#create-measurements)
33
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)
34
39
  - [Configuration](#configuration)
35
40
  - [Units](#units)
36
41
  - [Converting Temperature](#converting-temperature)
@@ -75,8 +80,8 @@ data.main.humidity # => 81
75
80
  data.main.pressure # => 1005
76
81
  data.main.temp # => 282.57
77
82
  data.main.temp_max # => 283.15, degrees Kelvin
78
- data.main.temp_max_c # => 10, degrees Celcius
79
- data.main.temp_max_f # => 50.0, degrees Farenheit
83
+ data.main.temp_max_c # => 10, degrees Celsius
84
+ data.main.temp_max_f # => 50.0, degrees Fahrenheit
80
85
  data.main.temp_min # => 281.48
81
86
  ```
82
87
 
@@ -379,6 +384,43 @@ client.get_measurements(
379
384
  ) # => Array[OpenWeather::Models::Stations::Measurement]
380
385
  ```
381
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
+
382
424
  ## Configuration
383
425
 
384
426
  You can configure client options, globally.
@@ -413,7 +455,7 @@ The OpenWeather API returns responses in `standard`, `metric`, and `imperial` un
413
455
  ```ruby
414
456
  data = client.weather(id: 2643743, units: 'metric')
415
457
  data.name # => 'London'
416
- data.main.temp # => 12, degrees Celcius
458
+ data.main.temp # => 12, degrees Celsius
417
459
  ```
418
460
 
419
461
  ```ruby
@@ -423,20 +465,20 @@ end
423
465
 
424
466
  data = client.weather(id: 2643743)
425
467
  data.name # => 'London'
426
- data.main.temp # => 12, degrees Celcius
468
+ data.main.temp # => 12, degrees Celsius
427
469
  ```
428
470
 
429
471
  #### Converting Temperature
430
472
 
431
- 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 Celcius and `_f` for Farenheit.
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.
432
474
 
433
475
  ```ruby
434
476
  data = client.current_weather(city: 'Moscow', units: 'metric') # => OpenWeather::Models::City::Weather
435
477
 
436
- data.main.temp_max # => 12, degrees Celcius, metric as requested
437
- data.main.temp_max_c # => 12, degrees Celcius
478
+ data.main.temp_max # => 12, degrees Celsius, metric as requested
479
+ data.main.temp_max_c # => 12, degrees Celsius
438
480
  data.main.temp_max_k # => 285.15, degrees Kelvin
439
- data.main.temp_max_f # => 53.6, degrees Farenheit
481
+ data.main.temp_max_f # => 53.6, degrees Fahrenheit
440
482
  ```
441
483
 
442
484
  #### Converting Wind Speed
@@ -10,6 +10,7 @@ module OpenWeather
10
10
  include Endpoints::FiveDayForecast
11
11
  include Endpoints::OneCall
12
12
  include Endpoints::Stations
13
+ include Endpoints::Geocoding
13
14
 
14
15
  attr_accessor(*Config::ATTRIBUTES)
15
16
 
@@ -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,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
@@ -6,3 +6,4 @@ require_relative 'endpoints/stations'
6
6
  require_relative 'endpoints/hourly'
7
7
  require_relative 'endpoints/thirty_day_forecast'
8
8
  require_relative 'endpoints/five_day_forecast'
9
+ require_relative 'endpoints/geocoding'
@@ -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
- to_celcius(send(field))
18
+ to_celsius(send(field))
19
19
  end
20
20
 
21
21
  define_method "#{field}_f" do
22
- to_farenheit(send(field))
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 to_celcius(value)
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 to_farenheit(value)
51
+ def to_fahrenheit(value)
52
52
  case units
53
53
  when :metric
54
54
  ((value.to_f * 9 / 5) + 32).round(2)
@@ -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'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenWeather
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,13 +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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-10-10 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: activesupport
@@ -205,6 +206,7 @@ dependencies:
205
206
  - - ">="
206
207
  - !ruby/object:Gem::Version
207
208
  version: '0'
209
+ description:
208
210
  email: dblock@dblock.org
209
211
  executables: []
210
212
  extensions: []
@@ -220,6 +222,7 @@ files:
220
222
  - lib/open_weather/endpoints.rb
221
223
  - lib/open_weather/endpoints/current.rb
222
224
  - lib/open_weather/endpoints/five_day_forecast.rb
225
+ - lib/open_weather/endpoints/geocoding.rb
223
226
  - lib/open_weather/endpoints/hourly.rb
224
227
  - lib/open_weather/endpoints/one_call.rb
225
228
  - lib/open_weather/endpoints/stations.rb
@@ -243,6 +246,8 @@ files:
243
246
  - lib/open_weather/models/forecast/thirty_day/forecast.rb
244
247
  - lib/open_weather/models/forecast/thirty_day/temp.rb
245
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
246
251
  - lib/open_weather/models/list.rb
247
252
  - lib/open_weather/models/main.rb
248
253
  - lib/open_weather/models/mixins.rb
@@ -276,6 +281,7 @@ homepage: http://github.com/dblock/open-weather-ruby-client
276
281
  licenses:
277
282
  - MIT
278
283
  metadata: {}
284
+ post_install_message:
279
285
  rdoc_options: []
280
286
  require_paths:
281
287
  - lib
@@ -290,7 +296,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
296
  - !ruby/object:Gem::Version
291
297
  version: 1.3.6
292
298
  requirements: []
293
- rubygems_version: 4.0.16
299
+ rubygems_version: 3.5.16
300
+ signing_key:
294
301
  specification_version: 4
295
302
  summary: OpenWeather API Ruby client.
296
303
  test_files: []