pluckit 1.3.0 → 1.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: 2fa3b9c0c3eaffdb1e373ecc4521c31808d9cc22539b2e1fdd05bd2529803e86
4
- data.tar.gz: 3235aa2e80347253725ad8e8abac1621cdaf2e0b75f2bfae044ab99cd947da4c
3
+ metadata.gz: 5c607d3a501e2f5bf3a971dc37b53a3088b2f009f4d9d47fbbbca030339de63f
4
+ data.tar.gz: 7f02ef863a371794cade093a6323f08782d493ae6142157b4fdc008b340b173e
5
5
  SHA512:
6
- metadata.gz: b34c574ba4f85ec05ed5e5237806c1a2c7b541a918f5afbc8a745c39ce8249c3a344d68d494bb73b3190068aa75f1c85d234e05da25f0935034883921ba2b343
7
- data.tar.gz: f5deee17d062cede83409fc849af459bc5e41308c0cd19db452464354fc3940459c8d9b158f704e48940e1958c814453a15611cecdc013cae79c70d6f4edd434
6
+ metadata.gz: 434128cd7cf59df1c0ae996b810ba5741775ea0a680a5b7e81d08c663353da3e53975d468fccc2a9e223de3212b9abb72a0d5d7ad9d5843684a6228642338f49
7
+ data.tar.gz: 6acdad5f4a933a5e53464904938172f09820af22ddf5af057dc66a22bc25805ec74bc78b315efe8c5aedc0833ae73b51475c19ab448fbdc553c2f1c4238977ef
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 1.3.1 (2026-11-03)
2
+ - fix: `PluckIt.pluck` on other Enumerables (Range, Enumerator, lazy) returns an Array (or a lazy enumerator) instead of raising NoMethodError
3
+ - fix: `PluckIt.pluck` on a frozen Array, Hash, or Set returns a new result instead of raising FrozenError
4
+
1
5
  ### 1.3.0 (2026-11-03)
2
6
  - drop Ruby 3.0 and 3.1 (end of life); requires Ruby >= 3.2
3
7
  - feature: a callable handle (lambda, proc, Method) is called with each value: `users.pluck(->(u) { u.name.upcase })`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pluckit (1.3.0)
4
+ pluckit (1.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -40,3 +40,17 @@ require 'pluckit'
40
40
  [ 'alice', 'bob' ].pluck ->(name) { name.capitalize }
41
41
  => [ 'Alice', 'Bob' ]
42
42
  ```
43
+
44
+
45
+ #### Without the monkey patch
46
+ `require 'pluckit'` adds `#pluck` to Array, Hash, and Set. To skip the global patch, load the module alone and use the refinement, or call it directly:
47
+
48
+ ```ruby
49
+ require 'pluckit/pluck'
50
+
51
+ using PluckIt
52
+ [ { id: 1 } ].pluck :id
53
+
54
+ # or
55
+ PluckIt.pluck [ { id: 1 } ], :id
56
+ ```
data/lib/pluckit/pluck.rb CHANGED
@@ -20,10 +20,14 @@ module PluckIt
20
20
  end
21
21
 
22
22
  def pluck enumerable, *handles
23
+ # these keep their type (and subclass) via dup.clear; anything else maps
24
+ unless [ Array, Hash, Set ].any? { |klass| enumerable.is_a?(klass) }
25
+ return enumerable.map { |val| pluckit(val, *handles) }
26
+ end
27
+
23
28
  items = enumerable.each_with_object(
24
- enumerable.clone.clear
29
+ enumerable.dup.clear # dup, not clone: clone keeps frozen and singleton methods
25
30
  )
26
- # TODO: if no clone / clear, use new
27
31
 
28
32
  if enumerable.is_a?(Hash)
29
33
  items.each do |(key, val), res|
@@ -1,3 +1,3 @@
1
1
  module PluckIt
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluckit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper