Ruby: 20 Day Gem Challenge Part 2

Recently on Bluesky, there was a #20DayGemChallenge where we were encouraged to choose 20 Ruby gems that we’ve used time and time again, or have inspired us in some way and post one gem per day in no particular order and with no explanation. This series of posts explains my specific reason for choosing each of these gems.

As a general guide, I tried to pick slightly unique gems in the hope that it would help others discover something different rather than the obvious ones that are always being discussed. Also, I wanted to pick gems that had some significance to my use of Ruby (or Rails) over the past many years.

So, let’s get started. Each post has 5 gems.

Gem 6: xlsxtream

I stumbled across xlsxtream when we were exporting a lot of data into an Excel file and realised that it needed a lot of memory. What we wanted was to move to a gem that could stream an Excel output rather than having it all in memory and then writing it across. It’s available at https://github.com/felixbuenemann/xlsxtream and really fits the bill.

It’s quite fast on JRuby but while using it, I discovered that using a different garbage collector in JRuby made quite a difference to memory usage.

By the way, if you’re using JRuby, you can use Java libraries and Apache POI is great for Excel file outputs if you need it.

Gem 7: RedCloth

I have a real soft spot for RedCloth, available at https://github.com/jgarber/redcloth. I was first exposed to Textile markup when working with Redmine for issue tracking and RadiantCMS for content and have loved it since. I would say that I prefer it to Markdown and even this site is written in Textile.

RedCloth is a fast Ruby library for converting Textile into HTML and works really well. I also often use it from other scripts to convert simple text files that I have written using Textile markup into HTML for better formatted documents.

This is one gem that I really intend to contribute to in 2025 – I was able to track down and fix some failures in using RedCloth on Windows and with JRuby. I hope to get back to fixing these permanently some time in 2025 so that the gem is available again for both platforms.

Gem 8: fast-json-parser

This gem is like Ox (which I covered in Part 1) and is a really fast parser for JSON. There have been recent improvements to the built-in parser in Ruby and it may be that some of these will be less needed in the future. I think in my case, I found fast-json-parser work better than “Oj” and so I kept using it.

Gem 9: fast-polylines

This gem is used to encode and decode coordinates into a format called “Google Polyline”: that can be used for visualising routes on maps. This is a native gem that is 300 times faster than the original Ruby version. You can find it at https://github.com/klaxit/fast-polylines

However, the real reason I really like this gem is because it is simple and forms the perfect backdrop for my series (currently at 7 parts) called Learning by Reversing a Ruby Native gem in which I go through every aspect of a native Ruby gem by examining what fast-polylines does (rather than creating a simple toy native gem).

Gem 10: win32ole

Finally, win32ole – a key gem for automating stuff on Windows using Windows OLE. I first used this almost 15 years back when I parsed a Word document using Word OLE Automation to create Textile and HTML markup that could be used inside an instance of Radiant CMS to host it as an online site. For me, this is a really key piece of supporting Ruby on Windows for doing things that can’t be done easily. It’s part of Ruby and can be found at: https://github.com/ruby/win32ole

That’s all for Part 2. If you have any other thoughts or questions, feel free to comment below, or connect with onghu@x or @onghu@ruby.social on Mastodon or @onghu.com on Bluesky to discuss more.