https://github.com/broothie/typeid-ruby
Ruby implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
https://github.com/broothie/typeid-ruby
typeid uuid uuidv7
Last synced: about 1 year ago
JSON representation
Ruby implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
- Host: GitHub
- URL: https://github.com/broothie/typeid-ruby
- Owner: broothie
- License: apache-2.0
- Created: 2023-06-30T20:11:53.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T19:44:01.000Z (about 2 years ago)
- Last Synced: 2024-04-14T13:19:02.153Z (about 2 years ago)
- Topics: typeid, uuid, uuidv7
- Language: Ruby
- Homepage: https://github.com/jetpack-io/typeid
- Size: 45.9 KB
- Stars: 33
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TypeID Ruby
### A Ruby implementation of [TypeIDs](https://github.com/jetpack-io/typeid)
[](https://badge.fury.io/rb/typeid)
[%5D&label=RubyDoc)](https://rubydoc.info/gems/typeid)
[](https://github.com/broothie/typeid-ruby/actions/workflows/main.yml)
[](https://codecov.io/gh/broothie/typeid-ruby)
[](https://opensource.org/licenses/Apache-2.0)
TypeIDs are a modern, **type-safe**, globally unique identifier based on the upcoming
UUIDv7 standard. They provide a ton of nice properties that make them a great choice
as the primary identifiers for your data in a database, APIs, and distributed systems.
Read more about TypeIDs in their [spec](https://github.com/jetpack-io/typeid).
This particular implementation provides a Ruby library for generating and parsing TypeIDs.
## Installation
### If using bundler
```shell
bundle add typeid
```
### If not
```shell
gem install typeid
```
## Usage
```ruby
require "typeid" #=> true
id = TypeID.new("user") #=> #
id.to_s #=> user_01h46z1k2cf2av8mp4r7we4697
other_id = TypeID.from_string(id.to_s) #=> #
id == other_id #=> true
```
## Attributions
This gem depends on [uuid7](https://github.com/sprql/uuid7-ruby) by [sprql](https://github.com/sprql).