0.01
No commit activity in last 3 years
No release in over 3 years
A simple, ready to go JRuby wrapper for the Neo4j graph database engine. Nothing more then Neo4j and Ruby goodness
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9
 Project Readme

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.