test_graph v0.1.0 TestGraph.LPG
Module for reading and writing a library of LPG graphs and Cypher queries.
The read_graph/1
and write_graph/2
functions allow for reading and writing
RDF graphs to the project data repository. (Default file names are provided
with the read_graph/0
and write_graph/1
forms.)
The list_graphs/0
function lists graph file names.
The read_query/1
and write_query/2
functions allow for reading and writing
SPARQL queries to the project data repository. (Default file names are provided
with the read_query/0
and write_query/1
forms.)
The list_queries/0
function lists query file names.
The books/0
and movies/0
functions return LPG example graphs.
Some simple accessor functions are also available:
Link to this section Summary
Functions
Reads a Books
graph from the graphs library
Returns the default LPG graph file
Returns the LPG graphs directory
Lists Cypher graphs in the LPG graphs library
Lists Cypher queries in the LPG queries library
Reads a Movies
graph from the graphs library
Returns the LPG queries directory
Returns the default Cypher query file
Reads a user LPG graph from the LPG graphs library
Reads a Cypher query from the LPG queries library
Returns the temp LPG graph file for writing
Returns the temp Cypher query file for writing
Writes a LPG graph to a user file in the LPG graphs library
Writes a Cypher query to a file in the LPG queries library
Link to this section Functions
books()
Reads a Books
graph from the graphs library.
Examples
iex> books().data
"CREATE\n(book:Book {\n iri: \"urn:isbn:978-1-68050-252-7\",\n"
graph_file()
Returns the default LPG graph file.
Examples
iex> TestGraph.LPG.graph_file()
"default.cypher"
graphs_dir()
Returns the LPG graphs directory.
list_graphs()
Lists Cypher graphs in the LPG graphs library.
Examples
iex> list_graphs()
["movies.cypher", "books.cypher", "default.cypher"]
list_queries()
Lists Cypher queries in the LPG queries library.
Examples
iex> list_queries()
["relationship1.cypher", "node1_and_relationships.cypher", "path1.cypher",
"paths.cypher", "relationship_ids.cypher", "relationships.cypher",
"node_by_id.cypher", "default.cypher", "nodes.cypher", "node_id1.cypher",
"node_ids.cypher", "nodes_and_relationships.cypher", "node1.cypher",
"relationship_by_id.cypher"]
movies()
Reads a Movies
graph from the graphs library.
Examples
iex> movies().data
"CREATE (TheMatrix:Movie {title:'The Matrix', released:1999,..."
queries_dir()
Returns the LPG queries directory.
query_file()
Returns the default Cypher query file.
Examples
iex> TestGraph.LPG.query_file()
"default.cypher"
read_graph(graph_file \\ graph_file())
Reads a user LPG graph from the LPG graphs library.
Examples
iex> read_graph()
%TestGraph.Graph{
data: "//\n// create nodes\n//\nCREATE\n(book:Book {\n..."
file: "default.cypher",
path: ".../test_graph/priv/lpg/graphs/default.cypher",
type: :lpg,
uri: "file:///.../test_graph/priv/lpg/graphs/default.cypher"
}
iex> read_graph("books.cypher")
%TestGraph.Graph{
data: "//\n// create nodes\n//\nCREATE\n(book:Book {\n..."
file: "books.cypher",
path: ".../test_graph/priv/lpg/graphs/books.cypher",
type: :lpg,
uri: "file:///.../test_graph/priv/lpg/graphs/books.cypher"
}
read_query(query_file \\ query_file())
Reads a Cypher query from the LPG queries library.
Examples
iex> read_query()
%TestGraph.Query{
data: "match (n) return n\n"
file: "nodes.cypher",
path: ".../test_graph/priv/lpg/queries/nodes.cypher",
type: :lpg,
uri: "file:///.../test_graph/priv/lpg/queries/nodes.cypher"
}
iex> read_query("nodes.cypher")
%TestGraph.Query{
data: "match (n) return n\n"
file: "nodes.cypher",
path: ".../test_graph/priv/lpg/queries/nodes.cypher",
type: :lpg,
uri: "file:///.../test_graph/priv/lpg/queries/nodes.cypher"
}
temp_graph_file()
Returns the temp LPG graph file for writing.
Examples
iex> TestGraph.LPG.temp_graph_file()
"temp.cypher"
temp_query_file()
Returns the temp Cypher query file for writing.
Examples
iex> TestGraph.LPG.temp_query_file()
"temp.cypher"
write_graph(graph_data, graph_file \\ temp_graph_file())
Writes a LPG graph to a user file in the LPG graphs library.
Examples
iex> data |> write_graph("my.cypher")
%TestGraph.Graph{
data: "//\n// create nodes\n//\nCREATE\n(book:Book {\n..."
file: "my.cypher",
path: ".../test_graph/priv/lpg/graphs/my.cypher",
type: :lpg,
uri: "file:///.../test_graph/priv/lpg/graphs/my.cypher"
}
write_query(query_data, query_file \\ temp_query_file())
Writes a Cypher query to a file in the LPG queries library.
Examples
iex> write_query("my.cypher")
%TestGraph.Query{
data: "match (n) return n\n"
file: "my.cypher",
path: "/test_graph/priv/lpg/queries/my.cypher",
type: :lpg,
uri: "file:///.../test_graph/priv/lpg/queries/my.cypher"
}