philly_frb_as_dataframe 0.1.1 → 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: 588a180b3a8a7f05794f14a446763788ece7624adc18f0850f86c7b40ea3a930
4
- data.tar.gz: 3aee0cb7dce6081ad007cc676f973084156bc465a544f3c5b7f96b46efe08805
3
+ metadata.gz: 0a4b46edc99f3ac1d3442b4fc77d77197d926f469a33efdf2c5801c5f04e9912
4
+ data.tar.gz: 52cb38a65d0f5f81d5e2bcd5d18fc45db7a5647f129fee6e39e2f1d48f324fe0
5
5
  SHA512:
6
- metadata.gz: 7a59ce1d48ff76b1db9bd64e7f6a2f855de0a305f90bad624d5832564944e0f4c4b8386fe6e393e5d7337f16b6aaf27e9dd37f9c3ac1b90228356f47bd08817b
7
- data.tar.gz: b29cdbcec23228600dfd5c9e8177fa269437b0f4424972a0dc9a7c5ebda6df0ce4df2bf0e603f7801ec2f2c6df5119d99eb33ba1d21b285f3d8849ce1a2e5a9f
6
+ metadata.gz: 27b62834b929b20a8bdc7d62f6cac49ed5251405b301484dd87721c87643c7f61437dd4b7baec435ec131f84d303ecd244514a817e7c5e97d83731c36dc4a7d9
7
+ data.tar.gz: ed396f66125918c75171010292457faf29bd7d251b251047a61c11065319af185ab629cb53fb1d6bd52f9354eddc151a94014ea390ad86c04c462a3947156d51
data/.DS_Store ADDED
Binary file
data/.gitignore CHANGED
@@ -8,5 +8,4 @@
8
8
  /tmp/
9
9
  *.gem
10
10
  Gemfile.lock
11
- .ruby-gemset
12
- .ruby-version
11
+ lib/.DS_Store
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ phillyfrb
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2026-08-28
4
+
5
+ - Updated required_ruby_version to >= 3.3
6
+ - Updated polars-df dependency to 0.27.1
7
+
3
8
  ## [0.1.0] - 2024-08-05
4
9
 
5
10
  - Initial release
data/Gemfile CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ ruby "3.3.6"
6
+
5
7
  # Specify your gem's dependencies in philly_frb_as_dataframe.gemspec
6
8
  gemspec
7
9
 
8
10
  gem "rake", "~> 13.0"
11
+
12
+ gem "write_xlsx", "~> 1.15", group: :development
data/README.md CHANGED
@@ -4,6 +4,10 @@ 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 Federal Reserve Bank of Philadelphia, and return the results as a Polars dataframe. For details regarding the data available from the Philadelphia FRB, see https://www.philadelphiafed.org/surveys-and-data . This gem exposes the Partisan Conflict Index (see https://www.philadelphiafed.org/surveys-and-data/macroeconomic-data/partisan-conflict-index) and the Survey of Professional Forecasters (see https://www.philadelphiafed.org/-/media/frbp/assets/surveys-and-data/survey-of-professional-forecasters/spf-documentation.pdf).
6
6
 
7
+ ## Requirements
8
+
9
+ - Ruby >= 3.3
10
+ - polars-df 0.27.1
7
11
 
8
12
  ## Installation
9
13
 
@@ -23,8 +27,8 @@ Or install it yourself as:
23
27
 
24
28
  ## Usage
25
29
 
26
- ```{ruby}
27
- 3.1.2 :001 > PhillyFrbAsDataframe::PartisanConflict.new.fetch
30
+ ```ruby
31
+ 3.3.6 :001 > PhillyFrbAsDataframe::PartisanConflict.new.fetch
28
32
  =>
29
33
  shape: (522, 2)
30
34
  ┌────────────┬───────────────────┐
@@ -44,7 +48,7 @@ shape: (522, 2)
44
48
  │ 2024-05-01 ┆ 113.41 │
45
49
  │ 2024-06-01 ┆ 103.95 │
46
50
  └────────────┴───────────────────┘
47
- 3.1.2 :002 > PhillyFrbAsDataframe::PartisanConflict.new.fetch(start: Date.new(2000,01,01), fin: Date.new(2020,12,31))
51
+ 3.3.6 :002 > PhillyFrbAsDataframe::PartisanConflict.new.fetch(start: Date.new(2000,01,01), fin: Date.new(2020,12,31))
48
52
  =>
49
53
  shape: (252, 2)
50
54
  ┌────────────┬───────────────────┐
@@ -68,10 +72,10 @@ shape: (252, 2)
68
72
 
69
73
  and
70
74
 
71
- ```{ruby}
72
- 3.1.2 :001 > a = PhillyFrbAsDataframe::SurveyProfForecasters.new
75
+ ```ruby
76
+ 3.3.6 :001 > a = PhillyFrbAsDataframe::SurveyProfForecasters.new
73
77
  => #<PhillyFrbAsDataframe::SurveyProfForecasters:0x0000000106e18640>
74
- 3.1.2 :002 > a.fetch
78
+ 3.3.6 :002 > a.fetch
75
79
  =>
76
80
  shape: (223, 308)
77
81
  ┌────────────┬────────────┬────────────┬────────────┬───┬──────────────────┬──────────────────┬──────────────────┬──────────────────┐
@@ -91,11 +95,11 @@ shape: (223, 308)
91
95
  │ 2024-01-01 ┆ 27938.8105 ┆ 28234.0069 ┆ 28497.6187 ┆ … ┆ 3.1199 ┆ 2.983 ┆ 2.692 ┆ 2.4174 │
92
96
  │ 2024-04-01 ┆ 28284.4998 ┆ 28625.8758 ┆ 28944.1106 ┆ … ┆ 2.5017 ┆ 2.6019 ┆ 2.4432 ┆ 2.1863 │
93
97
  └────────────┴────────────┴────────────┴────────────┴───┴──────────────────┴──────────────────┴──────────────────┴──────────────────┘
94
- 3.1.2 :003 > Polars::Config.set_tbl_rows(-1)
98
+ 3.3.6 :003 > Polars::Config.set_tbl_rows(-1)
95
99
  => Polars::Config
96
- 3.1.2 :004 > Polars::Config.set_tbl_cols(-1)
100
+ 3.3.6 :004 > Polars::Config.set_tbl_cols(-1)
97
101
  => Polars::Config
98
- 3.1.2 :005 > a.fetch
102
+ 3.3.6 :005 > a.fetch
99
103
  =>
100
104
  shape: (223, 308)
101
105
  ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
@@ -113,11 +117,11 @@ shape: (223, 308)
113
117
 
114
118
  (...snip...)
115
119
 
116
- 3.1.2 :006 > b = a.fetch
120
+ 3.3.6 :006 > b = a.fetch
117
121
  =>
118
122
  shape: (223, 308)
119
123
  ...
120
- 3.1.2 :007 > b.columns
124
+ 3.3.6 :007 > b.columns
121
125
  =>
122
126
  ["Timestamps",
123
127
  "NGDP1",
@@ -143,7 +147,7 @@ shape: (223, 308)
143
147
  "RR3_TBILL_CPCE_3",
144
148
  "RR3_TBILL_CPCE_4",
145
149
  "RR3_TBILL_CPCE_5"]
146
- 3.1.2 :008 > b['Timestamps']
150
+ 3.3.6 :008 > b['Timestamps']
147
151
  =>
148
152
  shape: (223,)
149
153
  Series: 'Timestamps' [date]
@@ -167,12 +171,41 @@ Series: 'Timestamps' [date]
167
171
  ]
168
172
  ```
169
173
 
174
+ ## Testing
175
+
176
+ Tests use minitest with mocked XLSX files and WebMock for network requests. Run tests with:
177
+
178
+ ```bash
179
+ bundle exec rake test
180
+ ```
181
+
182
+ No GitHub Actions or CI workflows are configured for this project.
183
+
170
184
  ## Development
171
185
 
172
186
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
173
187
 
174
188
  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).
175
189
 
190
+ ## Testing
191
+
192
+ This gem includes a comprehensive test suite using Minitest. Tests use webmock to stub HTTP requests, ensuring no live network calls are made during testing.
193
+
194
+ To run the test suite:
195
+
196
+ ```bash
197
+ bundle install
198
+ bundle exec rake test
199
+ ```
200
+
201
+ The test suite covers:
202
+ - `PartisanConflict#fetch` - fetching and parsing partisan conflict index data
203
+ - `SurveyProfForecasters#fetch` - fetching and parsing survey of professional forecasters data
204
+ - Date filtering with `start` and `fin` parameters
205
+ - DataFrame structure and column validation
206
+
207
+ All HTTP requests are mocked using webmock with xlsx fixtures stored in `test/fixtures/`.
208
+
176
209
  ## Contributing
