neography 1.3.8 → 1.3.9
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.
- checksums.yaml +4 -4
- data/ChangeLog +14 -0
- data/lib/neography/connection.rb +13 -3
- data/lib/neography/errors.rb +3 -0
- data/lib/neography/rest.rb +24 -0
- data/lib/neography/rest/batch.rb +4 -0
- data/lib/neography/rest/constraints.rb +48 -0
- data/lib/neography/version.rb +1 -1
- data/spec/integration/rest_batch_spec.rb +26 -0
- data/spec/integration/rest_constraints_spec.rb +72 -0
- data/spec/unit/rest/constraints_spec.rb +46 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 153541ce7b1f118e53b97931722139408722084d
|
4
|
+
data.tar.gz: 4134c1a97af5d2666d5e9b80863615dc66995bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fab8b438fb39df376d1071517dcadee4d2e402199d473f8d45957b7a7c3312a7d13398e8b64dfae5b980df418c9e256f1575debf6974fb94d53e5ba5821b534e
|
7
|
+
data.tar.gz: f7eb79617eb7d2bc449fa9be5282f3f3a4d3a0068dd1fc56d937cbe1982251ac547ccaca1fb302c289d0479d2cac10279a51cd949bcff1a7d427543d271b5fbc
|
data/ChangeLog
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
v1.3.8
|
2
|
+
======
|
3
|
+
3343c5e Bump to 1.3.8
|
4
|
+
e99ba36 add ChangeLog (using git-changelog gem)
|
5
|
+
de53b89 update neo to 2.0.1, update ruby tests to 2.0.0
|
6
|
+
9a76e11 add unmanaged extensions spec (skipped for test suite)
|
7
|
+
b788b68 moved broken spatial tests out to their own file, and skipping them until we track this Neo4j bug down
|
8
|
+
f1e172e more work on adding spatial to batch... failing test however...
|
9
|
+
8ee5de4 + .labels Node instance method
|
10
|
+
d358eb7 + colors in tests
|
11
|
+
07e63dc let body of post extension pass through without the to_json if headers are not nil
|
12
|
+
cb21b01 allow headers to be past in when using extensions
|
13
|
+
43b64d3 deal with unmanaged extensions a little better... well not really, but at least it should work
|
14
|
+
|
1
15
|
v1.3.7
|
2
16
|
======
|
3
17
|
6bd6842 Bump to 1.3.7
|
data/lib/neography/connection.rb
CHANGED
@@ -66,9 +66,18 @@ module Neography
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def authenticate(path = nil)
|
69
|
-
@
|
70
|
-
|
71
|
-
|
69
|
+
unless @authentication.empty?
|
70
|
+
auth_type = @authentication.keys.first
|
71
|
+
@client.set_auth(
|
72
|
+
path,
|
73
|
+
@authentication[auth_type][:username],
|
74
|
+
@authentication[auth_type][:password]
|
75
|
+
)
|
76
|
+
# Force http client to always send auth credentials without
|
77
|
+
# waiting for WWW-Authenticate headers, thus saving one request
|
78
|
+
# roundtrip for each URI. Only works for HTTP basic auth.
|
79
|
+
@client.www_auth.basic_auth.challenge(configuration) if auth_type == 'basic_auth'
|
80
|
+
end
|
72
81
|
end
|
73
82
|
|
74
83
|
private
|
@@ -204,6 +213,7 @@ module Neography
|
|
204
213
|
when /RelationshipNotFoundException/ ; RelationshipNotFoundException
|
205
214
|
when /NotFoundException/ ; NotFoundException
|
206
215
|
when /UniquePathNotUniqueException/ ; UniquePathNotUniqueException
|
216
|
+
when /DeadlockDetectedException/ ; DeadlockDetectedException
|
207
217
|
else
|
208
218
|
NeographyError
|
209
219
|
end
|
data/lib/neography/errors.rb
CHANGED
@@ -44,4 +44,7 @@ module Neography
|
|
44
44
|
# Thrown when CREATE UNIQUE matches multiple paths.
|
45
45
|
class UniquePathNotUniqueException < NeographyError; end
|
46
46
|
|
47
|
+
# Signals that a deadlock between two or more transactions has been detected
|
48
|
+
class DeadlockDetectedException < NeographyError; end
|
49
|
+
|
47
50
|
end
|
data/lib/neography/rest.rb
CHANGED
@@ -29,6 +29,7 @@ require 'neography/rest/batch'
|
|
29
29
|
require 'neography/rest/clean'
|
30
30
|
require 'neography/rest/transactions'
|
31
31
|
require 'neography/rest/spatial'
|
32
|
+
require 'neography/rest/constraints'
|
32
33
|
|
33
34
|
require 'neography/errors'
|
34
35
|
|
@@ -71,6 +72,7 @@ module Neography
|
|
71
72
|
@clean = Clean.new(@connection)
|
72
73
|
@transactions = Transactions.new(@connection)
|
73
74
|
@spatial = Spatial.new(@connection)
|
75
|
+
@constraints = Constraints.new(@connection)
|
74
76
|
end
|
75
77
|
|
76
78
|
# meta-data
|
@@ -123,6 +125,28 @@ module Neography
|
|
123
125
|
@schema_indexes.drop(label, property)
|
124
126
|
end
|
125
127
|
|
128
|
+
# constraints
|
129
|
+
|
130
|
+
def get_constraints(label=nil)
|
131
|
+
label.nil? ? @constraints.list : @constraints.get(label)
|
132
|
+
end
|
133
|
+
|
134
|
+
def drop_constraint(label, property)
|
135
|
+
@constraints.drop(label, property)
|
136
|
+
end
|
137
|
+
|
138
|
+
def get_uniqueness(label)
|
139
|
+
@constraints.get_uniqueness(label)
|
140
|
+
end
|
141
|
+
|
142
|
+
def get_unique_constraint(label, property)
|
143
|
+
@constraints.get_unique(label, property)
|
144
|
+
end
|
145
|
+
|
146
|
+
def create_unique_constraint(label, property)
|
147
|
+
@constraints.create_unique(label, property)
|
148
|
+
end
|
149
|
+
|
126
150
|
# transactions
|
127
151
|
|
128
152
|
def begin_transaction(statements=nil)
|
data/lib/neography/rest/batch.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
module Neography
|
2
|
+
class Rest
|
3
|
+
class Constraints
|
4
|
+
extend Neography::Rest::Paths
|
5
|
+
include Neography::Rest::Helpers
|
6
|
+
|
7
|
+
add_path :base, "/schema/constraint/"
|
8
|
+
add_path :label, "/schema/constraint/:label"
|
9
|
+
add_path :uniqueness, "/schema/constraint/:label/uniqueness/"
|
10
|
+
add_path :unique, "/schema/constraint/:label/uniqueness/:property"
|
11
|
+
|
12
|
+
def initialize(connection)
|
13
|
+
@connection = connection
|
14
|
+
end
|
15
|
+
|
16
|
+
def drop(label, property)
|
17
|
+
@connection.delete(unique_path(:label => label, :property => property))
|
18
|
+
end
|
19
|
+
|
20
|
+
def list
|
21
|
+
@connection.get(base_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get(label)
|
25
|
+
@connection.get(label_path(:label => label))
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_uniqueness(label)
|
29
|
+
@connection.get(uniqueness_path(:label => label))
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_unique(label, property)
|
33
|
+
@connection.get(unique_path(:label => label, :property => property))
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_unique(label, property)
|
37
|
+
options = {
|
38
|
+
:body => {
|
39
|
+
:property_keys => [property]
|
40
|
+
}.to_json,
|
41
|
+
:headers => json_content_type
|
42
|
+
}
|
43
|
+
@connection.post(uniqueness_path(:label => label), options)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/neography/version.rb
CHANGED
@@ -123,6 +123,32 @@ describe Neography::Rest do
|
|
123
123
|
existing_node["data"]["weight"].should be_nil
|
124
124
|
end
|
125
125
|
|
126
|
+
it "can remove a property of a node" do
|
127
|
+
new_node = @neo.create_node("name" => "Max", "weight" => 200)
|
128
|
+
batch_result = @neo.batch [:remove_node_property, new_node, "weight"]
|
129
|
+
batch_result.first.should have_key("id")
|
130
|
+
batch_result.first.should have_key("from")
|
131
|
+
existing_node = @neo.get_node(new_node)
|
132
|
+
existing_node["data"]["name"].should == "Max"
|
133
|
+
existing_node["data"]["weight"].should be_nil
|
134
|
+
end
|
135
|
+
|
136
|
+
it "can remove a property of multiple nodes" do
|
137
|
+
node1 = @neo.create_node("name" => "Max", "weight" => 200)
|
138
|
+
node2 = @neo.create_node("name" => "Marc", "weight" => 180)
|
139
|
+
batch_result = @neo.batch [:remove_node_property, node1, "name"], [:remove_node_property, node2, "name"]
|
140
|
+
batch_result.first.should have_key("id")
|
141
|
+
batch_result.first.should have_key("from")
|
142
|
+
batch_result.last.should have_key("id")
|
143
|
+
batch_result.last.should have_key("from")
|
144
|
+
existing_node = @neo.get_node(node1)
|
145
|
+
existing_node["data"]["name"].should be_nil
|
146
|
+
existing_node["data"]["weight"].should == 200
|
147
|
+
existing_node = @neo.get_node(node2)
|
148
|
+
existing_node["data"]["name"].should be_nil
|
149
|
+
existing_node["data"]["weight"].should == 180
|
150
|
+
end
|
151
|
+
|
126
152
|
it "can get a single relationship" do
|
127
153
|
node1 = @neo.create_node
|
128
154
|
node2 = @neo.create_node
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neography::Rest do
|
4
|
+
before(:each) do
|
5
|
+
@neo = Neography::Rest.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "create unique constraint" do
|
9
|
+
it "can create a unique constraint" do
|
10
|
+
label = "User"
|
11
|
+
property = "user_id"
|
12
|
+
uc = @neo.create_unique_constraint(label, property)
|
13
|
+
uc.should_not be_nil
|
14
|
+
uc["label"].should == label
|
15
|
+
uc["property_keys"].should == [property]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "get a unique constraint" do
|
20
|
+
it "can get a unique constraint" do
|
21
|
+
label = "User"
|
22
|
+
property = "user_id"
|
23
|
+
uc = @neo.get_unique_constraint(label, property)
|
24
|
+
uc.should_not be_nil
|
25
|
+
uc.first["label"].should == label
|
26
|
+
uc.first["property_keys"].should == [property]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "get unique constraints" do
|
31
|
+
it "can get unique constraints for a label" do
|
32
|
+
label = "User"
|
33
|
+
property = "user_id"
|
34
|
+
uc = @neo.get_uniqueness(label)
|
35
|
+
uc.should_not be_nil
|
36
|
+
uc.first["label"].should == label
|
37
|
+
uc.first["property_keys"].should == [property]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "list constraints" do
|
42
|
+
it "can get a list of constraints" do
|
43
|
+
label = "User"
|
44
|
+
property = "user_id"
|
45
|
+
cs = @neo.get_constraints
|
46
|
+
cs.should_not be_nil
|
47
|
+
cs.first["label"].should == label
|
48
|
+
cs.first["property_keys"].should == [property]
|
49
|
+
end
|
50
|
+
|
51
|
+
it "can get a list of constraints for a specifc label" do
|
52
|
+
label = "User"
|
53
|
+
property = "user_id"
|
54
|
+
cs = @neo.get_constraints(label)
|
55
|
+
cs.should_not be_nil
|
56
|
+
cs.first["label"].should == label
|
57
|
+
cs.first["property_keys"].should == [property]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "drop a constraint" do
|
62
|
+
it "can drop a constraint" do
|
63
|
+
label = "User"
|
64
|
+
property = "user_id"
|
65
|
+
uc = @neo.drop_constraint(label, property)
|
66
|
+
uc.should be_nil
|
67
|
+
cs = @neo.get_constraints(label)
|
68
|
+
cs.should be_empty
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Neography
|
4
|
+
class Rest
|
5
|
+
describe Constraints do
|
6
|
+
|
7
|
+
let(:connection) { double }
|
8
|
+
subject { Constraints.new(connection) }
|
9
|
+
|
10
|
+
it "list constraints" do
|
11
|
+
connection.should_receive(:get).with("/schema/constraint/")
|
12
|
+
subject.list
|
13
|
+
end
|
14
|
+
|
15
|
+
it "get constraints for a label" do
|
16
|
+
connection.should_receive(:get).with("/schema/constraint/label")
|
17
|
+
subject.get("label")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "create a unique constraint for a label" do
|
21
|
+
options = {
|
22
|
+
:body => '{"property_keys":["property"]}',
|
23
|
+
:headers => json_content_type
|
24
|
+
}
|
25
|
+
connection.should_receive(:post).with("/schema/constraint/label/uniqueness/", options)
|
26
|
+
subject.create_unique("label", "property")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "get unique constraints for a label" do
|
30
|
+
connection.should_receive(:get).with("/schema/constraint/label/uniqueness/")
|
31
|
+
subject.get_uniqueness("label")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "get a specific unique constraint for a label" do
|
35
|
+
connection.should_receive(:get).with("/schema/constraint/label/uniqueness/property")
|
36
|
+
subject.get_unique("label", "property")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "can delete a constraint for a label" do
|
40
|
+
connection.should_receive(:delete).with("/schema/constraint/label/uniqueness/property")
|
41
|
+
subject.drop("label","property")
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
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.3.
|
4
|
+
version: 1.3.9
|
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: 2014-02-
|
11
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- lib/neography/rest/auto_indexes.rb
|
183
183
|
- lib/neography/rest/batch.rb
|
184
184
|
- lib/neography/rest/clean.rb
|
185
|
+
- lib/neography/rest/constraints.rb
|
185
186
|
- lib/neography/rest/cypher.rb
|
186
187
|
- lib/neography/rest/extensions.rb
|
187
188
|
- lib/neography/rest/gremlin.rb
|
@@ -223,6 +224,7 @@ files:
|
|
223
224
|
- spec/integration/rest_batch_spec.rb
|
224
225
|
- spec/integration/rest_batch_streaming_spec.rb
|
225
226
|
- spec/integration/rest_bulk_spec.rb
|
227
|
+
- spec/integration/rest_constraints_spec.rb
|
226
228
|
- spec/integration/rest_experimental_spec.rb
|
227
229
|
- spec/integration/rest_gremlin_fail_spec.rb
|
228
230
|
- spec/integration/rest_header_spec.rb
|
@@ -249,6 +251,7 @@ files:
|
|
249
251
|
- spec/unit/relationship_spec.rb
|
250
252
|
- spec/unit/rest/batch_spec.rb
|
251
253
|
- spec/unit/rest/clean_spec.rb
|
254
|
+
- spec/unit/rest/constraints_spec.rb
|
252
255
|
- spec/unit/rest/cypher_spec.rb
|
253
256
|
- spec/unit/rest/extensions_spec.rb
|
254
257
|
- spec/unit/rest/gremlin_spec.rb
|
@@ -307,6 +310,7 @@ test_files:
|
|
307
310
|
- spec/integration/rest_batch_spec.rb
|
308
311
|
- spec/integration/rest_batch_streaming_spec.rb
|
309
312
|
- spec/integration/rest_bulk_spec.rb
|
313
|
+
- spec/integration/rest_constraints_spec.rb
|
310
314
|
- spec/integration/rest_experimental_spec.rb
|
311
315
|
- spec/integration/rest_gremlin_fail_spec.rb
|
312
316
|
- spec/integration/rest_header_spec.rb
|
@@ -333,6 +337,7 @@ test_files:
|
|
333
337
|
- spec/unit/relationship_spec.rb
|
334
338
|
- spec/unit/rest/batch_spec.rb
|
335
339
|
- spec/unit/rest/clean_spec.rb
|
340
|
+
- spec/unit/rest/constraints_spec.rb
|
336
341
|
- spec/unit/rest/cypher_spec.rb
|
337
342
|
- spec/unit/rest/extensions_spec.rb
|
338
343
|
- spec/unit/rest/gremlin_spec.rb
|