uuidx 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2e41b677c8a6cb523605c6f10620796d1b5831ad511a32b49e8d98415629677
4
- data.tar.gz: 8e8935a0b62e6538a5de355ec22119a0cba5242a3c76767bb720d5d13192431d
3
+ metadata.gz: 0ca7c3e75acfde9ce0b2cd6f05d8bdd1c9809e095a7b69200a1a0271c7dcadbe
4
+ data.tar.gz: d393cb6874eae6ff28a4537a5f634764d3946611e61e00bd5f840ead16179d04
5
5
  SHA512:
6
- metadata.gz: ff313efefe5c2ccca58479e2e208cd98d636b74e5311f5e29de20faaf5207f47baf708c304c2e15275fa2a75b26d0f050f7c38174ddeaadcbf8e9449e9dd8a1c
7
- data.tar.gz: 4def103fd92484499eef8474454eed8e7f6bc2a0e975e7f22deabe986d02f12d957b7bf2457b8d6c6101e66c4789cffaf3844812b6b0e973c95950e7b7abfbf5
6
+ metadata.gz: de256df49b04450bc9cc47c3f44ca58af19a77385c7b7b52ad3d856e454e0ff48a2a7325eab9d38a083fcd12091a6663fa57f07ff3f7065bedab5be87756ea26
7
+ data.tar.gz: 2d8878d99f1086f9867f03d76382e87d30e7c915a1779a73c8dfad47e8e8c9e03cb007307d07b9748fc488659f27b2de2fb0bb6f345ce9f0ee2005f018442b24
data/CHANGELOG.md CHANGED
@@ -6,6 +6,9 @@
6
6
 
7
7
  # Alpha Releases
8
8
 
9
+ ## 0.10.0 – 2023-02-21
10
+ - Refactor module name to `Uuidx`
11
+
9
12
  ## 0.9.0 – 2023-02-11
10
13
  - Swap gem name to shorter uuidx
11
14
  - Main documentation written
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  <h1 align="center">uuidx</h1>
2
2
  <p align="center">Fast Ruby implementations of UUID versions 4, 6, 7, and 8 🪪</p>
3
+ <p align="center"><a href="https://badge.fury.io/rb/uuidx"><img src="https://badge.fury.io/rb/uuidx.svg" alt="Gem Version" height="18"></a></p>
3
4
 
4
5
  ---
5
6
 
@@ -38,9 +39,9 @@ the library and call the associated method.
38
39
  ```ruby
39
40
  require "uuidx"
40
41
 
41
- Uuid.v4 # => "2b54639d-e43e-489f-9c64-30ecdcac3c95"
42
- Uuid.v6 # => "1eda9761-9f6f-6414-8c5f-fd61f1239907"
43
- Uuid.v7 # => "01863d24-6d1e-78ba-92ee-6e80c79c4e28"
42
+ Uuidx.v4 # => "2b54639d-e43e-489f-9c64-30ecdcac3c95"
43
+ Uuidx.v6 # => "1eda9761-9f6f-6414-8c5f-fd61f1239907"
44
+ Uuidx.v7 # => "01863d24-6d1e-78ba-92ee-6e80c79c4e28"
44
45
  ```
45
46
 
46
47
  These methods all use default generators and are thread-safe. However, if you
@@ -50,9 +51,9 @@ the generators you are using when each child process starts.
50
51
  ```ruby
51
52
  # Puma example that resets all default generators.
52
53
  on_worker_boot do
53
- Uuid.reset_v4!
54
- Uuid.reset_v6!
55
- Uuid.reset_v7!
54
+ Uuidx.reset_v4!
55
+ Uuidx.reset_v6!
56
+ Uuidx.reset_v7!
56
57
  end
57
58
  ```
58
59
 
@@ -60,13 +61,13 @@ This way you will get thread-safe state access per process without requiring
60
61
  IPC.
61
62
 
62
63
  ### Monotonicity & Batching
63
- The simple API provided by `Uuid` also supports monotonic batches. Provide the
64
+ The simple API provided by `Uuidx` also supports monotonic batches. Provide the
64
65
  batch size and you will receive an array of UUID values back.
65
66
 
