Module: Pacer

Defined in:
lib/pacer.rb,
lib/pacer.rb,
lib/pacer/pipes.rb,
lib/pacer/utils.rb,
lib/pacer/route.rb,
lib/pacer/loader.rb,
lib/pacer/version.rb,
lib/pacer/core/graph.rb,
lib/pacer/core/route.rb,
lib/pacer/exceptions.rb,
lib/pacer/utils/tsort.rb,
lib/pacer/blueprints/tg.rb,
lib/pacer/transform/map.rb,
lib/pacer/route_builder.rb,
lib/pacer/transform/cap.rb,
lib/pacer/utils/y_files.rb,
lib/pacer/graph/graph_ml.rb,
lib/pacer/transform/path.rb,
lib/pacer/transform/join.rb,
lib/pacer/core/hash_route.rb,
lib/pacer/pipe/naked_pipe.rb,
lib/pacer/transform/reduce.rb,
lib/pacer/transform/branch.rb,
lib/pacer/transform/gather.rb,
lib/pacer/visitors/section.rb,
lib/pacer/core/side_effect.rb,
lib/pacer/core/array_route.rb,
lib/pacer/transform/process.rb,
lib/pacer/graph/pacer_graph.rb,
lib/pacer/pipe/visitor_pipe.rb,
lib/pacer/function_resolver.rb,
lib/pacer/transform/scatter.rb,
lib/pacer/core/string_route.rb,
lib/pacer/transform/identity.rb,
lib/pacer/side_effect/as_var.rb,
lib/pacer/transform/flat_map.rb,
lib/pacer/transform/parallel.rb,
lib/pacer/pipe/wrapping_pipe.rb,
lib/pacer/graph/yaml_encoder.rb,
lib/pacer/filter/uniq_filter.rb,
lib/pacer/filter/loop_filter.rb,
lib/pacer/filter/range_filter.rb,
lib/pacer/filter/where_filter.rb,
lib/pacer/filter/block_filter.rb,
lib/pacer/transform/path_tree.rb,
lib/pacer/filter/empty_filter.rb,
lib/pacer/side_effect/visitor.rb,
lib/pacer/side_effect/counted.rb,
lib/pacer/filter/uniq_section.rb,
lib/pacer/filter/index_filter.rb,
lib/pacer/filter/future_filter.rb,
lib/pacer/transform/lookup_ids.rb,
lib/pacer/utils/graph_analysis.rb,
lib/pacer/pipe/unwrapping_pipe.rb,
lib/pacer/transform/make_pairs.rb,
lib/pacer/filter/object_filter.rb,
lib/pacer/filter/random_filter.rb,
lib/pacer/graph/simple_encoder.rb,
lib/pacer/transform/stream_sort.rb,
lib/pacer/transform/stream_uniq.rb,
lib/pacer/side_effect/is_unique.rb,
lib/pacer/side_effect/aggregate.rb,
lib/pacer/transform/sort_section.rb,
lib/pacer/filter/property_filter.rb,
lib/pacer/transform/wrapped_path.rb,
lib/pacer/visitors/visits_section.rb,
lib/pacer/transform/count_section.rb,
lib/pacer/blueprints/group_vertex.rb,
lib/pacer/filter/java_loop_filter.rb,
lib/pacer/transform/has_count_cap.rb,
lib/pacer/pipe/path_wrapping_pipe.rb,
lib/pacer/side_effect/group_count.rb,
lib/pacer/transform/gather_section.rb,
lib/pacer/filter/collection_filter.rb,
lib/pacer/pipe/simple_visitor_pipe.rb,
lib/pacer/filter/limit_section_filter.rb,
lib/pacer/blueprints/payload_elements.rb,
lib/pacer/transform/intersect_sections.rb,
lib/pacer/filter/property_filter/filters.rb,
lib/pacer/graph/graph_transactions_mixin.rb,
lib/pacer/wrappers/wrapping_pipe_function.rb,
lib/pacer/filter/where_filter/node_visitor.rb,
lib/pacer/filter/property_filter/edge_filters.rb,
lib/pacer/wrappers/path_wrapping_pipe_function.rb

Defined Under Namespace

Modules: Core, Filter, FunctionResolver, Graph, GraphTransactionsMixin, Payload, Pipes, Routes, SideEffect, Support, Transform, Utils, Visitors, Wrappers Classes: ClientError, ElementExists, ElementNotFound, Error, GraphML, GroupVertex, InternalError, LogicError, MockTransactionRollback, NestedMockTransactionRollback, NestedTransactionError, NestedTransactionRollback, PacerGraph, Route, RouteBuilder, SimpleEncoder, TransactionConcludedError, TransactionError, TransientError, UnsupportedOperation, UserError, YamlEncoder

Constant Summary collapse

PATH =
File.expand_path(File.join(File.dirname(__FILE__), '..'))
EmptyPipe =
com.tinkerpop.pipes.util.FastNoSuchElementException
VERSION =
"2.0.24"
START_TIME =
Time.now

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.debug_infoObject

A global place for pacer to put debug info if it's tucked deep in its internals. Should typically not be used unless a mysterious bug needs to be analyzed but that never really happens ;)



73
74
75
# File 'lib/pacer.rb', line 73

def debug_info
  @debug_info
end

.debug_pipesObject (readonly)

Used internally to collect debug information while using #debug_pipe



275
276
277
# File 'lib/pacer.rb', line 275

def debug_pipes
  @debug_pipes
end

.debug_sourceObject

Used internally to collect debug information while using #debug_pipe



272
273
274
# File 'lib/pacer.rb', line 272

def debug_source
  @debug_source
end

Class Method Details

.clear_plugin_cacheObject

TODO:

reimpliment as callbacks to keep the code all in one place.

Clear all cached data that may become invalid when #reload! is called.



192
193
194
195
196
# File 'lib/pacer.rb', line 192

def clear_plugin_cache
  Wrappers::VertexWrapper.clear_cache
  Wrappers::EdgeWrapper.clear_cache
  FunctionResolver.clear_cache
end

.close_all_open_graphsObject



260
261
262
263
264
265
266
267
268
# File 'lib/pacer.rb', line 260

def close_all_open_graphs
  open_graphs.each do |path, graph|
    begin
      graph.shutdown
    rescue Exception, StandardError => e
      puts "Exception on graph shutdown: #{ e.class } #{ e.message }\n\n#{e.backtrace.join "\n" }"
    end
  end
end

.columnsFixnum

Returns how many terminal columns we have.

Returns:

  • (Fixnum)

    number of terminal columns



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

def columns
  if defined? @columns
    @columns
  else
    150
  end
end

.columns=(n) ⇒ Object

Tell Pacer how many terminal columns we have so it can print elements out in nice columns.

Parameters:

  • n (Fixnum)

    number of terminal columns



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

def columns=(n)
  @columns = n
end

.debug_pipe(pipe) ⇒ [java.util.Iterator, Array<Hash>, com.tinkerpop.pipes.Pipe]

If a pipe is giving you trouble, you can get all of the intermediate pipes by using this method.

Each returned pipe can be iterated with it's #next method to see what it would have returned if it were the end pipe.

Examples:

how to use it:

Pacer.debug_pipe(graph.v.out_e)

Returns:

  • ([java.util.Iterator, Array<Hash>, com.tinkerpop.pipes.Pipe])

    the iterator is the data source. Each Hash in the array is information about one pipe in the pipeline that was created. These are in order of creation, not necessarily of attachment. However the hash will contain what pipe was used as the source for the given pipe along with all arguments used to create the pipe as well as other information if it seemed useful.



242
243
244
245
246
# File 'lib/pacer.rb', line 242

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

.debug_pipe!Object



248
249
250
# File 'lib/pacer.rb', line 248

def debug_pipe!
  @debug_pipes = []
end

.edge?(element) ⇒ Boolean

Is the object an edge?

Returns:

  • (Boolean)


212
213
214
# File 'lib/pacer.rb', line 212

def edge?(element)
  element.is_a? Pacer::Wrappers::EdgeWrapper
end

.edge_route?(obj) ⇒ Boolean Also known as: edges_route?

