bea_as_dataframe 0.1.2 → 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: cef8074124c70553556b8fa4673e7483c3aab7aaab3c4b81121e1a94f716e99e
4
- data.tar.gz: 0526b3ba29305027766aa9d401379702de1aa579849baf2fa0ca712ace5adf78
3
+ metadata.gz: 2d21e93351dc53aa5b39cda691e3e1e09112ab611524ef915d0aa4ad691bfe9f
4
+ data.tar.gz: 6f39aabb5ed29887c0c6ec9c70b5744f1c9ee8afd24bd2fa7bee32892c61b00e
5
5
  SHA512:
6
- metadata.gz: 0bb3e9e40d873b63d62ee1f1016e33d338ea700de82b1e7816ea5b25841b3b6ab36899108da6c3068b8ff8df5b50f4786eb6fb53cbb1d0d00ca9689a47f69ed3
7
- data.tar.gz: 15dcba51ec0a2b35e64508fd670b4a2e420c751ad0ebb62695cbd0c35d7c15d6fc23961f027170a610e8cfeb2f1d798a4e60053ea53aa156c40854f7570d5a65
6
+ metadata.gz: a2579181f64c2ec16414c32a36527ff18a1e8a0d5d154a3ec6a1dd0094ebc15283186360e0d0df985286137ec3581f61d3175e325e7e449e79adbaefdd586bdf
7
+ data.tar.gz: fb172cf88205d7269949c61495a9022b0f70c73902ae3c926ca1db8580740d5a1c4a784dbbf7d2b9990722d5eb9aac0b558d59817acc0f5673744ff487219557
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /tmp/
9
9
  Gemfile.lock
10
10
  *.gem
11
+ /vendor/bundle/
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2026-08-28
4
+
5
+ - Required Ruby version >= 3.3
6
+ - Updated polars-df dependency to 0.27.1
7
+
3
8
  ## [0.1.0] - 2024-08-20
4
9
 
5
10
  - Initial release
data/Gemfile CHANGED
@@ -6,3 +6,5 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
+ gem "minitest", "~> 5.0"
10
+ gem "webmock", "~> 3.0"
data/README.md CHANGED
@@ -4,6 +4,8 @@ Up to date remote economic data access for ruby, using Polars dataframes.
4
4
 
5
5
  This package will fetch economic and financial information from the Bureau of Economic Analysis, and return the results as a Polars Dataframe. For some operations, you may need an API key that can be fetched from the BEA website at https://apps.bea.gov/API/signup/ .
6
6
 
7
+ **Requirements:** Ruby >= 3.3.0
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -20,21 +22,51 @@ Or install it yourself as:
20
22
 
21
23
  $ gem install bea_as_dataframe
22
24
 
25
+ ## Requirements
26
+
27
+ - Ruby >= 3.3
28
+ - polars-df 0.27.1
29
+
23
30
  ## Configuration
24
31
 
25
32
  Some data sources will require the specification of an API key. These keys should be provided as part of a configuration file, e.g., config/bea_as_dataframe.rb
26
33
 
27
- Other operations (those in BeaAsDataframe::GdpPerCountySector) will require the specification of a directory for temporarily storing datafiles. See the following initialization snippet to providing that customization.
34
+ Operations in BeaAsDataframe::GdpPerCountySector require the specification of a directory for temporarily storing datafiles. See the following initialization snippet to provide that customization.
28
35
 
