diff --git a/Project.toml b/Project.toml index 5d9d7ec..606b1b1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "CitableBase" uuid = "d6f014bd-995c-41bd-9893-703339864534" authors = ["Neel Smith "] -version = "9.0.1" +version = "10.0.0" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" diff --git a/docs/make.jl b/docs/make.jl index 08b6ab1..8297e81 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -4,7 +4,7 @@ # # Serve docs from repository root: # -# julia -e 'using LiveServer; serve(dir="docs/build")'julia -e 'using LiveServer; serve(dir="docs/build")' +# julia -e 'using LiveServer; serve(dir="docs/build")' # using Pkg Pkg.activate(".") diff --git a/docs/src/citable.md b/docs/src/citable.md index f617ab1..e641305 100644 --- a/docs/src/citable.md +++ b/docs/src/citable.md @@ -288,7 +288,7 @@ The inverse of `cex` is `fromcex`. We need two essential pieces of information ```@example book import CitableBase: fromcex function fromcex(traitvalue::BookCex, cexsrc::AbstractString, T; - delimiter = "|", configuration = nothing) + delimiter = "|", configuration = nothing, strict = true) fields = split(cexsrc, delimiter) urn = Isbn10Urn(fields[1]) CitableBook(urn, fields[2], fields[3]) diff --git a/docs/src/collections.md b/docs/src/collections.md index 114522f..760ef65 100644 --- a/docs/src/collections.md +++ b/docs/src/collections.md @@ -110,7 +110,7 @@ end import CitableBase: fromcex function fromcex(traitvalue::BookCex, cexsrc::AbstractString, T; - delimiter = "|", configuration = nothing) + delimiter = "|", configuration = nothing, strict = true) fields = split(cexsrc, delimiter) urn = Isbn10Urn(fields[1]) CitableBook(urn, fields[2], fields[3]) @@ -323,7 +323,7 @@ Recall from our experience implementing CEX serialization for `CitableBook`s tha ```@example collections function fromcex(trait::ReadingListCex, cexsrc::AbstractString, T; - delimiter = "|", configuration = nothing) + delimiter = "|", configuration = nothing, strict = true) lines = split(cexsrc, "\n") datalines = filter(ln -> !isempty(ln), lines) diff --git a/src/cex.jl b/src/cex.jl index 9eeaed9..088ed60 100644 --- a/src/cex.jl +++ b/src/cex.jl @@ -55,9 +55,11 @@ end $(SIGNATURES) """ function fromcex(cexsrc::AbstractString, T; - delimiter = "|", configuration = nothing) + delimiter = "|", + configuration = nothing, + strict = true) fromcex(cextrait(T), cexsrc, T, - delimiter = delimiter, configuration = configuration) + delimiter = delimiter, configuration = configuration, strict = strict) end @@ -66,10 +68,10 @@ end $(SIGNATURES) """ function fromcex(fname::AbstractString, T, freader::Type{FileReader}; - delimiter = "|", configuration = nothing) + delimiter = "|", configuration = nothing, strict = true) cexsrc = open(f->read(f, String), fname) fromcex(cextrait(T), cexsrc, T, - delimiter = delimiter, configuration = configuration) + delimiter = delimiter, configuration = configuration, strict = strict) end """Implement `fromcex` using first string parameter for a URL. @@ -77,10 +79,10 @@ end $(SIGNATURES) """ function fromcex(url::AbstractString, T, ureader::Type{UrlReader}; - delimiter = "|", configuration = nothing) + delimiter = "|", configuration = nothing, strict = true) cexsrc = HTTP.get(url).body |> String fromcex(cextrait(T), cexsrc, T, - delimiter = delimiter, configuration = configuration) + delimiter = delimiter, configuration = configuration, strict = strict) end """Implement `fromcex` using first string parameter for raw string data. @@ -88,9 +90,9 @@ end $(SIGNATURES) """ function fromcex(cexsrc::AbstractString, T, freader::Type{StringReader}; - delimiter = "|", configuration = nothing) + delimiter = "|", configuration = nothing, strict = true) fromcex(cextrait(T), cexsrc, T, - delimiter = delimiter, configuration = configuration) + delimiter = delimiter, configuration = configuration, strict = strict) end # Catch attempts to use fromex on NotCexSerializable or on types with out an implementation @@ -98,7 +100,7 @@ end $(SIGNATURES) """ -function fromcex(::NotCexSerializable, cex, T::Type{<: Any}; delimiter , configuration) +function fromcex(::NotCexSerializable, cex, T::Type{<: Any}; delimiter , configuration, strict) throw(DomainError(T, "$(T) is not a CexSerializable type.")) end @@ -108,6 +110,6 @@ unimplemented trait value. $(SIGNATURES) """ function fromcex(traitvalue::TraitType, cexsrc::AbstractString, T; - delimiter, configuration) where {TraitType <: CexTrait} + delimiter, configuration, strict) where {TraitType <: CexTrait} throw(DomainError(traitvalue, "`fromcex` is not implemented for trait $(traitvalue) on type $(T).")) end diff --git a/src/citable.jl b/src/citable.jl index 64f4e29..b663ea0 100644 --- a/src/citable.jl +++ b/src/citable.jl @@ -75,5 +75,5 @@ end $(SIGNATURES) """ function urntype(::NotCitable, x) - throw(DomainError(x, string( typeof(x), " does not implement the urn function."))) + throw(DomainError(x, string( typeof(x), " does not implement the urntype function."))) end