uuid_v6 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -13
- data/lib/uuid_v6/sequence.rb +2 -2
- data/lib/uuid_v6/version.rb +1 -1
- data/lib/uuid_v6.rb +9 -0
- metadata +35 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6024a4b1c6ecd6595c71d6884bb9c50b8015578dc70e69608429ac9711ca7ffa
|
4
|
+
data.tar.gz: f6850e9cd7ef729f13c7368230b02b91385c0c950b4df191eddb2713e6e148a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1a028731bf37233012f5f2eab0d1f37dbe12feb2a80d702e79581477bb6b6ad018eafe2598ec9d87e52ae00782779dc3fe64eb45b732fa8e5616811fa1a0ada
|
7
|
+
data.tar.gz: f368b4f330873bec2e97522ead7fc3ab8516c54da90de10adc5b403c3ea6226b6cc39656f4d555d9045037c01f47383b1c30acd02e8b6fd7721c643ffcf0ba11
|
data/README.md
CHANGED
@@ -1,30 +1,43 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/uuid_v6.svg)](https://badge.fury.io/rb/uuid_v6)
|
2
|
+
|
1
3
|
# UUIDv6
|
2
4
|
|
3
|
-
|
5
|
+
**UUID v6** pure Ruby implementation. See http://gh.peabody.io/uuidv6/ for details.
|
4
6
|
|
5
|
-
|
7
|
+
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:
|
6
8
|
|
7
|
-
|
9
|
+
**UUIDv1**
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
```
|
12
|
+
0 1 2 3
|
13
|
+
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
|
14
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
15
|
+
| time_low |
|
16
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
17
|
+
| time_mid | time_hi_and_version |
|
13
18
|
```
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
+
**UUIDv6**
|
20
21
|
|
21
|
-
|
22
|
+
```
|
23
|
+
0 1 2 3
|
24
|
+
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
|
25
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
26
|
+
| time_high |
|
27
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
28
|
+
| time_mid | time_low_and_version |
|
29
|
+
```
|
22
30
|
|
23
31
|
## Usage
|
24
32
|
|
25
33
|
```ruby
|
26
34
|
require 'uuid_v6'
|
27
35
|
|
36
|
+
UUIDv6.uuid
|
37
|
+
=> "13bfcac9-187a-6600-51fa-2683e7d73645"
|
38
|
+
|
39
|
+
# or
|
40
|
+
|
28
41
|
seq = UUIDv6::Sequence.new
|
29
42
|
|
30
43
|
uid = seq.call
|
@@ -44,6 +57,22 @@ pp 10.times.map { seq.call }
|
|
44
57
|
=> ...
|
45
58
|
```
|
46
59
|
|
60
|
+
## Installation
|
61
|
+
|
62
|
+
Add this line to your application's Gemfile:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
gem 'uuid_v6'
|
66
|
+
```
|
67
|
+
|
68
|
+
And then execute:
|
69
|
+
|
70
|
+
$ bundle
|
71
|
+
|
72
|
+
Or install it yourself as:
|
73
|
+
|
74
|
+
$ gem install uuid_v6
|
75
|
+
|
47
76
|
## Development
|
48
77
|
|
49
78
|
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.
|
@@ -61,3 +90,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
61
90
|
## Code of Conduct
|
62
91
|
|
63
92
|
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).
|
93
|
+
|
94
|
+
[^1]: https://blog.devgenius.io/analyzing-new-unique-identifier-formats-uuidv6-uuidv7-and-uuidv8-d6cc5cd7391a
|
data/lib/uuid_v6/sequence.rb
CHANGED
@@ -21,7 +21,7 @@ module UUIDv6
|
|
21
21
|
tlo2 = uh[5...8]
|
22
22
|
tmid = uh[8...12]
|
23
23
|
thig = uh[13...16]
|
24
|
-
rest = uh[16
|
24
|
+
rest = uh[16..-1]
|
25
25
|
uh6 = thig + tmid + tlo1 + '6' + tlo2 + rest
|
26
26
|
to_uuid(uh6)
|
27
27
|
end
|
@@ -29,7 +29,7 @@ module UUIDv6
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def to_uuid(str)
|
32
|
-
[str[0..7], str[8..11], str[12..15], str[16..19], str[20
|
32
|
+
[str[0..7], str[8..11], str[12..15], str[16..19], str[20..-1]].join('-')
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/uuid_v6/version.rb
CHANGED
data/lib/uuid_v6.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuid_v6
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasily Kolesnikov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuid
|
@@ -24,7 +24,35 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
28
56
|
email:
|
29
57
|
- re.vkolesnikov@gmail.com
|
30
58
|
executables: []
|
@@ -42,7 +70,7 @@ homepage: https://github.com/v-kolesnikov/uuid_v6
|
|
42
70
|
licenses:
|
43
71
|
- MIT
|
44
72
|
metadata: {}
|
45
|
-
post_install_message:
|
73
|
+
post_install_message:
|
46
74
|
rdoc_options: []
|
47
75
|
require_paths:
|
48
76
|
- lib
|
@@ -57,9 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
85
|
- !ruby/object:Gem::Version
|
58
86
|
version: '0'
|
59
87
|
requirements: []
|
60
|
-
|
61
|
-
|
62
|
-
signing_key:
|
88
|
+
rubygems_version: 3.4.15
|
89
|
+
signing_key:
|
63
90
|
specification_version: 4
|
64
91
|
summary: UUID "version 6" implementation in Ruby
|
65
92
|
test_files: []
|