Skip to content

Commit

Permalink
Release v0.1.1 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
v-kolesnikov authored Jul 4, 2023
1 parent c6f93b6 commit a9c7e73
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog


## 0.1.1 (2023-07-04)

- UUIDv6.uuid method added (#7)
58 changes: 44 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
# UUIDv6

[![Build Status](https://travis-ci.org/v-kolesnikov/uuid_v6.svg?branch=master)](https://travis-ci.org/v-kolesnikov/uuid_v6)
[![Gem Version](https://badge.fury.io/rb/uuid_v6.svg)](https://badge.fury.io/rb/uuid_v6)

UUID version 6 implementation in Ruby. See http://gh.peabody.io/uuidv6/ for details.
# UUIDv6

## Installation
**UUID v6** pure Ruby implementation. See http://gh.peabody.io/uuidv6/ for details.

Add this line to your application's Gemfile:

```ruby
gem 'uuid_v6'
```
The expected[^1] use case for UUIDv6 is as a drop-in replacement for UUIDv1 which offers improved DB locality. If you don’t have the requirement to keep compatibility with UUIDv1 the suggestion is to use UUIDv7 instead. The only real difference between UUIDv6 and UUIDv1 is the order of the timestamp bits. Starting with the 60-bit timestamp, the first 48 bits of the timestamp come first in the UUID (the specification splits this between time_high, and time_mid likely to keep the same terms as RFC 4122). The next 4 bits contain the version (0110 in this case for v6) and then the final 12 bits of the timestamp can be found. This leads to the following difference:

And then execute:
**UUIDv1**

$ bundle
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_low |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_mid | time_hi_and_version |
```

Or install it yourself as:
**UUIDv6**

$ gem install uuid_v6
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_high |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_mid | time_low_and_version |
```

## Usage

```ruby
require 'uuid_v6'

UUIDv6.uuid
=> "13bfcac9-187a-6600-51fa-2683e7d73645"

# or

seq = UUIDv6::Sequence.new

uid = seq.call
Expand All @@ -45,6 +57,22 @@ pp 10.times.map { seq.call }
=> ...
```

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'uuid_v6'
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install uuid_v6

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand All @@ -62,3 +90,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
## Code of Conduct

Everyone interacting in the UUIDv6 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/v-kolesnikov/uuid_v6/blob/master/CODE_OF_CONDUCT.md).

[^1]: https://blog.devgenius.io/analyzing-new-unique-identifier-formats-uuidv6-uuidv7-and-uuidv8-d6cc5cd7391a
9 changes: 9 additions & 0 deletions lib/uuid_v6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@
require 'uuid_v6/sequence'
require 'uuid_v6/version'

# Usage:
#
# UUIDv6.uuid
# => "13bfc94b-6e81-6070-51da-2683e7d73645"
module UUIDv6
extend self

def uuid
Sequence.new.()
end
end
2 changes: 1 addition & 1 deletion lib/uuid_v6/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module UUIDv6
VERSION = "0.1.0"
VERSION = "0.1.1"
end

0 comments on commit a9c7e73

Please sign in to comment.