neo4j-core 6.1.0 → 6.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e65b214c5b462b02973ee2557d0624c893699d31
4
- data.tar.gz: c0c28e5026420b375a1a31b9d735845b4f6af5fa
3
+ metadata.gz: da06dc452a9115555f4c41864175e341829e75f9
4
+ data.tar.gz: 046393f931563d7bb4722b2ec7b9827a4d7c870a
5
5
  SHA512:
6
- metadata.gz: 227cb900863ceca9a5513079dbfac35efa785c6f95147ba93f73bfdab277111a13b055c8361d376b3be4da5489da9f5a9ea4492c32ecfacac1d43285c271405b
7
- data.tar.gz: 25cc03d274112e3a315de1dc91f664b18f39c2711201d81b577fde2fbd736dfe3a72f15ce9b555dd30bac21deb7fc644b281379c7fed1f4eb4ee5692d5c52191
6
+ metadata.gz: 18947051963ebfb10dfc13eb149587f4a36059c40b4838597d0b230c83eb7e9228d719e5deba355de9c23a3704f9740bbe55adc462c0250c455a7302d6f57c6a
7
+ data.tar.gz: 0a8ab8ec56c8843f2b91e1d0a0f670146a76b64632d3f2fa66003a550ba9f75d232e2497abe73d78f51094d097eb19c208894a80d43e841054d12f099643957d
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = '6.1.0'
3
+ VERSION = '6.1.1'
4
4
  end
5
5
  end
@@ -0,0 +1,127 @@
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
data/neo4j-core.gemspec CHANGED
@@ -33,7 +33,7 @@ Neo4j-core provides classes and methods to work with the graph database Neo4j.
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', '~> 0.3.0')
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.1.0
4
+ version: 6.1.1
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-01 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -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,9 +284,8 @@ 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
289
287
  - lib/neo4j/core/instrumentable.rb
288
+ - lib/neo4j/core/label.rb
290
289
  - lib/neo4j/core/node.rb
291
290
  - lib/neo4j/core/path.rb
292
291
  - lib/neo4j/core/relationship.rb
@@ -1,20 +0,0 @@
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
@@ -1,29 +0,0 @@
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