Project

sluggo

0.0
No commit activity in last 3 years
No release in over 3 years
A gobbledeygook string generator
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.0.8
>= 0
~> 10.1.0

Runtime

~> 1.0.1
 Project Readme

Sluggo

Sometimes, we just want a string of quasi-random gobbledeygook to use as a token of some sort. We may want these strings to be unique (or at least somewhat close to it), or we may just them to be a given length.

That's what this is for.

Important Note

This is very much not ready for primetime. I'm only releasing right now so as to stop working on it and accept a baseline.

Install

You can add it to your Gemfile:

gem 'sluggo'

Or you can do it the hard way:

gem install sluggo

Usage

require 'sluggo'

# Let's get a 6-character random base62 slug

slug = Sluggo::Random.base62(6)

# Heck, let's get a possibly unique 6-character base62 slug
# This works by passing a block to the rare method. If the block
# returns true, we assume that the proposed slug is unique and
# return it. We're going to assume that we're working with a
# Widget with a .open_key? method that returns true if the 
# supplied key isn't in use.

slug = Sluggo.rare(length: 6) {|slug| Widget.open_key?(slug)}

License

MIT License. Copyright 2013 Ess