Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added neo4j sample app

  • Loading branch information...
commit e90289a9596e6c6e9b7179b51463d3736749bd7a 1 parent 0550e5d
@jexp jexp authored
View
3  apps/neo4j_app/Gemfile
@@ -0,0 +1,3 @@
+source "http://rubygems.org"
+gem 'neography'
+gem 'sinatra'
View
22 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
View
34 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
Please sign in to comment.
Something went wrong with that request. Please try again.