elasticsearch-model-extensions 0.0.4 → 0.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/.rspec +2 -0
- data/.travis.yml +15 -0
- data/Gemfile +6 -0
- data/README.md +12 -0
- data/lib/elasticsearch/model/extensions/batch_updating.rb +5 -1
- data/lib/elasticsearch/model/extensions/configuration.rb +15 -2
- data/lib/elasticsearch/model/extensions/destroy_callback.rb +2 -1
- data/lib/elasticsearch/model/extensions/outer_document_updating.rb +15 -5
- data/lib/elasticsearch/model/extensions/partial_updating.rb +8 -2
- data/lib/elasticsearch/model/extensions/update_callback.rb +2 -1
- data/lib/elasticsearch/model/extensions/version.rb +1 -1
- data/spec/example/articles_with_comments.rb +8 -0
- data/spec/integration_spec.rb +7 -8
- data/spec/outer_document_updating_spec.rb +49 -0
- data/spec/partial_updating_spec.rb +30 -0
- data/spec/setup/articles_with_comments.rb +72 -0
- data/spec/setup/elasticsearch/model.rb +11 -0
- data/spec/setup/elasticsearch/start.rb +5 -0
- data/spec/setup/elasticsearch/stop.rb +3 -0
- data/spec/setup/sqlite.rb +10 -0
- data/spec/spec_helper.rb +22 -14
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc9cef5c332c7100957fd86118f2bc7e3b441d1c
|
4
|
+
data.tar.gz: ca19391b4737aad8eeef5a31ce4f939bf41125a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f33927f78adcf088dcd924a1961a131cd0d236db9fafc6be1fbc68a3d18788cdb4b0edd68dbd76e6261aed5dd39b844e533e1684ccbac6854350ee079ce43aa
|
7
|
+
data.tar.gz: eb90efb604e5244469a3b769d93f34ac1791240382686bd50ca8ce8db2c67f985cc15e3fe79962acbe1ff51fe68f51057aaa4809b14cca6c7ff58830e61fbe83
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
bundler_args: --without development
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.1.2
|
5
|
+
- 2.1.3
|
6
|
+
- ruby-head
|
7
|
+
matrix:
|
8
|
+
allow_failures:
|
9
|
+
- rvm: ruby-head
|
10
|
+
fast_finish: true
|
11
|
+
before_script:
|
12
|
+
- ls -la /usr/share/elasticsearch/bin/elasticsearch
|
13
|
+
- echo $PWD
|
14
|
+
before_install: gem install bundler
|
15
|
+
script: SERVER=launch TEST_CLUSTER_COMMAND=/usr/share/elasticsearch/bin/elasticsearch TEST_CLUSTER_PARAMS='-Des.default.path.conf=/etc/elasticsearch/ -Des.default.path.logs=/var/log/elasticsearch/' TEST_CLUSTER_PORT=19250 bundle exec rspec
|
data/Gemfile
CHANGED
@@ -5,7 +5,13 @@ gemspec
|
|
5
5
|
|
6
6
|
group :test do
|
7
7
|
gem 'rspec', '~> 3.1.0'
|
8
|
+
gem 'database_cleaner'
|
9
|
+
gem 'coveralls', require: false
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test, :development do
|
8
13
|
gem 'activerecord', '~> 3.2'
|
9
14
|
gem 'sqlite3'
|
10
15
|
gem 'elasticsearch-model'
|
16
|
+
gem 'elasticsearch-extensions'
|
11
17
|
end
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Elasticsearch::Model::Extensions
|
2
2
|
|
3
|
+
[](https://travis-ci.org/crowdworks/elasticsearch-model-extensions)
|
4
|
+
[](https://coveralls.io/r/crowdworks/elasticsearch-model-extensions)
|
5
|
+
[](https://codeclimate.com/github/crowdworks/elasticsearch-model-extensions)
|
6
|
+
|
3
7
|
TODO: Write a gem description
|
4
8
|
|
5
9
|
## Installation
|
@@ -22,6 +26,14 @@ Or install it yourself as:
|
|
22
26
|
|
23
27
|
TODO: Write usage instructions here
|
24
28
|
|
29
|
+
## Running examples
|
30
|
+
|
31
|
+
With Elasticsearch installed, you can run examples configured with an ES instance started on the port 9250 and AR connected to sqlite:
|
32
|
+
|
33
|
+
$ bundle exec irb -I spec -r example/articles_with_comments
|
34
|
+
(A bunch of log output here)
|
35
|
+
irb(main):001:0> Article.search('Comment1')
|
36
|
+
|
25
37
|
## Contributing
|
26
38
|
|
27
39
|
1. Fork it ( https://github.com/[my-github-username]/elasticsearch-model-extensions/fork )
|
@@ -92,7 +92,11 @@ module Elasticsearch
|
|
92
92
|
one_or_more_errors_occurred = response["errors"]
|
93
93
|
|
94
94
|
if one_or_more_errors_occurred
|
95
|
-
|
95
|
+
if defined? ::Rails
|
96
|
+
::Rails.logger.warn "One or more error(s) occurred while updating the index #{records} for the type #{type}\n#{JSON.pretty_generate(response)}"
|
97
|
+
else
|
98
|
+
warn "One or more error(s) occurred while updating the index #{records} for the type #{type}\n#{JSON.pretty_generate(response)}"
|
99
|
+
end
|
96
100
|
end
|
97
101
|
else
|
98
102
|
records.each do |r|
|
@@ -4,7 +4,7 @@ module Elasticsearch
|
|
4
4
|
class Configuration
|
5
5
|
attr_reader :delayed
|
6
6
|
|
7
|
-
def initialize(active_record_class, parent_class: parent_class, delayed:, only_if: -> r { true }, records_to_update_documents: nil, field_to_update: nil)
|
7
|
+
def initialize(active_record_class, parent_class: parent_class, delayed:, only_if: -> r { true }, records_to_update_documents: nil, field_to_update: nil, block: nil)
|
8
8
|
@delayed = @delayed
|
9
9
|
|
10
10
|
@active_record_class = active_record_class
|
@@ -12,6 +12,7 @@ module Elasticsearch
|
|
12
12
|
@if = binding.local_variable_get(:only_if)
|
13
13
|
@records_to_update_documents = records_to_update_documents
|
14
14
|
@field_to_update = field_to_update
|
15
|
+
@block = block
|
15
16
|
end
|
16
17
|
|
17
18
|
def to_hash
|
@@ -34,6 +35,10 @@ module Elasticsearch
|
|
34
35
|
-> t { delayed ? t.delay : t }
|
35
36
|
end
|
36
37
|
|
38
|
+
def block
|
39
|
+
to_hash[:block]
|
40
|
+
end
|
41
|
+
|
37
42
|
private
|
38
43
|
|
39
44
|
def build_hash
|
@@ -65,10 +70,18 @@ module Elasticsearch
|
|
65
70
|
|
66
71
|
only_if, records_to_update_documents = update_strategy.apply
|
67
72
|
|
73
|
+
# The default block used to trigger partial updating on the parent document.
|
74
|
+
# Replace this by specifying `block` parameter to a configuration like `Configuration.new(block: BLOCK)`
|
75
|
+
# when more fine-grained controls over it like feature-toggling, graceful-degradation are required.
|
76
|
+
default_partial_updating_block = -> t, field_to_update {
|
77
|
+
t.partially_update_document(field_to_update)
|
78
|
+
}
|
79
|
+
|
68
80
|
{
|
69
81
|
field_to_update: field_to_update,
|
70
82
|
records_to_update_documents: @records_to_update_documents || records_to_update_documents,
|
71
|
-
only_if: -> r { custom_if.call(r) && only_if.call(r) }
|
83
|
+
only_if: -> r { custom_if.call(r) && only_if.call(r) },
|
84
|
+
block: @block || default_partial_updating_block
|
72
85
|
}
|
73
86
|
end
|
74
87
|
end
|
@@ -9,6 +9,7 @@ module Elasticsearch
|
|
9
9
|
records_to_update_documents = config.records_to_update_documents
|
10
10
|
optionally_delayed = config.optionally_delayed
|
11
11
|
only_if = config.only_if
|
12
|
+
block = config.block
|
12
13
|
|
13
14
|
record.instance_eval do
|
14
15
|
return unless only_if.call(self)
|
@@ -17,7 +18,7 @@ module Elasticsearch
|
|
17
18
|
|
18
19
|
if target.respond_to? :each
|
19
20
|
target.map(&:reload).map(&optionally_delayed).each do |t|
|
20
|
-
|
21
|
+
block.call(t, [*field_to_update])
|
21
22
|
end
|
22
23
|
else
|
23
24
|
optionally_delayed.call(target.reload).partially_update_document(field_to_update)
|
@@ -39,7 +39,14 @@ module Elasticsearch
|
|
39
39
|
records_to_update_documents = begin
|
40
40
|
child_to_parent_path = Elasticsearch::Model::Extensions::OuterDocumentUpdating::ClassMethods::AssociationTraversal.shortest_path(from: child_class, to: parent_class)
|
41
41
|
|
42
|
-
-> updated_record {
|
42
|
+
-> updated_record {
|
43
|
+
if child_to_parent_path.nil?
|
44
|
+
warn "Couldn't automatically determine the path from the class `#{child_class}` to `#{parent_class}." +
|
45
|
+
"Use `partially_updates_document_of parent_class, records_to_update_documents: -> child { ... }` to specify it."
|
46
|
+
end
|
47
|
+
|
48
|
+
child_to_parent_path.inject(updated_record) { |d, parent_association| d.send parent_association }
|
49
|
+
}
|
43
50
|
end
|
44
51
|
|
45
52
|
[only_if, records_to_update_documents]
|
@@ -104,15 +111,17 @@ module Elasticsearch
|
|
104
111
|
first
|
105
112
|
end
|
106
113
|
|
107
|
-
def initialize_active_record!(active_record_class, parent_class: parent_class, delayed:, only_if: -> r { true }, records_to_update_documents: nil, field_to_update: nil)
|
114
|
+
def initialize_active_record!(active_record_class, parent_class: parent_class, delayed:, only_if: -> r { true }, records_to_update_documents: nil, field_to_update: nil, block: block)
|
108
115
|
config = Elasticsearch::Model::Extensions::Configuration.new(active_record_class, parent_class: parent_class, delayed: delayed, only_if: binding.local_variable_get(:only_if), records_to_update_documents: records_to_update_documents,
|
109
|
-
|
116
|
+
field_to_update: field_to_update,
|
117
|
+
block: block
|
118
|
+
)
|
110
119
|
|
111
120
|
active_record_class.after_commit Elasticsearch::Model::Extensions::UpdateCallback.new(config)
|
112
121
|
active_record_class.after_commit Elasticsearch::Model::Extensions::DestroyCallback.new(config), on: :destroy
|
113
122
|
end
|
114
123
|
|
115
|
-
def partially_updates_document_of(parent_class, options)
|
124
|
+
def partially_updates_document_of(parent_class, options, &block)
|
116
125
|
options ||= {}
|
117
126
|
delayed = options[:delayed] || nil
|
118
127
|
only_if = options[:if] || (-> r { true })
|
@@ -125,7 +134,8 @@ module Elasticsearch
|
|
125
134
|
:delayed => delayed,
|
126
135
|
:only_if => only_if,
|
127
136
|
:field_to_update => field_to_update,
|
128
|
-
:records_to_update_documents => records_to_update_documents
|
137
|
+
:records_to_update_documents => records_to_update_documents,
|
138
|
+
:block => block
|
129
139
|
)
|
130
140
|
end
|
131
141
|
|
@@ -16,7 +16,9 @@ module Elasticsearch
|
|
16
16
|
method_attributes = indexed_attributes - persisted_attributes - nested_attributes
|
17
17
|
only_attributes = indexed_attributes - nested_attributes
|
18
18
|
|
19
|
-
options = {
|
19
|
+
options = {
|
20
|
+
root: false
|
21
|
+
}
|
20
22
|
|
21
23
|
if only_attributes.size > 1
|
22
24
|
options[:only] = only_attributes
|
@@ -75,7 +77,11 @@ module Elasticsearch
|
|
75
77
|
begin
|
76
78
|
partial_document = build_partial_document_for_update(*changed_attributes)
|
77
79
|
rescue => e
|
78
|
-
|
80
|
+
if defined? ::Rails
|
81
|
+
::Rails.logger.error "Error in #partially_update_document: #{e.message}\n#{e.backtrace.join("\n")}"
|
82
|
+
else
|
83
|
+
warn "Error in #partially_update_document: #{e.message}\n#{e.backtrace.join("\n")}"
|
84
|
+
end
|
79
85
|
end
|
80
86
|
|
81
87
|
update_document(partial_document)
|
@@ -9,6 +9,7 @@ module Elasticsearch
|
|
9
9
|
records_to_update_documents = config.records_to_update_documents
|
10
10
|
optionally_delayed = config.optionally_delayed
|
11
11
|
only_if = config.only_if
|
12
|
+
block = config.block
|
12
13
|
|
13
14
|
record.instance_eval do
|
14
15
|
return unless only_if.call(self) && index_update_required?
|
@@ -30,7 +31,7 @@ module Elasticsearch
|
|
30
31
|
# Here, `article_comment.article` may contain outdated `comments` because `article_comment.article`
|
31
32
|
# won't be notified with changes in `article_comments` thus won't reload `comments` automatically.
|
32
33
|
target.map(&:reload).map(&optionally_delayed).each do |t|
|
33
|
-
|
34
|
+
block.call(t, [*field_to_update])
|
34
35
|
end
|
35
36
|
else
|
36
37
|
optionally_delayed.call(target.reload).partially_update_document(field_to_update)
|
data/spec/integration_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'elasticsearch/model/extensions/all'
|
2
2
|
|
3
3
|
RSpec.describe 'example' do
|
4
|
-
before :
|
4
|
+
before :each do
|
5
5
|
ActiveRecord::Schema.define(:version => 1) do
|
6
6
|
create_table :articles do |t|
|
7
7
|
t.string :title
|
@@ -12,13 +12,6 @@ RSpec.describe 'example' do
|
|
12
12
|
class ::Article < ActiveRecord::Base
|
13
13
|
include Elasticsearch::Model
|
14
14
|
include Elasticsearch::Model::Callbacks
|
15
|
-
include Elasticsearch::Model::Extensions::IndexOperations
|
16
|
-
include Elasticsearch::Model::Extensions::BatchUpdating
|
17
|
-
include Elasticsearch::Model::Extensions::PartialUpdating
|
18
|
-
|
19
|
-
DEPENDENT_CUSTOM_ATTRIBUTES = {}
|
20
|
-
|
21
|
-
include Elasticsearch::Model::Extensions::DependencyTracking
|
22
15
|
|
23
16
|
settings index: {number_of_shards: 1, number_of_replicas: 0} do
|
24
17
|
mapping do
|
@@ -38,6 +31,12 @@ RSpec.describe 'example' do
|
|
38
31
|
Article.__elasticsearch__.refresh_index!
|
39
32
|
end
|
40
33
|
|
34
|
+
after :each do
|
35
|
+
ActiveRecord::Schema.define(:version => 2) do
|
36
|
+
drop_table :articles
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
41
40
|
subject {
|
42
41
|
::Article.create(title: 'foo', created_at: Time.now)
|
43
42
|
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'elasticsearch/model/extensions/all'
|
2
|
+
|
3
|
+
RSpec.describe Elasticsearch::Model::Extensions::OuterDocumentUpdating do
|
4
|
+
before(:each) do
|
5
|
+
load 'setup/articles_with_comments.rb'
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
ActiveRecord::Schema.define(:version => 2) do
|
10
|
+
drop_table :comments
|
11
|
+
drop_table :articles
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'an article' do
|
16
|
+
def article
|
17
|
+
::Article.search('Comment1').records.first
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with a comment added' do
|
21
|
+
before(:each) do
|
22
|
+
article.comments.create(body: 'Comment2')
|
23
|
+
|
24
|
+
Article.__elasticsearch__.refresh_index!
|
25
|
+
end
|
26
|
+
|
27
|
+
specify {
|
28
|
+
expect(Article.search('Comment1').records.first).not_to be_nil
|
29
|
+
expect(Article.search('Comment2').records.first).not_to be_nil
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when a comment destroyed' do
|
34
|
+
before(:each) do
|
35
|
+
article.comments.first.destroy
|
36
|
+
|
37
|
+
Article.__elasticsearch__.refresh_index!
|
38
|
+
end
|
39
|
+
|
40
|
+
specify 'the article is updated' do
|
41
|
+
expect(Article.search('Comment1').records).to be_empty
|
42
|
+
end
|
43
|
+
|
44
|
+
specify 'the comment becomes unsearchable' do
|
45
|
+
expect(Comment.search('Comment1').records).to be_empty
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'elasticsearch/model/extensions/all'
|
2
|
+
|
3
|
+
RSpec.describe Elasticsearch::Model::Extensions::PartialUpdating do
|
4
|
+
before(:each) do
|
5
|
+
load 'setup/articles_with_comments.rb'
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
ActiveRecord::Schema.define(:version => 2) do
|
10
|
+
drop_table :comments
|
11
|
+
drop_table :articles
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:as_json_options) {
|
16
|
+
described_class.build_as_json_options(klass: Article, props: Article.mappings.to_hash[Article.document_type.intern][:properties])
|
17
|
+
}
|
18
|
+
|
19
|
+
subject {
|
20
|
+
Article.last
|
21
|
+
}
|
22
|
+
|
23
|
+
specify {
|
24
|
+
expect(as_json_options).to include(methods: :num_comments)
|
25
|
+
}
|
26
|
+
|
27
|
+
specify {
|
28
|
+
expect(subject.build_partial_document_for_update(:comments)).to include(:comments, :num_comments)
|
29
|
+
}
|
30
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'elasticsearch/model/extensions/all'
|
2
|
+
|
3
|
+
ActiveRecord::Schema.define(:version => 1) do
|
4
|
+
create_table :articles do |t|
|
5
|
+
t.string :title
|
6
|
+
t.datetime :created_at, :default => 'NOW()'
|
7
|
+
end
|
8
|
+
|
9
|
+
create_table :comments do |t|
|
10
|
+
t.integer :article_id
|
11
|
+
t.string :body
|
12
|
+
t.datetime :created_at, :default => 'NOW()'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class ::Article < ActiveRecord::Base
|
17
|
+
has_many :comments
|
18
|
+
|
19
|
+
accepts_nested_attributes_for :comments
|
20
|
+
|
21
|
+
include Elasticsearch::Model
|
22
|
+
include Elasticsearch::Model::Callbacks
|
23
|
+
include Elasticsearch::Model::Extensions::IndexOperations
|
24
|
+
include Elasticsearch::Model::Extensions::BatchUpdating
|
25
|
+
include Elasticsearch::Model::Extensions::PartialUpdating
|
26
|
+
|
27
|
+
DEPENDENT_CUSTOM_ATTRIBUTES = {
|
28
|
+
%w| comments | => %w| num_comments |
|
29
|
+
}
|
30
|
+
|
31
|
+
include Elasticsearch::Model::Extensions::DependencyTracking
|
32
|
+
|
33
|
+
settings index: {number_of_shards: 1, number_of_replicas: 0} do
|
34
|
+
mapping do
|
35
|
+
indexes :title, type: 'string', analyzer: 'snowball'
|
36
|
+
indexes :created_at, type: 'date'
|
37
|
+
indexes :comments, type: 'object' do
|
38
|
+
indexes :body, type: 'string', include_in_all: true
|
39
|
+
end
|
40
|
+
indexes :num_comments, type: 'long'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def num_comments
|
45
|
+
comments.count
|
46
|
+
end
|
47
|
+
|
48
|
+
# Required by Comment's `OuterDocumentUpdating`
|
49
|
+
include Elasticsearch::Model::Extensions::MappingReflection
|
50
|
+
end
|
51
|
+
|
52
|
+
class ::Comment < ActiveRecord::Base
|
53
|
+
include Elasticsearch::Model
|
54
|
+
include Elasticsearch::Model::Callbacks
|
55
|
+
include Elasticsearch::Model::Extensions::IndexOperations
|
56
|
+
include Elasticsearch::Model::Extensions::BatchUpdating
|
57
|
+
include Elasticsearch::Model::Extensions::PartialUpdating
|
58
|
+
include Elasticsearch::Model::Extensions::OuterDocumentUpdating
|
59
|
+
|
60
|
+
partially_updates_document_of ::Article, records_to_update_documents: -> comment { Article.find(comment.article_id) } do |t, changed_fields|
|
61
|
+
t.partially_update_document(*changed_fields)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Article.delete_all
|
66
|
+
Article.__elasticsearch__.create_index! force: true
|
67
|
+
|
68
|
+
::Article.create! title: 'Test'
|
69
|
+
::Article.create! title: 'Testing Coding'
|
70
|
+
::Article.create! title: 'Coding', comments_attributes: [{ body: 'Comment1' }]
|
71
|
+
|
72
|
+
Article.__elasticsearch__.refresh_index!
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'elasticsearch/model'
|
2
|
+
|
3
|
+
tracer = ::Logger.new(STDERR)
|
4
|
+
tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }}\n" }
|
5
|
+
|
6
|
+
listened_port = (ENV['TEST_CLUSTER_PORT'] || 9250)
|
7
|
+
|
8
|
+
tracer.info "Connecting to the Elasticsearch listening for the port: #{listened_port}"
|
9
|
+
|
10
|
+
Elasticsearch::Model.client = Elasticsearch::Client.new host: "localhost:#{listened_port}",
|
11
|
+
tracer: (ENV['QUIET'] ? nil : tracer)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ":memory:")
|
5
|
+
logger = ::Logger.new(STDERR)
|
6
|
+
logger.formatter = lambda { |s, d, p, m| "\e[2;36m#{m}\e[0m\n" }
|
7
|
+
ActiveRecord::Base.logger = logger unless ENV['QUIET']
|
8
|
+
|
9
|
+
ActiveRecord::LogSubscriber.colorize_logging = false
|
10
|
+
ActiveRecord::Migration.verbose = false
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
1
4
|
RSpec.configure do |config|
|
2
5
|
config.expect_with :rspec do |expectations|
|
3
6
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
@@ -13,23 +16,28 @@ RSpec.configure do |config|
|
|
13
16
|
|
14
17
|
Kernel.srand config.seed
|
15
18
|
|
16
|
-
config.before
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
config.before :all do
|
20
|
+
load 'setup/elasticsearch/start.rb'
|
21
|
+
load 'setup/elasticsearch/model.rb'
|
22
|
+
end
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
ActiveRecord::Base.logger = logger unless ENV['QUIET']
|
24
|
+
config.after :all do
|
25
|
+
load 'setup/elasticsearch/stop.rb'
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
config.before :suite do
|
29
|
+
require 'setup/sqlite.rb'
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
require 'database_cleaner'
|
32
|
+
|
33
|
+
# https://github.com/DatabaseCleaner/database_cleaner#additional-activerecord-options-for-truncation
|
34
|
+
DatabaseCleaner.clean_with :deletion, cache_tables: false
|
35
|
+
DatabaseCleaner.strategy = :deletion
|
36
|
+
end
|
31
37
|
|
32
|
-
|
33
|
-
|
38
|
+
config.around(:each) do |example|
|
39
|
+
DatabaseCleaner.cleaning do
|
40
|
+
example.run
|
41
|
+
end
|
34
42
|
end
|
35
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-model-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke KUOKA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -47,6 +47,8 @@ extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
49
|
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- ".travis.yml"
|
50
52
|
- Gemfile
|
51
53
|
- LICENSE.txt
|
52
54
|
- README.md
|
@@ -67,7 +69,15 @@ files:
|
|
67
69
|
- lib/elasticsearch/model/extensions/shortest_path.rb
|
68
70
|
- lib/elasticsearch/model/extensions/update_callback.rb
|
69
71
|
- lib/elasticsearch/model/extensions/version.rb
|
72
|
+
- spec/example/articles_with_comments.rb
|
70
73
|
- spec/integration_spec.rb
|
74
|
+
- spec/outer_document_updating_spec.rb
|
75
|
+
- spec/partial_updating_spec.rb
|
76
|
+
- spec/setup/articles_with_comments.rb
|
77
|
+
- spec/setup/elasticsearch/model.rb
|
78
|
+
- spec/setup/elasticsearch/start.rb
|
79
|
+
- spec/setup/elasticsearch/stop.rb
|
80
|
+
- spec/setup/sqlite.rb
|
71
81
|
- spec/spec_helper.rb
|
72
82
|
homepage: https://github.com/crowdworks/elasticsearch-model-extensions
|
73
83
|
licenses:
|
@@ -96,5 +106,14 @@ summary: A set of extensions for elasticsearch-model which aims to ease the burd
|
|
96
106
|
of things like re-indexing, verbose/complex mapping that you may face once you started
|
97
107
|
using elasticsearch seriously.
|
98
108
|
test_files:
|
109
|
+
- spec/example/articles_with_comments.rb
|
99
110
|
- spec/integration_spec.rb
|
111
|
+
- spec/outer_document_updating_spec.rb
|
112
|
+
- spec/partial_updating_spec.rb
|
113
|
+
- spec/setup/articles_with_comments.rb
|
114
|
+
- spec/setup/elasticsearch/model.rb
|
115
|
+
- spec/setup/elasticsearch/start.rb
|
116
|
+
- spec/setup/elasticsearch/stop.rb
|
117
|
+
- spec/setup/sqlite.rb
|
100
118
|
- spec/spec_helper.rb
|
119
|
+
has_rdoc:
|