open-weather-ruby-client 0.8.0 → 0.8.1

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: f58c9713754c10d3b49e6b5798db270924130a6b40cc96df49f1530cdff68bf4
4
- data.tar.gz: 8e05928fde71a02d177df35ae3b6f1ab78f19f756e21b1f6a766133de6c37fee
3
+ metadata.gz: 6a1d8500eb96ae00c27608e53223cdb9cbc3ab8fd5f2344a12b760d9e37c3613
4
+ data.tar.gz: 86e3df5f13df2e365fb431d477379c80362bd34e2cd882419f3815c3f28c6ddd
5
5
  SHA512:
6
- metadata.gz: f047b48bec6d1f0b5b8391c1c9f7ac7896383c169253cd0cb2096d4532bb2801309a0c68ede79b87853068aecf6090939e507cb6e2f520b5091dc22cb1fbff80
7
- data.tar.gz: 12c3e088084c4457e28659f4b82dca9b18d8926aea70eb87588a847a6523bb60c893b14919c3ce25a9ecc5458b33fb983a8af33ec62381d254a9a9c3ba5d8ffc
6
+ metadata.gz: 810123c712145a3efdb1b9299abc7df23a4102be9897872eef11572427d0631e0cc8adea63d331eb8f1514d35dd0b598c193ae07bb1fb22efefcee2300993d17
7
+ data.tar.gz: c277622f792ec918bda5b801f608163bcef945713c82d93aa717bec2edb730fa2e58c83b778831393f37e04207d08b1b56ff3089f35cef94a91e7d8ef182f53b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 0.8.1 (2026/11/24)
2
+
3
+ * [#57](https://github.com/dblock/open-weather-ruby-client/pull/57): Fixes `min`, `max` and `zip` with `hashie` >= 6.0, adds Appraisals (`hashie-5`, `hashie-6`) - [@dblock](https://github.com/dblock).
4
+ * [#58](https://github.com/dblock/open-weather-ruby-client/pull/58): Speeds up CI by reporting coverage from the Ruby 3.4 test job instead of a separate run, skipping duplicate push builds of PR branches, canceling superseded PR builds and using `JRUBY_OPTS=--dev`, and upgrades to [danger-pr-comment](https://github.com/danger/danger-pr-comment) 0.3.0 - [@dblock](https://github.com/dblock).
5
+ * [#59](https://github.com/dblock/open-weather-ruby-client/pull/59): Adds `rake benchmark`, speeds up responses 10-20% by not copying models' String keys and caching weather icon URIs, which are now frozen - [@dblock](https://github.com/dblock).
6
+ * [#60](https://github.com/dblock/open-weather-ruby-client/pull/60): Releases with [ruby-gem-release](https://github.com/dblock/ruby-gem-release) and RubyGems Trusted Publishing - [@dblock](https://github.com/dblock).
7
+ * [#61](https://github.com/dblock/open-weather-ruby-client/pull/61): Simplifies README usage, moves the API reference to [docs/USAGE.md](docs/USAGE.md) and fixes the units, language and wind speed examples - [@dblock](https://github.com/dblock).
8
+
1
9
  ### 0.8.0 (2026/10/09)
2
10
 
3
11
  * [#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).
data/README.md CHANGED
@@ -7,35 +7,15 @@ OpenWeather Ruby Client
7
7
 
8
8
  A Ruby client for the [OpenWeather API v2.5 and v3.0](https://openweathermap.org/api).
9
9
 
10
- Unlike other clients, including [open-weather](https://github.com/coderhs/ruby_open_weather_map), provides a rich first class interface to OpenWeather models, structured timestamps, built-in metrics conversion for temperature and wind speed, offers more consistent error handling, and is implemented with thorough test coverage using actual OpenWeather data.
10
+ It provides rich OpenWeather models with structured timestamps, temperature and wind speed conversion, and consistent error handling, and is tested with actual OpenWeather data.
11
11
 
12
12
  ## Table of Contents
13
13
 
14
14
  - [Installation](#installation)
15
15
  - [Usage](#usage)
16
16
  - [Current Weather](#current-weather)
17
- - [Current Weather for Several Cities](#current-weather-for-several-cities)
18
- - [Cities Within a Rectangle Zone](#cities-within-a-rectangle-zone)
19
- - [Cities Within a Circle](#cities-within-a-circle)
20
- - [Multiple Cities by Id](#multiple-cities-by-id)
21
- - [One Call](#one-call)
22
- - [Current and Forecast Weather](#current-and-forecast-weather)
23
- - [Historical Weather](#historical-weather)
24
- - [Hourly Forecast (Pro)](#hourly-forecast-pro)
25
- - [30 Day Forecast (Pro)](#30-day-forecast-pro)
26
- - [5 Day Forecast](#5-day-forecast)
27
- - [Stations](#stations)
28
- - [Register a Station](#register-a-station)
29
- - [List Stations](#list-stations)
30
- - [Get Station](#get-station)
31
- - [Update Station](#update-station)
32
- - [Delete Station](#delete-station)
33
- - [Create Measurements](#create-measurements)
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)
17
+ - [Forecasts](#forecasts)
18
+ - [More](#more)
39
19
  - [Configuration](#configuration)
40
20
  - [Units](#units)
41
21
  - [Converting Temperature](#converting-temperature)
@@ -58,368 +38,40 @@ Run `bundle install`.
58
38
 
59
39
  ## Usage
60
40
 
61
- Use an access token obtained from [API Keys](https://home.openweathermap.org/api_keys) on the OpenWeather website after registration.
41
+ Get an API key from [API Keys](https://home.openweathermap.org/api_keys) on the OpenWeather website after registration.
62
42
 
63
43
  ```ruby
64
- client = OpenWeather::Client.new(
65
- api_key: "1a2b3c4d5a6b7c8d9a8b7c6d5a4b3c2d1"
66
- )
44
+ client = OpenWeather::Client.new(api_key: ENV['OPEN_WEATHER_API_KEY'])
67
45
  ```
68
46
 
69
47
  ### Current Weather
70
48
 
71
- Returns [current weather](https://openweathermap.org/current).
72
-
73
49
  ```ruby
74
50
  data = client.current_weather(city: 'London') # => OpenWeather::Models::City::Weather
75
51
 
76
52
  data.name # => 'London'
77
53
  data.dt # => Time
78
- data.main.feels_like # => 277.73
79
- data.main.humidity # => 81
80
- data.main.pressure # => 1005
81
- data.main.temp # => 282.57
82
- data.main.temp_max # => 283.15, degrees Kelvin
83
- data.main.temp_max_c # => 10, degrees Celsius
84
- data.main.temp_max_f # => 50.0, degrees Fahrenheit
85
- data.main.temp_min # => 281.48
86
- ```
87
-
88
- Returns the current weather in metric units and Russian metadata.
89
-
90
- ```ruby
91
- data = client.current_weather(city: 'Moscow', units: 'metric', lang: 'ru') # => OpenWeather::Models::City::Weather
92
-
93
- data.name # => 'Москва'
94
- data.main.temp # => 12
95
- ```
96
-
97
- Returns weather by city, optional state (in the US) and optional ISO 3166 country code.
98
- Names that cannot be resolved will cause the API call to raise a `Faraday::ResourceNotFound` error.
99
-
100
- ```ruby
101
- client.current_city('Sydney')
102
- client.current_city('London, UK')
103
- client.current_city('London', 'UK')
104
- client.current_city('Albany')
105
- client.current_city('Albany, New York')
106
- client.current_city('Albany, New York', 'US')
107
- client.current_city('Albany, NY', 'US')
108
- client.current_city('Albany', 'New York', 'US')
109
- client.current_city('Albany', 'NY', 'US')
110
- client.current_city('Albany', 'NY') # 2-letter state abbreviation w/o country will raise Faraday::ResourceNotFound
111
-
112
- client.current_weather(city: 'Albany', state: 'NY', country: 'US')
113
- ```
114
-
115
- Returns weather by city ID.
116
-
117
- ```ruby
118
- client.current_city_id(2643743) # => weather in London
119
- client.current_weather(id: 2643743) # => weather in London
120
- ```
121
-
122
- Returns weather by latitude and longitude.
123
-
124
- ```ruby
125
- client.current_geo(51.51, -0.13) # => weather in London
126
- client.current_weather(lat: 51.51, lon: -0.13) # => weather in London
127
- ```
128
-
129
- Returns weather by zip code with an optional country code (defaults to US).
130
-
131
- ```ruby
132
- client.current_zip(10018, 'US') # => weather in New York, 10018
133
- client.current_weather(zip: 10018, country: 'US') # => weather in New York, 10018
134
- ```
135
-
136
- See [OpenWeather::Models::City::Weather](lib/open_weather/models/city/weather.rb) and related [OpenWeather::Models](lib/open_weather/models) for all available properties.
137
-
138
- ### Current Weather for Several Cities
139
-
140
- Collection APIs return [OpenWeather::Models::List](lib/open_weather/models/list.rb), which includes multiple instances of [OpenWeather::Models::City::Weather](lib/open_weather/models/city/weather.rb).
141
-
142
- #### Cities Within a Rectangle Zone
143
-
144
- ```ruby
145
- data = client.current_cities_geo_box(12, 32, 15, 37, 10) # => OpenWeather::Models::List
146
-
147
- data.first.name # 'Birkirkara'
148
- data.main.temp # => 16.23
149
- ```
150
-
151
- You can optionally name parameters.
152
-
153
- ```ruby
154
- client.current_cities_geo_box(lon_left: 12, lat_bottom: 32, lon_right: 15, lat_top: 37, zoom: 10) # => OpenWeather::Models::List
155
- ```
156
-
157
- You can use server clustering of points with `cluster: true`.
158
-
159
- ```ruby
160
- client.current_cities_geo_box(12, 32, 15, 37, 10, cluster: true) # => OpenWeather::Models::List
54
+ data.main.temp # => 282.57, degrees Kelvin by default
55
+ data.main.temp_c # => 9.42, degrees Celsius
56
+ data.weather.first.description # => 'light rain'
161
57
  ```
162
58
 
163
- #### Cities Within a Circle
164
-
165
- ```ruby
166
- data = client.current_cities_geo_circle(55.5, 37.5, 10) # => OpenWeather::Models::List
167
-
168
- data.first.name # 'Shcherbinka'
169
- data.main.temp # => 276.86
170
- ```
59
+ Look up weather by city and country (`city: 'London', country: 'UK'`), id (`id: 2643743`), coordinates (`lat: 51.51, lon: -0.13`) or zip code (`zip: 10018, country: 'US'`).
171
60
 
172
- You can optionally name parameters.
61
+ ### Forecasts
173
62
 
174
63
  ```ruby
175
- client.current_cities_geo_circle(lat: 55.5, lon: 37.5, cnt: 7) # => OpenWeather::Models::List
176
- ```
177
-
178
- #### Multiple Cities by Id
179
-
180
- ```ruby
181
- data = client.current_cities_id(524901, 703448, 2643743) # => OpenWeather::Models::List
182
-
183
- data.first.name # 'Moscow'
184
- data.main.temp # => 285.15
185
- ```
186
-
187
- ### One Call
188
-
189
- [One Call API](https://openweathermap.org/api/one-call-api) provides current weather, minute forecast for 1 hour, hourly forecast for 48 hours, daily forecast for 7 days, historical weather data for 5 previous days for any geographical coordinate, and national weather alerts.
64
+ data = client.one_call(lat: 33.5312, lon: -111.9426) # => OpenWeather::Models::OneCall::Weather
190
65
 
191
- See [OpenWeather::Models::OneCall](lib/open_weather/models/one_call) for all available models and properties.
192
-
193
- #### Current and Forecast Weather
194
-
195
- ```ruby
196
- data = client.one_call(lat: 33.441792, lon: -94.037689) # => OpenWeather::Models::OneCall::Weather
197
-
198
- data.lat # => 33.44
199
- data.lon # => -94.04
200
- data.timezone # => 'America/Chicago'
66
+ data.timezone # => 'America/Phoenix'
201
67
  data.current # => OpenWeather::Models::OneCall::CurrentWeather
202
- data.data # => Array]OpenWeather::Models::OneCall::CurrentWeather] (on base plan)
203
- data.minutely # => Array[OpenWeather::Models::OneCall::MinutelyWeather]
204
- data.hourly # => Array[OpenWeather::Models::OneCall::HourlyWeather]
68
+ data.hourly.first.temp # => 289.2
205
69
  data.daily # => Array[OpenWeather::Models::OneCall::DailyWeather]
206
- data.alerts # => Array[OpenWeather::Models::OneCall::Alert]
207
- ```
208
-
209
- Exclude minutely and hourly data.
210
-
211
- ```ruby
212
- client.one_call(lat: 33.441792, lon: -94.037689, exclude: ['minutely', 'hourly'])
213
70
  ```
214
71
 
215
- #### Historical Weather
72
+ ### More
216
73
 
217
- ```ruby
218
- data = client.one_call(lat: 33.441792, lon: -94.037689, dt: Time.now - 24 * 60 * 60) # => OpenWeather::Models::OneCall::Weather
219
-
220
- data.lat # => 33.44
221
- data.lon # => -94.04
222
- data.timezone # => 'America/Chicago'
223
- data.current # => OpenWeather::Models::OneCall::CurrentWeather
224
- data.hourly # => Array[OpenWeather::Models::OneCall::HourlyWeather]
225
- ```
226
-
227
- ### Hourly Forecast (Pro)
228
-
229
- 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).
230
-
231
- ```ruby
232
- data = client.client.hourly(lat: 33.5312, lon: -111.9426, appid: "<your api key>") # => OpenWeather::Models::Forecast::Hourly
233
-
234
- data.cnt # => 96 (number of entries)
235
- data.city # => OpenWeather::Models::Forecast::City
236
- data.list.first # => OpenWeather::Models::Forecast::Forecast
237
- data.list.first.dt # => Time
238
- data.list.first.main # => OpenWeather::Models::Forecast::Main
239
- data.list.first.weather # => Array[OpenWeather::Models::Forecast::Weather]
240
- data.list.first.clouds # => OpenWeather::Models::Forecast::Clouds or nil
241
- data.list.first.wind # => OpenWeather::Models::Forecast::Wind or nil
242
- data.list.first.visibility # => 10000
243
- data.list.first.pop # => 0.1 (probability of precipitation from 0.0 to 1.0 (0% to 100%))
244
- data.list.first.rain # => OpenWeather::Models::Forecast::Rain or nil
245
- data.list.first.snow # => OpenWeather::Models::Forecast::Snow or nil
246
- data.list.first.sys # => OpenWeather::Models::Forecast::Sys or nil
247
- data.list.first.dt_txt # => String (Time of data forecasted, ISO, UTC)
248
- ```
249
-
250
- ### 30 Day Forecast (Pro)
251
-
252
- 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).
253
-
254
- ```ruby
255
- data = client.client.forecast(lat: 33.5312, lon: -111.9426, appid: "<your api key>") # => OpenWeather::Models::Forecast::ThirtyDay::ThirtyDay
256
-
257
- data.cnt # => 30 (number of entries - sometimes this is 29)
258
- data.city # => OpenWeather::Models::Forecast::City
259
- data.list.first # => OpenWeather::Models::Forecast::ThirtyDay::Forecast
260
- data.list.first.dt # => Time - time of data forcasted, UTC
261
- data.list.first.sunrise # => Time - Sunrise time, UTC
262
- data.list.first.sunset # => Time - Sunset time, UTC
263
- data.list.first.temp # => OpenWeather::Models::Forecast::ThirtyDay::Temp
264
- data.list.first.feels_like # => OpenWeather::Models::OneCall::FeelsLike
265
- data.list.first.pressure # => int - Atmospheric pressure on the sea level, hPa
266
- data.list.first.humidity # => int - Humidity, % (e.g. integer 24 means 24% cloudiness)
267
- data.list.first.weather # => Array[OpenWeather::Models::Weather]
268
- data.list.first.speed # => double - Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour
269
- data.list.first.deg # => int - Wind direction, degrees (meteorological)
270
- data.list.first.clouds # => int - Cloudiness, % (e.g. integer 78 means 78% cloudiness)
271
- data.list.first.rain # => double or nil - Precipitation volume, mm. Please note that only mm as units of measurement are available for this parameter
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
273
- ```
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
-
297
- ### Stations
298
-
299
- The [Stations API](https://openweathermap.org/stations) lets your manage personal weather stations and measurements.
300
-
301
- #### Register a Station
302
-
303
- To register a station, you can call the client method:
304
- ```ruby
305
- data = client.register_station(external_id: 'SF_TEST001', ...) # => OpenWeather::Models::Station
306
- data.id # => '5ed2118acca8ce0001f1aeg1'
307
- data.external_id # => 'SF_TEST001'
308
- ```
309
- Alternatively, call `register!` on an instance of `Station`:
310
- ```ruby
311
- model = OpenWeather::Models::Station.new(external_id: 'SF_TEST001', ...)
312
- model.register!
313
- model.id # => '5ed2118acca8ce0001f1aeg1'
314
- ```
315
-
316
- #### List Stations
317
-
318
- To list all stations, call the client method:
319
- ```ruby
320
- client.list_stations # => Array[OpenWeather::Models::Station]
321
- ```
322
-
323
- #### Get Station
324
-
325
- To get a station, call the client method:
326
- ```ruby
327
- client.get_station('5ed2118acca8ce0001f1aeg1') # => OpenWeather::Models::Station
328
- ```
329
-
330
- #### Update Station
331
-
332
- To update a station, call the client method:
333
- ```ruby
334
- client.update_station('5ed2118acca8ce0001f1aeg1', external_id: 'SF_TEST002') # => OpenWeather::Models::Station
335
- ```
336
- Alternatively, call `update!` on an instance of `Station`:
337
- ```ruby
338
- model = OpenWeather::Models::Station.new(external_id: 'SF_TEST001', ...)
339
- model.register!
340
- model.update!(external_id: 'SF_TEST002')
341
- model.external_id # => 'SF_TEST002'
342
- ```
343
-
344
- #### Delete Station
345
-
346
- To delete a station, call the client method:
347
- ```ruby
348
- data = client.delete_station('5ed2118acca8ce0001f1aeg1') # => nil
349
- ```
350
-
351
- #### Create Measurements
352
-
353
- To create measurements, call the client method:
354
- ```ruby
355
- client.create_measurements([
356
- {
357
- "station_id": -1,
358
- "dt": 1479817340,
359
- "temperature": 18.7,
360
- "wind_speed": 1.2,
361
- "wind_gust": 3.4,
362
- "pressure": 1021,
363
- "humidity": 87,
364
- "rain_1h": 2,
365
- "clouds": [
366
- {
367
- "condition": 'NSC'
368
- }
369
- ]
370
- }
371
- ]) # => nil
372
- ```
373
-
374
- #### Get Measurements
375
-
376
- To get measurements, call the client method with the required parameters:
377
- ```ruby
378
- client.get_measurements(
379
- station_id: '5ed21a12cca8ce0001f1aef1',
380
- type: 'd',
381
- limit: 100,
382
- from: 1469817340,
383
- to: 1591620047
384
- ) # => Array[OpenWeather::Models::Stations::Measurement]
385
- ```
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
- ```
74
+ See [docs/USAGE.md](docs/USAGE.md) for all APIs, including weather for several cities, One Call history, hourly, 5 day and 30 day forecasts, stations and geocoding.
423
75
 
424
76
  ## Configuration
425
77
 
@@ -453,7 +105,7 @@ The following settings are supported.
453
105
  The OpenWeather API returns responses in `standard`, `metric`, and `imperial` units. You can pass `units` into API requests or configure the desired units globally.
454
106
 
455
107
  ```ruby
456
- data = client.weather(id: 2643743, units: 'metric')
108
+ data = client.current_weather(id: 2643743, units: 'metric')
457
109
  data.name # => 'London'
458
110
  data.main.temp # => 12, degrees Celsius
459
111
  ```
@@ -463,7 +115,7 @@ OpenWeather.configure do |config|
463
115
  config.units = 'metric'
464
116
  end
465
117
 
466
- data = client.weather(id: 2643743)
118
+ data = client.current_weather(id: 2643743)
467
119
  data.name # => 'London'
468
120
  data.main.temp # => 12, degrees Celsius
469
121
  ```
@@ -483,12 +135,12 @@ data.main.temp_max_f # => 53.6, degrees Fahrenheit
483
135
 
484
136
  #### Converting Wind Speed
485
137
 
486
- Use `_mps` for wind speed in meters-per-second, and `_mph` for miles-per-second.
138
+ Use `_mps` for wind speed in meters per second, and `_mph` for miles per hour.
487
139
 
488
140
  ```ruby
489
141
  data.wind.speed # => 3, in meters per second, metric as requested
490
- data.main.speed_mph # => 6.71, miles per hour
491
- data.main.speed_mps # 3, meters per second
142
+ data.wind.speed_mph # => 6.71, miles per hour
143
+ data.wind.speed_mps # => 3, meters per second
492
144
  ```
493
145
 
494
146
  ### Language
@@ -496,7 +148,7 @@ data.main.speed_mps # 3, meters per second
496
148
  The OpenWeather API returns responses in English and supports many other languages. You can pass `lang` into API requests or configure the desired language globally.
497
149
 
498
150
  ```ruby
499
- data = client.weather(id: 2643743, lang: 'ru')
151
+ data = client.current_weather(id: 2643743, lang: 'ru')
500
152
  data.name # => 'Лондон'
501
153
  ```
502
154
 
@@ -505,7 +157,7 @@ OpenWeather.configure do |config|
505
157
  config.lang = 'ru'
506
158
  end
507
159
 
508
- data = client.weather(id: 2643743)
160
+ data = client.current_weather(id: 2643743)
509
161
  data.name # => 'Лондон'
510
162
  ```
511
163
 
@@ -519,7 +171,7 @@ All errors that return HTTP codes 400-600 result in either `Faraday::ResourceNot
519
171
 
520
172
  ## Contributing
521
173
 
522
- See [CONTRIBUTING](CONTRIBUTING.md).
174
+ See [CONTRIBUTING](CONTRIBUTING.md), [CHANGELOG](CHANGELOG.md), [UPGRADING](UPGRADING.md) and [RELEASING](RELEASING.md).
523
175
 
524
176
  ## Copyright and License
525
177
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concurrent/map'
3
4
  require 'faraday'
4
5
  require 'faraday/multipart'
5
6
 
@@ -9,9 +9,25 @@ module OpenWeather
9
9
 
10
10
  attr_reader :options
11
11
 
12
+ # Hashie >= 6 does not define property readers that conflict with existing methods,
13
+ # such as `min`, `max` and `zip`.
14
+ if Gem::Version.new(Hashie::VERSION) >= Gem::Version.new('6.0')
15
+ def self.property(property_name, options = {})
16
+ conflict = method_defined?(property_name) || private_method_defined?(property_name)
17
+ super
18
+ define_method(property_name) { self[property_name] } if conflict
19
+ end
20
+ end
21
+
22
+ # Parsed JSON already has String keys, so only copy a Hash that does not.
23
+ def self.string_keys(args)
24
+ return args unless args.respond_to?(:transform_keys) && !args.each_key.all?(String)
25
+
26
+ args.transform_keys(&:to_s)
27
+ end
28
+
12
29
  def initialize(args = nil, options = {})
13
- transformed_args = args.respond_to?(:transform_keys) ? args.transform_keys(&:to_s) : args
14
- super transformed_args
30
+ super(self.class.string_keys(args))
15
31
  @options = { units: OpenWeather.config.units }.merge(options || {})
16
32
  end
17
33
 
@@ -3,10 +3,15 @@
3
3
  module OpenWeather
4
4
  module Models
5
5
  class Weather < Model
6
+ # Icon URIs by icon id, shared and frozen since there are only a few icons.
7
+ ICON_URIS = Concurrent::Map.new
8
+
6
9
  property 'id' # weather condition id
7
10
  property 'main' # group of weather parameters (Rain, Snow, Extreme, etc.)
8
11
  property 'description' # weather condition within the group, in your language
9
- property 'icon_uri', from: 'icon', transform_with: ->(v) { URI.parse("http://openweathermap.org/img/wn/#{v}@2x.png") }
12
+ property 'icon_uri', from: 'icon', transform_with: lambda { |v|
13
+ ICON_URIS.compute_if_absent(v) { URI.parse("http://openweathermap.org/img/wn/#{v}@2x.png").freeze }
14
+ }
10
15
  property 'icon' # weather icon id
11
16
  end
12
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenWeather
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.1'
5
5
  end
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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-10-10 00:00:00.000000000 Z
10
+ date: 2026-11-24 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -24,6 +23,20 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: concurrent-ruby
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
27
40
  - !ruby/object:Gem::Dependency
28
41
  name: faraday
29
42
  requirement: !ruby/object:Gem::Requirement
@@ -206,7 +219,6 @@ dependencies:
206
219
  - - ">="
207
220
  - !ruby/object:Gem::Version
208
221
  version: '0'
209
- description:
210
222
  email: dblock@dblock.org
211
223
  executables: []
212
224
  extensions: []
@@ -281,7 +293,6 @@ homepage: http://github.com/dblock/open-weather-ruby-client
281
293
  licenses:
282
294
  - MIT
283
295
  metadata: {}
284
- post_install_message:
285
296
  rdoc_options: []
286
297
  require_paths:
287
298
  - lib
@@ -296,8 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
307
  - !ruby/object:Gem::Version
297
308
  version: 1.3.6
298
309
  requirements: []
299
- rubygems_version: 3.5.16
300
- signing_key:
310
+ rubygems_version: 3.6.9
301
311
  specification_version: 4
302
312
  summary: OpenWeather API Ruby client.
303
313
  test_files: []