Handle resolving of terms from undefined modules consistently
This commit is contained in:
parent
5c7efe4cbd
commit
19457d61b9
3 changed files with 11 additions and 1 deletions
|
@ -24,6 +24,12 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
|
||||||
- `RDF.Literal.InvalidError` instead of `RDF.InvalidLiteralError`
|
- `RDF.Literal.InvalidError` instead of `RDF.InvalidLiteralError`
|
||||||
- `RDF.Namespace.InvalidVocabBaseIRIError` instead of `RDF.Namespace.InvalidVocabBaseURIError`
|
- `RDF.Namespace.InvalidVocabBaseIRIError` instead of `RDF.Namespace.InvalidVocabBaseURIError`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- when trying to resolve a term from an undefined module a `RDF.Namespace.UndefinedTermError`
|
||||||
|
exception
|
||||||
|
|
||||||
|
|
||||||
[Compare v0.2.0...HEAD](https://github.com/marcelotto/rdf-ex/compare/v0.2.0...HEAD)
|
[Compare v0.2.0...HEAD](https://github.com/marcelotto/rdf-ex/compare/v0.2.0...HEAD)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ defmodule RDF.Namespace do
|
||||||
defp do_resolve_term(RDF, term), do: do_resolve_term(RDF.NS.RDF, term)
|
defp do_resolve_term(RDF, term), do: do_resolve_term(RDF.NS.RDF, term)
|
||||||
|
|
||||||
defp do_resolve_term(namespace, term) do
|
defp do_resolve_term(namespace, term) do
|
||||||
if Keyword.has_key?(namespace.__info__(:functions), :__resolve_term__) do
|
if Code.ensure_compiled?(namespace) and
|
||||||
|
Keyword.has_key?(namespace.__info__(:functions), :__resolve_term__)do
|
||||||
namespace.__resolve_term__(term)
|
namespace.__resolve_term__(term)
|
||||||
else
|
else
|
||||||
raise RDF.Namespace.UndefinedTermError,
|
raise RDF.Namespace.UndefinedTermError,
|
||||||
|
|
|
@ -738,6 +738,9 @@ defmodule RDF.Vocabulary.NamespaceTest do
|
||||||
assert_raise RDF.Namespace.UndefinedTermError, fn -> RDF.iri(ExUnit.Test) end
|
assert_raise RDF.Namespace.UndefinedTermError, fn -> RDF.iri(ExUnit.Test) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "resolving an non-existing RDF.Namespace module" do
|
||||||
|
assert_raise RDF.Namespace.UndefinedTermError, fn -> RDF.iri(NonExisting.Test) end
|
||||||
|
end
|
||||||
|
|
||||||
describe "term resolution in a strict vocab namespace" do
|
describe "term resolution in a strict vocab namespace" do
|
||||||
alias TestNS.{ExampleFromGraph, ExampleFromNTriplesFile, StrictExampleFromTerms}
|
alias TestNS.{ExampleFromGraph, ExampleFromNTriplesFile, StrictExampleFromTerms}
|
||||||
|
|
Loading…
Reference in a new issue