Project

reloc

0.0
No release in over 3 years
Low commit activity in last 3 years
Create easy to read, hard to guess, domain specific unique IDs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0
 Project Readme

Reloc

A super simple way to generate easy to read, hard to guess, domain specific unique IDs.

Installation

Install the gem:

$ gem install reloc

Then require it

require 'reloc'

Usage

Throw Reloc an (auto-incrementing) integer to generate easy to read, hard to guess unique IDs.

Reloc.generate( 12345 )
#	=>	"7bmgk"
Reloc.generate( 12346 )
#	=>	"2wrdt"

You can ensure your IDs are domain specific

Reloc.generate( 12345, 'www.somedomain.com' )
#	=>	"8fgqb"
Reloc.generate( 12345, 'www.anotherdomain.com' )
#	=>	"oswn1"

And configure the minimum ID length (default is 5 characters)

Reloc.config( {:min_chars => 3} )
Reloc.generate( 12345 )
#	=>	"8z7"	

Hook it up to Redis and you've got your own URL shortener in just a few lines of code

require 'redis'
require 'reloc'

redis = Redis.new
redis.set( "counter", 0 )

counter = Reloc.generate( redis.incr "counter" )
#	=> "68hy1"

redis.set( counter, "http://some-url.com" )
#	=> OK

redis.get( "68hy1" )
#	=> "http://some-url.com"

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request