core: blank node sigil
This commit is contained in:
parent
b713361065
commit
34f6a0e28b
2 changed files with 21 additions and 0 deletions
|
@ -16,6 +16,21 @@ defmodule RDF.Sigils do
|
||||||
Macro.escape(RDF.uri(iri))
|
Macro.escape(RDF.uri(iri))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc ~S"""
|
||||||
|
Handles the sigil `~B` for blank nodes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> import RDF.Sigils
|
||||||
|
iex> ~B<foo>
|
||||||
|
RDF.bnode("foo")
|
||||||
|
|
||||||
|
"""
|
||||||
|
defmacro sigil_B({:<<>>, _, [bnode]}, []) when is_binary(bnode) do
|
||||||
|
Macro.escape(RDF.BlankNode.new(bnode))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
@doc ~S"""
|
@doc ~S"""
|
||||||
Handles the sigil `~L` for plain Literals.
|
Handles the sigil `~L` for plain Literals.
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,12 @@ defmodule RDF.SigilsTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "Blank node sigil without interpolation" do
|
||||||
|
test "creating a blank node" do
|
||||||
|
assert ~B<foo> == RDF.bnode("foo")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "Literal sigil without interpolation" do
|
describe "Literal sigil without interpolation" do
|
||||||
test "creating a plain Literal" do
|
test "creating a plain Literal" do
|
||||||
assert ~L"foo" == RDF.literal("foo")
|
assert ~L"foo" == RDF.literal("foo")
|
||||||
|
|
Loading…
Reference in a new issue