neoid 0.0.51 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +35 -0
- data/README.md +148 -47
- data/TODO.md +0 -2
- data/lib/neoid.rb +90 -13
- data/lib/neoid/batch.rb +168 -0
- data/lib/neoid/config.rb +6 -0
- data/lib/neoid/middleware.rb +4 -2
- data/lib/neoid/model_additions.rb +60 -15
- data/lib/neoid/model_config.rb +2 -0
- data/lib/neoid/node.rb +103 -54
- data/lib/neoid/relationship.rb +88 -53
- data/lib/neoid/version.rb +1 -1
- data/spec/neoid/batch_spec.rb +170 -0
- data/spec/neoid/config_spec.rb +13 -0
- data/spec/neoid/model_additions_spec.rb +111 -17
- data/spec/neoid/search_spec.rb +0 -1
- data/spec/neoid_spec.rb +7 -1
- data/spec/spec_helper.rb +11 -9
- data/spec/support/models.rb +12 -3
- data/spec/support/schema.rb +4 -0
- metadata +8 -2
data/spec/neoid/search_spec.rb
CHANGED
data/spec/neoid_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,8 @@ require 'active_record'
|
|
3
3
|
require 'neography'
|
4
4
|
require 'rest-client'
|
5
5
|
|
6
|
+
# ENV['NEOID_LOG'] = 'true'
|
7
|
+
|
6
8
|
uri = URI.parse(ENV["NEO4J_URL"] ? ENV["NEO4J_URL"] : ENV['TRAVIS'] ? "http://localhost:7474" : "http://localhost:7574")
|
7
9
|
$neo = Neography::Rest.new(uri.to_s)
|
8
10
|
|
@@ -19,9 +21,15 @@ end
|
|
19
21
|
|
20
22
|
Neoid.db = $neo
|
21
23
|
|
24
|
+
logger, ActiveRecord::Base.logger = ActiveRecord::Base.logger, Logger.new('/dev/null')
|
22
25
|
ActiveRecord::Base.configurations = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'support/database.yml')))
|
23
26
|
ActiveRecord::Base.establish_connection('sqlite3')
|
24
27
|
|
28
|
+
require 'support/schema'
|
29
|
+
require 'support/models'
|
30
|
+
|
31
|
+
ActiveRecord::Base.logger = logger
|
32
|
+
|
25
33
|
RSpec.configure do |config|
|
26
34
|
config.mock_with :rspec
|
27
35
|
|
@@ -29,16 +37,10 @@ RSpec.configure do |config|
|
|
29
37
|
end
|
30
38
|
|
31
39
|
config.before(:each) do
|
32
|
-
Neoid.
|
33
|
-
end
|
34
|
-
|
35
|
-
config.before(:each) do
|
40
|
+
Neoid.node_models.each(&:destroy_all)
|
36
41
|
Neoid.clean_db(:yes_i_am_sure)
|
37
|
-
Neoid.
|
42
|
+
Neoid.reset_cached_variables
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
41
|
-
|
42
|
-
require 'support/models'
|
43
|
-
|
44
|
-
Neoid.initialize_all
|
46
|
+
Neoid.initialize_all
|
data/spec/support/models.rb
CHANGED
@@ -12,6 +12,7 @@ class User < ActiveRecord::Base
|
|
12
12
|
|
13
13
|
def like!(movie)
|
14
14
|
movies << movie unless likes?(movie)
|
15
|
+
likes.where(movie_id: movie.id).first
|
15
16
|
end
|
16
17
|
|
17
18
|
def unlike!(movie)
|
@@ -52,7 +53,7 @@ end
|
|
52
53
|
class UserFollow < ActiveRecord::Base
|
53
54
|
include ActiveModel::Validations::Callbacks
|
54
55
|
|
55
|
-
belongs_to :user
|
56
|
+
belongs_to :user
|
56
57
|
belongs_to :item, polymorphic: true
|
57
58
|
|
58
59
|
include Neoid::Relationship
|
@@ -65,8 +66,8 @@ end
|
|
65
66
|
class Like < ActiveRecord::Base
|
66
67
|
include ActiveModel::Validations::Callbacks
|
67
68
|
|
68
|
-
belongs_to :user
|
69
|
-
belongs_to :movie
|
69
|
+
belongs_to :user
|
70
|
+
belongs_to :movie
|
70
71
|
|
71
72
|
include Neoid::Relationship
|
72
73
|
|
@@ -95,3 +96,11 @@ class Article < ActiveRecord::Base
|
|
95
96
|
end
|
96
97
|
end
|
97
98
|
end
|
99
|
+
|
100
|
+
class NoAutoIndexNode < ActiveRecord::Base
|
101
|
+
include ActiveModel::Validations::Callbacks
|
102
|
+
include Neoid::Node
|
103
|
+
neoidable auto_index: false do |c|
|
104
|
+
c.field :name
|
105
|
+
end
|
106
|
+
end
|
data/spec/support/schema.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.1'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -125,6 +125,8 @@ files:
|
|
125
125
|
- Rakefile
|
126
126
|
- TODO.md
|
127
127
|
- lib/neoid.rb
|
128
|
+
- lib/neoid/batch.rb
|
129
|
+
- lib/neoid/config.rb
|
128
130
|
- lib/neoid/database_cleaner.rb
|
129
131
|
- lib/neoid/middleware.rb
|
130
132
|
- lib/neoid/model_additions.rb
|
@@ -135,6 +137,8 @@ files:
|
|
135
137
|
- lib/neoid/search_session.rb
|
136
138
|
- lib/neoid/version.rb
|
137
139
|
- neoid.gemspec
|
140
|
+
- spec/neoid/batch_spec.rb
|
141
|
+
- spec/neoid/config_spec.rb
|
138
142
|
- spec/neoid/model_additions_spec.rb
|
139
143
|
- spec/neoid/model_config_spec.rb
|
140
144
|
- spec/neoid/search_spec.rb
|
@@ -168,6 +172,8 @@ signing_key:
|
|
168
172
|
specification_version: 3
|
169
173
|
summary: Neo4j for ActiveRecord
|
170
174
|
test_files:
|
175
|
+
- spec/neoid/batch_spec.rb
|
176
|
+
- spec/neoid/config_spec.rb
|
171
177
|
- spec/neoid/model_additions_spec.rb
|
172
178
|
- spec/neoid/model_config_spec.rb
|
173
179
|
- spec/neoid/search_spec.rb
|