177
210
 
178
211
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/philly_frb_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]/philly_frb_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
@@ -22,8 +22,8 @@ module PhillyFrbAsDataframe
22
22
  df = {}; (0..(keys.length-1)).to_a.each{|i| df[keys[i]] = vals[i]}
23
23
 
24
24
  df = Polars::DataFrame.new(df)
25
- df = df.filter(Polars.col('Timestamps_') <= fin.to_date) unless start.nil?
26
- df = df.filter(Polars.col('Timestamps_') >= start.to_date) unless fin.nil?
25
+ df = df.filter(Polars.col('Timestamps_') <= fin.to_date) unless fin.nil?
26
+ df = df.filter(Polars.col('Timestamps_') >= start.to_date) unless start.nil?
27
27
  s = Polars::Series.new('Timestamps', df['Timestamps_'].to_a)
28
28
  df = df.insert_column(0,s).drop(['Month', 'Year', 'Timestamps_'])
29
29
 
@@ -25,8 +25,8 @@ module PhillyFrbAsDataframe
25
25
  tmp_df = {}; (0..(keys.length-1)).to_a.each{|i| tmp_df[keys[i]] = vals[i]}
26
26
 
27
27
  tmp_df = Polars::DataFrame.new(tmp_df).drop(['QUARTER', 'YEAR'])
28
- tmp_df = tmp_df.filter(Polars.col('Timestamps_') <= fin.to_date) unless start.nil?
29
- tmp_df = tmp_df.filter(Polars.col('Timestamps_') >= start.to_date) unless fin.nil?
28
+ tmp_df = tmp_df.filter(Polars.col('Timestamps_') <= fin.to_date) unless fin.nil?
29
+ tmp_df = tmp_df.filter(Polars.col('Timestamps_') >= start.to_date) unless start.nil?
30
30
 
31
31
  if h == hsh.first
32
32
  df = tmp_df
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhillyFrbAsDataframe
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = "Alternative economic and financial data from the Philadelphia FRB"
11
11
  spec.homepage = "https://github.com/bmck/philly_frb_as_dataframe"
12
12
  spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.3")
14
14
 
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
@@ -28,7 +28,10 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  # Uncomment to register a new dependency of your gem
30
30
  # spec.add_dependency "typhoeus-gem", "~> 0.6.9"
31
- spec.add_dependency 'polars-df'
31
+ spec.add_dependency 'polars-df', '0.27.1'
32
32
  spec.add_dependency 'httparty'
33
33
  spec.add_dependency 'roo'
34
+
35
+ spec.add_development_dependency 'minitest', '~> 5.0'
36
+ spec.add_development_dependency 'webmock', '~> 3.0'
34
37
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philly_frb_as_dataframe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
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-14 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
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
55
83
  description: Alternative economic and financial data from the Philadelphia FRB
56
84
  email:
57
85
  - bill.mckinnon@bmck.org
@@ -59,7 +87,10 @@ executables: []
59
87
  extensions: []
60
88
  extra_rdoc_files: []
61
89
  files:
90
+ - ".DS_Store"
62
91
  - ".gitignore"
92
+ - ".ruby-gemset"
93
+ - ".ruby-version"
63
94
  - ".travis.yml"
64
95
  - CHANGELOG.md
65
96
  - CODE_OF_CONDUCT.md
@@ -89,14 +120,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
120
  requirements:
90
121
  - - ">="
91
122
  - !ruby/object:Gem::Version
92
- version: 2.3.0
123
+ version: '3.3'
93
124
  required_rubygems_version: !ruby/object:Gem::Requirement
94
125
  requirements:
95
126
  - - ">="
96
127
  - !ruby/object:Gem::Version
97
128
  version: '0'
98
129
  requirements: []
99
- rubygems_version: 3.3.7
130
+ rubygems_version: 3.5.22
100
131
  signing_key:
101
132
  specification_version: 4
102
133
  summary: Alternative economic and financial data from the Philadelphia FRB