r/ruby

▲ 17 r/ruby

I’ve been working on a small Ruby project — would love some feedback

Hey Ruby folks

I’ve been working on a small Ruby project called pinterest-dl. I started it because I wanted a simple way to work with Pinterest media from Ruby without making the workflow unnecessarily complicated.

It’s still a work in progress, and I’m mainly curious what other Ruby developers think about the approach and the API. If you have a minute to look through it, I’d really appreciate any honest feedback or suggestions.

https://github.com/monji024/pinterest-dl

u/Much-Stable-449 — 13 days ago
▲ 22 r/ruby

fast_xlsx: a fast Excel (.xlsx) writer for Ruby, built on Rust (rust_xlsxwriter). Looking for testers before 1.0

I've been working on fast_xlsx, a gem for writing Excel .xlsx files from Ruby. It's a native extension built on rust_xlsxwriter via magnus, and its API started from fast_excel's.

It's at 0.8, with the API frozen for 1.0. Before tagging 1.0 I'd like it used on real exports, so I'm looking for people to try it and tell me what breaks or feels awkward.

require "fast_xlsx"

wb = FastXlsx::Workbook.new(memory: :constant)   # rows go to disk as you add them
ws = wb.add_worksheet("Orders")
ws.append(["Order", "Customer", "Total", "Placed at"], format: { bold: true })
Order.includes(:customer).find_each do |o|
  ws << [o.number, o.customer.name, o.total, o.created_at]   # dates come out as dates
end
send_data wb.to_xlsx, filename: "orders.xlsx"

Speed (20,000 rows × 5 columns, build + serialize, Apple Silicon, Ruby 4.0; bench/compare.rb in the repo):

Library Time
fast_xlsx (memory: :constant) 75 ms
fast_xlsx (default) 85 ms
xlsxtream 3.1 173 ms
fast_excel 0.5 204–238 ms
write_xlsx 1.15 592 ms
caxlsx 4.5 671 ms

Memory (200,000 rows saved to a file, peak RSS added): memory: :constant adds about 1 MB however large the file. The default mode keeps everything in memory and is the heaviest of the bunch (+271 MB), so for big exports use :constant or :low.

Other things it does:

  • Formats, formulas, hyperlinks, rich text, merged cells, conditional formats, data validation, tables, charts, images, comments, sheet protection, outline groups, print setup
  • Cells as (row, col) or "B2", ranges as "A1:D10" or (0..9, 0..3), formats as a Format or just a Hash
  • Saving runs without the GVL, so other threads keep going in Puma/Sidekiq
  • Precompiled gems for Linux, macOS and Windows (no Rust toolchain needed); CRuby 3.3+

Limits: it only writes files (no reading), and needs CRuby 3.3+.

Feedback, issues and "this didn't work for my case" reports are all very welcome.

u/7a6163 — 12 days ago