csv_preview 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/.yardopts +8 -0
- data/CHANGELOG.md +25 -0
- data/LICENSE +21 -0
- data/README.md +587 -0
- data/SECURITY.md +51 -0
- data/fonts/Inter-Regular.ttf +0 -0
- data/fonts/Inter-SemiBold.ttf +0 -0
- data/fonts/OFL.txt +92 -0
- data/lib/csv_preview/active_storage_previewer.rb +97 -0
- data/lib/csv_preview/cell_kind.rb +75 -0
- data/lib/csv_preview/configuration.rb +183 -0
- data/lib/csv_preview/deadline.rb +31 -0
- data/lib/csv_preview/errors.rb +30 -0
- data/lib/csv_preview/layout.rb +590 -0
- data/lib/csv_preview/painter.rb +194 -0
- data/lib/csv_preview/parser.rb +456 -0
- data/lib/csv_preview/railtie.rb +54 -0
- data/lib/csv_preview/reader.rb +259 -0
- data/lib/csv_preview/sample.rb +85 -0
- data/lib/csv_preview/sanitizer.rb +31 -0
- data/lib/csv_preview/text.rb +621 -0
- data/lib/csv_preview/theme.rb +207 -0
- data/lib/csv_preview/version.rb +6 -0
- data/lib/csv_preview.rb +149 -0
- data/skills/csv-preview/SKILL.md +171 -0
- metadata +121 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e172c166bd81e5c319c609d96f2890656a37e551f9013d624b5f548ad077c6dd
|
|
4
|
+
data.tar.gz: 56063cf5e4068f8b514a2ba5fcf8546f2eee305789cfadadc6527cd3bf11e9af
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 786657f6c82b9dda36f6f1bf54d16247658310665be43c328b3b9d67123f131ec3c3b4597b421465c87785f90da590ee1b3e7137e2b6f49523e35504c90f1928
|
|
7
|
+
data.tar.gz: bbd9ac58f16849db4303f111ab72daa8dc7562fd4da303cbfb4bf30ba6a39d2fab1bf5e816c8343b2ec9252a19481cf594940bf7b7a2ed87cd02c339e056babb
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to csv_preview are recorded here. The format is based on [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/), and csv_preview follows [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html): before 1.0, a breaking change bumps the minor version and its entry includes an upgrading note.
|
|
4
|
+
|
|
5
|
+
Rendered pixels are not part of the API. Any release may change how previews look, and its entry says so when it does. Existing Active Storage previews keep their old look until they are regenerated (see [Regenerating previews](https://github.com/garyhtou/csv_preview#regenerating-previews)).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-11-17
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `CsvPreview.render(source, **options)` renders the first rows of a CSV or TSV file, or of any IO-like object, as a PNG, JPEG or WebP image in the Ledger look: Inter, a tinted header band, rules between rows, numbers right-aligned in tabular figures with a true minus sign, a fade for columns that do not fit, and a footer that says what was left out. A String or Pathname source is always a path.
|
|
14
|
+
- `CsvPreview.sample` reads and cleans the cells without rendering (and without libvips), returning a `CsvPreview::Sample`. `CsvPreview.layout` returns the `CsvPreview::Layout` for debugging and tests; its shape may change before 1.0.
|
|
15
|
+
- Options, per call or global through `CsvPreview.configure`: `max_input_bytes`, `max_rows`, `max_columns`, `max_cell_chars`, `max_width_px`, `max_height_px`, `scale`, `timeout`, `header_row`, `delimiter`, `encoding`, `format`, `theme` and `font`.
|
|
16
|
+
- Detection of the encoding (UTF-8 with or without a byte order mark, UTF-16, UTF-32 and Windows-1252), the delimiter (comma, semicolon, tab or pipe) and the header row, with lenient parsing of malformed, ragged and unbalanced input through Ruby's `csv` library.
|
|
17
|
+
- `CsvPreview::ActiveStoragePreviewer` for Rails 7.2 and newer: makes CSV and TSV attachments work with `preview`, `representation`, `previewable?` and preprocessed variants; reads only the first `max_input_bytes` of each blob with a ranged read; always produces PNG; and turns csv_preview's errors into `ActiveStorage::PreviewError`. Opt-in automatic registration with `config.csv_preview.register_previewer = true`.
|
|
18
|
+
- `CsvPreview.text_supported?` and `CsvPreview::ActiveStoragePreviewer.text_supported?` for health checks. The gem loads, and `sample` works, without libvips.
|
|
19
|
+
- Bounds for untrusted input: at most 2 MiB read by default, a cooperative `timeout` (5 seconds by default), capped image size, and no subprocesses, network, `eval`, ImageMagick, image decoders or file writes, each proved by a named test.
|
|
20
|
+
- `CsvPreview::UnreadableInput`, `CsvPreview::TimeoutExceeded` and `CsvPreview::RenderFailed`, all `CsvPreview::Error`. Messages never include input content, and each one links the README section that explains the fix.
|
|
21
|
+
- Bundled Inter 4.1 Regular and SemiBold fonts under the SIL Open Font License 1.1, and greyscale text antialiasing on every host.
|
|
22
|
+
- An integration guide for AI coding agents, packaged with the gem as an Agent Skill in `skills/csv-preview/SKILL.md`.
|
|
23
|
+
|
|
24
|
+
[Unreleased]: https://github.com/garyhtou/csv_preview/compare/v0.1.0...HEAD
|
|
25
|
+
[0.1.0]: https://github.com/garyhtou/csv_preview/releases/tag/v0.1.0
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gary Tou
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|