66
67
  ```ruby
67
- Uuid.batch_v4(10) # => ["2b54639d-e43e-489f-9c64-30ecdcac3c95", ...]
68
- Uuid.batch_v6(10) # => ["1eda9761-9f6f-6414-8c5f-fd61f1239907", ...]
69
- Uuid.batch_v7(10) # => ["01863d24-6d1e-78ba-92ee-6e80c79c4e28", ...]
68
+ Uuidx.batch_v4(10) # => ["2b54639d-e43e-489f-9c64-30ecdcac3c95", ...]
69
+ Uuidx.batch_v6(10) # => ["1eda9761-9f6f-6414-8c5f-fd61f1239907", ...]
70
+ Uuidx.batch_v7(10) # => ["01863d24-6d1e-78ba-92ee-6e80c79c4e28", ...]
70
71
  ```
71
72
 
72
73
  ### Advanced Usage
@@ -74,7 +75,7 @@ If you require multiple generators you can drop below the simple API presented
74
75
  above to create generators directly.
75
76
 
76
77
  ```ruby
77
- v6 = Uuid::Version6.new
78
+ v6 = Uuidx::Version6.new
78
79
  v6.generate # => "1eda9adc-2ed9-629e-9a02-4d2ccc87c569"
79
80
  ```
80
81
 
@@ -91,21 +92,21 @@ a generator directly. It takes a single parameter to its constructor which must
91
92
  be the class name of your UUID v8 definition.
92
93
 
93
94
  ```ruby
94
- v8 = Uuid::Version8.new(MyV8Definition)
95
+ v8 = Uuidx::Version8.new(MyV8Definition)
95
96
  v8.generate # => "..."
96
97
  ```
97
98
 
98
99
  The definition class should implement the methods `custom_a`, `custom_b`, and
99
100
  `custom_c` in order to fill out the UUID data [according to the draft](https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#name-uuid-version-8).
100
101
 
101
- See the [documentation for Version8](https://tinychameleon.github.io/uuidx/Uuid/Version8.html) for precise details.
102
+ See the [documentation for Version8](https://tinychameleon.github.io/uuidx/Uuidx/Version8.html) for precise details.
102
103
 
103
104
  #### Batching
104
- Any custom UUID v8 generators can also participate in thread-safe batching by using
105
- the `batch` method.
105
+ Any custom UUID v8 generators can also participate in batching by using the
106
+ `batch` method. The thread-safety of this depends on your UUID v8 implementation.
106
107
 
107
108
  ```ruby
108
- Uuid.batch(v8, 10) # => ["<a v8 uuid>", ...]
109
+ Uuidx.batch(v8, 10) # => ["<a v8 uuidx>", ...]
109
110
  ```
110
111
 
111
112
  ### Clock Resolution
@@ -115,24 +116,24 @@ is raised if the system has insufficient precision.
115
116
 
116
117
  ```ruby
117
118
  begin
118
- Uuid::Version6.verify_clock_resolution! # or Uuid::Version7
119
- rescue Uuid::ClockResolutionError
119
+ Uuidx::Version6.verify_clock_resolution! # or Uuidx::Version7
120
+ rescue Uuidx::ClockResolutionError
120
121
  # ...
121
122
  end
122
123
  ```
123
124
 
124
125
  The API documentation has details about what the clock resolution must be for
125
126
  each of the UUID versions. See the
126
- [Version 6](https://tinychameleon.github.io/uuidx/Uuid/Version6.html) and
127
- [Version 7](https://tinychameleon.github.io/uuidx/Uuid/Version7.html)
127
+ [Version 6](https://tinychameleon.github.io/uuidx/Uuidx/Version6.html) and
128
+ [Version 7](https://tinychameleon.github.io/uuidx/Uuidx/Version7.html)
128
129
  documentation for details.
129
130
 
130
131
  ### A Note on Clock Timings
131
132
  The API documentation contains specific details around how the implementations
132
133
  deal with clock drift. See the
133
- [Uuid](https://tinychameleon.github.io/uuidx/Uuid.html),
134
- [Version 6](https://tinychameleon.github.io/uuidx/Uuid/Version6.html), and
135
- [Version 7](https://tinychameleon.github.io/uuidx/Uuid/Version7.html)
134
+ [Uuidx](https://tinychameleon.github.io/uuidx/Uuidx.html),
135
+ [Version 6](https://tinychameleon.github.io/uuidx/Uuidx/Version6.html), and
136
+ [Version 7](https://tinychameleon.github.io/uuidx/Uuidx/Version7.html)
136
137
  documentation for more information.
137
138
 
138
139
  ## Performance
@@ -183,9 +184,9 @@ To release a new version:
183
184
 
184
185
  1. ensure the documentation and changelog are ready
185
186
  2. run `bundle exec rake rdoc` to generate the new documentation and commit it
186
- 3. update the version number in `lib/uuid/gem_version.rb`
187
+ 3. update the version number in `lib/uuidx/gem_version.rb`
187
188
  4. run `bundle install` to update the `Gemfile.lock`
188
- 5. create a release commit with the version updates
189
+ 5. create a release commit with these updates
189
190
  6. run `bundle exec rake release` to tag and push the version to RubyGems
190
191
 
191
192
  ## Contributing
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Uuid
4
- # Top-level error for all Uuid errors.
3
+ module Uuidx
4
+ # Top-level error for all Uuidx errors.
5
5
  class Error < StandardError
6
6
  end
7
7
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Uuid
3
+ module Uuidx
4
4
  # The gem version.
5
- VERSION = "0.9.0"
5
+ VERSION = "0.10.0"
6
6
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  require "securerandom"
4
4
 
5
- module Uuid
5
+ module Uuidx
6
6
  # UUID Version 7 defined by the
7
7
  # {RFC 4122 BIS-01 Draft}[https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#name-uuid-version-4].
8
8
  #
9
9
  # To construct a new UUID v4 value create a generator, then use #generate.
10
- # g = Uuid::Version4.new
10
+ # g = Uuidx::Version4.new
11
11
  # g.generate # => "2b54639d-e43e-489f-9c64-30ecdcac3c95"
12
12
  #
13
13
  # The implementation will cache 1024 bytes of random data from +SecureRandom+ to facilitate faster construction.
@@ -30,7 +30,7 @@ module Uuid
30
30
  @pool = SecureRandom.bytes(NEEDED_BYTES).unpack(UNPACK_FORMAT) if @pool.empty?
31
31
  ab, c = @pool.pop(2)
32
32
 
33
- Uuid.format(VERSION_VARIANT | ((ab & RANDOM_AB_MASK) << AB_SHIFT) | (c & RANDOM_C_MASK))
33
+ Uuidx.format(VERSION_VARIANT | ((ab & RANDOM_AB_MASK) << AB_SHIFT) | (c & RANDOM_C_MASK))
34
34
  end
35
35
  end
36
36
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  require "securerandom"
4
4
 
5
- module Uuid
5
+ module Uuidx
6
6
  # UUID Version 6 defined by the
7
7
  # {RFC 4122 BIS-01 Draft}[https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#name-uuid-version-6].
8
8
  #
9
9
  # To construct a new UUID v6 value create a generator, then use #generate.
10
- # g = Uuid::Version6.new
10
+ # g = Uuidx::Version6.new
11
11
  # g.generate # => "1eda9761-9f6f-6414-8c5f-fd61f1239907"
12
12
  #
13
13
  # The implementation will use +SecureRandom+ to populate the Node and Clock Sequence bits with a random value
@@ -20,8 +20,8 @@ module Uuid
20
20
  # you can call ::verify_clock_resolution! and handle the ClockResolutionError as you see fit.
21
21
  #
22
22
  # begin
23
- # Uuid::Version6.verify_clock_resolution!
24
- # rescue Uuid::ClockResolutionError
23
+ # Uuidx::Version6.verify_clock_resolution!
24
+ # rescue Uuidx::ClockResolutionError
25
25
  # # ...
26
26
  # end
27
27
  #
@@ -56,7 +56,7 @@ module Uuid
56
56
  ts = GREGORIAN_MICROSECOND_TENTHS + (Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond) / TS_NS_FACTOR)
57
57
  ts = ((ts << TS_MASK_SHIFT) & TS_HIGH_MID_MASK) | (ts & TS_LOW_MASK)
58
58
 
59
- Uuid.format(VERSION_VARIANT | (ts << TS_POSITIONAL_SHIFT) | @clock_sequence | @node_id)
59
+ Uuidx.format(VERSION_VARIANT | (ts << TS_POSITIONAL_SHIFT) | @clock_sequence | @node_id)
60
60
  end
61
61
 
62
62
  # Reset the generator with a new random node ID and clock sequence.
@@ -2,12 +2,12 @@
2
2
 
3
3
  require "securerandom"
4
4
 
5
- module Uuid
5
+ module Uuidx
6
6
  # UUID Version 7 defined by the
7
7
  # {RFC 4122 BIS-01 Draft}[https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#name-uuid-version-7].
8
8
  #
9
9
  # To construct a new UUID v7 value create a generator, then use #generate.
10
- # g = Uuid::Version7.new
10
+ # g = Uuidx::Version7.new
11
11
  # g.generate # => "01863d24-6d1e-78ba-92ee-6e80c79c4e28"
12
12
  #
13
13
  # The implementation will cache 640 bytes of random data from +SecureRandom+ to facilitate faster construction.
@@ -16,8 +16,8 @@ module Uuid
16
16
  # you can call ::verify_clock_resolution! and handle the ClockResolutionError as you see fit.
17
17
  #
18
18
  # begin
19
- # Uuid::Version7.verify_clock_resolution!
20
- # rescue Uuid::ClockResolutionError
19
+ # Uuidx::Version7.verify_clock_resolution!
20
+ # rescue Uuidx::ClockResolutionError
21
21
  # # ...
22
22
  # end
23
23
  #
@@ -53,7 +53,7 @@ module Uuid
53
53
  ts = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond) & TS_MASK
54
54
  high = (ts << TS_SHIFT) | (a & RAND_A_MASK)
55
55
 
56
- Uuid.format(VERSION_VARIANT | (high << HIGH_SHIFT) | (b & RAND_B_MASK))
56
+ Uuidx.format(VERSION_VARIANT | (high << HIGH_SHIFT) | (b & RAND_B_MASK))
57
57
  end
58
58
 
59
59
  # Verify that the clock resolution is capable of 1ms resolution.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Uuid
3
+ module Uuidx
4
4
  # UUID Version 8 defined by the
5
5
  # {RFC 4122 BIS-01 Draft}[https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#name-uuid-version-8].
6
6
  #
@@ -26,7 +26,7 @@ module Uuid
26
26
  # - +custom_c+ should generate a 62-bit value which acts as the remaining least significant octets.
27
27
  #
28
28
  # Then create a UUID v8 generator by passing in the class, and call #generate.
29
- # g = Uuid::Version8.new(MyGeneratorDefinition)
29
+ # g = Uuidx::Version8.new(MyGeneratorDefinition)
30
30
  # g.generate # => "00000000-0001-8002-8000-000000000003"
31
31
  #
32
32
  # The implementation will truncate the results of each generator module method so that they abide by the bit lengths
@@ -53,7 +53,7 @@ module Uuid
53
53
  high = (a << A_SHIFT) | b
54
54
  c = @definition.custom_c & CUSTOM_C_MASK
55
55
 
56
- Uuid.format(VERSION_VARIANT | (high << HIGH_SHIFT) | c)
56
+ Uuidx.format(VERSION_VARIANT | (high << HIGH_SHIFT) | c)
57
57
  end
58
58
  end
59
59
  end
@@ -1,22 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "set"
4
- require_relative "uuid/gem_version"
5
- require_relative "uuid/errors"
6
- require_relative "uuid/version4"
7
- require_relative "uuid/version6"
8
- require_relative "uuid/version7"
9
- require_relative "uuid/version8"
4
+ require_relative "uuidx/gem_version"
5
+ require_relative "uuidx/errors"
6
+ require_relative "uuidx/version4"
7
+ require_relative "uuidx/version6"
8
+ require_relative "uuidx/version7"
9
+ require_relative "uuidx/version8"
10
10
 
11
- # The Uuid module contains a simple API to generate v4, v6, and v7 UUIDs
11
+ # The Uuidx module contains a simple API to generate v4, v6, and v7 UUIDs
12
12
  # without needing to create generators manually.
13
13
  #
14
14
  # The simple API is exposed as a set of methods ::v4, ::v6, and ::v7 which
15
15
  # handle thread-safety and generator creation.
16
16
  #
17
- # Uuid.v4 # => "2b54639d-e43e-489f-9c64-30ecdcac3c95"
18
- # Uuid.v6 # => "1eda9761-9f6f-6414-8c5f-fd61f1239907"
19
- # Uuid.v7 # => "01863d24-6d1e-78ba-92ee-6e80c79c4e28"
17
+ # Uuidx.v4 # => "2b54639d-e43e-489f-9c64-30ecdcac3c95"
18
+ # Uuidx.v6 # => "1eda9761-9f6f-6414-8c5f-fd61f1239907"
19
+ # Uuidx.v7 # => "01863d24-6d1e-78ba-92ee-6e80c79c4e28"
20
20
  #
21
21
  # See the Version4, Version6, and Version7 classes for details on how to create
22
22
  # generators manually.
@@ -25,9 +25,9 @@ require_relative "uuid/version8"
25
25
  # The simple API also provides thread-safe monotonic batch methods which expect
26
26
  # an amount.
27
27
  #
28
- # Uuid.batch_v4(10) # => ["2b54639d-e43e-489f-9c64-30ecdcac3c95", ...]
29
- # Uuid.batch_v6(10) # => ["1eda9761-9f6f-6414-8c5f-fd61f1239907", ...]
30
- # Uuid.batch_v7(10) # => ["01863d24-6d1e-78ba-92ee-6e80c79c4e28", ...]
28
+ # Uuidx.batch_v4(10) # => ["2b54639d-e43e-489f-9c64-30ecdcac3c95", ...]
29
+ # Uuidx.batch_v6(10) # => ["1eda9761-9f6f-6414-8c5f-fd61f1239907", ...]
30
+ # Uuidx.batch_v7(10) # => ["01863d24-6d1e-78ba-92ee-6e80c79c4e28", ...]
31
31
  #
32
32
  # Monotonicity has little meaning with UUID v4, but the batches are ordered for
33
33
  # consistency.
@@ -39,7 +39,7 @@ require_relative "uuid/version8"
39
39
  # within the timestamp values.
40
40
  #
41
41
  # See the Version6 and Version7 documentation for manifestation details.
42
- module Uuid
42
+ module Uuidx
43
43
  # The nil UUID as defined by
44
44
  # {§5.10 of RFC 4122 BIS-01}[https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#name-nil-uuid].
45
45
  #
@@ -1,4 +1,4 @@
1
- module Uuid
1
+ module Uuidx
2
2
  class Error < StandardError
3
3
  end
4
4
 
@@ -1,4 +1,4 @@
1
- module Uuid
1
+ module Uuidx
2
2
  class Version4
3
3
  def initialize: () -> void
4
4
  def generate: () -> uuid
@@ -1,4 +1,4 @@
1
- module Uuid
1
+ module Uuidx
2
2
  class Version6
3
3
  public
4
4
 
@@ -1,4 +1,4 @@
1
- module Uuid
1
+ module Uuidx
2
2
  class Version7
3
3
  public
4
4
 
@@ -1,4 +1,4 @@
1
- module Uuid
1
+ module Uuidx
2
2
  class Version8
3
3
  public
4
4
 
@@ -1,6 +1,6 @@
1
1
  # See the writing guide of rbs: https://github.com/ruby/rbs#guides
2
2
 
3
- module Uuid
3
+ module Uuidx
4
4
  VERSION: String
5
5
 
6
6
  type uuid = String
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuidx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephan Tarulli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-11 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "A fast Ruby implementation of UUID versions 4, 6, 7, and 8 \U0001FAAA"
14
14
  email:
@@ -20,19 +20,19 @@ files:
20
20
  - CHANGELOG.md
21
21
  - LICENSE.txt
22
22
  - README.md
23
- - lib/uuid.rb
24
- - lib/uuid/errors.rb
25
- - lib/uuid/gem_version.rb
26
- - lib/uuid/version4.rb
27
- - lib/uuid/version6.rb
28
- - lib/uuid/version7.rb
29
- - lib/uuid/version8.rb
30
- - sig/uuid.rbs
31
- - sig/uuid/errors.rbs
32
- - sig/uuid/version4.rbs
33
- - sig/uuid/version6.rbs
34
- - sig/uuid/version7.rbs
35
- - sig/uuid/version8.rbs
23
+ - lib/uuidx.rb
24
+ - lib/uuidx/errors.rb
25
+ - lib/uuidx/gem_version.rb
26
+ - lib/uuidx/version4.rb
27
+ - lib/uuidx/version6.rb
28
+ - lib/uuidx/version7.rb
29
+ - lib/uuidx/version8.rb
30
+ - sig/uuidx.rbs
31
+ - sig/uuidx/errors.rbs
32
+ - sig/uuidx/version4.rbs
33
+ - sig/uuidx/version6.rbs
34
+ - sig/uuidx/version7.rbs
35
+ - sig/uuidx/version8.rbs
36
36
  homepage: https://github.com/tinychameleon/uuidx
37
37
  licenses:
38
38
  - MIT
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubygems_version: 3.4.3
61
+ rubygems_version: 3.4.7
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: "A fast Ruby implementation of UUID versions 4, 6, 7, and 8 \U0001FAAA"