Returns:

  • (Boolean)


221
222
223
# File 'lib/pacer.rb', line 221

def edge_route?(obj)
  obj.is_a? Pacer::Core::Graph::EdgesRoute
end

.edge_wrapper(*exts) ⇒ Object



202
203
204
# File 'lib/pacer.rb', line 202

def edge_wrapper(*exts)
  Wrappers::EdgeWrapper.wrapper_for(exts)
end

.executing_route(route) ⇒ Object



184
185
186
# File 'lib/pacer.rb', line 184

def executing_route(route)
  # override this if you want to know when a pipeline is about to be built.
end

.help(section = nil) ⇒ Object



66
67
68
# File 'lib/pacer.rb', line 66

def help(section = nil)
  Pacer.tg.help section
end

.hide_route_elements { ... } ⇒ true, false

TODO:

don't use negative method names.

Returns whether elements should be displayed. Also yields, temporarily setting the value to true to prevent a route containing routes from printing the contained routes' elements or going recursive if the route were to somehow contain itself.

Yields:

  • print elements while inside this block

Returns:

  • (true, false)

    should you not print elemets?



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/pacer.rb', line 115

def hide_route_elements
  @hide_route_elements = nil unless defined? @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

.hide_route_elements=(bool) ⇒ Object

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



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

def hide_route_elements=(bool)
  @hide_route_elements = bool
end

.inspect_limitFixnum

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

Returns:

  • (Fixnum)

    maximum number of elements to display



153
154
155
156
157
158
159
# File 'lib/pacer.rb', line 153

def inspect_limit
  if defined? @inspect_limit
    @inspect_limit
  else
    500
  end
end

.inspect_limit=(n) ⇒ Object

Set the maximum number of elements to print on the screen when inspecting a route.

Parameters:

  • n (Fixnum)

    maximum number of elements to display



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

def inspect_limit=(n)
  @inspect_limit = n
end

.open_graphsHash

All of the currently open graphs that are tied to the filesystem or a url or address.

Returns:

  • (Hash)

    address => graph



255
256
257
258
# File 'lib/pacer.rb', line 255

def open_graphs
  @open_graphs = {} unless defined? @open_graphs
  @open_graphs
end

.reload!Object

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.



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/pacer.rb', line 88

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

.reload_timeObject

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



76
77
78
79
80
81
82
# File 'lib/pacer.rb', line 76

def reload_time
  if defined? @reload_time
    @reload_time
  else
    START_TIME
  end
end

.tg(path = nil) ⇒ Object

Create a new TinkerGraph. If path is given, use Tinkergraph in its standard simple persistant mode.



6
7
8
9
10
11
12
# File 'lib/pacer/blueprints/tg.rb', line 6

def self.tg(path = nil)
  if path
    PacerGraph.new SimpleEncoder, TinkerGraph.new(path)
  else
    PacerGraph.new SimpleEncoder, TinkerGraph.new
  end
end

.verbose=(v) ⇒ Object

Set Pacer's general verbosity.

Parameters:

  • default (:very, true, false)

    is true, :very is more verbose, false is quiet



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

def verbose=(v)
  @verbose = v
end

.verbose?:very, ... Also known as: verbose

Current verbosity setting

Returns:

  • (:very, true, false)


177
178
179
180
181
# File 'lib/pacer.rb', line 177

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

.vertex?(element) ⇒ Boolean

Is the object a vertex?

Returns:

  • (Boolean)


207
208
209
# File 'lib/pacer.rb', line 207

def vertex?(element)
  element.is_a? Pacer::Wrappers::VertexWrapper
end

.vertex_route?(obj) ⇒ Boolean Also known as: vertices_route?

Returns:

  • (Boolean)


216
217
218
# File 'lib/pacer.rb', line 216

def vertex_route?(obj)
  obj.is_a? Pacer::Core::Graph::VerticesRoute
end

.vertex_wrapper(*exts) ⇒ Object



198
199
200
# File 'lib/pacer.rb', line 198

def vertex_wrapper(*exts)
  Wrappers::VertexWrapper.wrapper_for(exts)
end