Module: Pacer

Defined in:
lib/pacer.rb,
lib/pacer/core.rb,
lib/pacer/graph.rb,
lib/pacer/utils.rb,
lib/pacer/route.rb,
lib/pacer/pipes.rb,
lib/pacer/routes.rb,
lib/pacer/filter.rb,
lib/pacer/support.rb,
lib/pacer/wrappers.rb,
lib/pacer/transform.rb,
lib/pacer/exceptions.rb,
lib/pacer/core/graph.rb,
lib/pacer/extensions.rb,
lib/pacer/core/route.rb,
lib/pacer/utils/tsort.rb,
lib/pacer/side_effect.rb,
lib/pacer/transform/map.rb,
lib/pacer/blueprints/tg.rb,
lib/pacer/transform/cap.rb,
lib/pacer/utils/y_files.rb,
lib/pacer/blueprints/dex.rb,
lib/pacer/transform/group.rb,
lib/pacer/transform/gather.rb,
lib/pacer/blueprints/neo4j.rb,
lib/pacer/core/side_effect.rb,
lib/pacer/graph/edge_mixin.rb,
lib/pacer/graph/index_mixin.rb,
lib/pacer/graph/graph_mixin.rb,
lib/pacer/filter/uniq_filter.rb,
lib/pacer/filter/loop_filter.rb,
lib/pacer/graph/vertex_mixin.rb,
lib/pacer/filter/block_filter.rb,
lib/pacer/filter/index_filter.rb,
lib/pacer/filter/empty_filter.rb,
lib/pacer/graph/element_mixin.rb,
lib/pacer/side_effect/counted.rb,
lib/pacer/filter/range_filter.rb,
lib/pacer/filter/future_filter.rb,
lib/pacer/utils/graph_analysis.rb,
lib/pacer/side_effect/aggregate.rb,
lib/pacer/transform/stream_uniq.rb,
lib/pacer/transform/stream_sort.rb,
lib/pacer/filter/property_filter.rb,
lib/pacer/side_effect/group_count.rb,
lib/pacer/filter/collection_filter.rb,
lib/pacer/filter/expression_filter.rb,
lib/pacer/graph/graph_transactions_mixin.rb,
lib/pacer/filter/expression_filter/parser.rb,
lib/pacer/extensions/block_filter_element.rb,
lib/pacer/filter/expression_filter/builder.rb

Defined Under Namespace

Modules: Core, EdgeMixin, ElementMixin, Extensions, Filter, GraphMixin, GraphTransactionsMixin, GraphTransactionsStub, IndexMixin, ManagedTransactionsMixin, Pipes, Routes, SideEffect, Support, Transform, Utils, VertexMixin Classes: EdgeWrapper, ElementExists, ElementNotFound, ElementWrapper, Group, NewElement, Route, TinkerEdge, TinkerGraph, TinkerIndex, TinkerVertex, UnsupportedOperation, VertexWrapper

Constant Summary

PATH =
File.expand_path(File.join(File.dirname(__FILE__), '..'))
VERSION =
File.read(PATH + '/VERSION').chomp
START_TIME =
Time.now
Enumerator =
Enumerable::Enumerator
DexGraph =
com.tinkerpop.blueprints.pgm.impls.dex.DexGraph
DexVertex =
com.tinkerpop.blueprints.pgm.impls.dex.DexVertex
DexEdge =
com.tinkerpop.blueprints.pgm.impls.dex.DexEdge
DexElement =
com.tinkerpop.blueprints.pgm.impls.dex.DexElement
DexAutomaticIndex =
com.tinkerpop.blueprints.pgm.impls.dex.DexAutomaticIndex
Neo4jGraph =
com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jGraph
Neo4jVertex =
com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex
Neo4jEdge =
com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge
Neo4jElement =
com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jElement
Neo4jIndex =
com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jIndex

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Class Attribute Details

+ (Object) debug_info

Returns the value of attribute debug_info



45
46
47
# File 'lib/pacer.rb', line 45

def debug_info
  @debug_info
end

+ (Object) debug_pipes (readonly)

Returns the value of attribute debug_pipes



172
173
174
# File 'lib/pacer.rb', line 172

def debug_pipes
  @debug_pipes
end

+ (Object) debug_source

Returns the value of attribute debug_source



171
172
173
# File 'lib/pacer.rb', line 171

def debug_source
  @debug_source
end

Class Method Details

+ (Object) automatic_index



146
147
148
# File 'lib/pacer.rb', line 146

def automatic_index
  com.tinkerpop.blueprints.pgm.Index::Type::AUTOMATIC
end

+ (Object) clear_plugin_cache

TODO make things register for these callbacks.



123
124
125
126
127
128
# File 'lib/pacer.rb', line 123

def clear_plugin_cache
  VertexWrapper.clear_cache
  EdgeWrapper.clear_cache
  Route::Helpers.clear_cache
  Filter::ExpressionFilter::Parser.reset
end

+ (Object) columns

Returns how many terminal columns we have.



92
93
94
# File 'lib/pacer.rb', line 92

def columns
  @columns || 150
end

+ (Object) columns=(n)

Tell the graph how many terminal columns we have.



97
98
99
# File 'lib/pacer.rb', line 97

def columns=(n)
  @columns = n
end

+ (Object) debug_pipe(pipe)



