From 08f276ee41f2c62cd965d541a885c93994835658 Mon Sep 17 00:00:00 2001 From: Marcel Otto Date: Tue, 11 Apr 2017 02:05:57 +0200 Subject: [PATCH] core: graph names can be blank nodes --- lib/rdf/graph.ex | 4 ++-- test/unit/graph_test.exs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/rdf/graph.ex b/lib/rdf/graph.ex index 5a34689..0945122 100644 --- a/lib/rdf/graph.ex +++ b/lib/rdf/graph.ex @@ -10,7 +10,7 @@ defmodule RDF.Graph do @behaviour Access - alias RDF.{Description, Triple} + alias RDF.{Description, Triple, Quad} @type t :: module @@ -54,7 +54,7 @@ defmodule RDF.Graph do Creates an empty named `RDF.Graph`. """ def new(name), - do: %RDF.Graph{name: RDF.uri(name)} + do: %RDF.Graph{name: Quad.convert_graph_context(name)} @doc """ Creates a named `RDF.Graph` with an initial triple. diff --git a/test/unit/graph_test.exs b/test/unit/graph_test.exs index 3dbae61..96e20f2 100644 --- a/test/unit/graph_test.exs +++ b/test/unit/graph_test.exs @@ -14,6 +14,11 @@ defmodule RDF.GraphTest do assert named_graph?(named_graph()) end + test "creating an empty graph with a blank node as graph name" do + assert named_graph(bnode("graph_name")) + |> named_graph?(bnode("graph_name")) + end + test "creating an empty graph with a convertible graph name" do assert named_graph("http://example.com/graph/GraphName") |> named_graph?(uri("http://example.com/graph/GraphName"))