chewy 7.3.0 → 7.3.1

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
  SHA256:
3
- metadata.gz: fcd795c985f120c412c315bc0b87dd65e7b55a302aeae1bffbc5c71beb910652
4
- data.tar.gz: ad70c5ff382f8405146da2be5643d9ac397d60fbbf16842a509a950cc90acbd2
3
+ metadata.gz: 79428eb9af436a7a4c80a2db3c034583768eacc45d00074525f8e6559341ae20
4
+ data.tar.gz: 23377b8abb6ebfa81f8140990916022f8bbca769b5ad4474a076c8d890ece979
5
5
  SHA512:
6
- metadata.gz: 0f4ac34a7c84c9fc6dd2743ab77982b634bddb0ceda0116b2a2bfa9a0b902655b375bc215857002041159a5cd0ce52e9c409342f06ce7a41f0667d3c74c07ab4
7
- data.tar.gz: fa68110ccfc6acd942c54b279cfd99e36b980dcb408bd1508430598757c3efd57e8dc1eaa60c2bf77156eb9acba77c700715ac9676af0a36eacb600de730b1b5
6
+ metadata.gz: 89b6aa83fa54a6b5056623f8255eb34675ad9c3e1494915aa324af752d1a72f9c010fcbcbb3c929a232b32811bbc36956624848efabc09cb382c59fbcee54940
7
+ data.tar.gz: 90e1da06cf5c38903ca52c6b5379a9271cf277e3c70604b80d77d9ed13496b15ac3874249f2bf67fca7aec3eb9ac9db5e9a20de95eb1da7bb1bfa84307c9c846
data/CHANGELOG.md CHANGED
@@ -8,6 +8,13 @@
8
8
 
9
9
  ### Bugs Fixed
10
10
 
11
+ ## 7.3.1 (2023-04-20)
12
+
13
+ ### Bugs Fixed
14
+
15
+ * [#874](https://github.com/toptal/chewy/pull/874): Fix `chewy:journal:clean` task for ruby 3.x. ([@muk-ai](https://github.com/muk-ai))
16
+ * [#882](https://github.com/toptal/chewy/pull/882): Fix memory leak during `chewy:reset` for ruby 3.2 ([@konalegi](https://github.com/konalegi))
17
+
11
18
  ## 7.3.0 (2023-04-03)
12
19
 
13
20
  ### New Features
data/README.md CHANGED
@@ -503,7 +503,7 @@ class ProductsIndex < Chewy::Index
503
503
 
504
504
  field :name
505
505
  # simply use crutch-fetched data as a value:
506
- field :category_names, value: ->(product, crutches) { crutches.categories[product.id] }
506
+ field :category_names, value: ->(product, crutches) { crutches[:categories][product.id] }
507
507
  end
508
508
  ```
509
509
 
@@ -884,7 +884,9 @@ It is convenient for use in e.g. the Rails console with non-block notation:
884
884
 
885
885
  #### `:bypass`
886
886
 
887
- The bypass strategy simply silences index updates.
887
+ When the bypass strategy is active the index will not be automatically updated on object save.
888
+
889
+ For example, on `City.first.save!` the cities index would not be updated.
888
890
 
889
891
  #### Nesting
890
892
 
@@ -12,13 +12,21 @@ module Chewy
12
12
  def initialize(index, collection)
13
13
  @index = index
14
14
  @collection = collection
15
- @index._crutches.each_key do |name|
16
- singleton_class.class_eval <<-METHOD, __FILE__, __LINE__ + 1
17
- def #{name}
18
- @#{name} ||= @index._crutches[:#{name}].call @collection
19
- end
20
- METHOD
21
- end
15
+ @crutches_instances = {}
16
+ end
17
+
18
+ def method_missing(name, *, **)
19
+ return self[name] if @index._crutches.key?(name)
20
+
21
+ super
22
+ end
23
+
24
+ def respond_to_missing?(name, include_private = false)
25
+ @index._crutches.key?(name) || super
26
+ end
27
+
28
+ def [](name)
29
+ @crutches_instances[name] ||= @index._crutches[:"#{name}"].call(@collection)
22
30
  end
23
31
  end
24
32
 
data/lib/chewy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chewy
2
- VERSION = '7.3.0'.freeze
2
+ VERSION = '7.3.1'.freeze
3
3
  end
data/lib/tasks/chewy.rake CHANGED
@@ -96,7 +96,7 @@ namespace :chewy do
96
96
  task clean: :environment do |_task, args|
97
97
  delete_options = Chewy::RakeHelper.delete_by_query_options_from_env(ENV)
98
98
  Chewy::RakeHelper.journal_clean(
99
- [
99
+ **[
100
100
  parse_journal_args(args.extras),
101
101
  {delete_by_query_options: delete_options}
102
102
  ].reduce({}, :merge)
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'rake'
2
3
 
3
4
  describe Chewy::RakeHelper, :orm do
4
5
  before { Chewy.massacre }
@@ -456,6 +457,17 @@ Total: \\d+s\\Z
456
457
  Total: \\d+s\\Z
457
458
  OUTPUT
458
459
  end
460
+
461
+ context 'execute "chewy:journal:clean" rake task' do
462
+ subject(:task) { Rake.application['chewy:journal:clean'] }
463
+ before do
464
+ Rake::DefaultLoader.new.load('lib/tasks/chewy.rake')
465
+ Rake::Task.define_task(:environment)
466
+ end
467
+ it 'does not raise error' do
468
+ expect { task.invoke }.to_not raise_error
469
+ end
470
+ end
459
471
  end
460
472
 
461
473
  describe '.reindex' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chewy
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.0
4
+ version: 7.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toptal, LLC
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-03 00:00:00.000000000 Z
12
+ date: 2023-04-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: database_cleaner