Skip to content

Commit

Permalink
Merge pull request neo4j-documentation#70 from neo4jrb/gh-pages
Browse files Browse the repository at this point in the history
Update neo4j.rb project to work with Neo4j 2.2 and do some cleanup
  • Loading branch information
jexp committed Apr 10, 2015
2 parents 8aa34c1 + 286e5bb commit 7e04d99
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 13 deletions.
117 changes: 117 additions & 0 deletions language-guides/ruby/neo4jrb/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
GEM
remote: https://rubygems.org/
specs:
actionpack (4.2.1)
actionview (= 4.2.1)
activesupport (= 4.2.1)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.1)
activesupport (= 4.2.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
active_attr (0.8.5)
activemodel (>= 3.0.2, < 5.0)
activesupport (>= 3.0.2, < 5.0)
activemodel (4.2.1)
activesupport (= 4.2.1)
builder (~> 3.1)
activesupport (4.2.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
builder (3.2.2)
coderay (1.1.0)
erubis (2.7.0)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1)
faraday (>= 0.7.4, < 0.10)
httparty (0.13.3)
json (~> 1.8)
multi_xml (>= 0.5.2)
httpclient (2.6.0.1)
i18n (0.7.0)
json (1.8.2)
loofah (2.0.1)
nokogiri (>= 1.5.9)
method_source (0.8.2)
mini_portile (0.6.2)
minitest (5.5.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
neo4j (3.0.4)
active_attr (~> 0.8)
activemodel (~> 4)
activesupport (~> 4)
neo4j-core (~> 3.0.8)
orm_adapter (~> 0.5.0)
railties (~> 4)
neo4j-community (2.1.7)
neo4j-core (3.0.8)
activesupport
faraday (~> 0.9.0)
faraday_middleware (~> 0.9.1)
httparty
httpclient
json
neo4j-community (~> 2.1.1)
net-http-persistent
os
zip
net-http-persistent (2.9.4)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
orm_adapter (0.5.0)
os (0.9.6)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.0)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.1)
actionpack (= 4.2.1)
activesupport (= 4.2.1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
shotgun (0.9.1)
rack (>= 1.0)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slop (3.6.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
zip (2.0.2)

PLATFORMS
ruby

DEPENDENCIES
neo4j (~> 3.0.1)
pry
shotgun
sinatra
4 changes: 2 additions & 2 deletions language-guides/ruby/neo4jrb/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ This example demonstrates how to map node and relationships to Ruby classes.

## How to run

`bundle exec rackup config.ru`
`NEO4J_USERNAME=username NEO4J_PASSWORD=password bundle exec rackup config.ru`

or 'bundle exec shotgun config.ru'
or 'NEO4J_USERNAME=username NEO4J_PASSWORD=password bundle exec shotgun config.ru'


## Design
Expand Down
4 changes: 0 additions & 4 deletions language-guides/ruby/neo4jrb/config.ru
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
require File.join(File.dirname(__FILE__), 'movies')

map "/index.html" do
run Rack::File.new("./static/index.html")
end

run Sinatra::Application
4 changes: 2 additions & 2 deletions language-guides/ruby/neo4jrb/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class Movie
id_property :title
property :released
property :tagline
has_many :in, :actors, model_class: :Person, rel_class: Engagement
has_many :in, :actors, model_class: :Person, rel_class: 'Engagement'
has_many :in, :directors, model_class: :Person, type: :DIRECTED
end

class Person
include Neo4j::ActiveNode
id_property :name
has_many :out, :acted_in, model_class: :Movie, rel_class: Engagement
has_many :out, :acted_in, model_class: :Movie, rel_class: 'Engagement'
has_many :out, :directed, model_class: :Movie, type: :DIRECTED
end

10 changes: 5 additions & 5 deletions language-guides/ruby/neo4jrb/movies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

set :public_folder, File.dirname(__FILE__) + '/static'

Neo4j::Session.open

# We need to cache the label name as a _classname property in order to get better performance
Neo4j::Session.query("MATCH (p:Person)-[r:`ACTED_IN`]->(m:Movie) SET p._classname = 'Person', r._classname = 'Engagement', m._classname = 'Movie'")
neo4j_url = ENV['NEO4J_URL'] || 'http://localhost:7474'
neo4j_username = ENV['NEO4J_USERNAME']
neo4j_password = ENV['NEO4J_PASSWORD']

Neo4j::Session.open(:server_db, neo4j_url, basic_auth: {username: neo4j_username, password: neo4j_password})

get '/' do
redirect '/index.html'
File.read(File.join(File.dirname(__FILE__), 'static/index.html'))
end

get '/graph' do
Expand Down

0 comments on commit 7e04d99

Please sign in to comment.