neo4j-cypher 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/README.rdoc +2 -1
- data/lib/neo4j-cypher/clause.rb +2 -2
- data/lib/neo4j-cypher/clause_list.rb +2 -2
- data/lib/neo4j-cypher/context.rb +10 -0
- data/lib/neo4j-cypher/create.rb +21 -4
- data/lib/neo4j-cypher/node_var.rb +2 -2
- data/lib/neo4j-cypher/result_wrapper.rb +14 -3
- data/lib/neo4j-cypher/root.rb +2 -0
- data/lib/neo4j-cypher/version.rb +1 -1
- metadata +9 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4ab6db292610780f4016937d4872254f49424496
|
4
|
+
data.tar.gz: 7cb2c9c1fb21c70686fef80d3b8c268740f94843
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54514ebfad0fbce0db6b8016fdded8d78f63873dc9dcee0d8fde59e0d77735844ea1217ca12c180d82149c2f7a12d8841d30c75f2a0ffa3538e3edfc46dc80b2
|
7
|
+
data.tar.gz: f7286c628777fc15f810b8176eaa6e1011e3545f33f2b3654a6dc90b15a8c07e4abb798d3b25428a479b211e54c7d7302a8e3a503ef10c618eb32fbab6279115
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -5,7 +5,8 @@ The JRuby neo4j-core gem's cypher dsl has been moved to this gem.
|
|
5
5
|
|
6
6
|
== Docs
|
7
7
|
|
8
|
-
* {
|
8
|
+
* {The Cypher DSL docs}[https://github.com/andreasronge/neo4j/wiki/Neo4j%3A%3ACypher]
|
9
|
+
* {Blog: The Cypher Ruby DSL}[http://www.jayway.com/2012/10/04/the-cypher-ruby-dsl-for-the-neo4j-graph-database/]
|
9
10
|
* {Neo4j Cypher Docs}[http://docs.neo4j.org/chunked/stable/]
|
10
11
|
* RSpecs (100% test coverage)
|
11
12
|
|
data/lib/neo4j-cypher/clause.rb
CHANGED
@@ -5,10 +5,10 @@ module Neo4j
|
|
5
5
|
# Does expect a #clause method when included
|
6
6
|
module Clause
|
7
7
|
|
8
|
-
ORDER = [:start, :match, :create, :where, :with, :foreach, :set, :delete, :return, :order_by, :skip, :limit]
|
8
|
+
ORDER = [:start, :match, :create, :where, :with, :foreach, :set, :delete, :remove, :return, :order_by, :skip, :limit]
|
9
9
|
NAME = {:start => 'START', :create => 'CREATE', :match => 'MATCH', :where => "WHERE", :with => 'WITH',
|
10
10
|
:return => 'RETURN', :order_by => 'ORDER BY', :skip => 'SKIP', :limit => 'LIMIT', :set => 'SET',
|
11
|
-
:delete => 'DELETE', :foreach => 'FOREACH'}
|
11
|
+
:remove => 'REMOVE', :delete => 'DELETE', :foreach => 'FOREACH'}
|
12
12
|
|
13
13
|
attr_accessor :clause_type, :clause_list, :eval_context, :expr, :insert_order
|
14
14
|
|
@@ -108,9 +108,9 @@ module Neo4j
|
|
108
108
|
|
109
109
|
def prefix_for_depth_2
|
110
110
|
if include?(:match) && include?(:where)
|
111
|
-
[:set, :delete, :create, :where]
|
111
|
+
[:set, :delete, :create, :remove, :where]
|
112
112
|
else
|
113
|
-
[:set, :delete, :create]
|
113
|
+
[:set, :delete, :create, :remove]
|
114
114
|
end
|
115
115
|
|
116
116
|
end
|
data/lib/neo4j-cypher/context.rb
CHANGED
@@ -297,6 +297,16 @@ module Neo4j
|
|
297
297
|
self
|
298
298
|
end
|
299
299
|
|
300
|
+
def set_label(*labels)
|
301
|
+
Label.new(clause_list, clause, labels, :set)
|
302
|
+
self
|
303
|
+
end
|
304
|
+
|
305
|
+
def del_label(*labels)
|
306
|
+
Label.new(clause_list, clause, labels, :remove)
|
307
|
+
self
|
308
|
+
end
|
309
|
+
|
300
310
|
def del
|
301
311
|
Delete.new(clause_list, clause)
|
302
312
|
self
|
data/lib/neo4j-cypher/create.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
module Neo4j
|
2
2
|
module Cypher
|
3
3
|
|
4
|
+
class Label
|
5
|
+
include Clause
|
6
|
+
|
7
|
+
def initialize(clause_list, var, labels, clause_type)
|
8
|
+
super(clause_list, clause_type)
|
9
|
+
@var = var
|
10
|
+
@labels = labels
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_cypher
|
14
|
+
"#{@var.var_name.to_s} :#{@labels.map(&:to_s).join(':')}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
4
18
|
class Delete
|
5
19
|
include Clause
|
6
20
|
|
@@ -19,9 +33,10 @@ module Neo4j
|
|
19
33
|
class Create
|
20
34
|
include Clause
|
21
35
|
|
22
|
-
def initialize(clause_list, props)
|
36
|
+
def initialize(clause_list, props, labels=nil)
|
23
37
|
super(clause_list, :create, EvalContext)
|
24
|
-
@props = props
|
38
|
+
@props = props unless props && props.empty?
|
39
|
+
@labels = labels unless labels && labels.empty?
|
25
40
|
end
|
26
41
|
|
27
42
|
def as_create_path?
|
@@ -37,10 +52,12 @@ module Neo4j
|
|
37
52
|
end
|
38
53
|
|
39
54
|
def to_cypher
|
55
|
+
label_suffix = @labels && ":" + @labels.map{|name| "`#{name.to_s}`"}.join(':')
|
56
|
+
|
40
57
|
without_parantheses = if @props
|
41
|
-
"#{var_name} #{to_prop_string(@props)}"
|
58
|
+
"#{var_name}#{label_suffix} #{to_prop_string(@props)}"
|
42
59
|
else
|
43
|
-
var_name
|
60
|
+
"#{var_name}#{label_suffix}"
|
44
61
|
end
|
45
62
|
|
46
63
|
as_create_path? ? without_parantheses : "(#{without_parantheses})"
|
@@ -13,6 +13,8 @@ module Neo4j
|
|
13
13
|
# r[0][:n].neo_id.should == @a.neo_id
|
14
14
|
# r[1][:n].neo_id.should == @b.neo_id
|
15
15
|
class ResultWrapper
|
16
|
+
class ResultsAlreadyConsumedException < Exception; end;
|
17
|
+
|
16
18
|
include Enumerable
|
17
19
|
|
18
20
|
# @return the original result from the Neo4j Cypher Engine, once forward read only !
|
@@ -20,6 +22,7 @@ module Neo4j
|
|
20
22
|
|
21
23
|
def initialize(source)
|
22
24
|
@source = source
|
25
|
+
@unread = true
|
23
26
|
end
|
24
27
|
|
25
28
|
# @return [Array<Symbol>] the columns in the query result
|
@@ -29,12 +32,20 @@ module Neo4j
|
|
29
32
|
|
30
33
|
# for the Enumerable contract
|
31
34
|
def each
|
32
|
-
|
35
|
+
raise ResultsAlreadyConsumedException unless @unread
|
36
|
+
|
37
|
+
if block_given?
|
38
|
+
@unread = false
|
39
|
+
@source.each { |row| yield symbolize_row_keys(row) }
|
40
|
+
else
|
41
|
+
Enumerator.new(self)
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
45
|
+
private
|
46
|
+
|
35
47
|
# Maps each row so that we can use symbols for column names.
|
36
|
-
|
37
|
-
def map(row)
|
48
|
+
def symbolize_row_keys(row)
|
38
49
|
out = {} # move to a real hash!
|
39
50
|
row.each do |key, value|
|
40
51
|
out[key.to_sym] = value.respond_to?(:wrapper) ? value.wrapper : value
|
data/lib/neo4j-cypher/root.rb
CHANGED
@@ -14,6 +14,8 @@ module Neo4j
|
|
14
14
|
return if clause_list.include?(:return)
|
15
15
|
return if clause_list.include?(:with)
|
16
16
|
return if clause_list.include?(:delete)
|
17
|
+
return if clause_list.include?(:set)
|
18
|
+
return if clause_list.include?(:remove)
|
17
19
|
end
|
18
20
|
create_returns(result)
|
19
21
|
end
|
data/lib/neo4j-cypher/version.rb
CHANGED
metadata
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j-cypher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Andreas Ronge
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
implementation since it simply
|
16
|
-
|
13
|
+
description: |
|
14
|
+
This gem is used in the JRuby neo4j gem but should work on any Ruby implementation since it simply
|
17
15
|
translate a Ruby block (the dsl) to a cypher string.
|
18
|
-
|
19
|
-
'
|
20
16
|
email: andreas.ronge@gmail.com
|
21
17
|
executables: []
|
22
18
|
extensions: []
|
@@ -53,6 +49,7 @@ files:
|
|
53
49
|
- neo4j-cypher.gemspec
|
54
50
|
homepage: http://github.com/andreasronge/neo4j-cypher/tree
|
55
51
|
licenses: []
|
52
|
+
metadata: {}
|
56
53
|
post_install_message:
|
57
54
|
rdoc_options:
|
58
55
|
- --quiet
|
@@ -65,24 +62,19 @@ rdoc_options:
|
|
65
62
|
require_paths:
|
66
63
|
- lib
|
67
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
65
|
requirements:
|
70
|
-
- -
|
66
|
+
- - '>='
|
71
67
|
- !ruby/object:Gem::Version
|
72
68
|
version: 1.8.7
|
73
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
70
|
requirements:
|
76
|
-
- -
|
71
|
+
- - '>='
|
77
72
|
- !ruby/object:Gem::Version
|
78
73
|
version: '0'
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
hash: -2728689632116511744
|
82
74
|
requirements: []
|
83
75
|
rubyforge_project: neo4j-cypher
|
84
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 2.1.5
|
85
77
|
signing_key:
|
86
|
-
specification_version:
|
78
|
+
specification_version: 4
|
87
79
|
summary: A Ruby DSL for Cypher - the Neo4j Graph Query Language
|
88
80
|
test_files: []
|