neography-ajaycb 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/.project +12 -0
- data/.travis.yml +1 -0
- data/CONTRIBUTORS +12 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +39 -0
- data/LICENSE +19 -0
- data/README.rdoc +350 -0
- data/Rakefile +15 -0
- data/examples/facebook.rb +40 -0
- data/examples/facebook_v2.rb +25 -0
- data/examples/greatest.rb +43 -0
- data/examples/linkedin.rb +39 -0
- data/examples/linkedin_v2.rb +22 -0
- data/examples/traversal_example1.rb +65 -0
- data/examples/traversal_example2.rb +54 -0
- data/lib/neography.rb +46 -0
- data/lib/neography/config.rb +17 -0
- data/lib/neography/equal.rb +21 -0
- data/lib/neography/index.rb +13 -0
- data/lib/neography/neography.rb +10 -0
- data/lib/neography/node.rb +45 -0
- data/lib/neography/node_path.rb +29 -0
- data/lib/neography/node_relationship.rb +35 -0
- data/lib/neography/node_traverser.rb +142 -0
- data/lib/neography/path_traverser.rb +94 -0
- data/lib/neography/property.rb +53 -0
- data/lib/neography/property_container.rb +17 -0
- data/lib/neography/railtie.rb +8 -0
- data/lib/neography/relationship.rb +68 -0
- data/lib/neography/relationship_traverser.rb +80 -0
- data/lib/neography/rest.rb +534 -0
- data/lib/neography/tasks.rb +131 -0
- data/lib/neography/version.rb +3 -0
- data/neography.gemspec +29 -0
- data/spec/integration/authorization_spec.rb +48 -0
- data/spec/integration/index_spec.rb +32 -0
- data/spec/integration/neography_spec.rb +10 -0
- data/spec/integration/node_path_spec.rb +222 -0
- data/spec/integration/node_relationship_spec.rb +374 -0
- data/spec/integration/node_spec.rb +215 -0
- data/spec/integration/relationship_spec.rb +37 -0
- data/spec/integration/rest_batch_spec.rb +221 -0
- data/spec/integration/rest_bulk_spec.rb +106 -0
- data/spec/integration/rest_experimental_spec.rb +22 -0
- data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
- data/spec/integration/rest_index_spec.rb +297 -0
- data/spec/integration/rest_node_spec.rb +232 -0
- data/spec/integration/rest_path_spec.rb +209 -0
- data/spec/integration/rest_plugin_spec.rb +67 -0
- data/spec/integration/rest_relationship_spec.rb +327 -0
- data/spec/integration/rest_traverse_spec.rb +149 -0
- data/spec/spec_helper.rb +18 -0
- metadata +222 -0
@@ -0,0 +1,131 @@
|
|
1
|
+
# borrowed from architect4r
|
2
|
+
require 'os'
|
3
|
+
|
4
|
+
namespace :neo4j do
|
5
|
+
desc "Install Neo4j"
|
6
|
+
task :install, :edition, :version do |t, args|
|
7
|
+
args.with_defaults(:edition => "community", :version => "1.6")
|
8
|
+
puts "Installing Neo4j-#{args[:edition]}-#{args[:version]}"
|
9
|
+
|
10
|
+
if OS::Underlying.windows?
|
11
|
+
# Download Neo4j
|
12
|
+
unless File.exist?('neo4j.zip')
|
13
|
+
df = File.open('neo4j.zip', 'wb')
|
14
|
+
begin
|
15
|
+
df << HTTParty.get("http://dist.neo4j.org/neo4j-#{args[:edition]}-#{args[:version]}-windows.zip")
|
16
|
+
ensure
|
17
|
+
df.close()
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Extract and move to neo4j directory
|
22
|
+
unless File.exist?('neo4j')
|
23
|
+
Zip::ZipFile.open('neo4j.zip') do |zip_file|
|
24
|
+
zip_file.each do |f|
|
25
|
+
f_path=File.join(".", f.name)
|
26
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
27
|
+
begin
|
28
|
+
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
29
|
+
rescue
|
30
|
+
puts f.name + " failed to extract."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
FileUtils.mv "neo4j-#{args[:edition]}-#{args[:version]}", "neo4j"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Install if running with Admin Privileges
|
38
|
+
if %x[reg query "HKU\\S-1-5-19"].size > 0
|
39
|
+
%x[neo4j/bin/neo4j install]
|
40
|
+
puts "Neo4j Installed as a service."
|
41
|
+
end
|
42
|
+
|
43
|
+
else
|
44
|
+
%x[wget http://dist.neo4j.org/neo4j-#{args[:edition]}-#{args[:version]}-unix.tar.gz]
|
45
|
+
%x[tar -xvzf neo4j-#{args[:edition]}-#{args[:version]}-unix.tar.gz]
|
46
|
+
%x[mv neo4j-#{args[:edition]}-#{args[:version]} neo4j]
|
47
|
+
%x[rm neo4j-#{args[:edition]}-#{args[:version]}-unix.tar.gz]
|
48
|
+
puts "Neo4j Installed in to neo4j directory."
|
49
|
+
end
|
50
|
+
puts "Type 'rake neo4j:start' to start it"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Start the Neo4j Server"
|
54
|
+
task :start do
|
55
|
+
puts "Starting Neo4j..."
|
56
|
+
if OS::Underlying.windows?
|
57
|
+
if %x[reg query "HKU\\S-1-5-19"].size > 0
|
58
|
+
%x[neo4j/bin/Neo4j.bat start] #start service
|
59
|
+
else
|
60
|
+
puts "Starting Neo4j directly, not as a service."
|
61
|
+
%x[neo4j/bin/Neo4j.bat]
|
62
|
+
end
|
63
|
+
else
|
64
|
+
%x[neo4j/bin/neo4j start]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Stop the Neo4j Server"
|
69
|
+
task :stop do
|
70
|
+
puts "Stopping Neo4j..."
|
71
|
+
if OS::Underlying.windows?
|
72
|
+
if %x[reg query "HKU\\S-1-5-19"].size > 0
|
73
|
+
%x[neo4j/bin/Neo4j.bat stop] #stop service
|
74
|
+
else
|
75
|
+
puts "You do not have administrative rights to stop the Neo4j Service"
|
76
|
+
end
|
77
|
+
else
|
78
|
+
%x[neo4j/bin/neo4j stop]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Restart the Neo4j Server"
|
83
|
+
task :restart do
|
84
|
+
puts "Restarting Neo4j..."
|
85
|
+
if OS::Underlying.windows?
|
86
|
+
if %x[reg query "HKU\\S-1-5-19"].size > 0
|
87
|
+
%x[neo4j/bin/Neo4j.bat restart]
|
88
|
+
else
|
89
|
+
puts "You do not have administrative rights to restart the Neo4j Service"
|
90
|
+
end
|
91
|
+
else
|
92
|
+
%x[neo4j/bin/neo4j restart]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Reset the Neo4j Server"
|
97
|
+
task :reset_yes_i_am_sure do
|
98
|
+
# Stop the server
|
99
|
+
if OS::Underlying.windows?
|
100
|
+
if %x[reg query "HKU\\S-1-5-19"].size > 0
|
101
|
+
%x[neo4j/bin/Neo4j.bat stop]
|
102
|
+
|
103
|
+
# Reset the database
|
104
|
+
FileUtils.rm_rf("neo4j/data/graph.db")
|
105
|
+
FileUtils.mkdir("neo4j/data/graph.db")
|
106
|
+
|
107
|
+
# Remove log files
|
108
|
+
FileUtils.rm_rf("neo4j/data/log")
|
109
|
+
FileUtils.mkdir("neo4j/data/log")
|
110
|
+
|
111
|
+
%x[neo4j/bin/Neo4j.bat start]
|
112
|
+
else
|
113
|
+
puts "You do not have administrative rights to reset the Neo4j Service"
|
114
|
+
end
|
115
|
+
else
|
116
|
+
%x[neo4j/bin/neo4j stop]
|
117
|
+
|
118
|
+
# Reset the database
|
119
|
+
FileUtils.rm_rf("neo4j/data/graph.db")
|
120
|
+
FileUtils.mkdir("neo4j/data/graph.db")
|
121
|
+
|
122
|
+
# Remove log files
|
123
|
+
FileUtils.rm_rf("neo4j/data/log")
|
124
|
+
FileUtils.mkdir("neo4j/data/log")
|
125
|
+
|
126
|
+
# Start the server
|
127
|
+
%x[neo4j/bin/neo4j start]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
data/neography.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "neography/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "neography-ajaycb"
|
7
|
+
s.version = Neography::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = "Max De Marzi"
|
10
|
+
s.email = "maxdemarzi@gmail.com"
|
11
|
+
s.homepage = "http://rubygems.org/gems/neography"
|
12
|
+
s.summary = "ruby wrapper to Neo4j Rest API"
|
13
|
+
s.description = "A Ruby wrapper to the Neo4j Rest API see http://components.neo4j.org/neo4j-rest/ for more details."
|
14
|
+
|
15
|
+
s.rubyforge_project = "neography"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "net-http-spy", "0.2.1"
|
24
|
+
s.add_dependency "rake", ">= 0.8.7"
|
25
|
+
s.add_dependency "httparty", "~> 0.7.8"
|
26
|
+
s.add_dependency "json"
|
27
|
+
s.add_dependency "os"
|
28
|
+
s.add_dependency "rubyzip"
|
29
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Neography::Rest, :slow => true do
|
4
|
+
describe "basic authentication" do
|
5
|
+
describe "get_root" do
|
6
|
+
it "can get the root node"do
|
7
|
+
@neo = Neography::Rest.new({:server => '4c36b641.neo4j.atns.de', :port => 7474, :directory => '/9dc1fda5be8b5cde29621e21cae5adece3de0f37', :authentication => 'basic', :username => "abbe3c012", :password => "34d7b22eb"})
|
8
|
+
root_node = @neo.get_root
|
9
|
+
root_node.should have_key("reference_node")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "create_node" do
|
14
|
+
it "can create an empty node" do
|
15
|
+
@neo = Neography::Rest.new({:server => '4c36b641.neo4j.atns.de', :port => 7474, :directory => '/9dc1fda5be8b5cde29621e21cae5adece3de0f37', :authentication => 'basic', :username => "abbe3c012", :password => "34d7b22eb"})
|
16
|
+
new_node = @neo.create_node
|
17
|
+
new_node.should_not be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "quick initializer" do
|
22
|
+
it "can get the root node" do
|
23
|
+
@neo = Neography::Rest.new("http://abbe3c012:34d7b22eb@4c36b641.neo4j.atns.de:7474/9dc1fda5be8b5cde29621e21cae5adece3de0f37")
|
24
|
+
root_node = @neo.get_root
|
25
|
+
root_node.should have_key("reference_node")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "digest authentication" do
|
31
|
+
describe "get_root" do
|
32
|
+
it "can get the root node" do
|
33
|
+
@neo = Neography::Rest.new({:server => '4c36b641.neo4j.atns.de', :port => 7474, :directory => '/9dc1fda5be8b5cde29621e21cae5adece3de0f37', :authentication => 'digest', :username => "abbe3c012", :password => "34d7b22eb"})
|
34
|
+
root_node = @neo.get_root
|
35
|
+
root_node.should have_key("reference_node")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "create_node" do
|
40
|
+
it "can create an empty node" do
|
41
|
+
@neo = Neography::Rest.new({:server => '4c36b641.neo4j.atns.de', :port => 7474, :directory => '/9dc1fda5be8b5cde29621e21cae5adece3de0f37', :authentication => 'digest', :username => "abbe3c012", :password => "34d7b22eb"})
|
42
|
+
new_node = @neo.create_node
|
43
|
+
new_node.should_not be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Neography::Relationship, "find" do
|
4
|
+
before(:each) do
|
5
|
+
pending "Phase 2 - Index part is not done."
|
6
|
+
Neography::Relationship.index(:strength)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can index when Neography::Relationships are created" do
|
10
|
+
a = Neography::Node.create
|
11
|
+
b = Neography::Node.create
|
12
|
+
r = Neography::Relationship.create(:friends, a, b)
|
13
|
+
r[:strength] = 'strong'
|
14
|
+
Neography::Relationship.find('strength: strong').first.should == r
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can remove index when Neography::Relationship is deleted, just like nodes" do
|
18
|
+
a = Neography::Node.create
|
19
|
+
b = Neography::Node.create
|
20
|
+
r = Neography::Relationship.create(:friends, a, b)
|
21
|
+
r[:strength] = 'weak'
|
22
|
+
r2 = Neography::Relationship.find('strength: weak').first
|
23
|
+
r2.should == r
|
24
|
+
r2.del
|
25
|
+
Neography::Relationship.find('strength: weak').should be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
describe Neography::Node, "find" do
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Neography::NodePath do
|
4
|
+
|
5
|
+
def create_nodes
|
6
|
+
johnathan = Neography::Node.create("name" =>'Johnathan')
|
7
|
+
mark = Neography::Node.create("name" =>'Mark')
|
8
|
+
phill = Neography::Node.create("name" =>'Phill')
|
9
|
+
mary = Neography::Node.create("name" =>'Mary')
|
10
|
+
|
11
|
+
johnathan.both(:friends) << mark
|
12
|
+
mark.both(:friends) << mary
|
13
|
+
mark.both(:friends) << phill
|
14
|
+
phill.both(:friends) << mary
|
15
|
+
|
16
|
+
[johnathan, mark, phill, mary]
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "all_paths" do
|
20
|
+
it "can return nodes" do
|
21
|
+
johnathan, mark, phill, mary = create_nodes
|
22
|
+
|
23
|
+
johnathan.all_paths_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
24
|
+
path.map{|n| n.is_a?(Neography::Node).should be_true}
|
25
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_false}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can return relationships" do
|
30
|
+
johnathan, mark, phill, mary = create_nodes
|
31
|
+
|
32
|
+
johnathan.all_paths_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
33
|
+
path.map{|n| n.is_a?(Neography::Node).should be_false}
|
34
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_true}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can return both" do
|
39
|
+
johnathan, mark, phill, mary = create_nodes
|
40
|
+
|
41
|
+
johnathan.all_paths_to(mary).incoming(:friends).depth(4).each do |path|
|
42
|
+
path.each_with_index do |n,i|
|
43
|
+
if i.even?
|
44
|
+
n.is_a?(Neography::Node).should be_true
|
45
|
+
else
|
46
|
+
n.is_a?(Neography::Relationship).should be_true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "all_simple_paths" do
|
54
|
+
it "can return nodes" do
|
55
|
+
johnathan, mark, phill, mary = create_nodes
|
56
|
+
|
57
|
+
johnathan.all_simple_paths_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
58
|
+
path.map{|n| n.is_a?(Neography::Node).should be_true}
|
59
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_false}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "can return relationships" do
|
64
|
+
johnathan, mark, phill, mary = create_nodes
|
65
|
+
|
66
|
+
johnathan.all_simple_paths_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
67
|
+
path.map{|n| n.is_a?(Neography::Node).should be_false}
|
68
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_true}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "can return both" do
|
73
|
+
johnathan, mark, phill, mary = create_nodes
|
74
|
+
|
75
|
+
johnathan.all_simple_paths_to(mary).incoming(:friends).depth(4).each do |path|
|
76
|
+
path.each_with_index do |n,i|
|
77
|
+
if i.even?
|
78
|
+
n.is_a?(Neography::Node).should be_true
|
79
|
+
else
|
80
|
+
n.is_a?(Neography::Relationship).should be_true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "all_shortest_paths_to" do
|
88
|
+
it "can return nodes" do
|
89
|
+
johnathan, mark, phill, mary = create_nodes
|
90
|
+
|
91
|
+
johnathan.all_shortest_paths_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
92
|
+
path.map{|n| n.is_a?(Neography::Node).should be_true}
|
93
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_false}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it "can return relationships" do
|
98
|
+
johnathan, mark, phill, mary = create_nodes
|
99
|
+
|
100
|
+
johnathan.all_shortest_paths_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
101
|
+
path.map{|n| n.is_a?(Neography::Node).should be_false}
|
102
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_true}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "can return both" do
|
107
|
+
johnathan, mark, phill, mary = create_nodes
|
108
|
+
|
109
|
+
johnathan.all_shortest_paths_to(mary).incoming(:friends).depth(4).each do |path|
|
110
|
+
path.each_with_index do |n,i|
|
111
|
+
if i.even?
|
112
|
+
n.is_a?(Neography::Node).should be_true
|
113
|
+
else
|
114
|
+
n.is_a?(Neography::Relationship).should be_true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "path_to" do
|
122
|
+
it "can return nodes" do
|
123
|
+
johnathan, mark, phill, mary = create_nodes
|
124
|
+
|
125
|
+
johnathan.path_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
126
|
+
path.map{|n| n.is_a?(Neography::Node).should be_true}
|
127
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_false}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it "can return relationships" do
|
132
|
+
johnathan, mark, phill, mary = create_nodes
|
133
|
+
|
134
|
+
johnathan.path_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
135
|
+
path.map{|n| n.is_a?(Neography::Node).should be_false}
|
136
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_true}
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "can return both" do
|
141
|
+
johnathan, mark, phill, mary = create_nodes
|
142
|
+
|
143
|
+
johnathan.path_to(mary).incoming(:friends).depth(4).each do |path|
|
144
|
+
path.each_with_index do |n,i|
|
145
|
+
if i.even?
|
146
|
+
n.is_a?(Neography::Node).should be_true
|
147
|
+
else
|
148
|
+
n.is_a?(Neography::Relationship).should be_true
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "simple_path_to" do
|
156
|
+
it "can return nodes" do
|
157
|
+
johnathan, mark, phill, mary = create_nodes
|
158
|
+
|
159
|
+
johnathan.simple_path_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
160
|
+
path.map{|n| n.is_a?(Neography::Node).should be_true}
|
161
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_false}
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
it "can return relationships" do
|
166
|
+
johnathan, mark, phill, mary = create_nodes
|
167
|
+
|
168
|
+
johnathan.simple_path_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
169
|
+
path.map{|n| n.is_a?(Neography::Node).should be_false}
|
170
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_true}
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it "can return both" do
|
175
|
+
johnathan, mark, phill, mary = create_nodes
|
176
|
+
|
177
|
+
johnathan.simple_path_to(mary).incoming(:friends).depth(4).each do |path|
|
178
|
+
path.each_with_index do |n,i|
|
179
|
+
if i.even?
|
180
|
+
n.is_a?(Neography::Node).should be_true
|
181
|
+
else
|
182
|
+
n.is_a?(Neography::Relationship).should be_true
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "shortest_path_to" do
|
190
|
+
it "can return nodes" do
|
191
|
+
johnathan, mark, phill, mary = create_nodes
|
192
|
+
|
193
|
+
johnathan.shortest_path_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
194
|
+
path.map{|n| n.is_a?(Neography::Node).should be_true}
|
195
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_false}
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
it "can return relationships" do
|
200
|
+
johnathan, mark, phill, mary = create_nodes
|
201
|
+
|
202
|
+
johnathan.shortest_path_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
203
|
+
path.map{|n| n.is_a?(Neography::Node).should be_false}
|
204
|
+
path.map{|n| n.is_a?(Neography::Relationship).should be_true}
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
it "can return both" do
|
209
|
+
johnathan, mark, phill, mary = create_nodes
|
210
|
+
|
211
|
+
johnathan.shortest_path_to(mary).incoming(:friends).depth(4).each do |path|
|
212
|
+
path.each_with_index do |n,i|
|
213
|
+
if i.even?
|
214
|
+
n.is_a?(Neography::Node).should be_true
|
215
|
+
else
|
216
|
+
n.is_a?(Neography::Relationship).should be_true
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|