Project

tuid

0.0
No commit activity in last 3 years
No release in over 3 years
UUID compatible objects prefixed by time
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
>= 0
 Project Readme

Time based Unique IDentifiers

Gem Build Status Test Coverage Code Climate Inline docs

TUIDs are values compatible with UUIDs

They share the same base formati, so can be used instead of them. The main property of TUIDs is that they are prefixed by the time they were generated. Which allow them to be sorted and behave better on database indexes.

Installation

Add this line to your application's Gemfile:

gem 'tuid'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tuid

Usage

# Generate a random TUID
tuid = TUID.new
#=> #<TUID 56342da3-7cc0-280d-f0b8-507634551518(2015-10-30 23:55:31 -0300)>

# Get its generation time
tuid.time
#=> 2015-10-30 23:55:31 -0300

# Turn it into a String
tuid.to_s
#=> "56342da3-7cc0-280d-f0b8-507634551518"

# Generate a TUID from a UUID formated string
tuid2 = TUID.new("56342da3-7cc0-280d-f0b8-507634551518")
#=> #<TUID 56342da3-7cc0-280d-f0b8-507634551518(2015-10-30 23:55:31 -0300)>

# And they can be compared
tuid == tuid2
#=> true

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sagmor/tuid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.