Browse files

Avoid jruby warning by using Java Adaptor to call the PathEvaluator#e…

  • Loading branch information...
1 parent 27bffe8 commit 7691af552fd871d5a724fc8211b8ba806a6792ed @andreasronge andreasronge committed Dec 27, 2012
View
26 Rakefile
@@ -4,16 +4,30 @@ require "bundler/gem_tasks"
require 'rspec/core/rake_task'
#FileList = Rake::FileList
+def jar_path
+ spec = Gem::Specification.find_by_name("neo4j-community")
+ gem_root = spec.gem_dir
+ gem_root + "/lib/neo4j-community/jars"
+end
+
desc "Run all specs"
RSpec::Core::RakeTask.new("spec") do |t|
t.rspec_opts = ["-c"]
end
-#Rcov::RcovTask.new do |t|
-# t.libs << "spec"
-# t.test_files = Rake::FileList['spec/**/*_spec.rb']
-# t.verbose = true
-#end
-
+desc "Compile neo4jrb-adaptor.jar"
+task 'build-java' do
+ sh <<-END
+ rm -rf target
+ rm lib/neo4j-core/jars/neo4jrb-adaptor.jar
+ mkdir target
+ javac -d target -classpath $(echo #{jar_path}/*.jar | tr ' ' ':') java/neo4j/rb/Adaptor.java
+ jar cvf lib/neo4j-core/jars/neo4jrb-adaptor.jar -C target neo4j
+ rm -rf target
+ END
+end
+task 'bla' do
+ puts "GEM LIB #{gem_lib}"
+end
task :default => 'spec'
View
26 java/neo4j/rb/Adaptor.java
@@ -0,0 +1,26 @@
+package neo4j.rb;
+
+import org.neo4j.graphdb.PathExpander;
+import org.neo4j.graphdb.traversal.Evaluator;
+import org.neo4j.graphdb.traversal.PathEvaluator;
+import org.neo4j.graphdb.traversal.TraversalDescription;
+
+/**
+ * Since we can't call the Java method from JRuby we do it here instead.
+ * see https://groups.google.com/forum/?fromgroups#!topic/jruby-users/gUrc5pBfCiM
+ */
+public class Adaptor {
+
+ public static TraversalDescription callEvaluator(TraversalDescription td, Evaluator evaluator) {
+ return td.evaluator(evaluator);
+ }
+
+ public static TraversalDescription callPathEvaluator(TraversalDescription td, PathEvaluator evaluator) {
+ return td.evaluator(evaluator);
+ }
+
+ public static TraversalDescription expandPath(TraversalDescription td, PathExpander expander) {
+ return td.expand(expander);
+ }
+
+}
View
1 lib/neo4j-core.rb
@@ -6,6 +6,7 @@ module Neo4j
Enumerator = Enumerable::Enumerator unless defined? Enumerator
end
+require 'neo4j-core/jars/neo4jrb-adaptor.jar'
require 'set'
require 'neo4j-cypher'
View
BIN lib/neo4j-core/jars/neo4jrb-adaptor.jar
Binary file not shown.
View
3 lib/neo4j-core/traversal/traverser.rb
@@ -239,7 +239,8 @@ def both(type)
# @return self
# @see Neo4j::Core::Traversal#expand
def expander(&expander)
- @td = @td.expand(RelExpander.create_pair(&expander))
+ exp = RelExpander.create_pair(&expander)
+ @td = Java::Neo4jRb::Adaptor.expandPath(@td.java_object, exp)
self
end

0 comments on commit 7691af5

Please sign in to comment.