neo4j-core 6.0.6 → 6.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/README.md +1 -1
- data/lib/neo4j-core.rb +1 -12
- data/lib/neo4j-core/version.rb +1 -1
- data/lib/neo4j-embedded/embedded_node.rb +3 -1
- data/lib/neo4j-embedded/embedded_relationship.rb +2 -0
- data/lib/neo4j-server/cypher_node.rb +2 -0
- data/lib/neo4j-server/cypher_relationship.rb +2 -0
- data/lib/neo4j/core/cypher_session/transactions.rb +20 -0
- data/lib/neo4j/core/cypher_session/transactions/http.rb +29 -0
- data/lib/neo4j/entity_marshal.rb +20 -0
- data/lib/neo4j/node.rb +1 -0
- data/lib/neo4j/relationship.rb +1 -0
- data/lib/neo4j/session.rb +5 -0
- data/neo4j-core.gemspec +2 -2
- metadata +9 -7
- data/lib/neo4j/core/label.rb +0 -127
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e65b214c5b462b02973ee2557d0624c893699d31
|
4
|
+
data.tar.gz: c0c28e5026420b375a1a31b9d735845b4f6af5fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 227cb900863ceca9a5513079dbfac35efa785c6f95147ba93f73bfdab277111a13b055c8361d376b3be4da5489da9f5a9ea4492c32ecfacac1d43285c271405b
|
7
|
+
data.tar.gz: 25cc03d274112e3a315de1dc91f664b18f39c2711201d81b577fde2fbd736dfe3a72f15ce9b555dd30bac21deb7fc644b281379c7fed1f4eb4ee5692d5c52191
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ All new documentation will be done via our [readthedocs](http://neo4jrb.readthed
|
|
31
31
|
|
32
32
|
#### Contact Us
|
33
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)
|
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)
|
35
35
|
|
36
36
|
|
37
37
|
## Developers
|
data/lib/neo4j-core.rb
CHANGED
@@ -7,6 +7,7 @@ require 'fileutils'
|
|
7
7
|
require 'neo4j-core/version'
|
8
8
|
require 'neo4j/property_validator'
|
9
9
|
require 'neo4j/property_container'
|
10
|
+
require 'neo4j/entity_marshal'
|
10
11
|
require 'neo4j-core/active_entity'
|
11
12
|
require 'neo4j-core/helpers'
|
12
13
|
require 'neo4j-core/query_find_in_batches'
|
@@ -21,17 +22,5 @@ require 'neo4j/ansi'
|
|
21
22
|
require 'neo4j/relationship'
|
22
23
|
require 'neo4j/transaction'
|
23
24
|
|
24
|
-
require 'neo4j-server'
|
25
|
-
|
26
25
|
require 'rake'
|
27
26
|
require 'neo4j/rake_tasks'
|
28
|
-
|
29
|
-
if RUBY_PLATFORM == 'java' && !ENV['WITHOUT_NEO4J_EMBEDDED']
|
30
|
-
require 'neo4j-embedded'
|
31
|
-
else
|
32
|
-
# just for the tests
|
33
|
-
module Neo4j
|
34
|
-
module Embedded
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/neo4j-core/version.rb
CHANGED
@@ -4,6 +4,8 @@ module Neo4j
|
|
4
4
|
include Enumerable
|
5
5
|
extend Neo4j::Core::TxMethods
|
6
6
|
|
7
|
+
MARSHAL_INSTANCE_VARIABLES = [:@node, :@match]
|
8
|
+
|
7
9
|
def initialize(node, match)
|
8
10
|
@node = node
|
9
11
|
::Neo4j::Node.validate_match!(match)
|
@@ -168,7 +170,7 @@ module Neo4j
|
|
168
170
|
return nil if not iter.has_next
|
169
171
|
|
170
172
|
first = iter.next
|
171
|
-
fail "Expected to only find one relationship from node #{neo_id} matching
|
173
|
+
fail ArgumentError, "Expected to only find one relationship from node #{neo_id} matching" if iter.has_next
|
172
174
|
first
|
173
175
|
end
|
174
176
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module Core
|
3
|
+
class CypherSession
|
4
|
+
module Transactions
|
5
|
+
class Base < Neo4j::Transaction::Base
|
6
|
+
# Will perhaps be a bit odd as we will pass in the adaptor
|
7
|
+
# as the @session for these new transactions
|
8
|
+
|
9
|
+
def query(*args)
|
10
|
+
@adaptor.query(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def queries(*args)
|
14
|
+
@adaptor.queries(*args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'neo4j/core/cypher_session/transactions'
|
2
|
+
|
3
|
+
module Neo4j
|
4
|
+
module Core
|
5
|
+
class CypherSession
|
6
|
+
module Transactions
|
7
|
+
class HTTP < Base
|
8
|
+
def commit
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Because we're inheriting from the old Transaction class
|
17
|
+
# but the new adaptors work much like the old sessions
|
18
|
+
def adaptor
|
19
|
+
@session
|
20
|
+
end
|
21
|
+
|
22
|
+
def connection
|
23
|
+
adaptor.connection
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Neo4j
|
2
|
+
# To support Ruby marshaling
|
3
|
+
module EntityMarshal
|
4
|
+
def marshal_dump
|
5
|
+
marshal_instance_variables.map(&method(:instance_variable_get))
|
6
|
+
end
|
7
|
+
|
8
|
+
def marshal_load(array)
|
9
|
+
marshal_instance_variables.zip(array).each do |var, value|
|
10
|
+
instance_variable_set(var, value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def marshal_instance_variables
|
17
|
+
self.class::MARSHAL_INSTANCE_VARIABLES
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/neo4j/node.rb
CHANGED
data/lib/neo4j/relationship.rb
CHANGED
data/lib/neo4j/session.rb
CHANGED
@@ -98,6 +98,11 @@ module Neo4j
|
|
98
98
|
# @param [String] endpoint_url The path to the server, either a URL or path to embedded DB
|
99
99
|
# @param [Hash] params Additional configuration options
|
100
100
|
def open(db_type = :server_db, endpoint_url = nil, params = {})
|
101
|
+
case db_type
|
102
|
+
when :server_db then require 'neo4j-server'
|
103
|
+
when :embedded_db then require 'neo4j-embedded'
|
104
|
+
end
|
105
|
+
|
101
106
|
validate_session_num!(db_type)
|
102
107
|
name = params[:name]
|
103
108
|
default = params[:default]
|
data/neo4j-core.gemspec
CHANGED
@@ -28,12 +28,12 @@ Neo4j-core provides classes and methods to work with the graph database Neo4j.
|
|
28
28
|
s.add_dependency('faraday', '~> 0.9.0')
|
29
29
|
s.add_dependency('net-http-persistent')
|
30
30
|
s.add_dependency('httpclient')
|
31
|
-
s.add_dependency('faraday_middleware', '~> 0.
|
31
|
+
s.add_dependency('faraday_middleware', '~> 0.10.0')
|
32
32
|
s.add_dependency('json')
|
33
33
|
s.add_dependency('activesupport') # For ActiveSupport::Notifications
|
34
34
|
s.add_dependency('multi_json')
|
35
35
|
s.add_dependency('faraday_middleware-multi_json')
|
36
|
-
s.add_dependency('neo4j-rake_tasks', '
|
36
|
+
s.add_dependency('neo4j-rake_tasks', '~> 0.3.0')
|
37
37
|
|
38
38
|
s.add_development_dependency('pry')
|
39
39
|
s.add_development_dependency('yard')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge, Chris Grigg, Brian Underwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.10.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.10.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: json
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,14 +140,14 @@ dependencies:
|
|
140
140
|
name: neo4j-rake_tasks
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 0.3.0
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.3.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
@@ -284,13 +284,15 @@ files:
|
|
284
284
|
- lib/neo4j/core/cypher_session/responses/embedded.rb
|
285
285
|
- lib/neo4j/core/cypher_session/responses/http.rb
|
286
286
|
- lib/neo4j/core/cypher_session/result.rb
|
287
|
+
- lib/neo4j/core/cypher_session/transactions.rb
|
288
|
+
- lib/neo4j/core/cypher_session/transactions/http.rb
|
287
289
|
- lib/neo4j/core/instrumentable.rb
|
288
|
-
- lib/neo4j/core/label.rb
|
289
290
|
- lib/neo4j/core/node.rb
|
290
291
|
- lib/neo4j/core/path.rb
|
291
292
|
- lib/neo4j/core/relationship.rb
|
292
293
|
- lib/neo4j/core/wrappable.rb
|
293
294
|
- lib/neo4j/entity_equality.rb
|
295
|
+
- lib/neo4j/entity_marshal.rb
|
294
296
|
- lib/neo4j/label.rb
|
295
297
|
- lib/neo4j/node.rb
|
296
298
|
- lib/neo4j/property_container.rb
|
data/lib/neo4j/core/label.rb
DELETED
@@ -1,127 +0,0 @@
|
|
1
|
-
module Neo4j
|
2
|
-
module Core
|
3
|
-
class Label
|
4
|
-
attr_reader :name
|
5
|
-
|
6
|
-
def initialize(name, session)
|
7
|
-
@name = name
|
8
|
-
@session = session
|
9
|
-
schema_threads = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def create_index(property, options = {})
|
13
|
-
puts "create_index(#{property.inspect}, #{options.inspect})"
|
14
|
-
validate_index_options!(options)
|
15
|
-
properties = property.is_a?(Array) ? property.join(',') : property
|
16
|
-
schema_query("CREATE INDEX ON :`#{@name}`(#{properties})")
|
17
|
-
end
|
18
|
-
|
19
|
-
def drop_index(property, options = {})
|
20
|
-
puts "drop_index(#{property.inspect}, #{options.inspect})"
|
21
|
-
validate_index_options!(options)
|
22
|
-
schema_query("DROP INDEX ON :`#{@name}`(#{property})")
|
23
|
-
end
|
24
|
-
|
25
|
-
# Creates a neo4j constraint on a property
|
26
|
-
# See http://docs.neo4j.org/chunked/stable/query-constraints.html
|
27
|
-
# @example
|
28
|
-
# label = Neo4j::Label.create(:person, session)
|
29
|
-
# label.create_constraint(:name, {type: :unique}, session)
|
30
|
-
#
|
31
|
-
def create_constraint(property, constraints)
|
32
|
-
puts "create_constraint(#{property.inspect}, #{constraints.inspect})"
|
33
|
-
cypher = case constraints[:type]
|
34
|
-
when :unique
|
35
|
-
"CREATE CONSTRAINT ON (n:`#{name}`) ASSERT n.`#{property}` IS UNIQUE"
|
36
|
-
else
|
37
|
-
fail "Not supported constrain #{constraints.inspect} for property #{property} (expected :type => :unique)"
|
38
|
-
end
|
39
|
-
schema_query(cypher)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Drops a neo4j constraint on a property
|
43
|
-
# See http://docs.neo4j.org/chunked/stable/query-constraints.html
|
44
|
-
# @example
|
45
|
-
# label = Neo4j::Label.create(:person, session)
|
46
|
-
# label.create_constraint(:name, {type: :unique}, session)
|
47
|
-
# label.drop_constraint(:name, {type: :unique}, session)
|
48
|
-
#
|
49
|
-
def drop_constraint(property, constraint)
|
50
|
-
puts "drop_constraint(#{property.inspect}, #{constraint.inspect})"
|
51
|
-
cypher = case constraint[:type]
|
52
|
-
when :unique
|
53
|
-
"DROP CONSTRAINT ON (n:`#{name}`) ASSERT n.`#{property}` IS UNIQUE"
|
54
|
-
else
|
55
|
-
fail "Not supported constrain #{constraint.inspect}"
|
56
|
-
end
|
57
|
-
schema_query(cypher)
|
58
|
-
end
|
59
|
-
|
60
|
-
def indexes
|
61
|
-
@session.indexes_for_label(@name)
|
62
|
-
end
|
63
|
-
|
64
|
-
def index?(property)
|
65
|
-
indexes.include?(property)
|
66
|
-
end
|
67
|
-
|
68
|
-
def uniqueness_constraints
|
69
|
-
@session.uniqueness_constraints_for_label(@name)
|
70
|
-
end
|
71
|
-
|
72
|
-
def uniqueness_constraint?(property)
|
73
|
-
uniqueness_constraints.include?(property)
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.wait_for_schema_changes(session)
|
77
|
-
schema_threads(session).map(&:join)
|
78
|
-
set_schema_threads(session, [])
|
79
|
-
end
|
80
|
-
|
81
|
-
private
|
82
|
-
|
83
|
-
# Store schema threads on the session so that we can easily wait for all
|
84
|
-
# threads on a session regardless of label
|
85
|
-
def schema_threads
|
86
|
-
self.class.schema_threads(@session)
|
87
|
-
end
|
88
|
-
|
89
|
-
def schema_threads=(array)
|
90
|
-
self.class.set_schema_threads(@session, array)
|
91
|
-
end
|
92
|
-
|
93
|
-
def self.schema_threads(session)
|
94
|
-
session.instance_variable_get('@_schema_threads') || []
|
95
|
-
end
|
96
|
-
|
97
|
-
def self.set_schema_threads(session, array)
|
98
|
-
session.instance_variable_set('@_schema_threads', array)
|
99
|
-
end
|
100
|
-
|
101
|
-
# If there is a transaction going on, this could block
|
102
|
-
# So we run in a thread and it will go through at the next opportunity
|
103
|
-
def schema_query(cypher)
|
104
|
-
Thread.new do
|
105
|
-
begin
|
106
|
-
puts 'Starting transaction for schema query...'
|
107
|
-
@session.transaction do |tx|
|
108
|
-
puts 'Executing schema query...'
|
109
|
-
tx.query(cypher)
|
110
|
-
puts 'Executed schema query...'
|
111
|
-
end
|
112
|
-
rescue Exception => e
|
113
|
-
puts e.message
|
114
|
-
puts e.backtrace
|
115
|
-
end
|
116
|
-
end.tap do |thread|
|
117
|
-
schema_threads << thread
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def validate_index_options!(options)
|
122
|
-
return unless options[:type] && options[:type] != :exact
|
123
|
-
fail "Type #{options[:type]} is not supported"
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|