https://github.com/ess/sluggo
Let's generate some gobbledeygook strings!
https://github.com/ess/sluggo
Last synced: 11 months ago
JSON representation
Let's generate some gobbledeygook strings!
- Host: GitHub
- URL: https://github.com/ess/sluggo
- Owner: ess
- License: mit
- Created: 2013-12-05T10:35:23.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-06T08:57:45.000Z (over 12 years ago)
- Last Synced: 2025-01-03T20:09:54.762Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 125 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this 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 ##
```ruby
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