Fuzz—Use Fuzzy Matchers on Ruby Objects
Quick summary: I wrote a small Ruby library called fuzz.
Lately I’ve been writing a handful of interactive Ruby scripts that require the
user to choose among a collection of objects (File
objects, Configuration
s,
stuff like that).
There are a lot of great interactive tools for performing fuzzy matching on a
list of strings (I mostly use rofi
, but dmenu
is really popular,
too). Since these are Unix tools, though, you gotta shell out to them with a
list of strings, not real Ruby objects.
While it’s not all that difficult to translate between strings (which the user sees and selects) and objects (which your script uses), it’s a hassle to manually manage that translation in every script. So I extracted a little gem called fuzz to handle it.
Fuzz abstracts over rofi
and dmenu
, along with the CLI tools pick
,
peco
, and selecta
. It’s also easy to add a new custom selector. I
don’t have a Mac handy these days, so I’m not sure, but it would also be fairly
simple to integrate with Alfred or Quicksilver, for example.
If you wanna see what this looks like in practice, check out some of the examples.
Anyway, if you’re in the (admittedly small) set of folks that use Ruby to write interactive scripts with fuzzy matchers who also favor an especially OO style, check out fuzz! It might be right up your alley.
You might like these textually similar articles: