Skip to content

Repository files navigation

Keymaker

Build StatusCode Climate

A multi-layer REST API Ruby wrapper for the Neo4j graph database built on top of Faraday.

  • Layer 1 interacts with the Neo4j REST API raw requests
  • Layer 2 binds the raw HTTP requests into Ruby Objects
  • Layer 3 implements ActiveModel and treats Nodes and Relationships as Ruby Objects
Oracle: Our time is up. Listen to me, Neo.
You can save Zion if you reach The Source,
but to do that you will need the Keymaker.
Neo: The Keymaker?

Installation

Install and start the Neo4j server:

rakeneo4j:installrakeneo4j:start# optionally for testingrakeneo4j:installRAILS_ENV=testrakeneo4j:startRAILS_ENV=test

Add this line to your application's Gemfile:

gem"keymaker"

And then execute:

$ bundle

Usage

Configuration

Create a config/neo4j.yml file:

development:
server: localhostport: 7474test:
server: localhostport: 7475

Then, create a Rails initializer config/initializers/keymaker.rb:

ifRails.env.development? || Rails.env.test?database_config=YAML::load_file("config/neo4j.yml")Keymaker.configuredo |c|
c.server=database_config["#{Rails.env}"]["server"]c.port=database_config["#{Rails.env}"]["port"]endelse# Heroku neo4j add-onKeymaker.configuredo |c|
c.server=ENV["NEO4J_HOST"]c.port=ENV["NEO4J_PORT"]c.username=ENV["NEO4J_LOGIN"]c.password=ENV["NEO4J_PASSWORD"]endend

Low-level REST API Calls

Keymaker.configuredo |c|
c.server="localhost"c.port=7474end## Create a node ##terminator_response=Keymaker.service.create_node_request({:name=>"Terminator",:catch_phrase=>"I'll be back"})terminator=Keymaker.service.get_node(terminator_response.neo4j_id)john_response=Keymaker.service.create_node_request({:name=>"John Connor",:catch_phrase=>"No problemo"})john_connor=Keymaker.service.get_node(john_response.neo4j_id)john_connor.name# => "John Connor"john_connor.catch_phrase# => "No problemo"## Update node properties ##Keymaker.service.update_node_properties_request({:node_id=>john_connor.neo4j_id,:catch_phrase=>"Easy money!"})john_connor.catch_phrase# => "Easy money!"## Delete a node ##Keymaker.service.delete_node_request({:node_id=>john_connor.neo4j_id})Keymaker.service.get_node_request({:node_id=>john_connor.neo4j_id})# => Keymaker::ResourceNotFound raised## Create a relationship ##rel=Keymaker.service.create_relationship_request({:node_id=>john_connor.neo4j_id,:end_node_id=>terminator.neo4j_id,:rel_type=>"knows",:data=>{:since=>"Summer of 1984"})## Delete a relationship ##Keymaker.service.delete_relationship_request(:relationship_id=>rel.neo4j_id)

Nodes

Coming soon

Relationships

Coming soon

Indices

Coming soon

Querying

Coming soon

Contributing

  1. Fork it
  2. Create a feature branch (git checkout -b my_new_feature)
  3. Write passing tests!
  4. Commit your changes (git commit -v)
  5. Push to the branch (git push origin my_new_feature)
  6. Create new Pull Request

TODO:

  • Test coverage
  • Contributing documentation (installing neo4j, etc).
  • Documentation

Acknowledgements

  • Avdi Grimm
  • Micah Cooper
  • Stephen Caudill
  • Travis Anderson

Copyright

Copyright (c) 2012 Rogelio J. Samour See LICENSE for details.

About

A multi-layer REST API Ruby wrapper for the neo4j graph database.

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages