fast-uuid 0.1.0 → 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/CHANGELOG.md +4 -0
- data/README.md +45 -97
- data/lib/fast/uuid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5d760ee9964a286e6c707dbdc2305fe1dcdc50f026ca13dba2c02c8dfb74e370
|
|
4
|
+
data.tar.gz: 6b563ae643c6b08cf3ec72211a8730bca52d3505d428102a0e1b29bde2cae9fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f114c3ea808c32bc952c93a56a18a5b0fad6af30a375bc4276cffac1cd17c25e9d17d522c08236d16ca5afa29a7c5da0c03e7c411e7a5b83780a409531cd9729
|
|
7
|
+
data.tar.gz: dce54255f0cee5d7b2360dea748139120ac02fea325c4c3aa4cac3bd2194db8407d16e2264e54b3c94630f39eeb147b2376a6f6be3b5e38329e6b0ac62045ce6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,116 +1,64 @@
|
|
|
1
1
|
# fast-uuid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
fast-uuid is a pure Ruby UUID library with no dependencies.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- **Allocates half or fewer** objects per generation compared to Ruby's `SecureRandom`. [Benchmarks](docs/explanation/performance.md).
|
|
6
|
+
- drop-in & api-compatible with `SecureRandom`. [Migration guide](docs/how-to-guides/replace-securerandom.md).
|
|
7
|
+
- [RFC 9562 compliant](https://www.rfc-editor.org/info/rfc9562/)
|
|
8
|
+
- Covers all UUID versions: v1, v3, v4, v5, v6, and v7
|
|
9
|
+
- Offers immutable comparable value objects that can be used as Hash keys. See [Sort and compare](docs/how-to-guides/sort-and-compare.md)
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```ruby
|
|
10
|
-
# before
|
|
11
|
-
SecureRandom.uuid_v4 # => "cdbb6d1f-…"
|
|
12
|
-
SecureRandom.uuid_v7 # => "01a12861-…"
|
|
13
|
-
|
|
14
|
-
# after — the same calls, the same entropy, frozen, half the objects or fewer
|
|
15
|
-
Fast::UUID.uuid_v4 # => "e74ce176-…"
|
|
16
|
-
Fast::UUID.uuid_v7 # => "01a12861-…"
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Fast::UUID can also return immutable `Fast::UUID` objects that are directly `Comparable`. These also allocate fewer objects than `SecureRandom`'s `.uuid_v4` and `.uuid_v7`.
|
|
20
|
-
|
|
21
|
-
```ruby
|
|
22
|
-
a = Fast::UUID.v7(time: Time.utc(2026, 10, 10))
|
|
23
|
-
b = Fast::UUID.v7(time: Time.utc(2026, 10, 11))
|
|
24
|
-
a < b # => true — v7 byte order is time order
|
|
25
|
-
[a, b].max.timestamp # => 2026-10-11 00:00:00 UTC
|
|
26
|
-
Fast::UUID.parse(a.to_s) == a # => true — identity is the 128-bit value alone
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Fast::UUID's goal is to cover every UUID use-case a project could have in a way that is correct and of course, fast.
|
|
30
|
-
|
|
31
|
-
## Installation
|
|
32
|
-
|
|
33
|
-
Add to your Gemfile:
|
|
34
|
-
|
|
35
|
-
```ruby
|
|
36
|
-
gem "fast-uuid"
|
|
37
|
-
```
|
|
38
|
-
and `require "fast/uuid"`.
|
|
11
|
+
## Quickstart
|
|
39
12
|
|
|
40
|
-
|
|
13
|
+
Install from RubyGems `gem install fast-uuid` or add `gem "fast-uuid"` to your Gemfile & `bundle`.
|
|
41
14
|
|
|
42
|
-
|
|
15
|
+
The require is `fast/uuid`, not `fast-uuid`. Requires Ruby `>= 3.3`.
|
|
43
16
|
|
|
44
17
|
```ruby
|
|
45
18
|
require "fast/uuid"
|
|
46
19
|
|
|
47
|
-
uuid = Fast::UUID.generate
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Fast::UUID.v4.version # => 4
|
|
51
|
-
Fast::UUID.v7.timestamp # => a UTC Time, the 48-bit unix_ts_ms
|
|
52
|
-
Fast::UUID.v5(Fast::UUID::NAMESPACE_DNS, "www.example.com").to_s
|
|
53
|
-
# => "2ed6657d-e927-568b-95e1-2665a8aea6a2", same input, same UUID
|
|
20
|
+
uuid = Fast::UUID.generate
|
|
21
|
+
uuid.to_s
|
|
22
|
+
# => "017f22e2-79b0-7cc3-98c4-dc0c0c07398f" # canonical lowercase 8-4-4-4-12, 36 chars, frozen (example)
|
|
54
23
|
|
|
55
|
-
|
|
56
|
-
|
|
24
|
+
uuid.version # => 7
|
|
25
|
+
uuid.variant # => :rfc9562
|
|
26
|
+
uuid.timestamp # => 2022-02-22 19:22:22 UTC # current time as UTC Time at ms resolution (example)
|
|
57
27
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
and `valid?` are the non-raising forms. Every version and variant
|
|
61
|
-
parses, Nil and Max included.
|
|
28
|
+
Fast::UUID.parse("017f22e2-79b0-7cc3-98c4-dc0c0c07398f")
|
|
29
|
+
Fast::UUID.valid?("nope") # => false
|
|
62
30
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
[tutorial](docs/tutorials/generate-parse-and-sort-uuids.md) walks through the whole
|
|
66
|
-
story: generate, parse, introspect, sort, and a request-ID module at the end
|
|
67
|
-
of it.
|
|
31
|
+
Fast::UUID::NIL < uuid && uuid < Fast::UUID::MAX # => true
|
|
32
|
+
```
|
|
68
33
|
|
|
69
|
-
|
|
34
|
+
`Fast::UUID.generate` defaults to v7, the RFC's recommended default. `to_s` is the precomputed canonical lowercase form. `timestamp` returns a UTC `Time` for v1, v6, and v7 and `nil` for other versions. `valid?` answers `true`/`false` without raising. `NIL` and `MAX` bracket every UUID in opaque byte order.
|
|
70
35
|
|
|
71
|
-
|
|
72
|
-
against `securerandom`, parsing against `uuidtools` (Ruby 4.0.7; conditions,
|
|
73
|
-
the allocation columns and how to reproduce on the
|
|
74
|
-
[benchmarks page](docs/explanation/benchmarks.md)):
|
|
36
|
+
## Ordering caveat
|
|
75
37
|
|
|
76
|
-
-
|
|
77
|
-
0.65M vs 0.64M i/s for v4, 0.58M vs 0.65M for v7, at half or fewer of the
|
|
78
|
-
objects — and the String forms win outright: `uuid_v4` 0.72M vs 0.64M with a
|
|
79
|
-
quarter of the objects, `uuid_v7` 0.64M vs 0.65M — parity — with two fifths.
|
|
80
|
-
- Parsing is **2.7x faster than uuidtools with 4.5x fewer objects** — 1.14M vs
|
|
81
|
-
0.42M i/s, 6 objects per call against 27 — because it is a grammar check and
|
|
82
|
-
one `pack`, not a decoded field graph.
|
|
38
|
+
Comparison is opaque unsigned 128-bit byte order. v6 and v7 sort chronologically as raw bytes. v1 does not — its `time_low` field sits first on the wire. See [How the versions and variants are laid out](docs/explanation/version-variant-layout.md) for the field order.
|
|
83
39
|
|
|
84
40
|
## Documentation
|
|
85
41
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
- [
|
|
93
|
-
- [
|
|
94
|
-
-
|
|
95
|
-
- [
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
## Development
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
bundle exec sus
|
|
113
|
-
bundle exec rubocop
|
|
114
|
-
bundle exec ruby benchmark/uuid.rb # full run, about a minute
|
|
115
|
-
BENCH_QUICK=1 bundle exec ruby benchmark/uuid.rb # quick run, seconds
|
|
116
|
-
```
|
|
42
|
+
- Tutorial:
|
|
43
|
+
- [Getting started with fast-uuid](docs/tutorials/getting-started.md)
|
|
44
|
+
- How-to guides:
|
|
45
|
+
- [Replace SecureRandom UUID generation with fast-uuid](docs/how-to-guides/replace-securerandom.md)
|
|
46
|
+
- [Choose a UUID version](docs/how-to-guides/choose-a-uuid-version.md)
|
|
47
|
+
- [Validate and parse UUID strings from user input](docs/how-to-guides/validate-user-input.md)
|
|
48
|
+
- [Order, compare and key UUIDs](docs/how-to-guides/sort-and-compare.md)
|
|
49
|
+
- [Generate deterministic v3 and v5 UUIDs from names](docs/how-to-guides/name-based-uuids.md)
|
|
50
|
+
- Reference:
|
|
51
|
+
- [Fast::UUID — API reference](docs/reference/fast-uuid.md)
|
|
52
|
+
- Explanation:
|
|
53
|
+
- [Design decisions in fast-uuid](docs/explanation/design-decisions.md)
|
|
54
|
+
- [How the versions and variants are laid out](docs/explanation/version-variant-layout.md)
|
|
55
|
+
- [Performance and allocations](docs/explanation/performance.md)
|
|
56
|
+
|
|
57
|
+
## Compatibility
|
|
58
|
+
|
|
59
|
+
- Ruby `>= 3.3`.
|
|
60
|
+
- Tested on 3.3, 3.4, and 4.0 in CI.
|
|
61
|
+
- MIT license.
|
|
62
|
+
- Source and changelog at [github.com/jetpks/fast-uuid](https://github.com/jetpks/fast-uuid).
|
|
63
|
+
|
|
64
|
+
Install and compatibility details are authoritative in [`fast-uuid.gemspec`](fast-uuid.gemspec) and [`.github/workflows/ci.yml`](.github/workflows/ci.yml).
|
data/lib/fast/uuid/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fast-uuid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Jacobs
|
|
@@ -34,7 +34,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
34
34
|
requirements:
|
|
35
35
|
- - ">="
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: '3.
|
|
37
|
+
version: '3.4'
|
|
38
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
requirements:
|
|
40
40
|
- - ">="
|