Skip to content

Commit

Permalink
added neo4j sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
jexp committed May 13, 2011
1 parent 0550e5d commit e90289a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/neo4j_app/Gemfile
@@ -0,0 +1,3 @@
source "http://rubygems.org"
gem 'neography'
gem 'sinatra'
22 changes: 22 additions & 0 deletions apps/neo4j_app/Gemfile.lock
@@ -0,0 +1,22 @@
GEM
remote: http://rubygems.org/
specs:
crack (0.1.8)
httparty (0.7.7)
crack (= 0.1.8)
json (1.5.1)
neography (0.0.13)
httparty (~> 0.7.3)
json
rack (1.2.2)
sinatra (1.2.6)
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
tilt (1.3)

PLATFORMS
ruby

DEPENDENCIES
neography
sinatra
34 changes: 34 additions & 0 deletions apps/neo4j_app/neo4j.rb
@@ -0,0 +1,34 @@
require 'rubygems'
require 'sinatra'
require 'neography'

include Neography

before do
if ENV['VCAP_SERVICES']
services = ENV['VCAP_SERVICES']
neo4j = services['neo4j-1.4'][0]['credentials']
else
neo4j = {}
end

Neography::Config.server = neo4j['hostname'] || 'localhost'
Neography::Config.port = (ENV['port'] || "7474").to_i
Neography::Config.authentication = 'basic'
Neography::Config.username = ENV['username']||"test"
Neography::Config.password = ENV['password']||"test"

@neo = Rest.new
puts @neo.configuration
@root = Node.load(0)
end

get '/' do
node = Node.create("answer" => 42, "question" => "All")
@root.outgoing(:ANSWER) << node

"<h1>Answers from Neo4j!</h1>" +
"<dl>" +
@root.outgoing(:ANSWER).collect { |n| "<dt>Question: #{n.question}</dt><dd>Answer: #{n.answer}</dd>"}.join +
"</dl>"
end

0 comments on commit e90289a

Please sign in to comment.