neo4j 3.0.0.alpha.3 → 3.0.0.alpha.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/README.md +8 -8
- data/lib/neo4j/active_node/has_n/nodes.rb +1 -1
- data/lib/neo4j/active_node/validations.rb +47 -0
- data/lib/neo4j/railtie.rb +37 -25
- data/lib/neo4j/version.rb +1 -1
- data/lib/rails/generators/neo4j/model/model_generator.rb +7 -4
- data/neo4j.gemspec +2 -1
- metadata +31 -31
- data/lib/test.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d529b0a277c85beffcb02008e9a16911edd26e0b
|
4
|
+
data.tar.gz: 34d8210e6ca0f7808051743e7177dec65a20e92e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b3347a88211c4555f69bcbd2471fb41ac7353b5e831487546d7b42f3b3d79fbb75b7626ce683ef931bf9d8d0946a64ec0fe2a817f1cb3d5798cc00545ea31a5
|
7
|
+
data.tar.gz: c9c875a7c36e75f9cddcc204cc0fc83114319105dfca22f8f4e76cacd45b905081f6bbaca765e143e457aba888a594323ef42b886cdb8ba483599bb1d39e5449
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# Welcome to Neo4j.rb [![Build Status](https://secure.travis-ci.org/andreasronge/neo4j.png?branch=master)](http://travis-ci.org/andreasronge/neo4j) [![Coverage Status](https://coveralls.io/repos/andreasronge/neo4j/badge.png)](https://coveralls.io/r/andreasronge/neo4j) [![Code Climate](https://codeclimate.com/github/andreasronge/neo4j.png)](https://codeclimate.com/github/andreasronge/neo4j)
|
2
2
|
|
3
|
-
Neo4j.rb is
|
3
|
+
Neo4j.rb is an Active Model compliant Ruby/JRuby wrapper for [the Neo4j graph database](http://www.neo4j.org/). It uses the [neo4j-core](https://github.com/andreasronge/neo4j-core) and [active_attr](https://github.com/cgriego/active_attr) gems.
|
4
4
|
|
5
|
-
## Version 3.0
|
5
|
+
## Version 3.0.0.alpha.X
|
6
6
|
|
7
7
|
Unstable !
|
8
8
|
|
9
|
-
* Wiki
|
10
|
-
* Example
|
9
|
+
* [Wiki](https://github.com/andreasronge/neo4j/wiki/Neo4j-v3)
|
10
|
+
* [Basic Rails 4 Example](https://github.com/andreasronge/neo4j/blob/master/example/blog/README.md)
|
11
11
|
|
12
12
|
## Version 2.x
|
13
13
|
|
14
|
-
|
14
|
+
For the stable 2.x version, see [here](https://github.com/andreasronge/neo4j/tree/2.x)
|
15
15
|
|
16
16
|
## Contributing
|
17
17
|
|
18
|
-
* Have you found a bug, need help or have a patch ?
|
18
|
+
* Have you found a bug, need help, or have a patch ?
|
19
19
|
* Just clone neo4j.rb and send me a pull request or email me.
|
20
20
|
* Do you need help - send me an email (andreas.ronge at gmail dot com).
|
21
21
|
|
@@ -23,6 +23,6 @@ This is the stable version, see https://github.com/andreasronge/neo4j/tree/2.x
|
|
23
23
|
|
24
24
|
* Neo4j.rb - MIT, see the [LICENSE](http://github.com/andreasronge/neo4j/tree/master/LICENSE).
|
25
25
|
* Lucene - Apache, see the [Lucene Documentation](http://lucene.apache.org/java/docs/features.html).
|
26
|
-
* Neo4j - Dual free software/commercial license, see [
|
26
|
+
* Neo4j - Dual free software/commercial license, see [Licensing Guide](http://www.neo4j.org/learn/licensing).
|
27
27
|
|
28
|
-
**Notice:**
|
28
|
+
**Notice:** There are different licenses for the `neo4j-community`, `neo4j-advanced`, and `neo4j-enterprise` jar gems. Only the `neo4j-community` gem is required by default.
|
@@ -55,7 +55,7 @@ module Neo4j
|
|
55
55
|
|
56
56
|
# Creates a relationship instance between this and the other node.
|
57
57
|
# Returns the relationship object
|
58
|
-
def create(other, relationship_props)
|
58
|
+
def create(other, relationship_props = {})
|
59
59
|
@decl_rel.create_relationship_to(@node, other, relationship_props)
|
60
60
|
end
|
61
61
|
|
@@ -6,6 +6,11 @@ module Neo4j
|
|
6
6
|
|
7
7
|
include ActiveModel::Validations
|
8
8
|
|
9
|
+
module ClassMethods
|
10
|
+
def validates_uniqueness_of(*attr_names)
|
11
|
+
validates_with UniquenessValidator, _merge_attributes(attr_names)
|
12
|
+
end
|
13
|
+
end
|
9
14
|
|
10
15
|
# Implements the ActiveModel::Validation hook method.
|
11
16
|
# @see http://rubydoc.info/docs/rails/ActiveModel/Validations:read_attribute_for_validation
|
@@ -33,6 +38,48 @@ module Neo4j
|
|
33
38
|
errors.empty?
|
34
39
|
end
|
35
40
|
|
41
|
+
class UniquenessValidator < ::ActiveModel::EachValidator
|
42
|
+
def initialize(options)
|
43
|
+
super(options.reverse_merge(:case_sensitive => true))
|
44
|
+
end
|
45
|
+
|
46
|
+
def setup(klass)
|
47
|
+
@klass = klass
|
48
|
+
end
|
49
|
+
|
50
|
+
def validate_each(record, attribute, value)
|
51
|
+
conditions = scope_conditions(record)
|
52
|
+
|
53
|
+
# TODO: Added as find(:name => nil) throws error
|
54
|
+
value = "" if value == nil
|
55
|
+
|
56
|
+
if options[:case_sensitive]
|
57
|
+
conditions[attribute] = value
|
58
|
+
else
|
59
|
+
conditions[attribute] = /^#{Regexp.escape(value.to_s)}$/i
|
60
|
+
end
|
61
|
+
|
62
|
+
# prevent that same object is returned
|
63
|
+
# TODO: add negative condtion to not return current record
|
64
|
+
found = @klass.all(conditions).to_a
|
65
|
+
found.delete(record)
|
66
|
+
|
67
|
+
if found.count > 0
|
68
|
+
record.errors.add(attribute, :taken, options.except(:case_sensitive, :scope).merge(:value => value))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def message(instance)
|
73
|
+
super || "has already been taken"
|
74
|
+
end
|
75
|
+
|
76
|
+
def scope_conditions(instance)
|
77
|
+
Array(options[:scope] || []).inject({}) do |conditions, key|
|
78
|
+
conditions.merge(key => instance[key])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
36
83
|
private
|
37
84
|
def perform_validations(options={})
|
38
85
|
perform_validation = case options
|
data/lib/neo4j/railtie.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Neo4j
|
2
|
-
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
3
|
config.neo4j = ActiveSupport::OrderedOptions.new
|
4
4
|
|
5
5
|
# Add ActiveModel translations to the I18n load_path
|
@@ -7,46 +7,58 @@ module Neo4j
|
|
7
7
|
config.i18n.load_path += Dir[File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'locales', '*.{rb,yml}')]
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# Set Rails specific defaults
|
10
|
+
class << self
|
11
|
+
def java_platform?
|
12
|
+
RUBY_PLATFORM =~ /java/
|
13
|
+
end
|
15
14
|
|
16
|
-
cfg
|
17
|
-
|
18
|
-
|
15
|
+
def set_default_session(cfg)
|
16
|
+
cfg.session_type ||= :server_db
|
17
|
+
cfg.session_path ||= "http://localhost:7474"
|
18
|
+
cfg.sessions ||= []
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
if cfg.sessions.empty?
|
21
|
+
cfg.sessions << {type: cfg.session_type, path: cfg.session_path}
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
|
26
|
+
def start_embedded_session(session)
|
27
|
+
# See https://github.com/jruby/jruby/wiki/UnlimitedStrengthCrypto
|
28
|
+
security_class = java.lang.Class.for_name('javax.crypto.JceSecurity')
|
29
|
+
restricted_field = security_class.get_declared_field('isRestricted')
|
30
|
+
restricted_field.accessible = true
|
31
|
+
restricted_field.set nil, false
|
32
|
+
session.start
|
33
|
+
end
|
34
|
+
|
35
|
+
def open_neo4j_session(session_opts)
|
36
|
+
if !java_platform? && session_opts[:type] == :embedded_db
|
26
37
|
raise "Tried to start embedded Neo4j db without using JRuby (got #{RUBY_PLATFORM}), please run `rvm jruby`"
|
27
38
|
end
|
28
39
|
|
29
|
-
puts "Create Neo4j Session #{session_opts[:type]}, path: #{session_opts[:path]}"
|
30
40
|
if (session_opts.key? :name)
|
31
41
|
session = Neo4j::Session.open_named(session_opts[:type], session_opts[:name], session_opts[:default], session_opts[:path])
|
32
42
|
else
|
33
43
|
session = Neo4j::Session.open(session_opts[:type], session_opts[:path])
|
34
44
|
end
|
35
45
|
|
36
|
-
if session_opts[:type] == :embedded_db
|
46
|
+
start_embedded_session(session) if session_opts[:type] == :embedded_db
|
47
|
+
end
|
37
48
|
|
38
|
-
|
39
|
-
security_class = java.lang.Class.for_name('javax.crypto.JceSecurity')
|
40
|
-
restricted_field = security_class.get_declared_field('isRestricted')
|
41
|
-
restricted_field.accessible = true
|
42
|
-
restricted_field.set nil, false
|
49
|
+
end
|
43
50
|
|
44
|
-
session.start
|
45
|
-
end
|
46
|
-
end
|
47
51
|
|
48
|
-
|
49
|
-
|
52
|
+
# Starting Neo after :load_config_initializers allows apps to
|
53
|
+
# register migrations in config/initializers
|
54
|
+
initializer "neo4j.start", :after => :load_config_initializers do |app|
|
55
|
+
cfg = app.config.neo4j
|
56
|
+
# Set Rails specific defaults
|
57
|
+
Neo4j::Railtie.set_default_session(cfg)
|
58
|
+
|
59
|
+
cfg.sessions.each do |session_opts|
|
60
|
+
Neo4j::Railtie.open_neo4j_session(session_opts)
|
61
|
+
end
|
50
62
|
end
|
51
63
|
end
|
52
64
|
end
|
data/lib/neo4j/version.rb
CHANGED
@@ -31,8 +31,7 @@ class Neo4j::Generators::ModelGenerator < Neo4j::Generators::Base #:nodoc:
|
|
31
31
|
def has_n_statements
|
32
32
|
txt = ""
|
33
33
|
options[:has_n].each do |key|
|
34
|
-
|
35
|
-
txt << (from ? "\n has_n(:#{to}).from(:#{from})\n" : "\n has_n :#{to}")
|
34
|
+
txt << has_x('has_n', key)
|
36
35
|
end
|
37
36
|
txt
|
38
37
|
end
|
@@ -41,11 +40,15 @@ class Neo4j::Generators::ModelGenerator < Neo4j::Generators::Base #:nodoc:
|
|
41
40
|
options[:has_one]
|
42
41
|
end
|
43
42
|
|
43
|
+
def has_x(method, key)
|
44
|
+
to, from = key.split(':')
|
45
|
+
(from ? "\n #{method}(:#{to}).from(:#{from})\n" : "\n #{method} :#{to}")
|
46
|
+
end
|
47
|
+
|
44
48
|
def has_one_statements
|
45
49
|
txt = ""
|
46
50
|
options[:has_one].each do |key|
|
47
|
-
|
48
|
-
txt << (from ? "\n has_one(:#{to}).from(:#{from})\n" : "\n has_one :#{to}")
|
51
|
+
txt << has_x('has_one', key)
|
49
52
|
end
|
50
53
|
txt
|
51
54
|
end
|
data/neo4j.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.homepage = "http://github.com/andreasronge/neo4j/tree"
|
15
15
|
s.rubyforge_project = 'neo4j'
|
16
16
|
s.summary = "A graph database for Ruby"
|
17
|
+
s.license = 'MIT'
|
17
18
|
s.description = <<-EOF
|
18
19
|
You can think of Neo4j as a high-performance graph engine with all the features of a mature and robust database.
|
19
20
|
The programmer works with an object-oriented, flexible network structure rather than with strict and static tables
|
@@ -32,7 +33,7 @@ It comes included with the Apache Lucene document database.
|
|
32
33
|
s.add_dependency("activemodel", "~> 4.0.0")
|
33
34
|
s.add_dependency("railties", "~> 4.0.0")
|
34
35
|
s.add_dependency('active_attr', "~> 0.8")
|
35
|
-
s.add_dependency("neo4j-core", "= 3.0.0.alpha.
|
36
|
+
s.add_dependency("neo4j-core", "= 3.0.0.alpha.11")
|
36
37
|
|
37
38
|
if RUBY_PLATFORM =~ /java/
|
38
39
|
s.add_dependency("neo4j-community", '~> 2.0.0')
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.alpha.
|
4
|
+
version: 3.0.0.alpha.4
|
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-
|
11
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: orm_adapter
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 4.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: railties
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 4.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 4.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: active_attr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0.8'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.8'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.0.0.alpha.
|
75
|
+
version: 3.0.0.alpha.11
|
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: 3.0.0.alpha.
|
82
|
+
version: 3.0.0.alpha.11
|
83
83
|
description: "You can think of Neo4j as a high-performance graph engine with all the
|
84
84
|
features of a mature and robust database.\nThe programmer works with an object-oriented,
|
85
85
|
flexible network structure rather than with strict and static tables \nyet enjoys
|
@@ -92,11 +92,19 @@ extensions: []
|
|
92
92
|
extra_rdoc_files:
|
93
93
|
- README.md
|
94
94
|
files:
|
95
|
+
- CHANGELOG
|
96
|
+
- CONTRIBUTORS
|
97
|
+
- Gemfile
|
98
|
+
- README.md
|
95
99
|
- bin/neo4j-jars
|
100
|
+
- config/locales/en.yml
|
101
|
+
- config/neo4j/config.yml
|
102
|
+
- lib/neo4j.rb
|
103
|
+
- lib/neo4j/active_node.rb
|
96
104
|
- lib/neo4j/active_node/callbacks.rb
|
105
|
+
- lib/neo4j/active_node/has_n.rb
|
97
106
|
- lib/neo4j/active_node/has_n/decl_rel.rb
|
98
107
|
- lib/neo4j/active_node/has_n/nodes.rb
|
99
|
-
- lib/neo4j/active_node/has_n.rb
|
100
108
|
- lib/neo4j/active_node/identity.rb
|
101
109
|
- lib/neo4j/active_node/initialize.rb
|
102
110
|
- lib/neo4j/active_node/labels.rb
|
@@ -104,50 +112,42 @@ files:
|
|
104
112
|
- lib/neo4j/active_node/property.rb
|
105
113
|
- lib/neo4j/active_node/rels.rb
|
106
114
|
- lib/neo4j/active_node/validations.rb
|
107
|
-
- lib/neo4j/active_node.rb
|
108
115
|
- lib/neo4j/railtie.rb
|
109
116
|
- lib/neo4j/type_converters.rb
|
110
117
|
- lib/neo4j/version.rb
|
111
118
|
- lib/neo4j/wrapper.rb
|
112
|
-
- lib/neo4j.rb
|
113
119
|
- lib/rails/generators/neo4j/model/model_generator.rb
|
114
120
|
- lib/rails/generators/neo4j/model/templates/model.erb
|
115
121
|
- lib/rails/generators/neo4j_generator.rb
|
116
|
-
- lib/test.rb
|
117
|
-
- config/locales/en.yml
|
118
|
-
- config/neo4j/config.yml
|
119
|
-
- README.md
|
120
|
-
- CHANGELOG
|
121
|
-
- CONTRIBUTORS
|
122
|
-
- Gemfile
|
123
122
|
- neo4j.gemspec
|
124
123
|
homepage: http://github.com/andreasronge/neo4j/tree
|
125
|
-
licenses:
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
126
|
metadata: {}
|
127
127
|
post_install_message:
|
128
128
|
rdoc_options:
|
129
|
-
- --quiet
|
130
|
-
- --title
|
129
|
+
- "--quiet"
|
130
|
+
- "--title"
|
131
131
|
- Neo4j.rb
|
132
|
-
- --line-numbers
|
133
|
-
- --main
|
132
|
+
- "--line-numbers"
|
133
|
+
- "--main"
|
134
134
|
- README.rdoc
|
135
|
-
- --inline-source
|
135
|
+
- "--inline-source"
|
136
136
|
require_paths:
|
137
137
|
- lib
|
138
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
|
-
- -
|
140
|
+
- - ">="
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: 1.9.1
|
143
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- -
|
145
|
+
- - ">"
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: 1.3.1
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project: neo4j
|
150
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.2.2
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: A graph database for Ruby
|
data/lib/test.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'neo4j'
|
2
|
-
|
3
|
-
class Person
|
4
|
-
include Neo4j::ActiveNode
|
5
|
-
property :born, type: Date
|
6
|
-
property :since
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
#Neo4j::Session.open(:server_db, 'http://localhost:7474')
|
11
|
-
|
12
|
-
puts "Type #{Person._attribute_type(:born)}, class #{Person._attribute_type(:born).class}"
|
13
|
-
puts "Type since #{Person._attribute_type(:since)}"
|
14
|
-
p = Person.new(born: Date.today)
|
15
|
-
#p.save
|
16
|
-
puts "BORN #{p.born} type: #{p.born.class}"
|