neography 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f2234bb146cd1e3f2a8982a50ed7a40cc55cf7e
4
- data.tar.gz: 27d36db4460e5c928e22714c22e6d198a4af8178
3
+ metadata.gz: a9a5dbe19c881f5dc8577c897d7a497de8fa9395
4
+ data.tar.gz: eb4f67ddb12f04e1af6344ce25ccbad32fba6928
5
5
  SHA512:
6
- metadata.gz: 7b0fe9807a4ce69b2befcebe432f214bc4db21aa86ebd8c900f80062946ed44732c2a5b887b4666ad35c989beab923079d713ed2813d44431301b6fb529b865c
7
- data.tar.gz: 5753e7142a9e9d19598faec7ea62cc27613a45b386e184c2a004fddb9e85ff558abec6fb4c85e6b853a1ecd16d3cd0dc7689998424cbca4d2ef4886d392a5e00
6
+ metadata.gz: 27847345003d076c389aa67fc2fadaa3571e7c920a5b13456d9bc3c07ff52bb0c1ea931200991569809635ebfeac800d89488a34836db255fb6005984189dbb7
7
+ data.tar.gz: 49684298832804caffa8b733d4f82c2ad43acab56920e75343c706c0852131a7467255e71e30a65c77f76ec18c794f7c85e00a0f4cbe3441703eed6d08045376
@@ -25,7 +25,7 @@ module Neography
25
25
  def find(*args)
26
26
  db = args[3] ? args.pop : Neography::Rest.new
27
27
 
28
- if self.inspect == "Neography::Node"
28
+ if self <= Neography::Node
29
29
  nodes = []
30
30
  results = db.find_node_index(*args)
31
31
  return nil unless results
@@ -99,8 +99,12 @@ module Neography
99
99
 
100
100
  # NodeRelationships
101
101
 
102
- def get_node_relationships(id, direction = nil)
103
- get NodeRelationships.direction_path(:id => get_id(id), :direction => direction || 'all')
102
+ def get_node_relationships(id, direction = nil, types = nil)
103
+ if types.nil?
104
+ get NodeRelationships.direction_path(:id => get_id(id), :direction => direction || 'all')
105
+ else
106
+ get NodeRelationships.type_path(:id => get_id(id), :direction => direction, :types => Array(types).join('&'))
107
+ end
104
108
  end
105
109
 
106
110
  # Relationships
@@ -1,3 +1,3 @@
1
1
  module Neography
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -235,7 +235,7 @@ describe Neography::Rest do
235
235
  batch_result.first.should have_key("id")
236
236
  batch_result.first.should have_key("from")
237
237
  batch_result.first["body"].first["self"].should == new_node["self"]
238
- @neo.remove_node_from_index(index_name, key, value, new_node)
238
+ @neo.remove_node_from_index(index_name, key, value, new_node)
239
239
  end
240
240
 
241
241
  it "can get a relationship index" do
@@ -309,10 +309,10 @@ describe Neography::Rest do
309
309
  value3 = generate_text
310
310
 
311
311
  node1 = @neo.create_unique_node(index, key, value1, { "name" => "Max" })
312
- node2 = @neo.create_unique_node(index, key, value2, { "name" => "Neo" })
312
+ node2 = @neo.create_unique_node(index, key, value2, { "name" => "Neo" })
313
313
  node3 = @neo.create_unique_node(index, key, value3, { "name" => "Samir"})
314
314
 
315
- batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ],
315
+ batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ],
316
316
  [:remove_node_from_index, index, key, node2 ],
317
317
  [:remove_node_from_index, index, node3 ]
318
318
 
@@ -384,7 +384,7 @@ describe Neography::Rest do
384
384
  batch_result.first["body"]["data"]["since"].should == "high school"
385
385
  batch_result.first["body"]["start"].split('/').last.should == node1["self"].split('/').last
386
386
  batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
387
- existing_index = @neo.find_relationship_index("test_relationship_index", key, value)
387
+ existing_index = @neo.find_relationship_index("test_relationship_index", key, value)
388
388
  existing_index.should_not be_nil
