diff --git a/language-guides/ruby/neo4jrb/Gemfile.lock b/language-guides/ruby/neo4jrb/Gemfile.lock new file mode 100644 index 00000000..6025dffd --- /dev/null +++ b/language-guides/ruby/neo4jrb/Gemfile.lock @@ -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 diff --git a/language-guides/ruby/neo4jrb/README.adoc b/language-guides/ruby/neo4jrb/README.adoc index 741decbe..bef153dd 100644 --- a/language-guides/ruby/neo4jrb/README.adoc +++ b/language-guides/ruby/neo4jrb/README.adoc @@ -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 diff --git a/language-guides/ruby/neo4jrb/config.ru b/language-guides/ruby/neo4jrb/config.ru index 02ba03bd..adc155eb 100644 --- a/language-guides/ruby/neo4jrb/config.ru +++ b/language-guides/ruby/neo4jrb/config.ru @@ -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 diff --git a/language-guides/ruby/neo4jrb/models.rb b/language-guides/ruby/neo4jrb/models.rb index 92dca366..b0011f7a 100644 --- a/language-guides/ruby/neo4jrb/models.rb +++ b/language-guides/ruby/neo4jrb/models.rb @@ -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 diff --git a/language-guides/ruby/neo4jrb/movies.rb b/language-guides/ruby/neo4jrb/movies.rb index 51ca835f..d1358bba 100644 --- a/language-guides/ruby/neo4jrb/movies.rb +++ b/language-guides/ruby/neo4jrb/movies.rb @@ -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