diff --git a/src/CitableBase.jl b/src/CitableBase.jl index 79b164e..bf209a2 100644 --- a/src/CitableBase.jl +++ b/src/CitableBase.jl @@ -3,9 +3,10 @@ module CitableBase using Documenter, DocStringExtensions # Urn and its required functions: -export Urn -export components, parts, validurn +export Urn export dropversion, addversion +# Concrete implementations: +export components, parts # Citable and its required functions export Citable diff --git a/src/citable.jl b/src/citable.jl index 42babb8..713cf55 100644 --- a/src/citable.jl +++ b/src/citable.jl @@ -1,21 +1,14 @@ - -"Unique identifiers expressible in the syntax of the IETF's URN specification." -abstract type Urn end -# Classes extending the URN abstractions MUST -# have a member of type AbstractString named "urn": - - - "A citable unit of any kind is identified by a URN and has a human-readable label." abstract type Citable end """Citable content should always be serializable. """ -function cex(data::T, delim="|") where {T <: Citable} - @warn("No cex function defined for ", typeof(data)) -end +function cex end -function objectid(data::T) where {T <: Citable} - @warn("No cex function defined for ", typeof(data)) - nothing -end \ No newline at end of file +"""Citable content has a label. +""" +function label end + +"""Citable content is identified by a URN. +""" +function urn end \ No newline at end of file diff --git a/src/urns.jl b/src/urns.jl index 7251b5e..e017c98 100644 --- a/src/urns.jl +++ b/src/urns.jl @@ -20,10 +20,9 @@ $(SIGNATURES) Splits a URN's string representation into top-level components. """ function components(u::Urn) - split(u.urn, ":") + split(string(u), ":") end - """ $(SIGNATURES) Splits a string on periods (seprator for parts within components of URNs). diff --git a/test/runtests.jl b/test/runtests.jl index 7402e10..15eb236 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,8 +1,6 @@ using CitableBase using Test - include("test_urnimpl.jl") include("test_urnmanipulation.jl") include("test_citeimpl.jl") -include("test_cex.jl") \ No newline at end of file diff --git a/test/test_cex.jl b/test/test_cex.jl deleted file mode 100644 index 4a21c2f..0000000 --- a/test/test_cex.jl +++ /dev/null @@ -1,12 +0,0 @@ -@testset "Test extending cex function for serialization" begin - struct PretendCitable <: Citable - col1 - col2 - end - function cex(pc::PretendCitable, delim="|") - join([pc.col1, pc.col2], delim) - end - pc = PretendCitable("x", "y") - @test cex(pc) == "x|y" - @test cex(pc, "#") == "x#y" -end \ No newline at end of file diff --git a/test/test_citeimpl.jl b/test/test_citeimpl.jl index ffd7438..1da46bf 100644 --- a/test/test_citeimpl.jl +++ b/test/test_citeimpl.jl @@ -20,4 +20,21 @@ @test urn(c) == u @test label(c) == "label" @test cex(c) == "urn:fake:id.subid|label" -end \ No newline at end of file + +end + +@testset "Test incomplete implementation of Citable" begin + struct PretendCitable <: Citable + col1 + col2 + end + function cex(pc::PretendCitable, delim="|") + join([pc.col1, pc.col2], delim) + end + pc = PretendCitable("x", "y") + @test cex(pc) == "x|y" + @test cex(pc, "#") == "x#y" + @test_throws MethodError urn(pc) + @test_throws MethodError label(pc) +end +