Use RDF.read_file/1 in RDF.Vocabulary.Namespace
This commit is contained in:
parent
24aabc389b
commit
5aaf15bbcd
2 changed files with 5 additions and 13 deletions
|
@ -13,6 +13,10 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
|
||||||
`RDF.Serialization` module contains just simple RDF serialization related functions
|
`RDF.Serialization` module contains just simple RDF serialization related functions
|
||||||
- renamed `RDF.Serialization.Format.content_type/0` to `RDF.Serialization.Format.media_type/0`
|
- renamed `RDF.Serialization.Format.content_type/0` to `RDF.Serialization.Format.media_type/0`
|
||||||
- moved `RDF.Reader` and `RDF.Writer` into `RDF.Serialization` module
|
- moved `RDF.Reader` and `RDF.Writer` into `RDF.Serialization` module
|
||||||
|
- removed the limitation to serialization formats defined in the core RDF.ex package
|
||||||
|
for use as a source of `RDF.Vocabulary.Namespace`s; so you can now also define
|
||||||
|
vocabulary namespaces from JSON-LD files for example, provided that the corresponding
|
||||||
|
Hex package is defined as a dependency
|
||||||
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -176,7 +176,7 @@ defmodule RDF.Vocabulary.Namespace do
|
||||||
|
|
||||||
defp source!(opts) do
|
defp source!(opts) do
|
||||||
cond do
|
cond do
|
||||||
Keyword.has_key?(opts, :file) -> {:data, filename!(opts) |> load_file}
|
Keyword.has_key?(opts, :file) -> {:data, filename!(opts) |> RDF.read_file!()}
|
||||||
rdf_data = Keyword.get(opts, :data) -> {:data, raw_rdf_data(rdf_data)}
|
rdf_data = Keyword.get(opts, :data) -> {:data, raw_rdf_data(rdf_data)}
|
||||||
terms = Keyword.get(opts, :terms) -> {:terms, terms_from_user_input!(terms)}
|
terms = Keyword.get(opts, :terms) -> {:terms, terms_from_user_input!(terms)}
|
||||||
true ->
|
true ->
|
||||||
|
@ -519,18 +519,6 @@ defmodule RDF.Vocabulary.Namespace do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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, ".ttl") -> RDF.Turtle.read_file!(file)
|
|
||||||
true ->
|
|
||||||
raise ArgumentError,
|
|
||||||
"unsupported file type for #{file}: vocabulary namespaces can currently be created from NTriple, NQuad and Turtle files"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp rdf_data_env do
|
defp rdf_data_env do
|
||||||
import RDF.Sigils
|
import RDF.Sigils
|
||||||
__ENV__
|
__ENV__
|
||||||
|
|
Loading…
Reference in a new issue