pluckit 1.0.0 → 1.2.0

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
- SHA1:
3
- metadata.gz: 7587bb8c7e758bd2badc023cf95087b397386c67
4
- data.tar.gz: 0e230a36351043c05e174d0971ab28b259fca86f
2
+ SHA256:
3
+ metadata.gz: f0c8e686fd9ed75effb4ce6813bfa337ae81675547b5acacd5c40b2a6596cb69
4
+ data.tar.gz: 4dd1015875c89e0a4542e495316e82688cfa0ae64d1f1a67bcc9a040bc41586d
5
5
  SHA512:
6
- metadata.gz: 1c0fd9d9d4e9dfaf4ffbf4699ba33105e027392b9f7a484519aacf3c065482adf6ab4e2e3979e5dfa0b6f3f2906f7890eb46ed8a5194f3301343a5a923d2a699
7
- data.tar.gz: 7989512d5bb2373eacdef52c87c011c7953a9350472e795fee65a5f7f61c04c1155efd71b9bbdbed760635fc07d98515813ccf70072baefaa958dd58aaffc3ab
6
+ metadata.gz: f190970663dce56184c3fdd91169899cb4a0db126d4fe543414ea41427d3061169bd131b860c23d617f0b99bd76af5617dcc8d513cb3cdfecc12d25a848c8b93
7
+ data.tar.gz: 8eb335b2b94d83a000ab27bc9198dd911736465005cee80134fd8752228b3c6e57ae355170a43f8e0c4be77b8529249ba5d8e2ebcceaf802511fbe09295b43de
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ### 1.2.0 (2026-04-11)
2
+ - ruby and gem updates
3
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pluckit (1.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ date (3.5.1)
10
+ debug (1.11.1)
11
+ irb (~> 1.10)
12
+ reline (>= 0.3.8)
13
+ diff-lcs (1.6.2)
14
+ docile (1.4.1)
15
+ erb (6.0.2)
16
+ io-console (0.8.2)
17
+ irb (1.17.0)
18
+ pp (>= 0.6.0)
19
+ prism (>= 1.3.0)
20
+ rdoc (>= 4.0.0)
21
+ reline (>= 0.4.2)
22
+ pp (0.6.3)
23
+ prettyprint
24
+ prettyprint (0.2.0)
25
+ prism (1.9.0)
26
+ psych (5.3.1)
27
+ date
28
+ stringio
29
+ rdoc (7.2.0)
30
+ erb
31
+ psych (>= 4.0.0)
32
+ tsort
33
+ reline (0.6.3)
34
+ io-console (~> 0.5)
35
+ rspec (3.13.2)
36
+ rspec-core (~> 3.13.0)
37
+ rspec-expectations (~> 3.13.0)
38
+ rspec-mocks (~> 3.13.0)
39
+ rspec-core (3.13.6)
40
+ rspec-support (~> 3.13.0)
41
+ rspec-debugging (0.0.4)
42
+ rspec-expectations (>= 3)
43
+ rspec-expectations (3.13.5)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.13.0)
46
+ rspec-mocks (3.13.8)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.13.0)
49
+ rspec-support (3.13.7)
50
+ simplecov (0.22.0)
51
+ docile (~> 1.1)
52
+ simplecov-html (~> 0.11)
53
+ simplecov_json_formatter (~> 0.1)
54
+ simplecov-html (0.13.2)
55
+ simplecov_json_formatter (0.1.4)
56
+ stringio (3.2.0)
57
+ tsort (0.2.0)
58
+
59
+ PLATFORMS
60
+ arm64-darwin-25
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ debug (>= 1)
65
+ pluckit!
66
+ rspec (>= 3.10)
67
+ rspec-debugging
68
+ simplecov (>= 0.22)
69
+
70
+ BUNDLED WITH
71
+ 4.0.10
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Daniel Pepper
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ PluckIt
2
+ ======
3
+ ![Gem](https://img.shields.io/gem/dt/pluckit?style=plastic)
4
+ [![codecov](https://codecov.io/gh/dpep/pluckit_rb/branch/main/graph/badge.svg?token=Z6W48XUEQD)](https://codecov.io/gh/dpep/pluckit_rb)
5
+
6
+ Extract values from Enumerables
7
+
8
+ #### Install
9
+ ```gem install pluckit```
10
+
11
+
12
+ #### Usage
13
+ ```ruby
14
+ require 'pluckit'
15
+
16
+
17
+ # extract a field from a list of records
18
+ [
19
+ { id: 1, name: 'alice', age: 30},
20
+ { id: 2, name: 'bob', age: 24},
21
+ { id: 3, name: 'charlie', age: 88},
22
+ ].pluck :name
23
+ => [ 'alice', 'bob', 'charlie' ]
24
+
25
+
26
+ # find max temp for each month
27
+ {
28
+ june: [ 78, 82, 80 ],
29
+ july: [ 80, 83, 86 ],
30
+ august: [ 80, 76, 79 ],
31
+ }.pluck :max
32
+ => {
33
+ june: 82,
34
+ july: 86,
35
+ august: 80,
36
+ }
37
+ ```
data/lib/pluckit/pluck.rb CHANGED
@@ -1,30 +1,66 @@
1
1
  module PluckIt
2
- class << self
2
+ extend self
3
3
 
4
- def pluck v, *handles
5
- if handles.count > 1
6
- handles.map {|h| pluck_single v, h }
7
- else
8
- pluck_single v, handles.first
9
- end
4
+ refine Array do
5
+ def pluck *handles
6
+ PluckIt.pluck self, *handles
7
+ end
8
+ end
9
+
10
+ refine Hash do
11
+ def pluck *handles
12
+ PluckIt.pluck self, *handles
10
13
  end
14
+ end
11
15
 
16
+ refine Set do
17
+ def pluck *handles
18
+ PluckIt.pluck self, *handles
19
+ end
20
+ end
12
21
 
13
- private
22
+ def pluck enumerable, *handles
23
+ items = enumerable.each_with_object(
24
+ enumerable.clone.clear
25
+ )
26
+ # TODO: if no clone / clear, use new
14
27
 
15
- def pluck_single v, handle
16
- if v.is_a? Hash
17
- v[handle]
18
- elsif ([Symbol, String].include? handle.class) and v.respond_to? handle
19
- v.send handle
20
- elsif handle.is_a? Regexp and v.respond_to? :grep
21
- v.grep handle
22
- elsif v.respond_to? :[]
23
- v[handle]
24
- else
25
- raise ArgumentError.new "invalid handle: #{handle}, for value #{v}"
28
+ if enumerable.is_a?(Hash)
29
+ items.each do |(key, val), res|
30
+ res[key] = pluckit(val, *handles)
31
+ end
32
+ elsif enumerable.is_a?(Set)
33
+ items.each do |val, res|
34
+ res.add pluckit(val, *handles)
35
+ end
36
+ else
37
+ items.each do |val, res|
38
+ res << pluckit(val, *handles)
26
39
  end
27
40
  end
41
+ end
28
42
 
43
+ def pluckit v, *handles
44
+ if handles.count > 1
45
+ handles.map {|h| pluckit_single v, h }
46
+ else
47
+ pluckit_single v, handles.first
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def pluckit_single v, handle
54
+ if v.is_a? Hash
55
+ v[handle]
56
+ elsif ([Symbol, String].include? handle.class) && v.respond_to?(handle)
57
+ v.send handle
58
+ elsif handle.is_a?(Regexp) && v.respond_to?(:grep)
59
+ v.grep handle
60
+ elsif v.respond_to?(:[])
61
+ v[handle]
62
+ else
63
+ raise ArgumentError.new "invalid handle: #{handle}, for value #{v}"
64
+ end
29
65
  end
30
66
  end
@@ -0,0 +1,3 @@
1
+ module PluckIt
2
+ VERSION = '1.2.0'
3
+ end
data/lib/pluckit.rb CHANGED
@@ -1,33 +1,21 @@
1
- require_relative 'pluckit/pluck.rb'
2
-
3
- module PluckIt
4
- VERSION = '1.0.0'
5
- end
6
-
7
-
1
+ require 'set'
2
+ require_relative 'pluckit/version'
3
+ require_relative 'pluckit/pluck'
8
4
 
9
5
  class Array
10
6
  def pluck *handles
11
- each_with_object(clone.clear) do |val, res|
12
- res << PluckIt.pluck(val, *handles)
13
- end
7
+ PluckIt.pluck self, *handles
14
8
  end
15
9
  end
16
10
 
17
-
18
11
  class Hash
19
12
  def pluck *handles
20
- each_with_object(clone.clear) do |(key, val), res|
21
- res[key] = PluckIt.pluck(val, *handles)
22
- end
13
+ PluckIt.pluck self, *handles
23
14
  end
24
15
  end
25
16
 
26
-
27
17
  class Set
28
18
  def pluck *handles
29
- each_with_object(clone.clear) do |val, res|
30
- res.add PluckIt.pluck(val, *handles)
31
- end
19
+ PluckIt.pluck self, *handles
32
20
  end
33
21
  end
data/pluckit.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ package_name = File.basename(__FILE__, '.gemspec')
2
+ require_relative File.join('lib', package_name, 'version')
3
+ package = PluckIt
4
+
5
+ Gem::Specification.new do |s|
6
+ s.description = 'Extract values from Enumerables'
7
+ s.authors = ['Daniel Pepper']
8
+ s.files = `git ls-files * ':!:spec'`.split("\n")
9
+ s.homepage = "https://github.com/dpep/rb_#{package_name}"
10
+ s.license = 'MIT'
11
+ s.name = package_name
12
+ s.summary = 'PluckIt'
13
+ s.version = package.const_get('VERSION')
14
+
15
+ s.required_ruby_version = '>= 3'
16
+
17
+ s.add_development_dependency 'debug', '>= 1'
18
+ s.add_development_dependency 'rspec', '>= 3.10'
19
+ s.add_development_dependency 'rspec-debugging'
20
+ s.add_development_dependency 'simplecov', '>= 0.22'
21
+ end
metadata CHANGED
@@ -1,60 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluckit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2018-04-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: minitest
13
+ name: debug
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '5'
18
+ version: '1'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '5'
25
+ version: '1'
27
26
  - !ruby/object:Gem::Dependency
28
- name: rake
27
+ name: rspec
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: '10'
32
+ version: '3.10'
34
33
  type: :development
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - "~>"
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: '10'
39
+ version: '3.10'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec-debugging
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: simplecov
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0.22'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0.22'
41
68
  description: Extract values from Enumerables
42
- email:
43
69
  executables: []
44
70
  extensions: []
45
71
  extra_rdoc_files: []
46
72
  files:
73
+ - CHANGELOG.md
74
+ - Gemfile
75
+ - Gemfile.lock
76
+ - LICENSE.txt
77
+ - README.md
47
78
  - lib/pluckit.rb
48
79
  - lib/pluckit/pluck.rb
49
- - test/test_array.rb
50
- - test/test_hash.rb
51
- - test/test_pluck.rb
52
- - test/test_set.rb
80
+ - lib/pluckit/version.rb
81
+ - pluckit.gemspec
53
82
  homepage: https://github.com/dpep/rb_pluckit
54
83
  licenses:
55
84
  - MIT
56
85
  metadata: {}
57
- post_install_message:
58
86
  rdoc_options: []
59
87
  require_paths:
60
88
  - lib
@@ -62,20 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
90
  requirements:
63
91
  - - ">="
64
92
  - !ruby/object:Gem::Version
65
- version: '0'
93
+ version: '3'
66
94
  required_rubygems_version: !ruby/object:Gem::Requirement
67
95
  requirements:
68
96
  - - ">="
69
97
  - !ruby/object:Gem::Version
70
98
  version: '0'
71
99
  requirements: []
72
- rubyforge_project:
73
- rubygems_version: 2.6.11
74
- signing_key:
100
+ rubygems_version: 3.6.9
75
101
  specification_version: 4
76
102
  summary: PluckIt
77
- test_files:
78
- - test/test_array.rb
79
- - test/test_hash.rb
80
- - test/test_pluck.rb
81
- - test/test_set.rb
103
+ test_files: []
data/test/test_array.rb DELETED
@@ -1,109 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'pluckit'
3
-
4
-
5
- class PluckItArrayTest < Minitest::Test
6
-
7
-
8
- def test_basic
9
- data = [
10
- [ 1, 2, 3 ],
11
- [ 4, 5, 6 ],
12
- [ 7, 8, 9 ],
13
- ]
14
-
15
- assert_equal(
16
- [ 1, 4, 7 ],
17
- data.pluck(0)
18
- )
19
-
20
- assert_equal(
21
- [ 3, 6, 9 ],
22
- data.pluck(:last)
23
- )
24
-
25
- assert_equal(
26
- [
27
- [ 1, 2 ],
28
- [ 4, 5 ],
29
- [ 7, 8 ],
30
- ],
31
- data.pluck(0, 1)
32
- )
33
- end
34
-
35
-
36
- def test_empty
37
- assert_equal(
38
- [],
39
- [].pluck(nil)
40
- )
41
-
42
- assert_equal(
43
- [],
44
- [].pluck(0)
45
- )
46
- end
47
-
48
-
49
- def test_hashes
50
- data = [
51
- { k: 1, v: 2 },
52
- { k: 2, v: 4 },
53
- { k: 3, v: 6 },
54
- ]
55
-
56
- assert_equal(
57
- [ 1, 2, 3 ],
58
- data.pluck(:k)
59
- )
60
-
61
- assert_equal(
62
- [ 2, 4, 6 ],
63
- data.pluck(:v)
64
- )
65
- end
66
-
67
-
68
- def test_missing
69
- assert_equal(
70
- [ nil, 2 ],
71
- [{ a: 1 }, { k: 2 }].pluck(:k)
72
- )
73
- end
74
-
75
-
76
- class ABC
77
- attr_accessor :val
78
- def initialize(v) self.val = v end
79
- end
80
-
81
- def test_obj
82
- assert_equal(
83
- [ 1, 2, 3 ],
84
- [
85
- ABC.new(1),
86
- ABC.new(2),
87
- ABC.new(3),
88
- ].pluck(:val)
89
- )
90
- end
91
-
92
-
93
- class MyArray < Array; end
94
- def test_clone
95
- data = MyArray.new [ 1, 2, 3 ]
96
-
97
- assert_equal(
98
- [ 1, 2, 3 ],
99
- data.pluck(:itself)
100
- )
101
-
102
- assert_equal(
103
- self.class.const_get(:MyArray),
104
- data.pluck(:itself).class
105
- )
106
- end
107
-
108
-
109
- end
data/test/test_hash.rb DELETED
@@ -1,93 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'pluckit'
3
-
4
-
5
- class PluckItHashTest < Minitest::Test
6
-
7
-
8
- def test_basic
9
- assert_equal(
10
- {
11
- a: 1,
12
- b: 4,
13
- c: 7,
14
- },
15
- {
16
- a: [ 1, 2, 3 ],
17
- b: [ 4, 5, 6 ],
18
- c: [ 7, 8, 9 ],
19
- }.pluck(0)
20
- )
21
-
22
- assert_equal(
23
- {
24
- a: 1,
25
- b: 2,
26
- c: 3,
27
- },
28
- {
29
- a: { x: 1, y: 2 },
30
- b: { x: 2, y: 4 },
31
- c: { x: 3, y: 6 },
32
- }.pluck(:x)
33
- )
34
-
35
- assert_equal(
36
- {
37
- a: [ 1, 2 ],
38
- b: [ 2, 4 ],
39
- c: [ 3, 6 ],
40
- },
41
- {
42
- a: { x: 1, y: 2 },
43
- b: { x: 2, y: 4 },
44
- c: { x: 3, y: 6 },
45
- }.pluck(:x, :y)
46
- )
47
- end
48
-
49
-
50
- class ABC
51
- attr_accessor :val
52
- def initialize(v) self.val = v end
53
- end
54
-
55
- def test_obj
56
- assert_equal(
57
- {
58
- a: 1,
59
- b: 2,
60
- c: 3,
61
- },
62
- {
63
- a: ABC.new(1),
64
- b: ABC.new(2),
65
- c: ABC.new(3),
66
- }.pluck(:val)
67
- )
68
- end
69
-
70
-
71
- class MyHash < Hash; end
72
- def test_clone
73
- data = MyHash.new 'abc'
74
- data.update a: 1
75
-
76
- assert_equal(
77
- { a: 1 },
78
- data.pluck(:itself)
79
- )
80
-
81
- assert_equal(
82
- 'abc',
83
- data.pluck(:itself)[:missing]
84
- )
85
-
86
- assert_equal(
87
- self.class.const_get(:MyHash),
88
- data.pluck(:itself).class
89
- )
90
- end
91
-
92
-
93
- end
data/test/test_pluck.rb DELETED
@@ -1,147 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'set'
3
-
4
- $LOAD_PATH.unshift 'lib'
5
- require 'pluckit/pluck'
6
-
7
-
8
- class PluckItTest < Minitest::Test
9
-
10
- def test_array
11
- data = [ 1, 2, 3 ]
12
-
13
- assert_equal(
14
- 1,
15
- PluckIt.pluck(data, 0)
16
- )
17
-
18
- assert_equal(
19
- 2,
20
- PluckIt.pluck(data, 1)
21
- )
22
-
23
- assert_equal(
24
- 3,
25
- PluckIt.pluck(data, :last)
26
- )
27
-
28
- assert_equal(
29
- 3,
30
- PluckIt.pluck(data, :count)
31
- )
32
-
33
- assert_equal(
34
- [ 1, 2 ],
35
- PluckIt.pluck(data, 0..1)
36
- )
37
-
38
- assert_equal(
39
- [ 'a', 'ba', 'ca' ],
40
- PluckIt.pluck(
41
- [ 'a', 'ba', 'bb', 'bc', 'ca' ],
42
- /a/
43
- )
44
- )
45
-
46
- assert_equal(
47
- [ 1, 2 ],
48
- PluckIt.pluck(data, 0, 1)
49
- )
50
- end
51
-
52
-
53
- def test_hash
54
- data = {
55
- a: 1,
56
- b: 2,
57
- c: 3,
58
- }
59
-
60
- assert_equal(
61
- 2,
62
- PluckIt.pluck(data, :b)
63
- )
64
-
65
- assert_nil(
66
- PluckIt.pluck(data, :z)
67
- )
68
-
69
- assert_nil(
70
- PluckIt.pluck(data, :count)
71
- )
72
-
73
- assert_equal(
74
- [ 1, 2 ],
75
- PluckIt.pluck(data, :a, :b)
76
- )
77
- end
78
-
79
-
80
- class ABC
81
- def foo() 123 end
82
- def bar() 456 end
83
- end
84
-
85
- def test_obj
86
- assert_equal(
87
- 123,
88
- PluckIt.pluck(ABC.new, :foo)
89
- )
90
-
91
- assert_equal(
92
- self.class.const_get(:ABC),
93
- PluckIt.pluck(ABC.new, :class)
94
- )
95
-
96
- assert_equal(
97
- [ 123, 456 ],
98
- PluckIt.pluck(ABC.new, :foo, :bar)
99
- )
100
- end
101
-
102
-
103
- def test_set
104
- data = Set.new [ 1, 2, 3 ]
105
-
106
- assert_equal(
107
- 1,
108
- PluckIt.pluck(data, :first)
109
- )
110
-
111
- assert_equal(
112
- 3,
113
- PluckIt.pluck(data, :count)
114
- )
115
-
116
- assert_equal(
117
- [ 1, 3 ],
118
- PluckIt.pluck(data, :first, :count)
119
- )
120
- end
121
-
122
-
123
- def test_not_installed
124
- if defined? PluckIt::VERSION
125
- # entire library was loaded, so these tests are invalid.
126
- # this happens when run through `rake`
127
- return
128
- end
129
-
130
- # `require 'pluckit/pluck'` should load PluckIt
131
- # but not monkey patch
132
- assert_raises NoMethodError do
133
- [ 1, 2, 3 ].pluck 0
134
- end
135
-
136
- assert_raises NoMethodError do
137
- { a: 1 }.pluck 0
138
- end
139
-
140
- assert_raises NoMethodError do
141
- Set.new([ 1, 2, 3 ]).pluck 0
142
- end
143
-
144
- puts 'no monkey patching'
145
- end
146
-
147
- end
data/test/test_set.rb DELETED
@@ -1,52 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'pluckit'
3
-
4
-
5
- class PluckItSetTest < Minitest::Test
6
-
7
-
8
- def test_basic
9
- data = Set.new [
10
- [ 1, 2, 3 ],
11
- [ 4, 5, 6 ],
12
- [ 7, 8, 9 ],
13
- ]
14
-
15
- assert_equal(
16
- Set.new([ 1, 4, 7 ]),
17
- data.pluck(0)
18
- )
19
-
20
- assert_equal(
21
- Set.new([ 3, 6, 9 ]),
22
- data.pluck(:last)
23
- )
24
-
25
- assert_equal(
26
- Set.new([
27
- [ 1, 3 ],
28
- [ 4, 6 ],
29
- [ 7, 9 ],
30
- ]),
31
- data.pluck(:first, :max)
32
- )
33
- end
34
-
35
-
36
- class MySet < Set; end
37
- def test_clone
38
- data = MySet.new [ 1, 2, 3 ]
39
-
40
- assert_equal(
41
- Set.new([ 1, 2, 3 ]),
42
- data.pluck(:itself)
43
- )
44
-
45
- assert_equal(
46
- self.class.const_get(:MySet),
47
- data.pluck(:itself).class
48
- )
49
- end
50
-
51
-
52
- end