forked from pangloss/pacer
/
pacer.rb
111 lines (89 loc) · 2.68 KB
/
pacer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
require 'java'
require 'pp'
module Pacer
unless const_defined? :VERSION
VERSION = '0.1.0'
PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
$:.unshift File.join(PATH, 'lib')
unless require(File.join(PATH, 'vendor/pipes-0.2-SNAPSHOT-standalone.jar'))
STDERR.puts "Please build the pipes library from tinkerpop.com and place the jar in the vendor folder of this library."
exit 1
end
START_TIME = Time.now
require File.join(PATH, 'vendor/blueprints-neo4j-adapter-0.1-SNAPSHOT-standalone.jar')
require File.join(PATH, 'vendor/neo4j-lucene-index-0.2-1.2.M05.jar')
end
require 'pacer/graph'
require 'pacer/pipes'
require 'pacer/routes'
require 'pacer/neo4j'
require 'pacer/tg'
require 'pacer/support'
require 'pacer/utils'
class << self
attr_accessor :debug_info
# Returns the time pacer was last reloaded (or when it was started).
def reload_time
@reload_time || START_TIME
end
# 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.
def reload!
require 'pathname'
Pathname.new(__FILE__).parent.find do |path|
if path.extname == '.rb' and path.mtime > reload_time
puts path.to_s
load path.to_s
end
end
@reload_time = Time.now
end
# Set to true to prevent inspecting any route from printing
# the matching elements to the screen.
def hide_route_elements=(bool)
@hide_route_elements = bool
end
def hide_route_elements
@hide_route_elements
end
# Returns how many terminal columns we have.
def columns
@columns || 150
end
# Tell the graph how many terminal columns we have.
def columns=(n)
@columns = n
end
# Returns how many matching items should be displayed by #inspect before we
# give up and display nothing but the route definition.
def inspect_limit
@inspect_limit || 500
end
# Alter the inspect limit.
def inspect_limit=(n)
@inspect_limit = n
end
def verbose=(v)
@verbose = v
end
def verbose?
@verbose = true if @verbose.nil?
@verbose
end
alias verbose verbose?
def vertex?(element)
element.is_a? com.tinkerpop.blueprints.pgm.Vertex
end
def edge?(element)
element.is_a? com.tinkerpop.blueprints.pgm.Edge
end
def manual_index
com.tinkerpop.blueprints.pgm.Index::Type::MANUAL
end
def automatic_index
com.tinkerpop.blueprints.pgm.Index::Type::AUTOMATIC
end
end
end