Permalink
Browse files

Initial work

  • Loading branch information...
1 parent 8452eb9 commit 2e90479f5634ab92043094600c2c1b073dc65b6a Darrick Wiebe committed Oct 3, 2011
View
@@ -1,9 +1,40 @@
require "pacer-neo4j-algo/version"
+require 'neo4j'
+require 'pacer-neo4j'
module Pacer
module Neo4j
module Algo
- # Your code goes here...
+ # Returns the time pacer-zmq was last reloaded (or when it was started).
+ class << self
+ def reload_time
+ if defined? @reload_time
+ @reload_time
+ else
+ START_TIME
+ end
+ end
+
+ # Reload all Ruby modified files in the pacer-zmq 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.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
+ @reload_time = Time.now
+ end
+
+ end
end
end
end
+
+require 'pacer-neo4j-algo/support/neo4j_traverser'
+require 'pacer-neo4j-algo/traversal'
+require 'pacer-neo4j-algo/traversal_pipe'
@@ -0,0 +1,7 @@
+module Neo4j
+ module Traversal
+ class Traverser
+ attr_accessor :from
+ end
+ end
+end
@@ -0,0 +1,30 @@
+module Pacer::Neo4j::Algo
+ module Traversal
+ module RouteMixin
+ def traversal(&block)
+ chain_route transform: Traversal, block: block
+ end
+ end
+
+ attr_reader :traverser
+
+ def after_initialize
+ raise ArgumentError, 'traversal route must have a block' unless @block
+ end
+
+ def block=(block)
+ @block = block
+ end
+
+ def attach_pipe(end_pipe)
+ TraversalPipe.new(graph, @block).tap do |pipe|
+ pipe.setStarts end_pipe if end_pipe
+ end
+ end
+ end
+end
+
+module Pacer::Core::Graph::VerticesRoute
+ include Pacer::Neo4j::Algo::Traversal::RouteMixin
+end
+
@@ -0,0 +1,33 @@
+module Pacer::Neo4j::Algo
+ class TraversalPipe < Pacer::Pipes::RubyPipe
+ def initialize(graph, block)
+ @graph = graph
+ @block = block
+ reset
+ end
+
+ def processNextStart
+ prepare_traverser unless @iterator
+ begin
+ vertex = @iterator.next
+ Pacer::Neo4jVertex.new(vertex, @graph)
+ rescue StopIteration
+ prepare_traverser
+ retry
+ end
+ end
+
+ def reset
+ @traverser = ::Neo4j::Traversal::Traverser.new(nil)
+ @block.call(@traverser)
+ @iterator = nil
+ end
+
+ private
+
+ def prepare_traverser
+ @traverser.from = starts.next.getRawElement
+ @iterator = @traverser.iterator.to_enum
+ end
+ end
+end
@@ -2,6 +2,9 @@ module Pacer
module Neo4j
module Algo
VERSION = "0.0.1"
+ NEO4J_VERSION = "1.2.3"
+ PACER_NEO4J_VERSION = "1.0.7"
+ START_TIME = Time.now
end
end
end
View
@@ -5,20 +5,24 @@ require "pacer-neo4j-algo/version"
Gem::Specification.new do |s|
s.name = "pacer-neo4j-algo"
s.version = Pacer::Neo4j::Algo::VERSION
+ s.platform = 'java'
s.authors = ["Darrick Wiebe"]
- s.email = ["darrick@innatesoftware.com"]
+ s.email = ["dw@xnlogic.com"]
s.homepage = ""
- s.summary = %q{TODO: Write a gem summary}
- s.description = %q{TODO: Write a gem description}
+ s.summary = %q{Neo4J-specific algorithms and features integrated into Pacer}
+ s.description = %q{}
s.rubyforge_project = "pacer-neo4j-algo"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
# specify any dependencies here; for example:
- # s.add_development_dependency "rspec"
- # s.add_runtime_dependency "rest-client"
+ s.add_development_dependency "rspec"
+ s.add_development_dependency "pry"
+ s.add_development_dependency "awesome_print"
+
+ s.add_dependency "pacer-neo4j", Pacer::Neo4j::Algo::PACER_NEO4J_VERSION
+ s.add_dependency "neo4j", Pacer::Neo4j::Algo::NEO4J_VERSION
end

0 comments on commit 2e90479

Please sign in to comment.