neo4j-core 5.0.10 → 5.1.0.rc.1
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 -4
- data/README.md +32 -6
- data/lib/neo4j-core.rb +0 -1
- data/lib/neo4j-core/helpers.rb +2 -7
- data/lib/neo4j-core/query.rb +19 -5
- data/lib/neo4j-core/query_clauses.rb +123 -35
- data/lib/neo4j-core/version.rb +1 -1
- data/lib/neo4j-embedded.rb +1 -1
- data/lib/neo4j-embedded/embedded_session.rb +15 -9
- data/lib/neo4j-server.rb +0 -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 +20 -14
- data/lib/neo4j-server/cypher_transaction.rb +0 -1
- data/lib/neo4j/label.rb +0 -1
- data/lib/neo4j/node.rb +6 -1
- data/neo4j-core.gemspec +1 -2
- metadata +8 -27
- 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
- data/lib/neo4j/tasks/config_server.rb +0 -36
- data/lib/neo4j/tasks/neo4j_server.rake +0 -258
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ca70d80670e3232da4c5b05833cfa06ced3adf5
|
4
|
+
data.tar.gz: 7d32346859088e577bba8617ecd8b3d13f553880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4853d0684c0d1a9b1ca8d0af69e414a3b31ddaacb68535e9bddd3c489a3bea65142bf68114e858903cdaf5a5f3b6d5fcdae7c52663477a0555821bd681175a61
|
7
|
+
data.tar.gz: f870bc4b2b1dad67d625fde00a37f1e5ace304e31d26b2cc48396e937fd72a0d94a10f73a05fe1977fc9c4cc9cd6a257ff1a80d9b74e0b4234b0562543553162
|
data/Gemfile
CHANGED
@@ -2,20 +2,16 @@ 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
|
|
10
8
|
group 'development' do
|
11
9
|
gem 'guard-rspec', require: false
|
12
|
-
gem 'overcommit'
|
13
10
|
end
|
14
11
|
|
15
12
|
group 'test' do
|
16
13
|
gem 'coveralls', require: false
|
17
14
|
gem 'simplecov-html', require: false
|
18
|
-
gem 'rake', '>= 0.8.7'
|
19
15
|
gem 'rspec', '~> 3.0'
|
20
16
|
gem 'rspec-its'
|
21
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-core.rb
CHANGED
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: #{to_cypher.inspect}>"
|
35
|
+
end
|
36
|
+
|
29
37
|
# @method start *args
|
30
38
|
# START clause
|
31
39
|
# @return [Query]
|
@@ -174,8 +182,9 @@ module Neo4j
|
|
174
182
|
def response
|
175
183
|
return @response if @response
|
176
184
|
cypher = to_cypher
|
185
|
+
pretty_cypher = to_cypher(pretty: true).gsub(/\e[^m]+m/, '') #if self.class.pretty_cypher
|
177
186
|
|
178
|
-
@response = @session._query(cypher, merge_params, context: @options[:context])
|
187
|
+
@response = @session._query(cypher, merge_params, context: @options[:context], pretty_cypher: pretty_cypher)
|
179
188
|
|
180
189
|
if !response.respond_to?(:error?) || !response.error?
|
181
190
|
response
|
@@ -268,22 +277,27 @@ module Neo4j
|
|
268
277
|
#
|
269
278
|
# @return [String] Resulting cypher query string
|
270
279
|
EMPTY = ' '
|
271
|
-
|
280
|
+
NEWLINE = "\n"
|
281
|
+
def to_cypher(options = {})
|
272
282
|
cypher_string = PartitionedClauses.new(@clauses).map do |clauses|
|
273
283
|
clauses_by_class = clauses.group_by(&:class)
|
274
284
|
|
275
285
|
cypher_parts = CLAUSES.map do |clause_class|
|
276
|
-
clause_class.to_cypher(clauses) if clauses = clauses_by_class[clause_class]
|
286
|
+
clause_class.to_cypher(clauses, options) if clauses = clauses_by_class[clause_class]
|
277
287
|
end
|
278
288
|
|
279
289
|
cypher_parts.compact!
|
280
|
-
cypher_parts.join(EMPTY).tap(&:strip!)
|
281
|
-
end.join EMPTY
|
290
|
+
cypher_parts.join(options[:pretty] ? NEWLINE : EMPTY).tap(&:strip!)
|
291
|
+
end.join(options[:pretty] ? NEWLINE : EMPTY)
|
282
292
|
|
283
293
|
cypher_string = "CYPHER #{@options[:parser]} #{cypher_string}" if @options[:parser]
|
284
294
|
cypher_string.tap(&:strip!)
|
285
295
|
end
|
286
296
|
|
297
|
+
def print_cypher
|
298
|
+
puts to_cypher(pretty: true).gsub(/\e[^m]+m/, '')
|
299
|
+
end
|
300
|
+
|
287
301
|
# Returns a CYPHER query specifying the union of the callee object's query and the argument's query
|
288
302
|
#
|
289
303
|
# @example
|
@@ -11,7 +11,6 @@ module Neo4j
|
|
11
11
|
|
12
12
|
|
13
13
|
class Clause
|
14
|
-
include CypherTranslator
|
15
14
|
UNDERSCORE = '_'
|
16
15
|
COMMA_SPACE = ', '
|
17
16
|
AND = ' AND '
|
@@ -53,8 +52,10 @@ module Neo4j
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def node_from_key_and_value(key, value, options = {})
|
56
|
-
|
57
|
-
|
55
|
+
prefer = options[:prefer] || :var
|
56
|
+
var = var_from_key_and_value(key, value, prefer)
|
57
|
+
label = label_from_key_and_value(key, value, prefer)
|
58
|
+
|
58
59
|
attributes = attributes_from_key_and_value(key, value)
|
59
60
|
|
60
61
|
prefix_value = value
|
@@ -131,13 +132,34 @@ module Neo4j
|
|
131
132
|
new(arg, options) if !arg.respond_to?(:empty?) || !arg.empty?
|
132
133
|
end
|
133
134
|
|
134
|
-
def to_cypher(clauses)
|
135
|
+
def to_cypher(clauses, options = {})
|
135
136
|
@question_mark_param_index = 1
|
136
137
|
|
137
|
-
string = clause_string(clauses)
|
138
|
-
|
138
|
+
string = clause_string(clauses, options)
|
139
|
+
|
140
|
+
final_keyword = if options[:pretty]
|
141
|
+
"#{clause_color}#{keyword}#{ANSI::CLEAR}"
|
142
|
+
else
|
143
|
+
keyword
|
144
|
+
end
|
145
|
+
|
146
|
+
"#{final_keyword} #{string}" if string.size > 0
|
147
|
+
end
|
148
|
+
|
149
|
+
def clause_string(clauses, options = {})
|
150
|
+
join_string = clause_join + (options[:pretty] ? "\n " : '')
|
139
151
|
|
140
|
-
|
152
|
+
strings = clause_strings(clauses)
|
153
|
+
string = ((options[:pretty] && strings.size > 1) ? "\n " : '')
|
154
|
+
string + strings.join(join_string).strip
|
155
|
+
end
|
156
|
+
|
157
|
+
def clause_join
|
158
|
+
''
|
159
|
+
end
|
160
|
+
|
161
|
+
def clause_color
|
162
|
+
ANSI::CYAN
|
141
163
|
end
|
142
164
|
end
|
143
165
|
|
@@ -228,8 +250,12 @@ module Neo4j
|
|
228
250
|
end
|
229
251
|
|
230
252
|
class << self
|
231
|
-
def
|
232
|
-
clauses.map!(&:value)
|
253
|
+
def clause_strings(clauses)
|
254
|
+
clauses.map!(&:value)
|
255
|
+
end
|
256
|
+
|
257
|
+
def clause_join
|
258
|
+
Clause::COMMA_SPACE
|
233
259
|
end
|
234
260
|
end
|
235
261
|
end
|
@@ -249,8 +275,12 @@ module Neo4j
|
|
249
275
|
end
|
250
276
|
|
251
277
|
class << self
|
252
|
-
def
|
253
|
-
clauses.map!(&:value).tap(&:flatten!).map! { |value| "(#{value})" }
|
278
|
+
def clause_strings(clauses)
|
279
|
+
clauses.map!(&:value).tap(&:flatten!).map! { |value| "(#{value})" }
|
280
|
+
end
|
281
|
+
|
282
|
+
def clause_join
|
283
|
+
Clause::AND
|
254
284
|
end
|
255
285
|
end
|
256
286
|
|
@@ -322,8 +352,12 @@ module Neo4j
|
|
322
352
|
end
|
323
353
|
|
324
354
|
class << self
|
325
|
-
def
|
326
|
-
clauses.map!(&:value)
|
355
|
+
def clause_strings(clauses)
|
356
|
+
clauses.map!(&:value)
|
357
|
+
end
|
358
|
+
|
359
|
+
def clause_join
|
360
|
+
Clause::COMMA_SPACE
|
327
361
|
end
|
328
362
|
end
|
329
363
|
end
|
@@ -344,8 +378,12 @@ module Neo4j
|
|
344
378
|
end
|
345
379
|
|
346
380
|
class << self
|
347
|
-
def
|
348
|
-
clauses.map!(&:value)
|
381
|
+
def clause_strings(clauses)
|
382
|
+
clauses.map!(&:value)
|
383
|
+
end
|
384
|
+
|
385
|
+
def clause_join
|
386
|
+
Clause::COMMA_SPACE
|
349
387
|
end
|
350
388
|
end
|
351
389
|
end
|
@@ -354,8 +392,12 @@ module Neo4j
|
|
354
392
|
KEYWORD = 'USING'
|
355
393
|
|
356
394
|
class << self
|
357
|
-
def
|
358
|
-
clauses.map!(&:value)
|
395
|
+
def clause_strings(clauses)
|
396
|
+
clauses.map!(&:value)
|
397
|
+
end
|
398
|
+
|
399
|
+
def clause_join
|
400
|
+
" #{keyword} "
|
359
401
|
end
|
360
402
|
end
|
361
403
|
end
|
@@ -386,8 +428,16 @@ module Neo4j
|
|
386
428
|
end
|
387
429
|
|
388
430
|
class << self
|
389
|
-
def
|
390
|
-
clauses.map!(&:value)
|
431
|
+
def clause_strings(clauses)
|
432
|
+
clauses.map!(&:value)
|
433
|
+
end
|
434
|
+
|
435
|
+
def clause_join
|
436
|
+
', '
|
437
|
+
end
|
438
|
+
|
439
|
+
def clause_color
|
440
|
+
ANSI::GREEN
|
391
441
|
end
|
392
442
|
end
|
393
443
|
end
|
@@ -398,6 +448,12 @@ module Neo4j
|
|
398
448
|
|
399
449
|
class MergeClause < CreateClause
|
400
450
|
KEYWORD = 'MERGE'
|
451
|
+
|
452
|
+
class << self
|
453
|
+
def clause_color
|
454
|
+
ANSI::MAGENTA
|
455
|
+
end
|
456
|
+
end
|
401
457
|
end
|
402
458
|
|
403
459
|
class DeleteClause < Clause
|
@@ -408,8 +464,16 @@ module Neo4j
|
|
408
464
|
end
|
409
465
|
|
410
466
|
class << self
|
411
|
-
def
|
412
|
-
clauses.map!(&:value)
|
467
|
+
def clause_strings(clauses)
|
468
|
+
clauses.map!(&:value)
|
469
|
+
end
|
470
|
+
|
471
|
+
def clause_join
|
472
|
+
Clause::COMMA_SPACE
|
473
|
+
end
|
474
|
+
|
475
|
+
def clause_color
|
476
|
+
ANSI::RED
|
413
477
|
end
|
414
478
|
end
|
415
479
|
end
|
@@ -435,8 +499,12 @@ module Neo4j
|
|
435
499
|
end
|
436
500
|
|
437
501
|
class << self
|
438
|
-
def
|
439
|
-
clauses.map!(&:value)
|
502
|
+
def clause_strings(clauses)
|
503
|
+
clauses.map!(&:value)
|
504
|
+
end
|
505
|
+
|
506
|
+
def clause_join
|
507
|
+
Clause::COMMA_SPACE
|
440
508
|
end
|
441
509
|
end
|
442
510
|
end
|
@@ -461,8 +529,8 @@ module Neo4j
|
|
461
529
|
end
|
462
530
|
|
463
531
|
class << self
|
464
|
-
def
|
465
|
-
clauses.last.value
|
532
|
+
def clause_strings(clauses)
|
533
|
+
[clauses.last.value]
|
466
534
|
end
|
467
535
|
end
|
468
536
|
end
|
@@ -483,8 +551,8 @@ module Neo4j
|
|
483
551
|
end
|
484
552
|
|
485
553
|
class << self
|
486
|
-
def
|
487
|
-
clauses.last.value
|
554
|
+
def clause_strings(clauses)
|
555
|
+
[clauses.last.value]
|
488
556
|
end
|
489
557
|
end
|
490
558
|
end
|
@@ -510,8 +578,16 @@ module Neo4j
|
|
510
578
|
end
|
511
579
|
|
512
580
|
class << self
|
513
|
-
def
|
514
|
-
clauses.map!(&:value)
|
581
|
+
def clause_strings(clauses)
|
582
|
+
clauses.map!(&:value)
|
583
|
+
end
|
584
|
+
|
585
|
+
def clause_join
|
586
|
+
Clause::COMMA_SPACE
|
587
|
+
end
|
588
|
+
|
589
|
+
def clause_color
|
590
|
+
ANSI::YELLOW
|
515
591
|
end
|
516
592
|
end
|
517
593
|
end
|
@@ -550,8 +626,12 @@ module Neo4j
|
|
550
626
|
end
|
551
627
|
|
552
628
|
class << self
|
553
|
-
def
|
554
|
-
clauses.map!(&:value)
|
629
|
+
def clause_strings(clauses)
|
630
|
+
clauses.map!(&:value)
|
631
|
+
end
|
632
|
+
|
633
|
+
def clause_join
|
634
|
+
Clause::COMMA_SPACE
|
555
635
|
end
|
556
636
|
end
|
557
637
|
end
|
@@ -571,8 +651,12 @@ module Neo4j
|
|
571
651
|
end
|
572
652
|
|
573
653
|
class << self
|
574
|
-
def
|
575
|
-
clauses.map!(&:value)
|
654
|
+
def clause_strings(clauses)
|
655
|
+
clauses.map!(&:value)
|
656
|
+
end
|
657
|
+
|
658
|
+
def clause_join
|
659
|
+
' UNWIND '
|
576
660
|
end
|
577
661
|
end
|
578
662
|
end
|
@@ -602,8 +686,12 @@ module Neo4j
|
|
602
686
|
end
|
603
687
|
|
604
688
|
class << self
|
605
|
-
def
|
606
|
-
clauses.map!(&:value)
|
689
|
+
def clause_strings(clauses)
|
690
|
+
clauses.map!(&:value)
|
691
|
+
end
|
692
|
+
|
693
|
+
def clause_join
|
694
|
+
Clause::COMMA_SPACE
|
607
695
|
end
|
608
696
|
end
|
609
697
|
end
|