389
389
  existing_index.first["self"].should == batch_result.first["body"]["self"]
390
390
  end
@@ -424,6 +424,7 @@ describe Neography::Rest do
424
424
  new_relationship1 = @neo.create_relationship("friends", node1, node2)
425
425
  new_relationship2 = @neo.create_relationship("brothers", node1, node3)
426
426
  batch_result = @neo.batch [:get_node_relationships, node1]
427
+ batch_result.first["body"].length.should be(2)
427
428
  batch_result.first["body"][0]["type"].should == "friends"
428
429
  batch_result.first["body"][0]["start"].split('/').last.should == node1["self"].split('/').last
429
430
  batch_result.first["body"][0]["end"].split('/').last.should == node2["self"].split('/').last
@@ -434,6 +435,20 @@ describe Neography::Rest do
434
435
  batch_result.first["body"][1]["self"].should == new_relationship2["self"]
435
436
  end
436
437
 
438
+ it "can get relationships of specific type" do
439
+ node1 = @neo.create_node
440
+ node2 = @neo.create_node
441
+ node3 = @neo.create_node
442
+ new_relationship1 = @neo.create_relationship("friends", node1, node2)
443
+ new_relationship2 = @neo.create_relationship("brothers", node1, node3)
444
+ batch_result = @neo.batch [:get_node_relationships, node1, "out", "friends"]
445
+ batch_result.first["body"].length.should be(1)
446
+ batch_result.first["body"][0]["type"].should == "friends"
447
+ batch_result.first["body"][0]["start"].split('/').last.should == node1["self"].split('/').last
448
+ batch_result.first["body"][0]["end"].split('/').last.should == node2["self"].split('/').last
449
+ batch_result.first["body"][0]["self"].should == new_relationship1["self"]
450
+ end
451
+
437
452
  it "can create a relationship from a unique node" do
438
453
  batch_result = @neo.batch [:create_node, {:street1=>"94437 Kemmer Crossing", :street2=>"Apt. 333", :city=>"Abshireton", :state=>"AA", :zip=>"65820", :_type=>"Address", :created_at=>1335269478}],
439
454
  [:add_node_to_index, "person_ssn", "ssn", "000-00-0001", "{0}"],
@@ -449,7 +464,7 @@ describe Neography::Rest do
449
464
  [:add_node_to_index, "person_ssn", "ssn", "000-00-0001", "{0}"],
450
465
  [:create_node, {:street1=>"94437 Kemmer Crossing", :street2=>"Apt. 333", :city=>"Abshireton", :state=>"AA", :zip=>"65820", :_type=>"Address", :created_at=>1335269478}],
451
466
  [:create_relationship, "has", "{0}", "{2}", {}]
452
- }.to raise_error(Neography::NeographyError)
467
+ }.to raise_error(Neography::NeographyError)
453
468
  end
454
469
 
455
470
  end
@@ -457,24 +472,24 @@ describe Neography::Rest do
457
472
  describe "broken queries" do
458
473
  it "should return errors when bad syntax is passed in batch" do
459
474
  batch_commands = []
460
-
475
+
461
476
  batch_commands << [ :execute_query, "start person_n=node:person(ssn = '000-00-0002')
462
477
  set bar1 = {foo}",
463
478
  { :other => "what" }
464
479
  ]
465
480
 
466
- expect {
481
+ expect {
467
482
  batch_result = @neo.batch *batch_commands
468
- }.to raise_exception Neography::SyntaxException
483
+ }.to raise_exception Neography::SyntaxException
469
484
 
470
- expect {
485
+ expect {
471
486
  @neo.execute_query("start person_n=node:person(ssn = '000-00-0001')
472
487
  set bar = {foo}",
473
488
  { :other => "what" })
474
489
  }.to raise_exception Neography::SyntaxException
475
-
476
-
477
- end
490
+
491
+
492
+ end
478
493
  end
479
494
 
480
495
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neography
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max De Marzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec