diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 63e14e2..1c1a582 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -32,7 +32,7 @@ jobs: - os: macos-latest julia-version: nightly steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: persist-credentials: false - uses: julia-actions/setup-julia@v1 @@ -40,6 +40,8 @@ jobs: show-versioninfo: true version: ${{ matrix.julia-version }} - uses: julia-actions/julia-buildpkg@v1 + with: + ignore-no-cache: true - uses: julia-actions/julia-runtest@v1 - uses: heptazhou/julia-codecov@v1 - uses: codecov/codecov-action@v3 diff --git a/Project.toml b/Project.toml index 912a55f..c705cab 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "UUID4" uuid = "379725f3-1ad5-416d-b88a-50ced391fe04" authors = ["Heptazhou "] -version = "1.8.0" +version = "1.10.0" [deps] OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" diff --git a/src/UUID4.jl b/src/UUID4.jl index 1da92b0..c2fa410 100644 --- a/src/UUID4.jl +++ b/src/UUID4.jl @@ -16,7 +16,7 @@ """ UUID4 -The `UUID4` module provides universally unique identifier (UUID), version 4, +This module provides universally unique identifier (UUID) version 4, along with related functions. """ module UUID4 @@ -30,15 +30,15 @@ export uuid_version export AbstractRNG, MersenneTwister, RandomDevice export LittleDict, OrderedDict export UUID -const UUID = Base.UUID +using Base: UUID using OrderedCollections: LittleDict, OrderedDict using Random: AbstractRNG, MersenneTwister, RandomDevice """ uuid(rng::AbstractRNG = RandomDevice()) -> UUID -Generate a version 4 (random or pseudo-random) universally unique identifier -(UUID), as specified by [RFC 4122](https://www.ietf.org/rfc/rfc4122). +Generate a version 4 (random or pseudo-random) universally unique identifier (UUID), +as specified by [RFC 4122](https://tools.ietf.org/html/rfc4122). # Examples ```jldoctest @@ -76,16 +76,13 @@ function uuid_formats()::Vector{Int} end """ - uuid_parse(str::String; fmt::Int = length(str)) -> Tuple{Int, UUID} + uuid_parse(str::AbstractString; fmt::Int = length(str)) -> Tuple{Int, UUID} """ function uuid_parse end -function uuid_parse(str::UUID; fmt::Any = 0x0)::Tuple{Int, UUID} - uuid_parse(string(str); fmt = Int(fmt)) +function uuid_parse(id::UUID; fmt::Number = 0)::Tuple{Int, UUID} + (length("$id"), id) # 36, id end -function uuid_parse(str::Any; fmt::Number = 0)::Tuple{Int, UUID} - uuid_parse(String(str); fmt = Int(fmt)) -end -function uuid_parse(str::String; fmt::Int = 0)::Tuple{Int, UUID} +function uuid_parse(str::AbstractString; fmt::Int = 0)::Tuple{Int, UUID} len = length(str) ret = if 0 > fmt argumenterror("Invalid format `$fmt` (should be positive)") @@ -181,11 +178,11 @@ function uuid_string(id::UUID, fmt::Int)::String end """ - uuid_version(id::String) -> Int - uuid_version(id::UUID) -> Int + uuid_version(id::AbstractString) -> Int + uuid_version(id::UUID) -> Int -Inspect the given UUID or UUID string and return its version (see [RFC -4122](https://www.ietf.org/rfc/rfc4122)). +Inspect the given UUID or UUID string and return its version +(see [RFC 4122](https://tools.ietf.org/html/rfc4122)). # Examples ```jldoctest @@ -194,9 +191,8 @@ julia> uuid_version(uuid()) ``` """ function uuid_version end -uuid_version(id::Any)::Int = uuid_version(String(id)) -uuid_version(id::String)::Int = uuid_version(uuid_parse(id)[end]) -uuid_version(id::UUID)::Int = Int(id.value >> 76 & 0xf) +uuid_version(id::Any)::Int = uuid_version(uuid_parse(id)[end]) +uuid_version(id::UUID)::Int = id.value >> 76 & 0xf |> Int @noinline argumenterror(msg::AbstractString) = throw(ArgumentError(msg))