liquid 5.7.0 → 5.7.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: 72a0f18697a90c81db846fc86027cbec36198105fb458d40989f88b1acd55687
4
- data.tar.gz: ba8f6ecc9612f737f954006109b91759ea7cea41074de2ab38e73221d4e18be2
3
+ metadata.gz: 771dc6f35b1b6c881e98289584bbcf8f0b0a2c494ddf1b6bf14bda94aa6ef991
4
+ data.tar.gz: 5de0ba09a9e281fd713480edafb79dc5580f3ef1233a6f7c27d45897649a2fa6
5
5
  SHA512:
6
- metadata.gz: ad608314f023c78123d3cf57a3c9b54229ec7dca712f1b3897218c27880e5f78d7188cdce775d15759960803a31c5e7d1adc81c9282ab784a6f6fa50efeb051e
7
- data.tar.gz: 6988a403789ca9a3a3d3d48e5cba0639f81226b3cd8af477dcce1d8eeb9db3693e90b373ea391f5d458a723ec40d7c0c6d28f7e445d3d0562b219e9cbcfff1ee
6
+ metadata.gz: '09c9b6247637be3d1a7f9b9bdaff3351d72d3215d2cd7eaaf213d97eaca99ba5faef92bc89165c13f1b34fa3742a3de4e26fddba0d6390587e7a640d3af54ae3'
7
+ data.tar.gz: 1afb6aca240c13c8ca09bb5079094a69e98bf48d83a1016ee261c34862dadd35e1bf8d64c906f12ecba3c616656f33f3576a3237eddc0d2ec4e97fd0e10bd43f
data/History.md CHANGED
@@ -2,9 +2,15 @@
2
2
 
3
3
  ## 5.8.0 (unreleased)
4
4
 
5
+ ## 5.7.1 2025-01-23
6
+
7
+ * Fix the `find` and `find_index`filters to return `nil` when filtering empty arrays
8
+ * Fix the `has` filter to return `false` when filtering empty arrays
9
+
5
10
  ## 5.7.0 2025-01-16
6
11
 
7
12
  ### Features
13
+
8
14
  * Add `find`, `find_index`, `has`, and `reject` filters to arrays
9
15
  * Compatibility with Ruby 3.4
10
16
 
@@ -459,7 +459,7 @@ module Liquid
459
459
  # @liquid_syntax array | some: string, string
460
460
  # @liquid_return [boolean]
461
461
  def has(input, property, target_value = nil)
462
- filter_array(input, property, target_value) { |ary, &block| ary.any?(&block) }
462
+ filter_array(input, property, target_value, false) { |ary, &block| ary.any?(&block) }
463
463
  end
464
464
 
465
465
  # @liquid_public_docs
@@ -472,7 +472,7 @@ module Liquid
472
472
  # @liquid_syntax array | find: string, string
473
473
  # @liquid_return [untyped]
474
474
  def find(input, property, target_value = nil)
475
- filter_array(input, property, target_value) { |ary, &block| ary.find(&block) }
475
+ filter_array(input, property, target_value, nil) { |ary, &block| ary.find(&block) }
476
476
  end
477
477
 
478
478
  # @liquid_public_docs
@@ -485,7 +485,7 @@ module Liquid
485
485
  # @liquid_syntax array | find_index: string, string
486
486
  # @liquid_return [number]
487
487
  def find_index(input, property, target_value = nil)
488
- filter_array(input, property, target_value) { |ary, &block| ary.find_index(&block) }
488
+ filter_array(input, property, target_value, nil) { |ary, &block| ary.find_index(&block) }
489
489
  end
490
490
 
491
491
  # @liquid_public_docs
@@ -969,10 +969,10 @@ module Liquid
969
969
 
970
970
  attr_reader :context
971
971
 
972
- def filter_array(input, property, target_value, &block)
972
+ def filter_array(input, property, target_value, default_value = [], &block)
973
973
  ary = InputIterator.new(input, context)
974
974
 
975
- return [] if ary.empty?
975
+ return default_value if ary.empty?
976
976
 
977
977
  block.call(ary) do |item|
978
978
  if target_value.nil?
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Liquid
5
- VERSION = "5.7.0"
5
+ VERSION = "5.7.1"
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.7.0
4
+ version: 5.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Lütke
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-17 00:00:00.000000000 Z
10
+ date: 2025-01-24 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: strscan