Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UUID module #546

Merged
merged 7 commits into from Nov 2, 2023
Merged

Add UUID module #546

merged 7 commits into from Nov 2, 2023

Conversation

stilist
Copy link
Contributor

@stilist stilist commented Oct 29, 2023

I recently used FFaker::Guid.guid and realized it can produce invalid UUIDs: UUIDs can’t be arbitrary data; bits 48–51 and 64–65 must have predefined values. Rather than change Guid.guid to produce a valid UUID, I’ve deprecated it and replaced it with more-specific UUID.uuidv4, .uuidv6, .uuidv7, and .uuidv8 methods. These follow the specification (which is still being worked on, but close to approval — current draft).

  • I chose not to implement UUID v1, v2, v3, or v5 because I don’t remember seeing them used in the past 15 years. They can be added to the module if needed, though.
  • I debated whether to have the v6 and v7 methods use real timestamps by accepting from, to arguments like Date.between. I decided it wasn’t necessary, though it might be useful for testing code that relies on those versions’ behavior of putting the slowest-changing part of the timestamp at the start of the UUID. (For example, a trie.)

Provides methods for generating standard-compliant v4, v6, v7, and v8
UUIDs. Deprecates GUID.guid.
lib/ffaker/guid.rb Outdated Show resolved Hide resolved
Co-authored-by: marocchino <marocchino@users.noreply.github.com>
Handle UUID.uuidv4 returning lowercase; be strict about '4' in string.
(In the UUID tests this the '4' is handled by assert_version.)
@marocchino marocchino merged commit 45e9b6c into ffaker:main Nov 2, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants