Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 1.27 KB

README.md

File metadata and controls

52 lines (33 loc) · 1.27 KB

Build Status Gem Version

bocadillo

Converts a list of strings into a compact, readable representation with delimiters of choice

bocadillo 'alba,albero,albergo,alberto'
# => alb(a|er(go|o|to))

bocadillo 'aria:arianna' ':' '[' '+' ']'
# => aria[+nna]

What?

In Spanish, bocadillo means sandwich. The name hints at the strings being sliced and interleaved with bread, the delimiters. Bocadillo is the Ruby port of the PHP package Tramezzino.

Why?

Useful when you need to pass long lists of URL params

Ruby Gem

Add it to your Ruby project as a Ruby Gem:

gem install bocadillo

Then have it your way:

require 'bocadillo'

encoded = Bocadillo.encode(['alba', 'albero', 'albergo', 'alberto'])
# => encoded == 'alb(a|er(go|o|to))'

The bocadillo gem also installs a bocadillo command:

$ bocadillo 'alba,albero,albino'
alb(a|ero|ino)

License

Copyright (c) 2017, Claudio Procida

MIT