chewy 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/CHANGELOG.md +43 -1
- data/Gemfile +3 -0
- data/README.md +49 -11
- data/chewy.gemspec +1 -2
- data/gemfiles/Gemfile.rails-3.2 +1 -0
- data/gemfiles/Gemfile.rails-4.0 +1 -0
- data/lib/chewy.rb +8 -2
- data/lib/chewy/backports/deep_dup.rb +46 -0
- data/lib/chewy/backports/duplicable.rb +90 -0
- data/lib/chewy/config.rb +33 -6
- data/lib/chewy/errors.rb +1 -1
- data/lib/chewy/fields/base.rb +19 -7
- data/lib/chewy/fields/root.rb +13 -0
- data/lib/chewy/index/actions.rb +14 -6
- data/lib/chewy/index/search.rb +3 -2
- data/lib/chewy/query.rb +131 -17
- data/lib/chewy/query/compose.rb +27 -17
- data/lib/chewy/query/criteria.rb +34 -22
- data/lib/chewy/query/loading.rb +94 -10
- data/lib/chewy/query/nodes/exists.rb +1 -1
- data/lib/chewy/query/nodes/has_relation.rb +1 -1
- data/lib/chewy/query/nodes/missing.rb +1 -1
- data/lib/chewy/query/pagination.rb +8 -38
- data/lib/chewy/query/pagination/kaminari.rb +37 -0
- data/lib/chewy/runtime.rb +9 -0
- data/lib/chewy/runtime/version.rb +25 -0
- data/lib/chewy/type/adapter/active_record.rb +21 -7
- data/lib/chewy/type/adapter/base.rb +1 -1
- data/lib/chewy/type/adapter/object.rb +9 -6
- data/lib/chewy/type/import.rb +7 -4
- data/lib/chewy/type/mapping.rb +9 -9
- data/lib/chewy/type/wrapper.rb +1 -1
- data/lib/chewy/version.rb +1 -1
- data/lib/tasks/chewy.rake +40 -21
- data/spec/chewy/config_spec.rb +1 -1
- data/spec/chewy/fields/base_spec.rb +273 -8
- data/spec/chewy/index/actions_spec.rb +1 -2
- data/spec/chewy/index/aliases_spec.rb +0 -1
- data/spec/chewy/index/search_spec.rb +0 -8
- data/spec/chewy/index/settings_spec.rb +0 -2
- data/spec/chewy/index_spec.rb +0 -2
- data/spec/chewy/query/criteria_spec.rb +85 -18
- data/spec/chewy/query/loading_spec.rb +26 -9
- data/spec/chewy/query/nodes/and_spec.rb +2 -2
- data/spec/chewy/query/nodes/exists_spec.rb +6 -6
- data/spec/chewy/query/nodes/missing_spec.rb +4 -4
- data/spec/chewy/query/nodes/or_spec.rb +2 -2
- data/spec/chewy/query/pagination/kaminari_spec.rb +55 -0
- data/spec/chewy/query/pagination_spec.rb +15 -22
- data/spec/chewy/query_spec.rb +121 -52
- data/spec/chewy/rspec/update_index_spec.rb +0 -1
- data/spec/chewy/runtime/version_spec.rb +48 -0
- data/spec/chewy/runtime_spec.rb +9 -0
- data/spec/chewy/type/adapter/active_record_spec.rb +52 -0
- data/spec/chewy/type/adapter/object_spec.rb +33 -0
- data/spec/chewy/type/import_spec.rb +1 -3
- data/spec/chewy/type/mapping_spec.rb +4 -6
- data/spec/chewy/type/observe_spec.rb +0 -2
- data/spec/chewy/type/wrapper_spec.rb +0 -2
- data/spec/chewy/type_spec.rb +26 -5
- data/spec/chewy_spec.rb +0 -2
- data/spec/spec_helper.rb +2 -2
- metadata +15 -21
- data/lib/chewy/fields/default.rb +0 -10
- data/spec/chewy/fields/default_spec.rb +0 -6
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Chewy::Type::Import do
|
4
|
-
include ClassHelpers
|
5
|
-
|
6
4
|
before { Chewy.client.indices.delete index: '*' }
|
7
5
|
|
8
6
|
before do
|
@@ -188,7 +186,7 @@ describe Chewy::Type::Import do
|
|
188
186
|
end
|
189
187
|
end
|
190
188
|
|
191
|
-
specify { expect { city.import!(dummy_cities) }.to raise_error Chewy::
|
189
|
+
specify { expect { city.import!(dummy_cities) }.to raise_error Chewy::ImportFailed }
|
192
190
|
end
|
193
191
|
end
|
194
192
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Chewy::Type::Mapping do
|
4
|
-
include ClassHelpers
|
5
|
-
|
6
4
|
let(:product) { ProductsIndex::Product }
|
7
5
|
|
8
6
|
before do
|
@@ -23,13 +21,13 @@ describe Chewy::Type::Mapping do
|
|
23
21
|
|
24
22
|
describe '.field' do
|
25
23
|
specify { product.root_object.nested.keys.should =~ [:name, :surname, :title, :price] }
|
26
|
-
specify { product.root_object.nested.values.should satisfy { |v| v.all? { |f| f.is_a? Chewy::Fields::
|
24
|
+
specify { product.root_object.nested.values.should satisfy { |v| v.all? { |f| f.is_a? Chewy::Fields::Base } } }
|
27
25
|
|
28
26
|
specify { product.root_object.nested[:title].nested.keys.should == [:subfield1] }
|
29
|
-
specify { product.root_object.nested[:title].nested[:subfield1].should be_a Chewy::Fields::
|
27
|
+
specify { product.root_object.nested[:title].nested[:subfield1].should be_a Chewy::Fields::Base }
|
30
28
|
|
31
29
|
specify { product.root_object.nested[:price].nested.keys.should == [:subfield2] }
|
32
|
-
specify { product.root_object.nested[:price].nested[:subfield2].should be_a Chewy::Fields::
|
30
|
+
specify { product.root_object.nested[:price].nested[:subfield2].should be_a Chewy::Fields::Base }
|
33
31
|
end
|
34
32
|
|
35
33
|
describe '.mappings_hash' do
|
@@ -49,6 +47,6 @@ describe Chewy::Type::Mapping do
|
|
49
47
|
end
|
50
48
|
|
51
49
|
specify { product.root_object.nested[:title].nested.keys.should == [:subfield1] }
|
52
|
-
specify { product.root_object.nested[:title].nested[:subfield1].should be_a Chewy::Fields::
|
50
|
+
specify { product.root_object.nested[:title].nested[:subfield1].should be_a Chewy::Fields::Base }
|
53
51
|
end
|
54
52
|
end
|
data/spec/chewy/type_spec.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Chewy::Type do
|
4
|
-
include ClassHelpers
|
5
|
-
|
6
4
|
describe '.new' do
|
7
|
-
before
|
8
|
-
stub_index(:cities)
|
9
|
-
end
|
5
|
+
before { stub_index(:cities) }
|
10
6
|
|
11
7
|
context 'Symbol' do
|
12
8
|
subject { described_class.new(CitiesIndex, :city) }
|
@@ -39,5 +35,30 @@ describe Chewy::Type do
|
|
39
35
|
its(:index) { should == CitiesIndex }
|
40
36
|
its(:type_name) { should == 'city' }
|
41
37
|
end
|
38
|
+
|
39
|
+
context 'Namespaced index' do
|
40
|
+
before { stub_model(:city) }
|
41
|
+
before { stub_index('namespace/cities') }
|
42
|
+
|
43
|
+
subject { described_class.new(Namespace::CitiesIndex, City) }
|
44
|
+
|
45
|
+
it { should be_a Class }
|
46
|
+
it { should be < Chewy::Type::Base }
|
47
|
+
its(:name) { should == 'Namespace::CitiesIndex::City' }
|
48
|
+
its(:index) { should == Namespace::CitiesIndex }
|
49
|
+
its(:type_name) { should == 'city' }
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'Namespaced model' do
|
53
|
+
before { stub_model('namespace/city') }
|
54
|
+
|
55
|
+
subject { described_class.new(CitiesIndex, Namespace::City) }
|
56
|
+
|
57
|
+
it { should be_a Class }
|
58
|
+
it { should be < Chewy::Type::Base }
|
59
|
+
its(:name) { should == 'CitiesIndex::City' }
|
60
|
+
its(:index) { should == CitiesIndex }
|
61
|
+
its(:type_name) { should == 'city' }
|
62
|
+
end
|
42
63
|
end
|
43
64
|
end
|
data/spec/chewy_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -9,11 +9,11 @@ require 'support/class_helpers'
|
|
9
9
|
|
10
10
|
require 'chewy/rspec'
|
11
11
|
|
12
|
+
Kaminari::Hooks.init
|
13
|
+
|
12
14
|
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
13
15
|
ActiveRecord::Base.logger = Logger.new('/dev/null')
|
14
16
|
|
15
|
-
Kaminari::Hooks.init
|
16
|
-
|
17
17
|
ActiveRecord::Schema.define do
|
18
18
|
create_table :countries do |t|
|
19
19
|
t.column :name, :string
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyromaniac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.14.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.14.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: kaminari
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: activerecord
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,10 +144,11 @@ files:
|
|
158
144
|
- gemfiles/Gemfile.rails-3.2
|
159
145
|
- gemfiles/Gemfile.rails-4.0
|
160
146
|
- lib/chewy.rb
|
147
|
+
- lib/chewy/backports/deep_dup.rb
|
148
|
+
- lib/chewy/backports/duplicable.rb
|
161
149
|
- lib/chewy/config.rb
|
162
150
|
- lib/chewy/errors.rb
|
163
151
|
- lib/chewy/fields/base.rb
|
164
|
-
- lib/chewy/fields/default.rb
|
165
152
|
- lib/chewy/fields/root.rb
|
166
153
|
- lib/chewy/index.rb
|
167
154
|
- lib/chewy/index/actions.rb
|
@@ -194,9 +181,12 @@ files:
|
|
194
181
|
- lib/chewy/query/nodes/regexp.rb
|
195
182
|
- lib/chewy/query/nodes/script.rb
|
196
183
|
- lib/chewy/query/pagination.rb
|
184
|
+
- lib/chewy/query/pagination/kaminari.rb
|
197
185
|
- lib/chewy/railtie.rb
|
198
186
|
- lib/chewy/rspec.rb
|
199
187
|
- lib/chewy/rspec/update_index.rb
|
188
|
+
- lib/chewy/runtime.rb
|
189
|
+
- lib/chewy/runtime/version.rb
|
200
190
|
- lib/chewy/type.rb
|
201
191
|
- lib/chewy/type/adapter/active_record.rb
|
202
192
|
- lib/chewy/type/adapter/base.rb
|
@@ -210,7 +200,6 @@ files:
|
|
210
200
|
- lib/tasks/chewy.rake
|
211
201
|
- spec/chewy/config_spec.rb
|
212
202
|
- spec/chewy/fields/base_spec.rb
|
213
|
-
- spec/chewy/fields/default_spec.rb
|
214
203
|
- spec/chewy/fields/root_spec.rb
|
215
204
|
- spec/chewy/index/actions_spec.rb
|
216
205
|
- spec/chewy/index/aliases_spec.rb
|
@@ -236,9 +225,12 @@ files:
|
|
236
225
|
- spec/chewy/query/nodes/raw_spec.rb
|
237
226
|
- spec/chewy/query/nodes/regexp_spec.rb
|
238
227
|
- spec/chewy/query/nodes/script_spec.rb
|
228
|
+
- spec/chewy/query/pagination/kaminari_spec.rb
|
239
229
|
- spec/chewy/query/pagination_spec.rb
|
240
230
|
- spec/chewy/query_spec.rb
|
241
231
|
- spec/chewy/rspec/update_index_spec.rb
|
232
|
+
- spec/chewy/runtime/version_spec.rb
|
233
|
+
- spec/chewy/runtime_spec.rb
|
242
234
|
- spec/chewy/type/adapter/active_record_spec.rb
|
243
235
|
- spec/chewy/type/adapter/object_spec.rb
|
244
236
|
- spec/chewy/type/import_spec.rb
|
@@ -277,7 +269,6 @@ summary: Elasticsearch ODM client wrapper
|
|
277
269
|
test_files:
|
278
270
|
- spec/chewy/config_spec.rb
|
279
271
|
- spec/chewy/fields/base_spec.rb
|
280
|
-
- spec/chewy/fields/default_spec.rb
|
281
272
|
- spec/chewy/fields/root_spec.rb
|
282
273
|
- spec/chewy/index/actions_spec.rb
|
283
274
|
- spec/chewy/index/aliases_spec.rb
|
@@ -303,9 +294,12 @@ test_files:
|
|
303
294
|
- spec/chewy/query/nodes/raw_spec.rb
|
304
295
|
- spec/chewy/query/nodes/regexp_spec.rb
|
305
296
|
- spec/chewy/query/nodes/script_spec.rb
|
297
|
+
- spec/chewy/query/pagination/kaminari_spec.rb
|
306
298
|
- spec/chewy/query/pagination_spec.rb
|
307
299
|
- spec/chewy/query_spec.rb
|
308
300
|
- spec/chewy/rspec/update_index_spec.rb
|
301
|
+
- spec/chewy/runtime/version_spec.rb
|
302
|
+
- spec/chewy/runtime_spec.rb
|
309
303
|
- spec/chewy/type/adapter/active_record_spec.rb
|
310
304
|
- spec/chewy/type/adapter/object_spec.rb
|
311
305
|
- spec/chewy/type/import_spec.rb
|
data/lib/chewy/fields/default.rb
DELETED