test_match v0.1.0 TestMatch.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

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"

Returns the default LPG graph file.

Examples

iex> TestMatch.LPG.graph_file()
"default.cypher"

Returns the LPG graphs directory.

Lists Cypher graphs in the LPG graphs library.

Examples

iex> list_graphs()
["movies.cypher", "books.cypher", "default.cypher"]

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"]

Reads a Movies graph from the graphs library.

Examples

iex> movies().data
"CREATE (TheMatrix:Movie {title:'The Matrix', released:1999,..."

Returns the LPG queries directory.

Returns the default Cypher query file.

Examples

iex> TestMatch.LPG.query_file()
"default.cypher"
Link to this function

read_graph(graph_file \\ graph_file())

Reads a user LPG graph from the LPG graphs library.

Examples

iex> read_graph()
%TestMatch.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")
%TestMatch.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"
}
Link to this function

read_query(query_file \\ query_file())

Reads a Cypher query from the LPG queries library.

Examples

iex> read_query()
%TestMatch.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")
%TestMatch.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"
}
Link to this function

temp_graph_file()

Returns the temp LPG graph file for writing.

Examples

iex> TestMatch.LPG.temp_graph_file()
"temp.cypher"
Link to this function

temp_query_file()

Returns the temp Cypher query file for writing.

Examples

iex> TestMatch.LPG.temp_query_file()
"temp.cypher"
Link to this function

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")
%TestMatch.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"
}
Link to this function

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")
%TestMatch.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"
}