neo4j-core 5.0.1 → 5.1.0
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/Gemfile +0 -3
- data/README.md +32 -6
- data/lib/neo4j/ansi.rb +14 -0
- data/lib/neo4j/label.rb +0 -1
- data/lib/neo4j/node.rb +6 -1
- data/lib/neo4j-core/helpers.rb +2 -7
- data/lib/neo4j-core/query.rb +38 -7
- data/lib/neo4j-core/query_clauses.rb +186 -57
- data/lib/neo4j-core/version.rb +1 -1
- data/lib/neo4j-core.rb +1 -1
- data/lib/neo4j-embedded/embedded_session.rb +18 -10
- data/lib/neo4j-embedded.rb +1 -1
- data/lib/neo4j-server/cypher_node.rb +8 -6
- data/lib/neo4j-server/cypher_relationship.rb +11 -5
- data/lib/neo4j-server/cypher_response.rb +9 -6
- data/lib/neo4j-server/cypher_session.rb +29 -25
- data/lib/neo4j-server/cypher_transaction.rb +0 -1
- data/lib/neo4j-server.rb +0 -1
- data/neo4j-core.gemspec +1 -2
- metadata +7 -25
- data/lib/neo4j/tasks/config_server.rb +0 -36
- data/lib/neo4j/tasks/neo4j_server.rake +0 -245
- data/lib/neo4j-core/cypher_translator.rb +0 -76
- data/lib/neo4j-core/hash_with_indifferent_access.rb +0 -174
- data/lib/neo4j-server/cypher_node_uncommited.rb +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 413db701027dd75c0757902fba22db6a5b289781
|
|
4
|
+
data.tar.gz: 59d07ba453f252c053fbd6b353b3604415cd3a0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cf46b06d8cf1c4b4152fe7ce4f870ca019cdb475d06a2e2d902db223c7d6d2c8abf20b44cba5a352e3e3b4122d4e79e698bdc105a169e41fdc51bca506958474
|
|
7
|
+
data.tar.gz: 9dcdf5e2fdb993c3de4203a0e21029bc497fd6562096bdd6b76b761565c0e56206f16cccd2bc449d5625c8235931f4312810697ed2b547a41d3fb42286d98bb1
|
data/Gemfile
CHANGED
|
@@ -2,8 +2,6 @@ source 'https://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
gem 'zip'
|
|
6
|
-
|
|
7
5
|
# gem 'neo4j-advanced', '>= 1.8.1', '< 2.0', :require => false
|
|
8
6
|
# gem 'neo4j-enterprise', '>= 1.8.1', '< 2.0', :require => false
|
|
9
7
|
|
|
@@ -14,7 +12,6 @@ end
|
|
|
14
12
|
group 'test' do
|
|
15
13
|
gem 'coveralls', require: false
|
|
16
14
|
gem 'simplecov-html', require: false
|
|
17
|
-
gem 'rake', '>= 0.8.7'
|
|
18
15
|
gem 'rspec', '~> 3.0'
|
|
19
16
|
gem 'rspec-its'
|
|
20
17
|
end
|
data/README.md
CHANGED
|
@@ -1,25 +1,51 @@
|
|
|
1
|
-
# Neo4j-core
|
|
1
|
+
# Neo4j-core [](https://codeclimate.com/github/neo4jrb/neo4j-core) [](https://travis-ci.org/neo4jrb/neo4j-core) [](https://coveralls.io/r/neo4jrb/neo4j-core?branch=master) [](https://www.pullreview.com/github/neo4jrb/neo4j-core/reviews/master)
|
|
2
2
|
|
|
3
3
|
A simple Ruby wrapper around the Neo4j graph database that works with the server and embedded Neo4j API. This gem can be used both from JRuby and normal MRI.
|
|
4
4
|
It can be used standalone without the neo4j gem.
|
|
5
5
|
|
|
6
6
|
## Documentation
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* [2.x Documentation](https://github.com/neo4jrb/neo4j-core/tree/v2.x)
|
|
8
|
+
### 3.0+ Documentation:
|
|
10
9
|
|
|
10
|
+
* http://neo4jrb.readthedocs.org/en/stable/
|
|
11
|
+
* https://github.com/neo4jrb/neo4j-core/wiki
|
|
12
|
+
|
|
13
|
+
### 2.x Documentation
|
|
14
|
+
|
|
15
|
+
https://github.com/neo4jrb/neo4j-core/tree/v2.x
|
|
11
16
|
|
|
12
17
|
## Support
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
### Issues
|
|
20
|
+
|
|
21
|
+
[  ](https://waffle.io/neo4jrb/neo4j-core)
|
|
22
|
+
|
|
23
|
+
[](https://waffle.io/neo4jrb/neo4j-core)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Get Support
|
|
27
|
+
|
|
28
|
+
#### Documentation
|
|
29
|
+
|
|
30
|
+
All new documentation will be done via our [readthedocs](http://neo4jrb.readthedocs.org) site, though some old documentation has yet to be moved from our [wiki](https://github.com/neo4jrb/neo4j/wiki) (also there is the [neo4j-core wiki](https://github.com/neo4jrb/neo4j-core/wiki))
|
|
31
|
+
|
|
32
|
+
#### Contact Us
|
|
33
|
+
|
|
34
|
+
[](http://stackoverflow.com/questions/ask?tags=neo4j.rb+neo4j+ruby) [](https://gitter.im/neo4jrb/neo4j?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://twitter.com/neo4jrb) [](https://groups.google.com/forum/#!forum/neo4jrb)
|
|
35
|
+
|
|
16
36
|
|
|
17
37
|
## Developers
|
|
18
38
|
|
|
19
|
-
|
|
39
|
+
### Original Author
|
|
40
|
+
|
|
41
|
+
* [Andreas Ronge](https://github.com/andreasronge)
|
|
42
|
+
|
|
43
|
+
### Current Maintainers
|
|
44
|
+
|
|
20
45
|
* [Brian Underwood](https://github.com/cheerfulstoic)
|
|
21
46
|
* [Chris Grigg](https://github.com/subvertallchris)
|
|
22
47
|
|
|
48
|
+
Consulting support? Contact [Chris](http://subvertallmedia.com/) and/or [Brian](http://www.brian-underwood.codes/)
|
|
23
49
|
|
|
24
50
|
## Contributing
|
|
25
51
|
|
data/lib/neo4j/ansi.rb
ADDED
data/lib/neo4j/label.rb
CHANGED
data/lib/neo4j/node.rb
CHANGED
|
@@ -168,7 +168,12 @@ module Neo4j
|
|
|
168
168
|
class << self
|
|
169
169
|
# Creates a node
|
|
170
170
|
def create(props = nil, *labels_or_db)
|
|
171
|
-
session = Neo4j::
|
|
171
|
+
session = if labels_or_db.last.is_a?(Neo4j::Session)
|
|
172
|
+
labels_or_db.pop
|
|
173
|
+
else
|
|
174
|
+
Neo4j::Session.current!
|
|
175
|
+
end
|
|
176
|
+
|
|
172
177
|
session.create_node(props, labels_or_db)
|
|
173
178
|
end
|
|
174
179
|
|
data/lib/neo4j-core/helpers.rb
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
module Neo4j
|
|
2
2
|
module Core
|
|
3
|
-
module ArgumentHelper
|
|
4
|
-
def self.session(args)
|
|
5
|
-
args.last.is_a?(Neo4j::Session) ? args.pop : Neo4j::Session.current!
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
3
|
module TxMethods
|
|
10
4
|
def tx_methods(*methods)
|
|
11
5
|
methods.each do |method|
|
|
12
6
|
tx_method = "#{method}_in_tx"
|
|
13
7
|
send(:alias_method, tx_method, method)
|
|
14
8
|
send(:define_method, method) do |*args, &block|
|
|
15
|
-
session =
|
|
9
|
+
session = args.last.is_a?(Neo4j::Session) ? args.pop : Neo4j::Session.current!
|
|
10
|
+
|
|
16
11
|
Neo4j::Transaction.run(session.auto_commit?) { send(tx_method, *args, &block) }
|
|
17
12
|
end
|
|
18
13
|
end
|
data/lib/neo4j-core/query.rb
CHANGED
|
@@ -18,6 +18,10 @@ module Neo4j
|
|
|
18
18
|
|
|
19
19
|
attr_accessor :clauses
|
|
20
20
|
|
|
21
|
+
class << self
|
|
22
|
+
attr_accessor :pretty_cypher
|
|
23
|
+
end
|
|
24
|
+
|
|
21
25
|
def initialize(options = {})
|
|
22
26
|
@session = options[:session] || Neo4j::Session.current
|
|
23
27
|
|
|
@@ -26,6 +30,10 @@ module Neo4j
|
|
|
26
30
|
@_params = {}
|
|
27
31
|
end
|
|
28
32
|
|
|
33
|
+
def inspect
|
|
34
|
+
"#<Query CYPHER: #{ANSI::YELLOW}#{to_cypher.inspect}#{ANSI::CLEAR}>"
|
|
35
|
+
end
|
|
36
|
+
|
|
29
37
|
# @method start *args
|
|
30
38
|
# START clause
|
|
31
39
|
# @return [Query]
|
|
@@ -133,6 +141,12 @@ module Neo4j
|
|
|
133
141
|
query.order(*args)
|
|
134
142
|
end
|
|
135
143
|
|
|
144
|
+
# Works the same as the #where method, but the clause is surrounded by a
|
|
145
|
+
# Cypher NOT() function
|
|
146
|
+
def where_not(*args)
|
|
147
|
+
build_deeper_query(WhereClause, args, not: true)
|
|
148
|
+
end
|
|
149
|
+
|
|
136
150
|
# Works the same as the #set method, but when given a nested array it will set properties rather than setting entire objects
|
|
137
151
|
# @example
|
|
138
152
|
# # Creates a query representing the cypher: MATCH (n:Person) SET n.age = 19
|
|
@@ -174,9 +188,10 @@ module Neo4j
|
|
|
174
188
|
def response
|
|
175
189
|
return @response if @response
|
|
176
190
|
cypher = to_cypher
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
191
|
+
pretty_cypher = to_cypher(pretty: true) if self.class.pretty_cypher
|
|
192
|
+
|
|
193
|
+
@response = @session._query(cypher, merge_params, context: @options[:context], pretty_cypher: pretty_cypher)
|
|
194
|
+
|
|
180
195
|
if !response.respond_to?(:error?) || !response.error?
|
|
181
196
|
response
|
|
182
197
|
else
|
|
@@ -184,6 +199,17 @@ module Neo4j
|
|
|
184
199
|
end
|
|
185
200
|
end
|
|
186
201
|
|
|
202
|
+
def match_nodes(hash)
|
|
203
|
+
hash.inject(self) do |query, (variable, node_object)|
|
|
204
|
+
neo_id = if node_object.respond_to?(:neo_id)
|
|
205
|
+
node_object.neo_id
|
|
206
|
+
else
|
|
207
|
+
node_object
|
|
208
|
+
end
|
|
209
|
+
query.match(variable).where(variable => {neo_id: neo_id})
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
187
213
|
include Enumerable
|
|
188
214
|
|
|
189
215
|
def count(var = nil)
|
|
@@ -257,22 +283,27 @@ module Neo4j
|
|
|
257
283
|
#
|
|
258
284
|
# @return [String] Resulting cypher query string
|
|
259
285
|
EMPTY = ' '
|
|
260
|
-
|
|
286
|
+
NEWLINE = "\n"
|
|
287
|
+
def to_cypher(options = {})
|
|
261
288
|
cypher_string = PartitionedClauses.new(@clauses).map do |clauses|
|
|
262
289
|
clauses_by_class = clauses.group_by(&:class)
|
|
263
290
|
|
|
264
291
|
cypher_parts = CLAUSES.map do |clause_class|
|
|
265
|
-
clause_class.to_cypher(clauses) if clauses = clauses_by_class[clause_class]
|
|
292
|
+
clause_class.to_cypher(clauses, options) if clauses = clauses_by_class[clause_class]
|
|
266
293
|
end
|
|
267
294
|
|
|
268
295
|
cypher_parts.compact!
|
|
269
|
-
cypher_parts.join(EMPTY).tap(&:strip!)
|
|
270
|
-
end.join EMPTY
|
|
296
|
+
cypher_parts.join(options[:pretty] ? NEWLINE : EMPTY).tap(&:strip!)
|
|
297
|
+
end.join(options[:pretty] ? NEWLINE : EMPTY)
|
|
271
298
|
|
|
272
299
|
cypher_string = "CYPHER #{@options[:parser]} #{cypher_string}" if @options[:parser]
|
|
273
300
|
cypher_string.tap(&:strip!)
|
|
274
301
|
end
|
|
275
302
|
|
|
303
|
+
def print_cypher
|
|
304
|
+
puts to_cypher(pretty: true).gsub(/\e[^m]+m/, '')
|
|
305
|
+
end
|
|
306
|
+
|
|
276
307
|
# Returns a CYPHER query specifying the union of the callee object's query and the argument's query
|
|
277
308
|
#
|
|
278
309
|
# @example
|