Module: Pacer

Defined in:
lib/pacer-dex/graph.rb,
lib/pacer-dex/version.rb

Defined Under Namespace

Modules: Dex

Class Method Summary collapse

Class Method Details

.dex(path) ⇒ Object

Return a graph for the given path. Will create a graph if none exists at that location. (The graph is only created if data is actually added to it).



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pacer-dex/graph.rb', line 5

def dex(path)
  dex = com.tinkerpop.blueprints.impls.dex.DexGraph
  path = File.expand_path(path)
  open = proc do
    graph = Pacer.open_graphs[path]
    unless graph
      graph = dex.new(path)
      Pacer.open_graphs[path] = graph
    end
    graph
  end
  shutdown = proc do |g|
    g.blueprints_graph.shutdown
    Pacer.open_graphs[path] = nil
  end
  PacerGraph.new(Pacer::YamlEncoder, open, shutdown)
end