deeply_enumerable 2.0.0 → 2.0.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +14 -0
- data/lib/deeply_enumerable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c47df8d3946c3b010f0af6c185ebd93a0bcf7cbb4007ddbd89d3105496dcb78c
|
|
4
|
+
data.tar.gz: 9c8e54ca07f94145a0efd58b5f3dab64760d4d58244b12cb520946ee0d206ee1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e413f4cb0fac8f72c728126fb62e0f5ade142add7aede779c25de83051e41c9d38d6ff84f9b093ef472c5edb789db02d4f82dc77582d621265faaa63d5d01a40
|
|
7
|
+
data.tar.gz: 9008c5e856de8a746c6be66664c59e02af8c948377bc55fde22a99628c63753e8a8601f07de1ec127eaf327f3ee28c090ca0410d363c8af1dece5a3c82b3469c
|
data/CHANGELOG.md
CHANGED
|
@@ -21,6 +21,12 @@ been replaced with four clearly-named methods, and "blank" now matches Rails'
|
|
|
21
21
|
- **"Blank" now means `blank?`, not just empty.** The `_blank` family now also
|
|
22
22
|
removes `false` and blank strings (`""`, `" "`), in addition to `nil` and empty
|
|
23
23
|
collections — matching Rails' `#compact_blank`.
|
|
24
|
+
- **A Hash's `default`/`default_proc` is no longer preserved through compaction.**
|
|
25
|
+
v1 mutated a `dup` (which carried the proc); v2 builds a fresh `Hash`, which has
|
|
26
|
+
none. This matches `Hash#reject` and Rails' `#compact_blank`, but can silently
|
|
27
|
+
break code relying on auto-vivification after compaction (e.g. an accumulator
|
|
28
|
+
`Hash.new { |h, k| h[k] = [] }`). Apply the default proc to the compacted
|
|
29
|
+
*result* rather than before compacting.
|
|
24
30
|
|
|
25
31
|
### Added
|
|
26
32
|
|
data/README.md
CHANGED
|
@@ -93,6 +93,20 @@ blank strings (`""`, `" "`), matching Rails' `#compact_blank`. Blankness is
|
|
|
93
93
|
determined by an internal equivalent of ActiveSupport's `Object#blank?`, so the
|
|
94
94
|
gem still has **no ActiveSupport dependency**.
|
|
95
95
|
|
|
96
|
+
⚠️ **`default`/`default_proc` is not preserved.** v2 returns a freshly-built
|
|
97
|
+
`Hash`, so a default value or proc does not survive compaction (matching
|
|
98
|
+
`Hash#reject` and Rails' `#compact_blank`). v1 happened to keep it because it
|
|
99
|
+
mutated a `dup`. If you rely on auto-vivification, apply the default proc to the
|
|
100
|
+
compacted *result* rather than before compacting:
|
|
101
|
+
|
|
102
|
+
```ruby
|
|
103
|
+
# Fragile — the proc is dropped by compaction:
|
|
104
|
+
Hash.new { |h, k| h[k] = [] }.merge(value).deep_compact_blank
|
|
105
|
+
|
|
106
|
+
# Robust — compact first, then land the data in the proc-bearing Hash:
|
|
107
|
+
Hash.new { |h, k| h[k] = [] }.merge(value.deep_compact_blank)
|
|
108
|
+
```
|
|
109
|
+
|
|
96
110
|
## Installation
|
|
97
111
|
Add this line to your application's Gemfile:
|
|
98
112
|
```ruby
|