rails-excel-reporter 0.1.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 +7 -0
- data/CLAUDE.md +94 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +306 -0
- data/README.md +506 -0
- data/lib/generators/report/report_generator.rb +32 -0
- data/lib/generators/report/templates/report.rb.erb +43 -0
- data/lib/rails_excel_reporter/base.rb +210 -0
- data/lib/rails_excel_reporter/configuration.rb +40 -0
- data/lib/rails_excel_reporter/controller_helpers.rb +34 -0
- data/lib/rails_excel_reporter/railtie.rb +35 -0
- data/lib/rails_excel_reporter/streaming.rb +81 -0
- data/lib/rails_excel_reporter/styling.rb +87 -0
- data/lib/rails_excel_reporter/version.rb +3 -0
- data/lib/rails_excel_reporter.rb +19 -0
- data/rails_excel_reporter.gemspec +36 -0
- data/spec/rails_excel_reporter/base_spec.rb +190 -0
- data/spec/rails_excel_reporter/configuration_spec.rb +75 -0
- data/spec/rails_excel_reporter/controller_helpers_spec.rb +121 -0
- data/spec/rails_excel_reporter/streaming_spec.rb +139 -0
- data/spec/rails_excel_reporter/styling_spec.rb +124 -0
- data/spec/rails_excel_reporter_spec.rb +25 -0
- data/spec/spec_helper.rb +30 -0
- metadata +211 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cab2208fe66d4d978d2ee278824b4f763269c13e434d61b156499c76003886d1
|
4
|
+
data.tar.gz: 7f5d12a44647eed1036c570cf5f0a4752e64382ef8b222fac512205f5258da7c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bbfc84c48105979757adaff62eed4924e8520bfece1e22524f5e4c78e3bdb32a9fbd096902784482debb23a1aeef3021f85233b9cf9af5347484e516b1a63571
|
7
|
+
data.tar.gz: 54c81b98c90949ea5c5fc791e9693ecf35942cf8c4e1d37f88961d8ce263e70a18372d7b0f1967c1183ccf1268d1ba63b49f187012ca603458ff37a4fa02e4f9
|
data/CLAUDE.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# CLAUDE.md
|
2
|
+
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
4
|
+
|
5
|
+
## Project Overview
|
6
|
+
|
7
|
+
This is a Ruby gem called `rails-excel-reporter` that provides a simple DSL for generating Excel reports (.xlsx format) in Ruby on Rails applications. The gem uses the `caxlsx` library (version 4.x) for Excel generation and includes features like streaming for large datasets, custom styling, callbacks, and Rails controller helpers.
|
8
|
+
|
9
|
+
## Development Commands
|
10
|
+
|
11
|
+
### Testing
|
12
|
+
```bash
|
13
|
+
# Run all tests
|
14
|
+
bundle exec rspec
|
15
|
+
|
16
|
+
# Run specific test file
|
17
|
+
bundle exec rspec spec/rails_excel_reporter/base_spec.rb
|
18
|
+
|
19
|
+
# Run tests with documentation format
|
20
|
+
bundle exec rspec --format documentation
|
21
|
+
```
|
22
|
+
|
23
|
+
### Code Quality
|
24
|
+
```bash
|
25
|
+
# Run linter
|
26
|
+
bundle exec rubocop
|
27
|
+
|
28
|
+
# Generate documentation
|
29
|
+
bundle exec yard
|
30
|
+
```
|
31
|
+
|
32
|
+
### Build and Install
|
33
|
+
```bash
|
34
|
+
# Build the gem
|
35
|
+
gem build rails_excel_reporter.gemspec
|
36
|
+
|
37
|
+
# Install locally
|
38
|
+
gem install rails-excel-reporter-0.1.0.gem
|
39
|
+
```
|
40
|
+
|
41
|
+
## Architecture
|
42
|
+
|
43
|
+
### Core Components
|
44
|
+
|
45
|
+
1. **`RailsExcelReporter::Base`** (`lib/rails_excel_reporter/base.rb`) - Main class that report classes inherit from. Contains the core DSL and rendering logic.
|
46
|
+
|
47
|
+
2. **Modules:**
|
48
|
+
- **`Styling`** (`lib/rails_excel_reporter/styling.rb`) - Handles custom styling for headers, columns, and cells
|
49
|
+
- **`Streaming`** (`lib/rails_excel_reporter/streaming.rb`) - Manages streaming for large datasets with configurable thresholds
|
50
|
+
- **`ControllerHelpers`** (`lib/rails_excel_reporter/controller_helpers.rb`) - Provides Rails controller methods for sending Excel responses
|
51
|
+
|
52
|
+
3. **`Configuration`** (`lib/rails_excel_reporter/configuration.rb`) - Global configuration management with defaults for styling, streaming thresholds, and file paths
|
53
|
+
|
54
|
+
4. **`ReportGenerator`** (`lib/generators/report/report_generator.rb`) - Rails generator for scaffolding new report classes
|
55
|
+
|
56
|
+
### Key Patterns
|
57
|
+
|
58
|
+
- **DSL Design**: Uses `attributes` class method to define report columns with support for custom headers and methods
|
59
|
+
- **Streaming**: Automatically streams large datasets (>1000 records by default) using `find_each` for ActiveRecord or manual iteration
|
60
|
+
- **Styling**: Supports custom styling through the `style` class method with conversion to caxlsx format
|
61
|
+
- **Callbacks**: Provides `before_render`, `after_render`, `before_row`, and `after_row` hooks
|
62
|
+
- **Flexible Data Sources**: Works with ActiveRecord collections, arrays, and any enumerable
|
63
|
+
|
64
|
+
### Report Class Structure
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
class MyReport < RailsExcelReporter::Base
|
68
|
+
attributes :column1, :column2, { name: :column3, header: "Custom Header" }
|
69
|
+
|
70
|
+
style :header, { bg_color: "4472C4", fg_color: "FFFFFF", bold: true }
|
71
|
+
style :column1, { alignment: { horizontal: :center } }
|
72
|
+
|
73
|
+
# Custom attribute methods override default behavior
|
74
|
+
def column1
|
75
|
+
# Access current record via `object`
|
76
|
+
object.column1.upcase
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
### Error Handling
|
82
|
+
|
83
|
+
The gem defines specific error classes:
|
84
|
+
- `RailsExcelReporter::Error` - Base error class
|
85
|
+
- `AttributeNotFoundError` - When an attribute doesn't exist on the data source
|
86
|
+
- `InvalidConfigurationError` - For configuration issues
|
87
|
+
|
88
|
+
## File Structure
|
89
|
+
|
90
|
+
- `lib/rails_excel_reporter.rb` - Main entry point and module definition
|
91
|
+
- `lib/rails_excel_reporter/` - Core gem modules
|
92
|
+
- `lib/generators/` - Rails generator for creating report classes
|
93
|
+
- `spec/` - RSpec test suite
|
94
|
+
- `rails_excel_reporter.gemspec` - Gem specification
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,306 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rails-excel-reporter (0.1.0)
|
5
|
+
activesupport (~> 8.0)
|
6
|
+
caxlsx (~> 4.0)
|
7
|
+
rails (~> 8.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actioncable (8.0.2)
|
13
|
+
actionpack (= 8.0.2)
|
14
|
+
activesupport (= 8.0.2)
|
15
|
+
nio4r (~> 2.0)
|
16
|
+
websocket-driver (>= 0.6.1)
|
17
|
+
zeitwerk (~> 2.6)
|
18
|
+
actionmailbox (8.0.2)
|
19
|
+
actionpack (= 8.0.2)
|
20
|
+
activejob (= 8.0.2)
|
21
|
+
activerecord (= 8.0.2)
|
22
|
+
activestorage (= 8.0.2)
|
23
|
+
activesupport (= 8.0.2)
|
24
|
+
mail (>= 2.8.0)
|
25
|
+
actionmailer (8.0.2)
|
26
|
+
actionpack (= 8.0.2)
|
27
|
+
actionview (= 8.0.2)
|
28
|
+
activejob (= 8.0.2)
|
29
|
+
activesupport (= 8.0.2)
|
30
|
+
mail (>= 2.8.0)
|
31
|
+
rails-dom-testing (~> 2.2)
|
32
|
+
actionpack (8.0.2)
|
33
|
+
actionview (= 8.0.2)
|
34
|
+
activesupport (= 8.0.2)
|
35
|
+
nokogiri (>= 1.8.5)
|
36
|
+
rack (>= 2.2.4)
|
37
|
+
rack-session (>= 1.0.1)
|
38
|
+
rack-test (>= 0.6.3)
|
39
|
+
rails-dom-testing (~> 2.2)
|
40
|
+
rails-html-sanitizer (~> 1.6)
|
41
|
+
useragent (~> 0.16)
|
42
|
+
actiontext (8.0.2)
|
43
|
+
actionpack (= 8.0.2)
|
44
|
+
activerecord (= 8.0.2)
|
45
|
+
activestorage (= 8.0.2)
|
46
|
+
activesupport (= 8.0.2)
|
47
|
+
globalid (>= 0.6.0)
|
48
|
+
nokogiri (>= 1.8.5)
|
49
|
+
actionview (8.0.2)
|
50
|
+
activesupport (= 8.0.2)
|
51
|
+
builder (~> 3.1)
|
52
|
+
erubi (~> 1.11)
|
53
|
+
rails-dom-testing (~> 2.2)
|
54
|
+
rails-html-sanitizer (~> 1.6)
|
55
|
+
activejob (8.0.2)
|
56
|
+
activesupport (= 8.0.2)
|
57
|
+
globalid (>= 0.3.6)
|
58
|
+
activemodel (8.0.2)
|
59
|
+
activesupport (= 8.0.2)
|
60
|
+
activerecord (8.0.2)
|
61
|
+
activemodel (= 8.0.2)
|
62
|
+
activesupport (= 8.0.2)
|
63
|
+
timeout (>= 0.4.0)
|
64
|
+
activestorage (8.0.2)
|
65
|
+
actionpack (= 8.0.2)
|
66
|
+
activejob (= 8.0.2)
|
67
|
+
activerecord (= 8.0.2)
|
68
|
+
activesupport (= 8.0.2)
|
69
|
+
marcel (~> 1.0)
|
70
|
+
activesupport (8.0.2)
|
71
|
+
base64
|
72
|
+
benchmark (>= 0.3)
|
73
|
+
bigdecimal
|
74
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
75
|
+
connection_pool (>= 2.2.5)
|
76
|
+
drb
|
77
|
+
i18n (>= 1.6, < 2)
|
78
|
+
logger (>= 1.4.2)
|
79
|
+
minitest (>= 5.1)
|
80
|
+
securerandom (>= 0.3)
|
81
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
82
|
+
uri (>= 0.13.1)
|
83
|
+
ast (2.4.3)
|
84
|
+
base64 (0.3.0)
|
85
|
+
benchmark (0.4.1)
|
86
|
+
bigdecimal (3.2.2)
|
87
|
+
builder (3.3.0)
|
88
|
+
caxlsx (4.2.0)
|
89
|
+
htmlentities (~> 4.3, >= 4.3.4)
|
90
|
+
marcel (~> 1.0)
|
91
|
+
nokogiri (~> 1.10, >= 1.10.4)
|
92
|
+
rubyzip (>= 1.3.0, < 3)
|
93
|
+
coderay (1.1.3)
|
94
|
+
concurrent-ruby (1.3.5)
|
95
|
+
connection_pool (2.5.3)
|
96
|
+
crass (1.0.6)
|
97
|
+
date (3.4.1)
|
98
|
+
diff-lcs (1.6.2)
|
99
|
+
docile (1.4.1)
|
100
|
+
drb (2.2.3)
|
101
|
+
erb (5.0.1)
|
102
|
+
erubi (1.13.1)
|
103
|
+
globalid (1.2.1)
|
104
|
+
activesupport (>= 6.1)
|
105
|
+
htmlentities (4.3.4)
|
106
|
+
i18n (1.14.7)
|
107
|
+
concurrent-ruby (~> 1.0)
|
108
|
+
io-console (0.8.0)
|
109
|
+
irb (1.15.2)
|
110
|
+
pp (>= 0.6.0)
|
111
|
+
rdoc (>= 4.0.0)
|
112
|
+
reline (>= 0.4.2)
|
113
|
+
json (2.12.2)
|
114
|
+
language_server-protocol (3.17.0.5)
|
115
|
+
lint_roller (1.1.0)
|
116
|
+
logger (1.7.0)
|
117
|
+
loofah (2.24.1)
|
118
|
+
crass (~> 1.0.2)
|
119
|
+
nokogiri (>= 1.12.0)
|
120
|
+
mail (2.8.1)
|
121
|
+
mini_mime (>= 0.1.1)
|
122
|
+
net-imap
|
123
|
+
net-pop
|
124
|
+
net-smtp
|
125
|
+
marcel (1.0.4)
|
126
|
+
method_source (1.1.0)
|
127
|
+
mini_mime (1.1.5)
|
128
|
+
minitest (5.25.5)
|
129
|
+
net-imap (0.5.9)
|
130
|
+
date
|
131
|
+
net-protocol
|
132
|
+
net-pop (0.1.2)
|
133
|
+
net-protocol
|
134
|
+
net-protocol (0.2.2)
|
135
|
+
timeout
|
136
|
+
net-smtp (0.5.1)
|
137
|
+
net-protocol
|
138
|
+
nio4r (2.7.4)
|
139
|
+
nokogiri (1.18.8-aarch64-linux-gnu)
|
140
|
+
racc (~> 1.4)
|
141
|
+
nokogiri (1.18.8-aarch64-linux-musl)
|
142
|
+
racc (~> 1.4)
|
143
|
+
nokogiri (1.18.8-arm-linux-gnu)
|
144
|
+
racc (~> 1.4)
|
145
|
+
nokogiri (1.18.8-arm-linux-musl)
|
146
|
+
racc (~> 1.4)
|
147
|
+
nokogiri (1.18.8-arm64-darwin)
|
148
|
+
racc (~> 1.4)
|
149
|
+
nokogiri (1.18.8-x86_64-darwin)
|
150
|
+
racc (~> 1.4)
|
151
|
+
nokogiri (1.18.8-x86_64-linux-gnu)
|
152
|
+
racc (~> 1.4)
|
153
|
+
nokogiri (1.18.8-x86_64-linux-musl)
|
154
|
+
racc (~> 1.4)
|
155
|
+
parallel (1.27.0)
|
156
|
+
parser (3.3.8.0)
|
157
|
+
ast (~> 2.4.1)
|
158
|
+
racc
|
159
|
+
pp (0.6.2)
|
160
|
+
prettyprint
|
161
|
+
prettyprint (0.2.0)
|
162
|
+
prism (1.4.0)
|
163
|
+
pry (0.15.2)
|
164
|
+
coderay (~> 1.1)
|
165
|
+
method_source (~> 1.0)
|
166
|
+
psych (5.2.6)
|
167
|
+
date
|
168
|
+
stringio
|
169
|
+
racc (1.8.1)
|
170
|
+
rack (3.1.16)
|
171
|
+
rack-session (2.1.1)
|
172
|
+
base64 (>= 0.1.0)
|
173
|
+
rack (>= 3.0.0)
|
174
|
+
rack-test (2.2.0)
|
175
|
+
rack (>= 1.3)
|
176
|
+
rackup (2.2.1)
|
177
|
+
rack (>= 3)
|
178
|
+
rails (8.0.2)
|
179
|
+
actioncable (= 8.0.2)
|
180
|
+
actionmailbox (= 8.0.2)
|
181
|
+
actionmailer (= 8.0.2)
|
182
|
+
actionpack (= 8.0.2)
|
183
|
+
actiontext (= 8.0.2)
|
184
|
+
actionview (= 8.0.2)
|
185
|
+
activejob (= 8.0.2)
|
186
|
+
activemodel (= 8.0.2)
|
187
|
+
activerecord (= 8.0.2)
|
188
|
+
activestorage (= 8.0.2)
|
189
|
+
activesupport (= 8.0.2)
|
190
|
+
bundler (>= 1.15.0)
|
191
|
+
railties (= 8.0.2)
|
192
|
+
rails-dom-testing (2.3.0)
|
193
|
+
activesupport (>= 5.0.0)
|
194
|
+
minitest
|
195
|
+
nokogiri (>= 1.6)
|
196
|
+
rails-html-sanitizer (1.6.2)
|
197
|
+
loofah (~> 2.21)
|
198
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
199
|
+
railties (8.0.2)
|
200
|
+
actionpack (= 8.0.2)
|
201
|
+
activesupport (= 8.0.2)
|
202
|
+
irb (~> 1.13)
|
203
|
+
rackup (>= 1.0.0)
|
204
|
+
rake (>= 12.2)
|
205
|
+
thor (~> 1.0, >= 1.2.2)
|
206
|
+
zeitwerk (~> 2.6)
|
207
|
+
rainbow (3.1.1)
|
208
|
+
rake (13.3.0)
|
209
|
+
rdoc (6.14.2)
|
210
|
+
erb
|
211
|
+
psych (>= 4.0.0)
|
212
|
+
regexp_parser (2.10.0)
|
213
|
+
reline (0.6.1)
|
214
|
+
io-console (~> 0.5)
|
215
|
+
rspec (3.13.1)
|
216
|
+
rspec-core (~> 3.13.0)
|
217
|
+
rspec-expectations (~> 3.13.0)
|
218
|
+
rspec-mocks (~> 3.13.0)
|
219
|
+
rspec-core (3.13.5)
|
220
|
+
rspec-support (~> 3.13.0)
|
221
|
+
rspec-expectations (3.13.5)
|
222
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
223
|
+
rspec-support (~> 3.13.0)
|
224
|
+
rspec-mocks (3.13.5)
|
225
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
226
|
+
rspec-support (~> 3.13.0)
|
227
|
+
rspec-rails (5.1.2)
|
228
|
+
actionpack (>= 5.2)
|
229
|
+
activesupport (>= 5.2)
|
230
|
+
railties (>= 5.2)
|
231
|
+
rspec-core (~> 3.10)
|
232
|
+
rspec-expectations (~> 3.10)
|
233
|
+
rspec-mocks (~> 3.10)
|
234
|
+
rspec-support (~> 3.10)
|
235
|
+
rspec-support (3.13.4)
|
236
|
+
rubocop (1.78.0)
|
237
|
+
json (~> 2.3)
|
238
|
+
language_server-protocol (~> 3.17.0.2)
|
239
|
+
lint_roller (~> 1.1.0)
|
240
|
+
parallel (~> 1.10)
|
241
|
+
parser (>= 3.3.0.2)
|
242
|
+
rainbow (>= 2.2.2, < 4.0)
|
243
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
244
|
+
rubocop-ast (>= 1.45.1, < 2.0)
|
245
|
+
ruby-progressbar (~> 1.7)
|
246
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
247
|
+
rubocop-ast (1.45.1)
|
248
|
+
parser (>= 3.3.7.2)
|
249
|
+
prism (~> 1.4)
|
250
|
+
ruby-progressbar (1.13.0)
|
251
|
+
rubyzip (2.4.1)
|
252
|
+
securerandom (0.4.1)
|
253
|
+
simplecov (0.22.0)
|
254
|
+
docile (~> 1.1)
|
255
|
+
simplecov-html (~> 0.11)
|
256
|
+
simplecov_json_formatter (~> 0.1)
|
257
|
+
simplecov-html (0.13.1)
|
258
|
+
simplecov_json_formatter (0.1.4)
|
259
|
+
sqlite3 (1.7.3-aarch64-linux)
|
260
|
+
sqlite3 (1.7.3-arm-linux)
|
261
|
+
sqlite3 (1.7.3-arm64-darwin)
|
262
|
+
sqlite3 (1.7.3-x86_64-darwin)
|
263
|
+
sqlite3 (1.7.3-x86_64-linux)
|
264
|
+
stringio (3.1.7)
|
265
|
+
thor (1.3.2)
|
266
|
+
timeout (0.4.3)
|
267
|
+
tzinfo (2.0.6)
|
268
|
+
concurrent-ruby (~> 1.0)
|
269
|
+
unicode-display_width (3.1.4)
|
270
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
271
|
+
unicode-emoji (4.0.4)
|
272
|
+
uri (1.0.3)
|
273
|
+
useragent (0.16.11)
|
274
|
+
websocket-driver (0.8.0)
|
275
|
+
base64
|
276
|
+
websocket-extensions (>= 0.1.0)
|
277
|
+
websocket-extensions (0.1.5)
|
278
|
+
yard (0.9.37)
|
279
|
+
zeitwerk (2.7.3)
|
280
|
+
|
281
|
+
PLATFORMS
|
282
|
+
aarch64-linux
|
283
|
+
aarch64-linux-gnu
|
284
|
+
aarch64-linux-musl
|
285
|
+
arm-linux
|
286
|
+
arm-linux-gnu
|
287
|
+
arm-linux-musl
|
288
|
+
arm64-darwin
|
289
|
+
x86_64-darwin
|
290
|
+
x86_64-linux
|
291
|
+
x86_64-linux-gnu
|
292
|
+
x86_64-linux-musl
|
293
|
+
|
294
|
+
DEPENDENCIES
|
295
|
+
pry (~> 0.14)
|
296
|
+
rails-excel-reporter!
|
297
|
+
rake (~> 13.0)
|
298
|
+
rspec (~> 3.0)
|
299
|
+
rspec-rails (~> 5.0)
|
300
|
+
rubocop (~> 1.0)
|
301
|
+
simplecov (~> 0.21)
|
302
|
+
sqlite3 (~> 1.4)
|
303
|
+
yard (~> 0.9)
|
304
|
+
|
305
|
+
BUNDLED WITH
|
306
|
+
2.6.9
|