neo4j-core 3.0.0.alpha.7 → 3.0.0.alpha.8

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: 8d1f4739d5310c9630aa978a30139764ca721ba8
4
- data.tar.gz: 288f2ce9b48122d99c4edbce147e5278f933bd6b
3
+ metadata.gz: 25b0be124fa4f41c0d4fd9326c5711ca7d094ce6
4
+ data.tar.gz: a2aefe6c77b194f4296ae74efed3365b2bdb1aa1
5
5
  SHA512:
6
- metadata.gz: fd729be854e8df8c59e4f2e96f8720f0a09d5bc66aed7b2a13c5abfa1ef7146a1997f6042302139968180b6a8a6a59aae08908ef79fab5d7d5a005a4585d3fff
7
- data.tar.gz: 394e87ad9bfb563d1d27d61bc5e4bcb884b23cb319d8d78a4489b457398e37ebbb44bd0b45f27b2d98640653a5e9b8e2d34507148aa1ace1ce7c8a511719fa7a
6
+ metadata.gz: 131b612496659cfc56fac4d950621e4e9ce0227a910c35b502e9234507df67485e75840abe918caf9a36da1fa306ac41db5a51787393daf9ef98881ce952b65f
7
+ data.tar.gz: e36089a513af01b0651c97494fa16efb7ebc490253f5fb2991185445b1b83e93564d6890e5858e4c36e6da4b4e3866e47db803d0d1ca0b492224f87130be92e4
data/Gemfile CHANGED
@@ -9,7 +9,6 @@ gem 'neo4j-cypher', '~> 1.0.1'
9
9
  #gem 'neo4j-enterprise', '>= 1.8.1', '< 2.0', :require => false
10
10
 
11
11
  group 'development' do
12
- gem 'os'
13
12
  gem 'yard'
14
13
  # gem 'pry'
15
14
  end
data/README.md CHANGED
@@ -120,6 +120,16 @@ Add index on a label
120
120
  red.indexes # => {:property_keys => [[:age]]}
121
121
  ```
122
122
 
123
+ Constraints
124
+
125
+ Only unique constraint and single property is supported (yet).
126
+
127
+ ```ruby
128
+ label = Neo4j::Label.create(:person)
129
+ label.create_constraint(:name, type: :unique)
130
+ label.drop_constraint(:name, type: :unique)
131
+ ```
132
+
123
133
  ### Creating Nodes
124
134
 
125
135
  ```ruby
data/lib/neo4j/label.rb CHANGED
@@ -22,6 +22,39 @@ module Neo4j
22
22
  raise 'not implemented'
23
23
  end
24
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, session = Neo4j::Session.current)
32
+ cypher = case constraints[:type]
33
+ when :unique
34
+ "CREATE CONSTRAINT ON (n:`#{name}`) ASSERT n.`#{property}` IS UNIQUE"
35
+ else
36
+ raise "Not supported constrain #{constraints.inspect} for property #{property} (expected :type => :unique)"
37
+ end
38
+ session._query_or_fail(cypher)
39
+ end
40
+
41
+ # Drops a neo4j constraint on a property
42
+ # See http://docs.neo4j.org/chunked/stable/query-constraints.html
43
+ # @example
44
+ # label = Neo4j::Label.create(:person, session)
45
+ # label.create_constraint(:name, {type: :unique}, session)
46
+ # label.drop_constraint(:name, {type: :unique}, session)
47
+ #
48
+ def drop_constraint(property, constraint, session = Neo4j::Session.current)
49
+ cypher = case constraint[:type]
50
+ when :unique
51
+ "DROP CONSTRAINT ON (n:`#{name}`) ASSERT n.`#{property}` IS UNIQUE"
52
+ else
53
+ raise "Not supported constrain #{constraint.inspect}"
54
+ end
55
+ session._query_or_fail(cypher)
56
+ end
57
+
25
58
  class << self
26
59
  include Neo4j::Core::CypherTranslator
27
60
 
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = "3.0.0.alpha.7"
3
+ VERSION = "3.0.0.alpha.8"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Neo4j::Embedded
2
- class EmbeddedLabel
2
+ class EmbeddedLabel < Neo4j::Label
3
3
  extend Neo4j::Core::TxMethods
4
4
  attr_reader :name
5
5
  JAVA_CLASS = Java::OrgNeo4jGraphdb::DynamicLabel
@@ -1,5 +1,5 @@
1
1
  module Neo4j::Server
2
- class CypherLabel
2
+ class CypherLabel < Neo4j::Label
3
3
  extend Forwardable
4
4
  def_delegator :@session, :query_cypher_for
5
5
  attr_reader :name
@@ -2,7 +2,7 @@ module Neo4j::Server
2
2
 
3
3
  # Plugin
4
4
  Neo4j::Session.register_db(:server_db) do |endpoint_url|
5
- response = HTTParty.get(endpoint_url)
5
+ response = HTTParty.get(endpoint_url || 'http://localhost:7474')
6
6
  raise "Server not available on #{endpoint_url} (response code #{response.code})" unless response.code == 200
7
7
  root_data = JSON.parse(response.body)
8
8
  Neo4j::Server::CypherSession.new(root_data['data'])
data/neo4j-core.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.summary = "A graph database for JRuby"
16
16
  s.description = <<-EOF
17
17
  You can think of Neo4j as a high-performance graph engine with all the features of a mature and robust database.
18
- The programmer works with an object-oriented, flexible network structure rather than with strict and static tables
18
+ The programmer works with an object-oriented, flexible network structure rather than with strict and static tables
19
19
  yet enjoys all the benefits of a fully transactional, enterprise-strength database.
20
20
  It comes included with the Apache Lucene document database.
21
21
  EOF
@@ -29,6 +29,7 @@ It comes included with the Apache Lucene document database.
29
29
  # Not released yet
30
30
  s.add_dependency("httparty")
31
31
  s.add_dependency("json")
32
+ s.add_dependency("os")
32
33
  s.add_dependency("neo4j-cypher")
33
34
 
34
35
  if RUBY_PLATFORM =~ /java/
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: 3.0.0.alpha.7
4
+ version: 3.0.0.alpha.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-18 00:00:00.000000000 Z
11
+ date: 2014-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: os
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: neo4j-cypher
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,11 +66,11 @@ dependencies:
52
66
  - - '>='
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
- description: "You can think of Neo4j as a high-performance graph engine with all the
56
- features of a mature and robust database.\nThe programmer works with an object-oriented,
57
- flexible network structure rather than with strict and static tables \nyet enjoys
58
- all the benefits of a fully transactional, enterprise-strength database.\nIt comes
59
- included with the Apache Lucene document database.\n"
69
+ description: |
70
+ You can think of Neo4j as a high-performance graph engine with all the features of a mature and robust database.
71
+ The programmer works with an object-oriented, flexible network structure rather than with strict and static tables
72
+ yet enjoys all the benefits of a fully transactional, enterprise-strength database.
73
+ It comes included with the Apache Lucene document database.
60
74
  email: andreas.ronge@gmail.com
61
75
  executables: []
62
76
  extensions: []