weather_gov_api 0.1.0 → 0.2.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: 9974cbb0b1c129fdd1ff2721046d7085a82fa42b0c734777a79e00177111d7ac
4
- data.tar.gz: 570b527a1d54efac9e59e499e6883c426430da3d3a89eff2b24f807422f0ad2c
3
+ metadata.gz: ef2d712f1eb48bd665d2026b525fa1350b6df2074d708404ab909c6e7cc07157
4
+ data.tar.gz: 85c59f8fc33f121b29ef6a8f0470afd9ac80e794f1502aa97ab317d8e702a6a2
5
5
  SHA512:
6
- metadata.gz: 0cf8b11d5fd70eef8601f45e47e560ca603098e313e072e59a83a3089d4e3378cc8a3a3c7938fec91866e0b32a56eda516e4c4fe6758a932c63f6182644122d1
7
- data.tar.gz: ae7ecaf2cf5feab72bb5a94846f78957405e3009c4490e22957d1d54edf9290f1a984557f3e7aa969ed6782603a68cb462cf6b150b4e92388b4d748bb5c6dcfc
6
+ metadata.gz: e0bc42ef1eb84d7071f11c5125fe97fa13b140a060a312a464f7fdeeb79f40bc0a094804d73a73182698a03cbe5f7b1717c2981325854875ec8a0bbcec1d3df7
7
+ data.tar.gz: 466cf682be9fa48f9cf4c947472a2cf2a194769632ba083bdbd3d458344df62d0a385a19932d17c74aa1a6fa6665bca584c71fac75603090717060a59e4bdd5e
data/CHANGELOG.md CHANGED
@@ -1,8 +1,17 @@
1
- ## [0.1.0] - 2025-02-17
1
+ # Changelog
2
+
3
+ ## [0.2.0] - 2025-02-19
4
+
5
+ ### Added
6
+ - `observation_stations` method to fetch nearby weather stations
7
+ - `current_weather` method to fetch latest weather data from the closest station
8
+
9
+ ## [0.1.0] - Initial Release
2
10
 
3
11
  ### Added
12
+ - Basic client implementation
4
13
  - Basic client implementation for weather.gov API
5
- - `points` endpoint support for fetching weather data by coordinates
14
+ - `points` method for fetching weather data by coordinates
6
15
  - Error handling for:
7
16
  - Non-US coordinates
8
17
  - Network timeouts
data/README.md CHANGED
@@ -28,6 +28,17 @@ puts response.body
28
28
  ```ruby
29
29
  client = WeatherGovApi::Client.new(user_agent: 'MyApp/1.0')
30
30
  ```
31
+ ## Available Methods
32
+
33
+ ### points(latitude:, longitude:)
34
+ Fetches basic point data for the given coordinates.
35
+
36
+ ### observation_stations(latitude:, longitude:)
37
+ Fetches a list of nearby weather observation stations.
38
+
39
+ ### current_weather(latitude:, longitude:)
40
+ Fetches the current weather conditions from the closest observation station.
41
+
31
42
 
32
43
  ## Development
33
44
 
@@ -18,6 +18,29 @@ module WeatherGovApi
18
18
  raise Error, "API request failed: #{e.message}"
19
19
  end
20
20
 
21
+ def observation_stations(latitude:, longitude:)
22
+ points_response = points(latitude: latitude, longitude: longitude)
23
+ stations_url = points_response.data.dig("properties", "observationStations")
24
+ raise Error, "No observation stations URL found in points response" unless stations_url
25
+
26
+ response = connection.get(stations_url.sub(BASE_URL, ""))
27
+ Response.new(response)
28
+ rescue Faraday::Error => e
29
+ raise Error, "API request failed: #{e.message}"
30
+ end
31
+
32
+ def current_weather(latitude:, longitude:)
33
+ stations_response = observation_stations(latitude: latitude, longitude: longitude)
34
+ station = stations_response.data.dig("features", 0)
35
+ raise Error, "No observation stations found" unless station
36
+
37
+ station_id = station.dig("properties", "stationIdentifier")
38
+ response = connection.get("/stations/#{station_id}/observations/latest")
39
+ Response.new(response)
40
+ rescue Faraday::Error => e
41
+ raise Error, "API request failed: #{e.message}"
42
+ end
43
+
21
44
  private
22
45
 
23
46
  def validate_coordinates(latitude, longitude)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WeatherGovApi
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weather_gov_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JeffreyMPrice
@@ -87,6 +87,7 @@ files:
87
87
  - lib/weather_gov_api/response.rb
88
88
  - lib/weather_gov_api/version.rb
89
89
  - sig/weather_gov_api.rbs
90
+ - weather_gov_api-0.1.0.gem
90
91
  homepage: https://github.com/JeffreyMPrice/weather_gov_api
91
92
  licenses:
92
93
  - MIT