A simple, ready to go JRuby wrapper for the Neo4j graph database engine.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin added more flexible command line inteface Dec 21, 2009
lib Updated neo4j libs to 1.0 May 3, 2010
spec Updated neo4j libs to 1.0 May 3, 2010
.document Initial commit to neo4jr-simple. Dec 19, 2009
.gitignore upgrading to neo4j RC1 apoc jars Jan 25, 2010
LICENSE Initial commit to neo4jr-simple. Dec 19, 2009
README.rdoc
Rakefile fixed bug with VERSION Jan 13, 2010
VERSION
neo4jr-simple.gemspec Regenerated gemspec for version 0.2.2 Jun 6, 2010

README.rdoc

neo4jr-simple

A simple, ready to go JRuby wrapper for the Neo4j graph database engine which provides:

  • The Neo4j Core Java Library (required and ready to use)

  • Raw access to the Java API (using Neo4j::DB.instance )

  • Extensions to the Java API to make node manipulation and traversal more rubyesque

  • Working specs

  • Loaded Neo4j sample database with IMDB data

  • Nothing more then Neo4j goodness

Prerequisites

  • Java

  • JRuby

Recommend way of installing JRuby

  1. Install RVM: rvm.beginrescueend.com/

  2. Install Jruby using rvm: rvm install jruby

  3. Switch ruby to JRuby: rvm use jruby

Getting Started

Basic Node creation:

Neo4jr::DB.execute do |neo|
  node = neo.createNode
  node[:name] = 'Deiters, Matt'
end

Retrieve a Node:

Neo4jr::DB.execute do |neo|
  node = neo.getNodeById(1234)
end

Find a Node by some value you control:

Neo4jr::DB.execute do |neo|
  # If you add a property 'identifier' to a node, the value can be used to retrieve the node by
  # This can by an id or string but the value must be unique to this node
  # e.g. node[:identifier] = user.id
  node = neo.find_node_by_identifier(user.id)
end

Traverse Database from a node:

Neo4jr::DB.execute do |neo|
  philip_seymour_hoffman = neo.getNodeById(1102)

  order         = Neo4jr::Order::BREADTH_FIRST
  stop_when     = Neo4jr::StopEvaluator::END_OF_GRAPH
  return_when   = Neo4jr::ReturnableEvaluator::ALL
  relationships = Neo4jr::RelationshipType.outgoing(:acted_in)

  traverser = philip_seymour_hoffman.traverse(order, stop_when, return_when, relationships)
  traverser.each do |node|
    #...
  end
end

Use command line shell to query and modify the graph:

neosh -path <path_to_neo_db>

Contributors

https://github.com/mdeiters
https://github.com/klobuczek  
https://github.com/gregormelhorn

Copyright © 2009 Matthew Deiters. See LICENSE for details.