typed_uuid 1.0 → 2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +7 -7
- data/db/migrate/20191222234546_add_typed_uuid_function.rb +2 -2
- data/lib/typed_uuid/active_record.rb +1 -1
- data/lib/typed_uuid/version.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +1 -2
- data/Gemfile.lock +0 -168
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9f8cc6a9d2e7768a94386004a4e36062d225eccb9671525d338e7e1b49b5a58
|
4
|
+
data.tar.gz: 383fad6086cdd955c79a85efe0f408b27d1b4ed4fa8c586bda2ec02c501ac2ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1442e2de994415398ba67ad9ba28ae491985d297303d8351d4472cf6a0bfa17e687ede6e15b0152066843cbcf987f86f569bdeaca29c09abc9744e14d49ea6fc
|
7
|
+
data.tar.gz: f923a8e624f697f0043edd593a0fde9801744769f849a52e8d6f443f96b70e143d2ac208482c18347fcfab403afe41d8c0301ad71db73fc2a765810bb499e1e2
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -13,18 +13,18 @@ Where:
|
|
13
13
|
- N is 3 bits and is the Variant of the Version followed a bit
|
14
14
|
|
15
15
|
We modify this and use the following structure where the 7th & 8th bytes in the
|
16
|
-
UUID are enum XORed with bytes 5 & 6.
|
16
|
+
UUID are enum XORed with the result of XORing bytes 5 & 6 with bytes 9 & 10.
|
17
17
|
|
18
|
-
`xxxxxxxx-YYYY-TTTT-
|
18
|
+
`xxxxxxxx-YYYY-TTTT-ZZZZ-xxxxxxxxxxxx`
|
19
19
|
|
20
20
|
Where:
|
21
21
|
|
22
|
-
- TTTT is the
|
23
|
-
- YYYY
|
24
|
-
|
22
|
+
- TTTT is the Type ENUM 0bNNNN_NNNN_NNNN_NNNN (0 - 65,535) XORed with (YYYY xor ZZZZ)
|
23
|
+
- YYYY bytes XORed with ZZZZ and the Type ENUM to produce the identifying bytes
|
24
|
+
- ZZZZ bytes XORed with YYYY and the Type ENUM to produce the identifying bytes
|
25
25
|
|
26
|
-
XORing bytes
|
27
|
-
of the Type using soley the UUID.
|
26
|
+
XORing bytes 5 & 6 with 9 & 10 and XORing again with bytes 5 & 6 of the Typed UUID
|
27
|
+
will give us back the ENUM of the Type using soley the UUID.
|
28
28
|
|
29
29
|
## Install
|
30
30
|
|
@@ -8,8 +8,8 @@ class AddTypedUuidFunction < ActiveRecord::Migration[6.0]
|
|
8
8
|
bytes bytea := gen_random_bytes(16);
|
9
9
|
uuid bytea;
|
10
10
|
BEGIN
|
11
|
-
bytes := set_byte(bytes, 6, get_byte(bytes, 4) # get_byte(t, 0));
|
12
|
-
bytes := set_byte(bytes, 7, get_byte(bytes, 5) # get_byte(t, 1));
|
11
|
+
bytes := set_byte(bytes, 6, (get_byte(bytes, 4) # get_byte(bytes, 8)) # get_byte(t, 0));
|
12
|
+
bytes := set_byte(bytes, 7, (get_byte(bytes, 5) # get_byte(bytes, 9)) # get_byte(t, 1));
|
13
13
|
RETURN encode( bytes, 'hex') :: uuid;
|
14
14
|
END;
|
15
15
|
$$ LANGUAGE plpgsql;
|
@@ -61,7 +61,7 @@ module TypedUUID::ActiveRecord
|
|
61
61
|
|
62
62
|
def class_from_uuid(uuid)
|
63
63
|
uuid = uuid.gsub('-', '')
|
64
|
-
class_from_uuid_type(uuid[8..11].to_i(16) ^ uuid[12..15].to_i(16))
|
64
|
+
class_from_uuid_type((uuid[8..11].to_i(16) ^ uuid[16..19].to_i(16)) ^ uuid[12..15].to_i(16))
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
data/lib/typed_uuid/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -19,7 +19,7 @@ require 'active_record'
|
|
19
19
|
require 'rails'
|
20
20
|
require 'typed_uuid'
|
21
21
|
require 'typed_uuid/railtie'
|
22
|
-
require File.expand_path('../../db/migrate/
|
22
|
+
require File.expand_path('../../db/migrate/20191222234546_add_typed_uuid_function', __FILE__)
|
23
23
|
|
24
24
|
module ActiveRecord::Tasks::DatabaseTasks
|
25
25
|
def migrations_paths
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typed_uuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Bracy
|
@@ -174,7 +174,6 @@ files:
|
|
174
174
|
- ".gitignore"
|
175
175
|
- ".tm_properties"
|
176
176
|
- Gemfile
|
177
|
-
- Gemfile.lock
|
178
177
|
- LICENSE
|
179
178
|
- README.md
|
180
179
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
typed_uuid (0.1)
|
5
|
-
activerecord (>= 6.0.0)
|
6
|
-
pg
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
actioncable (6.0.2.1)
|
12
|
-
actionpack (= 6.0.2.1)
|
13
|
-
nio4r (~> 2.0)
|
14
|
-
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (6.0.2.1)
|
16
|
-
actionpack (= 6.0.2.1)
|
17
|
-
activejob (= 6.0.2.1)
|
18
|
-
activerecord (= 6.0.2.1)
|
19
|
-
activestorage (= 6.0.2.1)
|
20
|
-
activesupport (= 6.0.2.1)
|
21
|
-
mail (>= 2.7.1)
|
22
|
-
actionmailer (6.0.2.1)
|
23
|
-
actionpack (= 6.0.2.1)
|
24
|
-
actionview (= 6.0.2.1)
|
25
|
-
activejob (= 6.0.2.1)
|
26
|
-
mail (~> 2.5, >= 2.5.4)
|
27
|
-
rails-dom-testing (~> 2.0)
|
28
|
-
actionpack (6.0.2.1)
|
29
|
-
actionview (= 6.0.2.1)
|
30
|
-
activesupport (= 6.0.2.1)
|
31
|
-
rack (~> 2.0, >= 2.0.8)
|
32
|
-
rack-test (>= 0.6.3)
|
33
|
-
rails-dom-testing (~> 2.0)
|
34
|
-
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
-
actiontext (6.0.2.1)
|
36
|
-
actionpack (= 6.0.2.1)
|
37
|
-
activerecord (= 6.0.2.1)
|
38
|
-
activestorage (= 6.0.2.1)
|
39
|
-
activesupport (= 6.0.2.1)
|
40
|
-
nokogiri (>= 1.8.5)
|
41
|
-
actionview (6.0.2.1)
|
42
|
-
activesupport (= 6.0.2.1)
|
43
|
-
builder (~> 3.1)
|
44
|
-
erubi (~> 1.4)
|
45
|
-
rails-dom-testing (~> 2.0)
|
46
|
-
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
-
activejob (6.0.2.1)
|
48
|
-
activesupport (= 6.0.2.1)
|
49
|
-
globalid (>= 0.3.6)
|
50
|
-
activemodel (6.0.2.1)
|
51
|
-
activesupport (= 6.0.2.1)
|
52
|
-
activerecord (6.0.2.1)
|
53
|
-
activemodel (= 6.0.2.1)
|
54
|
-
activesupport (= 6.0.2.1)
|
55
|
-
activestorage (6.0.2.1)
|
56
|
-
actionpack (= 6.0.2.1)
|
57
|
-
activejob (= 6.0.2.1)
|
58
|
-
activerecord (= 6.0.2.1)
|
59
|
-
marcel (~> 0.3.1)
|
60
|
-
activesupport (6.0.2.1)
|
61
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
62
|
-
i18n (>= 0.7, < 2)
|
63
|
-
minitest (~> 5.1)
|
64
|
-
tzinfo (~> 1.1)
|
65
|
-
zeitwerk (~> 2.2)
|
66
|
-
ansi (1.5.0)
|
67
|
-
builder (3.2.4)
|
68
|
-
byebug (11.0.1)
|
69
|
-
concurrent-ruby (1.1.5)
|
70
|
-
crass (1.0.5)
|
71
|
-
docile (1.3.2)
|
72
|
-
erubi (1.9.0)
|
73
|
-
globalid (0.4.2)
|
74
|
-
activesupport (>= 4.2.0)
|
75
|
-
i18n (1.7.0)
|
76
|
-
concurrent-ruby (~> 1.0)
|
77
|
-
json (2.3.0)
|
78
|
-
loofah (2.4.0)
|
79
|
-
crass (~> 1.0.2)
|
80
|
-
nokogiri (>= 1.5.9)
|
81
|
-
mail (2.7.1)
|
82
|
-
mini_mime (>= 0.1.1)
|
83
|
-
marcel (0.3.3)
|
84
|
-
mimemagic (~> 0.3.2)
|
85
|
-
method_source (0.9.2)
|
86
|
-
mimemagic (0.3.3)
|
87
|
-
mini_mime (1.0.2)
|
88
|
-
mini_portile2 (2.4.0)
|
89
|
-
minitest (5.13.0)
|
90
|
-
minitest-reporters (1.4.2)
|
91
|
-
ansi
|
92
|
-
builder
|
93
|
-
minitest (>= 5.0)
|
94
|
-
ruby-progressbar
|
95
|
-
mocha (1.11.1)
|
96
|
-
nio4r (2.5.2)
|
97
|
-
nokogiri (1.10.7)
|
98
|
-
mini_portile2 (~> 2.4.0)
|
99
|
-
pg (1.1.4)
|
100
|
-
rack (2.0.8)
|
101
|
-
rack-test (1.1.0)
|
102
|
-
rack (>= 1.0, < 3)
|
103
|
-
rails (6.0.2.1)
|
104
|
-
actioncable (= 6.0.2.1)
|
105
|
-
actionmailbox (= 6.0.2.1)
|
106
|
-
actionmailer (= 6.0.2.1)
|
107
|
-
actionpack (= 6.0.2.1)
|
108
|
-
actiontext (= 6.0.2.1)
|
109
|
-
actionview (= 6.0.2.1)
|
110
|
-
activejob (= 6.0.2.1)
|
111
|
-
activemodel (= 6.0.2.1)
|
112
|
-
activerecord (= 6.0.2.1)
|
113
|
-
activestorage (= 6.0.2.1)
|
114
|
-
activesupport (= 6.0.2.1)
|
115
|
-
bundler (>= 1.3.0)
|
116
|
-
railties (= 6.0.2.1)
|
117
|
-
sprockets-rails (>= 2.0.0)
|
118
|
-
rails-dom-testing (2.0.3)
|
119
|
-
activesupport (>= 4.2.0)
|
120
|
-
nokogiri (>= 1.6)
|
121
|
-
rails-html-sanitizer (1.3.0)
|
122
|
-
loofah (~> 2.3)
|
123
|
-
railties (6.0.2.1)
|
124
|
-
actionpack (= 6.0.2.1)
|
125
|
-
activesupport (= 6.0.2.1)
|
126
|
-
method_source
|
127
|
-
rake (>= 0.8.7)
|
128
|
-
thor (>= 0.20.3, < 2.0)
|
129
|
-
rake (13.0.1)
|
130
|
-
ruby-progressbar (1.10.1)
|
131
|
-
simplecov (0.17.1)
|
132
|
-
docile (~> 1.1)
|
133
|
-
json (>= 1.8, < 3)
|
134
|
-
simplecov-html (~> 0.10.0)
|
135
|
-
simplecov-html (0.10.2)
|
136
|
-
sprockets (4.0.0)
|
137
|
-
concurrent-ruby (~> 1.0)
|
138
|
-
rack (> 1, < 3)
|
139
|
-
sprockets-rails (3.2.1)
|
140
|
-
actionpack (>= 4.0)
|
141
|
-
activesupport (>= 4.0)
|
142
|
-
sprockets (>= 3.0.0)
|
143
|
-
thor (1.0.1)
|
144
|
-
thread_safe (0.3.6)
|
145
|
-
tzinfo (1.2.5)
|
146
|
-
thread_safe (~> 0.1)
|
147
|
-
websocket-driver (0.7.1)
|
148
|
-
websocket-extensions (>= 0.1.0)
|
149
|
-
websocket-extensions (0.1.4)
|
150
|
-
zeitwerk (2.2.2)
|
151
|
-
|
152
|
-
PLATFORMS
|
153
|
-
ruby
|
154
|
-
|
155
|
-
DEPENDENCIES
|
156
|
-
activesupport (>= 6.0.0)
|
157
|
-
bundler
|
158
|
-
byebug
|
159
|
-
minitest
|
160
|
-
minitest-reporters
|
161
|
-
mocha
|
162
|
-
rails (>= 6.0.0)
|
163
|
-
rake
|
164
|
-
simplecov
|
165
|
-
typed_uuid!
|
166
|
-
|
167
|
-
BUNDLED WITH
|
168
|
-
2.0.2
|