diff --git a/lib/rdf.ex b/lib/rdf.ex index 0caa654..f0a634f 100644 --- a/lib/rdf.ex +++ b/lib/rdf.ex @@ -4,6 +4,8 @@ defmodule RDF do @doc """ Generator function for URIs from strings or term atoms of a `RDF.Namespace`. + This function is used for the `~I` sigil. + ## Examples iex> RDF.uri("http://www.example.com/foo") diff --git a/lib/rdf/quad.ex b/lib/rdf/quad.ex index b7ded8e..003d6b7 100644 --- a/lib/rdf/quad.ex +++ b/lib/rdf/quad.ex @@ -23,7 +23,7 @@ defmodule RDF.Quad do # Examples iex> RDF.Quad.new("http://example.com/S", "http://example.com/p", 42, "http://example.com/Graph") - {RDF.uri("http://example.com/S"), RDF.uri("http://example.com/p"), RDF.literal(42), RDF.uri("http://example.com/Graph")} + {~I, ~I, RDF.literal(42), ~I} """ def new(subject, predicate, object, graph_context) do { @@ -44,7 +44,7 @@ defmodule RDF.Quad do # Examples iex> RDF.Quad.new {"http://example.com/S", "http://example.com/p", 42, "http://example.com/Graph"} - {RDF.uri("http://example.com/S"), RDF.uri("http://example.com/p"), RDF.literal(42), RDF.uri("http://example.com/Graph")} + {~I, ~I, RDF.literal(42), ~I} """ def new({subject, predicate, object, graph_context}), do: new(subject, predicate, object, graph_context) diff --git a/lib/rdf/sigils.ex b/lib/rdf/sigils.ex index b81e579..71d5494 100644 --- a/lib/rdf/sigils.ex +++ b/lib/rdf/sigils.ex @@ -3,6 +3,8 @@ defmodule RDF.Sigils do @doc ~S""" Handles the sigil `~I` for IRIs. + Note: The given IRI string is precompiled into an IRI struct. + ## Examples iex> import RDF.Sigils diff --git a/lib/rdf/triple.ex b/lib/rdf/triple.ex index 223c00d..0d67c52 100644 --- a/lib/rdf/triple.ex +++ b/lib/rdf/triple.ex @@ -26,7 +26,7 @@ defmodule RDF.Triple do # Examples iex> RDF.Triple.new("http://example.com/S", "http://example.com/p", 42) - {RDF.uri("http://example.com/S"), RDF.uri("http://example.com/p"), RDF.literal(42)} + {~I, ~I, RDF.literal(42)} """ def new(subject, predicate, object) do { @@ -46,7 +46,7 @@ defmodule RDF.Triple do # Examples iex> RDF.Triple.new {"http://example.com/S", "http://example.com/p", 42} - {RDF.uri("http://example.com/S"), RDF.uri("http://example.com/p"), RDF.literal(42)} + {~I, ~I, RDF.literal(42)} """ def new({subject, predicate, object}), do: new(subject, predicate, object) diff --git a/test/unit/literal_test.exs b/test/unit/literal_test.exs index f75b9e9..e8a6871 100644 --- a/test/unit/literal_test.exs +++ b/test/unit/literal_test.exs @@ -1,6 +1,8 @@ defmodule RDF.LiteralTest do use ExUnit.Case + import RDF.Sigils + alias RDF.{Literal} alias RDF.NS.XSD @@ -35,7 +37,7 @@ defmodule RDF.LiteralTest do describe "construction with an explicit unknown datatype" do literal = Literal.new("custom typed value", datatype: "http://example/dt") assert literal.value == "custom typed value" - assert literal.datatype == RDF.uri("http://example/dt") + assert literal.datatype == ~I end describe "construction with an explicit known (XSD) datatype" do diff --git a/test/unit/quad_test.exs b/test/unit/quad_test.exs index 4330f01..f9d4848 100644 --- a/test/unit/quad_test.exs +++ b/test/unit/quad_test.exs @@ -1,5 +1,7 @@ defmodule RDF.QuadTest do use ExUnit.Case + import RDF.Sigils + doctest RDF.Quad end diff --git a/test/unit/triple_test.exs b/test/unit/triple_test.exs index 17eca85..cba8e53 100644 --- a/test/unit/triple_test.exs +++ b/test/unit/triple_test.exs @@ -1,8 +1,8 @@ defmodule RDF.TripleTest do use ExUnit.Case + import RDF.Sigils + doctest RDF.Triple -# alias RDF.{Triple, Literal, BlankNode} - end