neography 0.0.28 → 0.0.29
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile.lock +1 -2
- data/lib/neography.rb +2 -2
- data/lib/neography/config.rb +2 -2
- data/lib/neography/multi_json_parser.rb +29 -0
- data/lib/neography/rest.rb +2 -0
- data/lib/neography/version.rb +1 -1
- data/neography.gemspec +1 -1
- data/spec/integration/rest_batch_spec.rb +12 -0
- metadata +89 -25
- data/lib/neography/oj_parser.rb +0 -8
data/Gemfile.lock
CHANGED
@@ -4,7 +4,7 @@ PATH
|
|
4
4
|
neography (0.0.28)
|
5
5
|
httparty (>= 0.8.1)
|
6
6
|
json
|
7
|
-
|
7
|
+
multi_json
|
8
8
|
os
|
9
9
|
rake (>= 0.8.7)
|
10
10
|
rubyzip
|
@@ -20,7 +20,6 @@ GEM
|
|
20
20
|
multi_json (1.3.6)
|
21
21
|
multi_xml (0.5.1)
|
22
22
|
net-http-spy (0.2.1)
|
23
|
-
oj (1.2.9)
|
24
23
|
os (0.9.6)
|
25
24
|
rake (0.8.7)
|
26
25
|
rspec (2.10.0)
|
data/lib/neography.rb
CHANGED
@@ -18,13 +18,13 @@ DIRECTIONS = ["incoming", "in", "outgoing", "out", "all", "both"]
|
|
18
18
|
require 'cgi'
|
19
19
|
require 'httparty'
|
20
20
|
require 'json'
|
21
|
-
require '
|
21
|
+
require 'multi_json'
|
22
22
|
require 'logger'
|
23
23
|
require 'ostruct'
|
24
24
|
require 'os'
|
25
25
|
require 'zip/zipfilesystem'
|
26
26
|
|
27
|
-
require 'neography/
|
27
|
+
require 'neography/multi_json_parser'
|
28
28
|
|
29
29
|
require 'neography/config'
|
30
30
|
require 'neography/rest'
|
data/lib/neography/config.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
class MultiJsonParser < HTTParty::Parser
|
2
|
+
|
3
|
+
protected
|
4
|
+
|
5
|
+
# I know this looks pretty ugly, but we have issues with Neo4j returning true, false,
|
6
|
+
# plain numbers and plain strings, which is considered by some JSON libraries to be
|
7
|
+
# invalid JSON, but some consider it perfectly fine.
|
8
|
+
# This ugly hack deals with the problem. Send me a Pull Request if you
|
9
|
+
# come up with a nicer solution... please!
|
10
|
+
#
|
11
|
+
def json
|
12
|
+
begin
|
13
|
+
MultiJson.load(body)
|
14
|
+
rescue MultiJson::DecodeError, ArgumentError
|
15
|
+
case
|
16
|
+
when body == "true"
|
17
|
+
true
|
18
|
+
when body == "false"
|
19
|
+
false
|
20
|
+
when body.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
|
21
|
+
Float(body)
|
22
|
+
else
|
23
|
+
body[1..-2]
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/neography/rest.rb
CHANGED
@@ -509,6 +509,8 @@ module Neography
|
|
509
509
|
{:method => "POST", :to => (args[2].is_a?(String) && args[2].start_with?("{") ? "" : "/node/") + "#{get_id(args[2])}/relationships", :body => {:to => (args[3].is_a?(String) && args[3].start_with?("{") ? "" : "/node/") + "#{get_id(args[3])}", :type => args[1], :data => args[4] } }
|
510
510
|
when :create_unique_relationship
|
511
511
|
{:method => "POST", :to => "/index/relationship/#{args[1]}?unique", :body => {:key => args[2], :value => args[3], :type => args[4], :start => (args[5].is_a?(String) && args[5].start_with?("{") ? "" : "/node/") + "#{get_id(args[5])}", :end=> (args[6].is_a?(String) && args[6].start_with?("{") ? "" : "/node/") + "#{get_id(args[6])}"} }
|
512
|
+
when :delete_relationship
|
513
|
+
{:method => "DELETE", :to => "/relationship/#{get_id(args[1])}"}
|
512
514
|
when :set_relationship_property
|
513
515
|
{:method => "PUT", :to => "/relationship/#{get_id(args[1])}/properties/#{args[2].keys.first}", :body => args[2].values.first}
|
514
516
|
when :reset_relationship_properties
|
data/lib/neography/version.rb
CHANGED
data/neography.gemspec
CHANGED
@@ -144,6 +144,18 @@ describe Neography::Rest do
|
|
144
144
|
batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
|
145
145
|
end
|
146
146
|
|
147
|
+
it "can delete a single relationship" do
|
148
|
+
node1 = @neo.create_node
|
149
|
+
node2 = @neo.create_node
|
150
|
+
batch_result = @neo.batch [:create_relationship, "friends", node1, node2, {:since => "time immemorial"}]
|
151
|
+
batch_result.should_not be_nil
|
152
|
+
batch_result[0]["status"].should == 201
|
153
|
+
id = batch_result.first["body"]["self"].split("/").last
|
154
|
+
batch_result = @neo.batch [:delete_relationship, id]
|
155
|
+
batch_result[0]["status"].should == 204
|
156
|
+
batch_result[0]["from"].should == "/relationship/#{id}"
|
157
|
+
end
|
158
|
+
|
147
159
|
it "can create a unique relationship" do
|
148
160
|
index_name = generate_text(6)
|
149
161
|
key = generate_text(6)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neography
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.29
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07
|
12
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,31 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: net-http-spy
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
|
-
- - =
|
35
|
+
- - '='
|
31
36
|
- !ruby/object:Gem::Version
|
32
37
|
version: 0.2.1
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.1
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rake
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 0.8.7
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.7
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: httparty
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: 0.8.1
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.8.1
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: rake
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: 0.8.7
|
66
86
|
type: :runtime
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.8.7
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: json
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :runtime
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: os
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,10 +117,15 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :runtime
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
- !ruby/object:Gem::Dependency
|
92
127
|
name: rubyzip
|
93
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
94
129
|
none: false
|
95
130
|
requirements:
|
96
131
|
- - ! '>='
|
@@ -98,10 +133,15 @@ dependencies:
|
|
98
133
|
version: '0'
|
99
134
|
type: :runtime
|
100
135
|
prerelease: false
|
101
|
-
version_requirements:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
102
142
|
- !ruby/object:Gem::Dependency
|
103
|
-
name:
|
104
|
-
requirement:
|
143
|
+
name: multi_json
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
105
145
|
none: false
|
106
146
|
requirements:
|
107
147
|
- - ! '>='
|
@@ -109,7 +149,12 @@ dependencies:
|
|
109
149
|
version: '0'
|
110
150
|
type: :runtime
|
111
151
|
prerelease: false
|
112
|
-
version_requirements:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
113
158
|
description: A Ruby wrapper to the Neo4j Rest API see http://components.neo4j.org/neo4j-rest/
|
114
159
|
for more details.
|
115
160
|
email: maxdemarzi@gmail.com
|
@@ -137,12 +182,12 @@ files:
|
|
137
182
|
- lib/neography/config.rb
|
138
183
|
- lib/neography/equal.rb
|
139
184
|
- lib/neography/index.rb
|
185
|
+
- lib/neography/multi_json_parser.rb
|
140
186
|
- lib/neography/neography.rb
|
141
187
|
- lib/neography/node.rb
|
142
188
|
- lib/neography/node_path.rb
|
143
189
|
- lib/neography/node_relationship.rb
|
144
190
|
- lib/neography/node_traverser.rb
|
145
|
-
- lib/neography/oj_parser.rb
|
146
191
|
- lib/neography/path_traverser.rb
|
147
192
|
- lib/neography/property.rb
|
148
193
|
- lib/neography/property_container.rb
|
@@ -192,8 +237,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
237
|
version: '0'
|
193
238
|
requirements: []
|
194
239
|
rubyforge_project: neography
|
195
|
-
rubygems_version: 1.8.
|
240
|
+
rubygems_version: 1.8.24
|
196
241
|
signing_key:
|
197
242
|
specification_version: 3
|
198
243
|
summary: ruby wrapper to Neo4j Rest API
|
199
|
-
test_files:
|
244
|
+
test_files:
|
245
|
+
- spec/integration/authorization_spec.rb
|
246
|
+
- spec/integration/index_spec.rb
|
247
|
+
- spec/integration/neography_spec.rb
|
248
|
+
- spec/integration/node_path_spec.rb
|
249
|
+
- spec/integration/node_relationship_spec.rb
|
250
|
+
- spec/integration/node_spec.rb
|
251
|
+
- spec/integration/parsing_spec.rb
|
252
|
+
- spec/integration/relationship_spec.rb
|
253
|
+
- spec/integration/rest_batch_spec.rb
|
254
|
+
- spec/integration/rest_bulk_spec.rb
|
255
|
+
- spec/integration/rest_experimental_spec.rb
|
256
|
+
- spec/integration/rest_gremlin_fail_spec.rb
|
257
|
+
- spec/integration/rest_index_spec.rb
|
258
|
+
- spec/integration/rest_node_spec.rb
|
259
|
+
- spec/integration/rest_path_spec.rb
|
260
|
+
- spec/integration/rest_plugin_spec.rb
|
261
|
+
- spec/integration/rest_relationship_spec.rb
|
262
|
+
- spec/integration/rest_traverse_spec.rb
|
263
|
+
- spec/spec_helper.rb
|