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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a8b04df8089715f0156dc86feb6b73dd3abebea996b08c213e9b43844bfc9ce
4
- data.tar.gz: a6e2cae4c744b1b238af21188dab84a6e2830e2108760db5e71c465a789205dd
3
+ metadata.gz: 5d760ee9964a286e6c707dbdc2305fe1dcdc50f026ca13dba2c02c8dfb74e370
4
+ data.tar.gz: 6b563ae643c6b08cf3ec72211a8730bca52d3505d428102a0e1b29bde2cae9fa
5
5
  SHA512:
6
- metadata.gz: a629ab2256ed2043b278d6953b67a96a057888c60a01bed3cd740f9690047be5dcfcec16d0e3f92ec47e91eef051cd24a48f9d3d4d2ee6758fa9c6efe0a05cf4
7
- data.tar.gz: 4037526e2102bbcf3cfff76b8a2a700ebcfe29ceb85c0793e9fb3b7aac35600ae898c312fa7130c1f6e594e4920e033fef8e2744d18fef79a3c3c5b0d2a932ba
6
+ metadata.gz: f114c3ea808c32bc952c93a56a18a5b0fad6af30a375bc4276cffac1cd17c25e9d17d522c08236d16ca5afa29a7c5da0c03e7c411e7a5b83780a409531cd9729
7
+ data.tar.gz: dce54255f0cee5d7b2360dea748139120ac02fea325c4c3aa4cac3bd2194db8407d16e2264e54b3c94630f39eeb147b2376a6f6be3b5e38329e6b0ac62045ce6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ - Ruby 3.3 support dropped; the floor is now `>= 3.4`; CI matrix 3.4/4.0.
6
+
3
7
  ## 0.1.0
4
8
 
5
9
  - Initial release: `Fast::UUID`, one immutable, frozen value class. Generate
data/README.md CHANGED
@@ -1,116 +1,64 @@
1
1
  # fast-uuid
2
2
 
3
- > **Status:** _Alpha, pre-1.0_ The API surface may still move between v0.x and v1.0.
3
+ fast-uuid is a pure Ruby UUID library with no dependencies.
4
4
 
5
- A UUID library for Ruby that is fast, complete, and RFC 9562-compliant.
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
- Fast::UUID provides drop-in, api-compatible replacements for `SecureRandom`'s `.uuid_v4` and `.uuid_v7` that are as fast (within 2%) or faster while allocating half as many objects or fewer while using the same source of entropy.
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
- Fast::UUID has no dependencies and is implemented in pure Ruby.
13
+ Install from RubyGems `gem install fast-uuid` or add `gem "fast-uuid"` to your Gemfile & `bundle`.
41
14
 
42
- ## Quickstart
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 # v7, the RFC's recommended default
48
- Fast::UUID.uuid_v4 # => "b4c7b0f1-…", or uuid_v1 - uuid_v7. Returns a String just like SecureRandom
49
- Fast::UUID.parse(uuid.to_s) == uuid # => true, from any conforming String, any case
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
- sorted = [Fast::UUID.v7, Fast::UUID.v7].sort # v7 sorts chronologically, RFC 6.11
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
- `Fast::UUID.parse` raises `Fast::UUID::ParseError` for anything the RFC
59
- 4 grammar rejects and `TypeError` for an object with no `to_s`; `parse?`
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
- One caveat the RFC does not decide for you: opaque byte order makes v6 and
64
- v7 sort chronologically, but **v1 does not**. The
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
- ## Performance
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
- Measured on the six operations the gem and its references share — generation
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
- - Generation is **ahead of the stdlib String for v4, within 10% for v7** —
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
- ### Tutorials
87
-
88
- - [Tutorial: generate, parse and sort UUIDs](docs/tutorials/generate-parse-and-sort-uuids.md) — generate, parse, introspect and sort, ending in a sortable request ID.
89
-
90
- ### How-to guides
91
-
92
- - [How to choose a UUID version](docs/how-to/choose-a-uuid-version.md) — v7 by default, v6 for a v1 fleet, v5 for name-derived determinism, v4 for randomness, v1 for legacy systems.
93
- - [How to generate deterministic UUIDs](docs/how-to/generate-deterministic-uuids.md) — pin a v7 to an exact millisecond with `v7(time:)`, pin a v1 or v6 to the 100-ns tick, or derive a stable v5 from a namespace and name.
94
- - [How to validate untrusted input](docs/how-to/validate-untrusted-input.md) — what `parse?` and `valid?` return, and what `parse` raises.
95
- - [How to sort UUIDs](docs/how-to/sort-uuids.md) — `<=>` byte order, and the v1 caveat.
96
- - [How to store a UUID as 16 bytes](docs/how-to/store-a-uuid-as-16-bytes.md) — `bytes` out, `new(bytes)` back.
97
-
98
- ### Reference
99
-
100
- - [Reference: Fast::UUID](docs/reference/uuid.md) — every class method, instance method, constant and error.
101
-
102
- ### Explanation
103
-
104
- - [What a UUID is, and what its versions are](docs/explanation/uuid-versions.md) — embedded time, natural sorting, name-derived determinism, and randomness as one option among five.
105
- - [Why validity is the grammar and nothing more](docs/explanation/validity.md) — why no version or variant gate: the RFC defines none, and Nil and Max sit outside the 10xx variant by design.
106
- - [In what order UUIDs sort](docs/explanation/comparison-order.md) — opaque bytes per RFC §6.11, v6/v7 chronological, v1 anti-chronological.
107
- - [Benchmarks](docs/explanation/benchmarks.md) — generation against securerandom, parsing against uuidtools, and how to reproduce them.
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).
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fast
4
4
  class UUID
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
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.1.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.3'
37
+ version: '3.4'
38
38
  required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="