diff --git a/README.md b/README.md
index 733849e..ae07935 100644
--- a/README.md
+++ b/README.md
@@ -183,7 +183,7 @@ defmodule YourApp.NS do
end
```
-Currently only NTriple and NQuad files are supported at this place.
+Currently only N-Triples, N-Quads and Turtle files are supported at this place.
During compilation the terms will be validated and checked for proper capitalisation by analysing the schema description of the resp. resource in the given data.
This validation behaviour can be modified with the `case_violations` options, which is by default set to `:warn`. By setting it explicitly to `:fail` errors will be raised during compilation or it can be turned off with `:ignore`.
diff --git a/lib/rdf/vocabulary_namespace.ex b/lib/rdf/vocabulary_namespace.ex
index 3b15d07..43661c6 100644
--- a/lib/rdf/vocabulary_namespace.ex
+++ b/lib/rdf/vocabulary_namespace.ex
@@ -529,11 +529,12 @@ defmodule RDF.Vocabulary.Namespace do
defp load_file(file) do
# TODO: support other formats
cond do
- String.ends_with?(file, ".nt") -> RDF.NTriples.read_file!(file)
- String.ends_with?(file, ".nq") -> RDF.NQuads.read_file!(file)
+ String.ends_with?(file, ".nt") -> RDF.NTriples.read_file!(file)
+ String.ends_with?(file, ".nq") -> RDF.NQuads.read_file!(file)
+ String.ends_with?(file, ".ttl") -> RDF.Turtle.read_file!(file)
true ->
raise ArgumentError,
- "unsupported file type for #{file}: vocabulary namespaces can currently be created from NTriple and NQuad files"
+ "unsupported file type for #{file}: vocabulary namespaces can currently be created from NTriple, NQuad and Turtle files"
end
end
diff --git a/test/data/vocab_ns_example.ttl b/test/data/vocab_ns_example.ttl
new file mode 100644
index 0000000..99a12d5
--- /dev/null
+++ b/test/data/vocab_ns_example.ttl
@@ -0,0 +1,6 @@
+@prefix : .
+@prefix rdf: .
+@prefix rdfs: .
+
+:foo a rdf:Property .
+:Bar a rdfs:Resource .
diff --git a/test/unit/vocabulary_namespace_test.exs b/test/unit/vocabulary_namespace_test.exs
index a91b5c3..e03c23a 100644
--- a/test/unit/vocabulary_namespace_test.exs
+++ b/test/unit/vocabulary_namespace_test.exs
@@ -41,6 +41,10 @@ defmodule RDF.Vocabulary.NamespaceTest do
base_uri: "http://example.com/from_nquads/",
file: "test/data/vocab_ns_example.nq"
+ defvocab ExampleFromTurtleFile,
+ base_uri: "http://example.com/from_turtle/",
+ file: "test/data/vocab_ns_example.ttl"
+
defvocab StrictExampleFromTerms,
base_uri: "http://example.com/strict_from_terms#",
terms: ~w[foo Bar]
@@ -688,6 +692,11 @@ defmodule RDF.Vocabulary.NamespaceTest do
assert RDF.uri(Example3.foo) in Example3.__uris__
assert RDF.uri(Example3.Bar) in Example3.__uris__
+ alias TestNS.ExampleFromTurtleFile, as: Example4
+ assert length(Example4.__uris__) == 2
+ assert RDF.uri(Example4.foo) in Example4.__uris__
+ assert RDF.uri(Example4.Bar) in Example4.__uris__
+
alias TestNS.StrictExampleFromAliasedTerms, as: Example4
assert length(Example4.__uris__) == 4
assert RDF.uri(Example4.Term1) in Example4.__uris__