29
36
  ```ruby
30
- BeaAsDataframe::Client.configure do |config|
37
+ BeaAsDataframe.configure do |config|
31
38
  config.api_key = '1234567890ABCDEF'
32
39
  # OR
33
40
  config.api_key = File.read(File.join('','home', 'user', '.bea_api_key.txt'))
34
41
 
35
42
  config.tmp_dir = File.join('', 'tmp')
36
43
  end
37
- ```
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ### Fetch GDP per County and Sector Data
49
+
50
+ The `BeaAsDataframe::GdpPerCountySector#fetch` method downloads GDP data by county and sector from the BEA website and returns it as a Polars DataFrame.
51
+
52
+ ```ruby
53
+ require 'bea_as_dataframe'
54
+
55
+ # Configure the temporary directory (optional - defaults to /tmp)
56
+ BeaAsDataframe.configure do |config|
57
+ config.tmp_dir = File.join('', 'tmp')
58
+ end
59
+
60
+ # Fetch the data
61
+ fetcher = BeaAsDataframe::GdpPerCountySector.new
62
+ df = fetcher.fetch
63
+
64
+ # The DataFrame contains GDP data by county and sector
65
+ # with columns like GeoFIPS, GeoName, Description, etc.
66
+ puts df.shape
67
+ ```
68
+
69
+ The `fetch` method will raise a `BeaAsDataframe::HTTPError` if the download fails (e.g., HTTP 404 or other network errors).
38
70
 
39
71
  ## Development
40
72
 
@@ -42,9 +74,19 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
42
74
 
43
75
  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).
44
76
 
77
+ ## Testing
78
+
79
+ This project uses minitest for testing. Run the test suite with:
80
+
81
+ ```bash
82
+ bundle exec rake test
83
+ ```
84
+
85
+ All tests use mocked HTTP responses - no live BEA API calls are made during testing. This project does not use GitHub Actions for CI.
86
+
45
87
  ## Contributing
46
88
 
47
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bea_as_dataframe. 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/[USERNAME]/bea_as_dataframe/blob/main/CODE_OF_CONDUCT.md).
89
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bmck/bea_as_dataframe. 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/bmck/bea_as_dataframe/blob/main/CODE_OF_CONDUCT.md).
48
90
 
49
91
  ## License
50
92
 
@@ -52,4 +94,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
52
94
 
53
95
  ## Code of Conduct
54
96
 
55
- Everyone interacting in the BeaAsDataframe project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/bea_as_dataframe/blob/main/CODE_OF_CONDUCT.md).
97
+ Everyone interacting in the BeaAsDataframe project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bmck/bea_as_dataframe/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,4 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- task default: %i[]
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Economic and financial data from BEA'
13
13
  spec.homepage = "https://github.com/bmck/bea_as_dataframe"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/bmck/bea_as_dataframe"
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  # Uncomment to register a new dependency of your gem
31
31
  # spec.add_dependency "typhoeus-gem", "~> 0.6.9"
32
- spec.add_dependency 'polars-df'
32
+ spec.add_dependency 'polars-df', '0.27.1'
33
33
  spec.add_dependency 'httparty'
34
34
  spec.add_dependency 'rubyzip'
35
35
  end
@@ -19,7 +19,7 @@ class BeaAsDataframe
19
19
  all_areas_fn = nil
20
20
 
21
21
  resp = HTTParty.get(url)
22
- exit if resp.code == 404
22
+ raise BeaAsDataframe::HTTPError, "HTTP #{resp.code}: #{resp.message}" unless resp.success?
23
23
 
24
24
  Tempfile.create(['CAGDP9','.zip'], @tmp_dir, mode: File::RDWR, binmode: true) do |fn_a|
25
25
  fn_a.write resp.parsed_response
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class BeaAsDataframe
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -4,6 +4,9 @@ require_relative "bea_as_dataframe/version"
4
4
  require_relative "bea_as_dataframe/gdp_per_county_sector"
5
5
 
6
6
  class BeaAsDataframe
7
+ class Error < StandardError; end
8
+ class HTTPError < Error; end
9
+
7
10
  def self.configure
8
11
  yield self
9
12
  true
@@ -12,7 +15,4 @@ class BeaAsDataframe
12
15
  class << self
13
16
  attr_accessor :api_key, :tmp_dir
14
17
  end
15
-
16
- # class Error < StandardError; end
17
- # Your code goes here...
18
18
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bea_as_dataframe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill McKinnon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-21 00:00:00.000000000 Z
11
+ date: 2026-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: polars-df
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.27.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.27.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: httparty
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -89,14 +89,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 2.3.0
92
+ version: 3.3.0
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubygems_version: 3.2.33
99
+ rubygems_version: 3.5.22
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Economic and financial data from BEA