150
151
152
153
154
# File 'lib/pacer.rb', line 150

def debug_pipe(pipe)
  @debug_pipes = []
  result = pipe.send :iterator
  [debug_source, debug_pipes, result]
end

+ (Object) debug_pipe!



156
157
158
# File 'lib/pacer.rb', line 156

def debug_pipe!
  @debug_pipes = []
end

+ (Object) dex(path)

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).



14
15
16
17
18
19
# File 'lib/pacer/blueprints/dex.rb', line 14

def dex(path)
  path = File.expand_path(path)
  Pacer.starting_graph(self, path) do
    DexGraph.new(path)
  end
end

+ (Boolean) edge?(element)



136
137
138
139
140
# File 'lib/pacer.rb', line 136

def edge?(element)
  element.is_a? com.tinkerpop.blueprints.pgm.Edge
    (element.respond_to? :element and
     element.element.is_a? com.tinkerpop.blueprints.pgm.Edge)
end

+ (Object) edge_wrapper(*exts)



8
9
10
# File 'lib/pacer/wrappers.rb', line 8

def self.edge_wrapper(*exts)
  EdgeWrapper.wrapper_for(exts)
end

+ (Set) graphs_in_transaction

Collect a global set of graphs that are currently in a transaction.



7
8
9
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 7

def self.graphs_in_transaction
  @graphs ||= Set[]
end

+ (Object) hide_route_elements



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/pacer.rb', line 74

def hide_route_elements
  if block_given?
    if @hide_route_elements
      yield
    else
      begin
        @hide_route_elements = true
        yield
      ensure
        @hide_route_elements = false
      end
    end
  else
    @hide_route_elements
  end
end

+ (Object) hide_route_elements=(bool)

Set to true to prevent inspecting any route from printing the matching elements to the screen.



70
71
72
# File 'lib/pacer.rb', line 70

def hide_route_elements=(bool)
  @hide_route_elements = bool
end

+ (Object) inspect_limit

Returns how many matching items should be displayed by #inspect before we give up and display nothing but the route definition.



103
104
105
# File 'lib/pacer.rb', line 103

def inspect_limit
  @inspect_limit || 500
end

+ (Object) inspect_limit=(n)

Alter the inspect limit.



108
109
110
# File 'lib/pacer.rb', line 108

def inspect_limit=(n)
  @inspect_limit = n
end

+ (Object) manual_index



142
143
144
# File 'lib/pacer.rb', line 142

def manual_index
  com.tinkerpop.blueprints.pgm.Index::Type::MANUAL
end

+ (Object) neo4j(path, args = nil)

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).



14
15
16
17
18
19
20
21
22
23
# File 'lib/pacer/blueprints/neo4j.rb', line 14

def neo4j(path, args = nil)
  path = File.expand_path(path)
  Pacer.starting_graph(self, path) do
    if args
      Neo4jGraph.new(path, args.to_hash_map)
    else
      Neo4jGraph.new(path)
    end
  end
end

+ (Object) open_graphs



160
161
162
# File 'lib/pacer.rb', line 160

def open_graphs
  @open_graphs ||= Hash.new { |h, k| h[k] = {} }
end

+ (Object) reload!

Reload all Ruby modified files in the Pacer library. Useful for debugging in the console. Does not do any of the fancy stuff that Rails reloading does. Certain types of changes will still require restarting the session.



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/pacer.rb', line 56

def reload!
  require 'pathname'
  Pathname.new(File.expand_path(__FILE__)).parent.find do |path|
    if path.extname == '.rb' and path.mtime > reload_time
      puts path.to_s
      load path.to_s
    end
  end
  clear_plugin_cache
  @reload_time = Time.now
end

+ (Object) reload_time

Returns the time pacer was last reloaded (or when it was started).



48
49
50
# File 'lib/pacer.rb', line 48

def reload_time
  @reload_time || START_TIME
end

+ (Object) starting_graph(type, key)



164
165
166
167
168
169
# File 'lib/pacer.rb', line 164

def starting_graph(type, key)
  graph = open_graphs[type][key]
  return graph if graph
  graph = yield
  open_graphs[type][key] = graph
end

+ (Object) tg(path = nil)

Create a new TinkerGraph. If path is given, import the GraphML data from the file specified.



10
11
12
13
14
15
16
# File 'lib/pacer/blueprints/tg.rb', line 10

def self.tg(path = nil)
  graph = TinkerGraph.new
  if path
    graph.import(path)
  end
  graph
end

+ (Object) verbose=(v)



112
113
114
# File 'lib/pacer.rb', line 112

def verbose=(v)
  @verbose = v
end

+ (Boolean) verbose? Also known as: verbose



116
117
118
119
# File 'lib/pacer.rb', line 116

def verbose?
  @verbose = true if @verbose.nil?
  @verbose
end

+ (Boolean) vertex?(element)



130
131
132
133
134
# File 'lib/pacer.rb', line 130

def vertex?(element)
  element.is_a? com.tinkerpop.blueprints.pgm.Vertex or
    (element.respond_to? :element and
     element.element.is_a? com.tinkerpop.blueprints.pgm.Vertex)
end

+ (Object) vertex_wrapper(*exts)



4
5
6
# File 'lib/pacer/wrappers.rb', line 4

def self.vertex_wrapper(*exts)
  VertexWrapper.wrapper_for(exts)
end