weather_gov_api 0.1.0 → 0.2.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: 9974cbb0b1c129fdd1ff2721046d7085a82fa42b0c734777a79e00177111d7ac
4
- data.tar.gz: 570b527a1d54efac9e59e499e6883c426430da3d3a89eff2b24f807422f0ad2c
3
+ metadata.gz: 9a3357a492f9e0fefc3414c9f9e8cd54d4fbf1bd24caff3741021af46948b9a6
4
+ data.tar.gz: 9f5f503e4db23945aa94eb18dfac9d24f1bb5fbf11d72f2040201c5db7cb004e
5
5
  SHA512:
6
- metadata.gz: 0cf8b11d5fd70eef8601f45e47e560ca603098e313e072e59a83a3089d4e3378cc8a3a3c7938fec91866e0b32a56eda516e4c4fe6758a932c63f6182644122d1
7
- data.tar.gz: ae7ecaf2cf5feab72bb5a94846f78957405e3009c4490e22957d1d54edf9290f1a984557f3e7aa969ed6782603a68cb462cf6b150b4e92388b4d748bb5c6dcfc
6
+ metadata.gz: fcbe8dc202094f73f1693806a6356644b7e68b37a5c5f378b3e129377bae89d883dbe5905768db8124f74c15a83ea4d4d55b50569dc508fa731f9d4ab246b0ce
7
+ data.tar.gz: d6f8cbbb7ccb653fb09d0e05a191b306ed69c650346f05a5b7c1a5baa0000a0ac29c7afa184b10918430f1e1b5f625e9cc6d05c63c4d4427b7142df07c4c2937
data/.rubocop.yml CHANGED
@@ -1,24 +1,30 @@
1
- AllCops:
2
- TargetRubyVersion: 3.1
3
-
4
- Style/StringLiterals:
5
- EnforcedStyle: double_quotes
6
-
7
- Style/StringLiteralsInInterpolation:
8
- EnforcedStyle: double_quotes
9
-
10
- Layout/EndOfLine:
11
- EnforcedStyle: lf
12
-
13
- # Disable documentation requirements for specs
14
- Style/Documentation:
15
- Enabled: true
16
- Exclude:
17
- - "spec/**/*"
18
-
19
- # Allow longer blocks in specs
20
- Metrics/BlockLength:
21
- Enabled: true
22
- Exclude:
23
- - "spec/**/*"
24
- - "*.gemspec"
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require:
4
+ - rubocop-rspec
5
+
6
+ AllCops:
7
+ NewCops: enable
8
+ TargetRubyVersion: 3.1
9
+
10
+ Style/StringLiterals:
11
+ EnforcedStyle: double_quotes
12
+
13
+ Style/StringLiteralsInInterpolation:
14
+ EnforcedStyle: double_quotes
15
+
16
+ Layout/EndOfLine:
17
+ EnforcedStyle: lf
18
+
19
+ # Disable documentation requirements for specs
20
+ Style/Documentation:
21
+ Enabled: true
22
+ Exclude:
23
+ - "spec/**/*"
24
+
25
+ # Allow longer blocks in specs
26
+ Metrics/BlockLength:
27
+ Enabled: true
28
+ Exclude:
29
+ - "spec/**/*"
30
+ - "*.gemspec"
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,39 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-02-22 02:13:57 UTC using RuboCop version 1.72.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ # Configuration parameters: EnforcedStyle, AllowedGems, Include.
11
+ # SupportedStyles: Gemfile, gems.rb, gemspec
12
+ # Include: **/*.gemspec, **/Gemfile, **/gems.rb
13
+ Gemspec/DevelopmentDependencies:
14
+ Exclude:
15
+ - 'weather_gov_api.gemspec'
16
+
17
+ # Offense count: 2
18
+ # Configuration parameters: EnforcedStyle.
19
+ # SupportedStyles: native, lf, crlf
20
+ Layout/EndOfLine:
21
+ Exclude:
22
+ - 'spec/weather_gov_api_spec.rb'
23
+ - 'weather_gov_api.gemspec'
24
+
25
+ # Offense count: 1
26
+ # Configuration parameters: Prefixes, AllowedPatterns.
27
+ # Prefixes: when, with, without
28
+ RSpec/ContextWording:
29
+ Exclude:
30
+ - 'spec/weather_gov_api/client_spec.rb'
31
+
32
+ # Offense count: 10
33
+ # Configuration parameters: CountAsOne.
34
+ RSpec/ExampleLength:
35
+ Max: 22
36
+
37
+ # Offense count: 5
38
+ RSpec/MultipleExpectations:
39
+ Max: 4
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,17 +28,58 @@ 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
 
34
45
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
35
46
 
47
+ ### Building and Releasing
48
+
49
+ 1. Update the version number in `version.rb`
50
+ 2. Build the gem:
51
+ ```bash
52
+ gem build weather_gov_api.gemspec
53
+ ```
54
+ 3. Test the built gem locally:
55
+ ```bash
56
+ gem install ./weather_gov_api-X.X.X.gem
57
+ ```
58
+ 4. Release to RubyGems:
59
+ ```bash
60
+ gem push weather_gov_api-X.X.X.gem
61
+ ```
62
+
36
63
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
64
 
38
65
  ## Contributing
39
66
 
40
67
  Bug reports and pull requests are welcome on GitHub at https://github.com/JeffreyMPrice/weather_gov_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/JeffreyMPrice/weather_gov_api/blob/main/CODE_OF_CONDUCT.md).
41
68
 
69
+ ## TODO
70
+
71
+ - [ ] Implement forecast retrieval functionality
72
+ - [ ] Add validation to limit latitude and longitude to 4 decimal places (weather.gov API requirement)
73
+ - [ ] Improve error handling to properly surface weather.gov API error messages
74
+ - [ ] Implement rate limiting strategies:
75
+ - [ ] Local rate limiting
76
+ - [ ] Distributed rate limiting (Redis/DB-based)
77
+ - [ ] Add caching support for API responses
78
+ - [ ] Automate CHANGELOG.md updates during release process
79
+ - [ ] Configure Git repository settings:
80
+ - [ ] Disable direct commits to main branch
81
+ - [ ] Require passing CI builds for branch merges
82
+
42
83
  ## License
43
84
 
44
85
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JeffreyMPrice
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-19 00:00:00.000000000 Z
11
+ date: 2025-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -77,6 +77,7 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - ".rspec"
79
79
  - ".rubocop.yml"
80
+ - ".rubocop_todo.yml"
80
81
  - CHANGELOG.md
81
82
  - CODE_OF_CONDUCT.md
82
83
  - LICENSE.txt
@@ -95,6 +96,7 @@ metadata:
95
96
  homepage_uri: https://github.com/JeffreyMPrice/weather_gov_api
96
97
  source_code_uri: https://github.com/JeffreyMPrice/weather_gov_api
97
98
  changelog_uri: https://github.com/JeffreyMPrice/weather_gov_api/blob/main/CHANGELOG.md
99
+ rubygems_mfa_required: 'true'
98
100
  post_install_message:
99
101
  rdoc_options: []
100
102
  require_paths: