set 1.0.1 → 1.1.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 +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +3 -5
- data/CHANGELOG.md +36 -1
- data/lib/set/sorted_set.rb +1 -1
- data/lib/set.rb +206 -46
- data/set.gemspec +11 -6
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cef560e603f6d6413751c31bb94fddf3838a66af8e71cff73c74760ff479ff6a
|
4
|
+
data.tar.gz: 448e22e93eebe57b26200fc1c8be476d60494193136aabb09a50c68e878e96cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91fa3052d7f25eaf6c0066013a5bd2d0c58961fe330c8923853634bac908ae83323d01b26ec8f85c4ab1ae309a83cc8e30e0918802ebb6f96fc3fcb7b7bdd433
|
7
|
+
data.tar.gz: 07b57081279057d476e1fe7c07587db1de0243cb78d36bc04b5b3ed303643b54320f08e98ed3672e610df84c42f0d503c7fae7eba040d2cf260c84319e7f9745
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @knu
|
data/.github/workflows/test.yml
CHANGED
@@ -7,18 +7,16 @@ jobs:
|
|
7
7
|
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
8
|
strategy:
|
9
9
|
matrix:
|
10
|
-
ruby: [ 2
|
10
|
+
ruby: [ 3.2, 3.1, "3.0", head ]
|
11
11
|
os: [ ubuntu-latest, macos-latest ]
|
12
12
|
runs-on: ${{ matrix.os }}
|
13
13
|
steps:
|
14
|
-
- uses: actions/checkout@
|
14
|
+
- uses: actions/checkout@v4
|
15
15
|
- name: Set up Ruby
|
16
16
|
uses: ruby/setup-ruby@v1
|
17
17
|
with:
|
18
18
|
ruby-version: ${{ matrix.ruby }}
|
19
19
|
- name: Install dependencies
|
20
|
-
run:
|
21
|
-
gem install bundler --no-document
|
22
|
-
bundle install
|
20
|
+
run: bundle install
|
23
21
|
- name: Run test
|
24
22
|
run: rake test
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Set Changelog
|
2
2
|
|
3
|
+
# 1.1.0 (2023-12-23)
|
4
|
+
|
5
|
+
* Optimize for and require Ruby >=3
|
6
|
+
|
7
|
+
# 1.0.4 (2023-12-08)
|
8
|
+
|
9
|
+
* Enhancements
|
10
|
+
* Avoid the `block or return` pattern to save Proc allocations [#29][] ([@casperisfine][])
|
11
|
+
* Set#merge takes many enumerable objects [#30][]
|
12
|
+
|
13
|
+
# 1.0.3 (2022-09-06)
|
14
|
+
|
15
|
+
* Enhancements
|
16
|
+
* Make Set a builtin feature \[[Feature #16989][]]
|
17
|
+
|
18
|
+
# 1.0.2 (2021-10-25)
|
19
|
+
|
20
|
+
* Enhancements
|
21
|
+
* Allow Set#intersect? and #disjoint? to accept array argument \[[Feature #17838][]] [#18][] ([@jeremyevans][])
|
22
|
+
* Make Set#pretty_print IRB::ColorPrinter friendly [#17][] ([@k-tsj][])
|
23
|
+
* Improve documentation [#16][], [#20][] ([@BurdetteLamar][])
|
24
|
+
* Follow the license change in Ruby and add BSD-2-Clause
|
25
|
+
|
3
26
|
# 1.0.1 (2020-12-22)
|
4
27
|
|
5
28
|
* Enhancements
|
@@ -19,6 +42,18 @@ This is the first release of set as a gem. Here lists the changes since the ver
|
|
19
42
|
[#2]: https://github.com/ruby/set/pull/2
|
20
43
|
[#4]: https://github.com/ruby/set/pull/4
|
21
44
|
[#5]: https://github.com/ruby/set/pull/5
|
22
|
-
|
45
|
+
[#16]: https://github.com/ruby/set/pull/16
|
46
|
+
[#17]: https://github.com/ruby/set/pull/17
|
47
|
+
[#18]: https://github.com/ruby/set/pull/18
|
48
|
+
[#20]: https://github.com/ruby/set/pull/20
|
49
|
+
[#29]: https://github.com/ruby/set/pull/29
|
50
|
+
[#30]: https://github.com/ruby/set/pull/30
|
51
|
+
[Feature #17838]: https://bugs.ruby-lang.org/issues/17838
|
52
|
+
[Feature #16989]: https://bugs.ruby-lang.org/issues/16989
|
53
|
+
|
54
|
+
[@BurdetteLamar]: https://github.com/BurdetteLamar
|
55
|
+
[@casperisfine]: https://github.com/casperisfine
|
56
|
+
[@jeremyevans]: https://github.com/jeremyevans
|
57
|
+
[@k-tsj]: https://github.com/k-tsj
|
23
58
|
[@knu]: https://github.com/knu
|
24
59
|
[@marcandre]: https://github.com/marcandre
|
data/lib/set/sorted_set.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
begin
|
2
2
|
require 'sorted_set'
|
3
3
|
rescue ::LoadError
|
4
|
-
raise "The `SortedSet` class has been extracted from the `set` library." \
|
4
|
+
raise "The `SortedSet` class has been extracted from the `set` library. " \
|
5
5
|
"You must use the `sorted_set` gem or other alternatives."
|
6
6
|
end
|
data/lib/set.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# set.rb - defines the Set class
|
5
5
|
#
|
6
|
-
# Copyright (c) 2002-
|
6
|
+
# Copyright (c) 2002-2023 Akinori MUSHA <knu@iDaemons.org>
|
7
7
|
#
|
8
8
|
# Documentation by Akinori MUSHA and Gavin Sinclair.
|
9
9
|
#
|
@@ -12,16 +12,12 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
##
|
15
|
-
# This library provides the Set class, which
|
16
|
-
# of unordered values with no duplicates.
|
15
|
+
# This library provides the Set class, which implements a collection
|
16
|
+
# of unordered values with no duplicates. It is a hybrid of Array's
|
17
17
|
# intuitive inter-operation facilities and Hash's fast lookup.
|
18
18
|
#
|
19
19
|
# The method `to_set` is added to Enumerable for convenience.
|
20
20
|
#
|
21
|
-
# Set implements a collection of unordered values with no duplicates.
|
22
|
-
# This is a hybrid of Array's intuitive inter-operation facilities and
|
23
|
-
# Hash's fast lookup.
|
24
|
-
#
|
25
21
|
# Set is easy to use with Enumerable objects (implementing `each`).
|
26
22
|
# Most of the initializer methods and binary operators accept generic
|
27
23
|
# Enumerable objects besides sets and arrays. An Enumerable object
|
@@ -62,7 +58,166 @@
|
|
62
58
|
#
|
63
59
|
# - Akinori MUSHA <<knu@iDaemons.org>> (current maintainer)
|
64
60
|
#
|
61
|
+
# ## What's Here
|
62
|
+
#
|
63
|
+
# First, what's elsewhere. \Class \Set:
|
64
|
+
#
|
65
|
+
# - Inherits from {class Object}[https://docs.ruby-lang.org/en/master/Object.html#class-Object-label-What-27s+Here].
|
66
|
+
# - Includes {module Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-What-27s+Here],
|
67
|
+
# which provides dozens of additional methods.
|
68
|
+
#
|
69
|
+
# In particular, class \Set does not have many methods of its own
|
70
|
+
# for fetching or for iterating.
|
71
|
+
# Instead, it relies on those in \Enumerable.
|
72
|
+
#
|
73
|
+
# Here, class \Set provides methods that are useful for:
|
74
|
+
#
|
75
|
+
# - [Creating a Set](#class-Set-label-Methods+for+Creating+a+Set)
|
76
|
+
# - [Set Operations](#class-Set-label-Methods+for+Set+Operations)
|
77
|
+
# - [Comparing](#class-Set-label-Methods+for+Comparing)
|
78
|
+
# - [Querying](#class-Set-label-Methods+for+Querying)
|
79
|
+
# - [Assigning](#class-Set-label-Methods+for+Assigning)
|
80
|
+
# - [Deleting](#class-Set-label-Methods+for+Deleting)
|
81
|
+
# - [Converting](#class-Set-label-Methods+for+Converting)
|
82
|
+
# - [Iterating](#class-Set-label-Methods+for+Iterating)
|
83
|
+
# - [And more....](#class-Set-label-Other+Methods)
|
84
|
+
#
|
85
|
+
# ### Methods for Creating a \Set
|
86
|
+
#
|
87
|
+
# - ::[]:
|
88
|
+
# Returns a new set containing the given objects.
|
89
|
+
# - ::new:
|
90
|
+
# Returns a new set containing either the given objects
|
91
|
+
# (if no block given) or the return values from the called block
|
92
|
+
# (if a block given).
|
93
|
+
#
|
94
|
+
# ### Methods for \Set Operations
|
95
|
+
#
|
96
|
+
# - [|](#method-i-7C) (aliased as #union and #+):
|
97
|
+
# Returns a new set containing all elements from +self+
|
98
|
+
# and all elements from a given enumerable (no duplicates).
|
99
|
+
# - [&](#method-i-26) (aliased as #intersection):
|
100
|
+
# Returns a new set containing all elements common to +self+
|
101
|
+
# and a given enumerable.
|
102
|
+
# - [-](#method-i-2D) (aliased as #difference):
|
103
|
+
# Returns a copy of +self+ with all elements
|
104
|
+
# in a given enumerable removed.
|
105
|
+
# - [\^](#method-i-5E):
|
106
|
+
# Returns a new set containing all elements from +self+
|
107
|
+
# and a given enumerable except those common to both.
|
108
|
+
#
|
109
|
+
# ### Methods for Comparing
|
110
|
+
#
|
111
|
+
# - [<=>](#method-i-3C-3D-3E):
|
112
|
+
# Returns -1, 0, or 1 as +self+ is less than, equal to,
|
113
|
+
# or greater than a given object.
|
114
|
+
# - [==](#method-i-3D-3D):
|
115
|
+
# Returns whether +self+ and a given enumerable are equal,
|
116
|
+
# as determined by Object#eql?.
|
117
|
+
# - \#compare_by_identity?:
|
118
|
+
# Returns whether the set considers only identity
|
119
|
+
# when comparing elements.
|
120
|
+
#
|
121
|
+
# ### Methods for Querying
|
122
|
+
#
|
123
|
+
# - \#length (aliased as #size):
|
124
|
+
# Returns the count of elements.
|
125
|
+
# - \#empty?:
|
126
|
+
# Returns whether the set has no elements.
|
127
|
+
# - \#include? (aliased as #member? and #===):
|
128
|
+
# Returns whether a given object is an element in the set.
|
129
|
+
# - \#subset? (aliased as [<=](#method-i-3C-3D)):
|
130
|
+
# Returns whether a given object is a subset of the set.
|
131
|
+
# - \#proper_subset? (aliased as [<](#method-i-3C)):
|
132
|
+
# Returns whether a given enumerable is a proper subset of the set.
|
133
|
+
# - \#superset? (aliased as [>=](#method-i-3E-3D])):
|
134
|
+
# Returns whether a given enumerable is a superset of the set.
|
135
|
+
# - \#proper_superset? (aliased as [>](#method-i-3E)):
|
136
|
+
# Returns whether a given enumerable is a proper superset of the set.
|
137
|
+
# - \#disjoint?:
|
138
|
+
# Returns +true+ if the set and a given enumerable
|
139
|
+
# have no common elements, +false+ otherwise.
|
140
|
+
# - \#intersect?:
|
141
|
+
# Returns +true+ if the set and a given enumerable:
|
142
|
+
# have any common elements, +false+ otherwise.
|
143
|
+
# - \#compare_by_identity?:
|
144
|
+
# Returns whether the set considers only identity
|
145
|
+
# when comparing elements.
|
146
|
+
#
|
147
|
+
# ### Methods for Assigning
|
148
|
+
#
|
149
|
+
# - \#add (aliased as #<<):
|
150
|
+
# Adds a given object to the set; returns +self+.
|
151
|
+
# - \#add?:
|
152
|
+
# If the given object is not an element in the set,
|
153
|
+
# adds it and returns +self+; otherwise, returns +nil+.
|
154
|
+
# - \#merge:
|
155
|
+
# Merges the elements of each given enumerable object to the set; returns +self+.
|
156
|
+
# - \#replace:
|
157
|
+
# Replaces the contents of the set with the contents
|
158
|
+
# of a given enumerable.
|
159
|
+
#
|
160
|
+
# ### Methods for Deleting
|
161
|
+
#
|
162
|
+
# - \#clear:
|
163
|
+
# Removes all elements in the set; returns +self+.
|
164
|
+
# - \#delete:
|
165
|
+
# Removes a given object from the set; returns +self+.
|
166
|
+
# - \#delete?:
|
167
|
+
# If the given object is an element in the set,
|
168
|
+
# removes it and returns +self+; otherwise, returns +nil+.
|
169
|
+
# - \#subtract:
|
170
|
+
# Removes each given object from the set; returns +self+.
|
171
|
+
# - \#delete_if - Removes elements specified by a given block.
|
172
|
+
# - \#select! (aliased as #filter!):
|
173
|
+
# Removes elements not specified by a given block.
|
174
|
+
# - \#keep_if:
|
175
|
+
# Removes elements not specified by a given block.
|
176
|
+
# - \#reject!
|
177
|
+
# Removes elements specified by a given block.
|
178
|
+
#
|
179
|
+
# ### Methods for Converting
|
180
|
+
#
|
181
|
+
# - \#classify:
|
182
|
+
# Returns a hash that classifies the elements,
|
183
|
+
# as determined by the given block.
|
184
|
+
# - \#collect! (aliased as #map!):
|
185
|
+
# Replaces each element with a block return-value.
|
186
|
+
# - \#divide:
|
187
|
+
# Returns a hash that classifies the elements,
|
188
|
+
# as determined by the given block;
|
189
|
+
# differs from #classify in that the block may accept
|
190
|
+
# either one or two arguments.
|
191
|
+
# - \#flatten:
|
192
|
+
# Returns a new set that is a recursive flattening of +self+.
|
193
|
+
# \#flatten!:
|
194
|
+
# Replaces each nested set in +self+ with the elements from that set.
|
195
|
+
# - \#inspect (aliased as #to_s):
|
196
|
+
# Returns a string displaying the elements.
|
197
|
+
# - \#join:
|
198
|
+
# Returns a string containing all elements, converted to strings
|
199
|
+
# as needed, and joined by the given record separator.
|
200
|
+
# - \#to_a:
|
201
|
+
# Returns an array containing all set elements.
|
202
|
+
# - \#to_set:
|
203
|
+
# Returns +self+ if given no arguments and no block;
|
204
|
+
# with a block given, returns a new set consisting of block
|
205
|
+
# return values.
|
206
|
+
#
|
207
|
+
# ### Methods for Iterating
|
208
|
+
#
|
209
|
+
# - \#each:
|
210
|
+
# Calls the block with each successive element; returns +self+.
|
211
|
+
#
|
212
|
+
# ### Other Methods
|
213
|
+
#
|
214
|
+
# - \#reset:
|
215
|
+
# Resets the internal state; useful if an object
|
216
|
+
# has been modified while an element in the set.
|
217
|
+
#
|
65
218
|
class Set
|
219
|
+
VERSION = "1.1.0"
|
220
|
+
|
66
221
|
include Enumerable
|
67
222
|
|
68
223
|
# Creates a new set containing the given objects.
|
@@ -131,18 +286,10 @@ class Set
|
|
131
286
|
@hash = orig.instance_variable_get(:@hash).dup
|
132
287
|
end
|
133
288
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
@hash = orig.instance_variable_get(:@hash).clone(**options)
|
139
|
-
end
|
140
|
-
else
|
141
|
-
# Clone internal hash.
|
142
|
-
def initialize_clone(orig)
|
143
|
-
super
|
144
|
-
@hash = orig.instance_variable_get(:@hash).clone
|
145
|
-
end
|
289
|
+
# Clone internal hash.
|
290
|
+
def initialize_clone(orig, **options)
|
291
|
+
super
|
292
|
+
@hash = orig.instance_variable_get(:@hash).clone(**options)
|
146
293
|
end
|
147
294
|
|
148
295
|
def freeze # :nodoc:
|
@@ -234,7 +381,7 @@ class Set
|
|
234
381
|
# Equivalent to Set#flatten, but replaces the receiver with the
|
235
382
|
# result in place. Returns nil if no modifications were made.
|
236
383
|
def flatten!
|
237
|
-
replace(flatten()) if any?
|
384
|
+
replace(flatten()) if any?(Set)
|
238
385
|
end
|
239
386
|
|
240
387
|
# Returns true if the set contains the given object.
|
@@ -254,7 +401,7 @@ class Set
|
|
254
401
|
when set.instance_of?(self.class) && @hash.respond_to?(:>=)
|
255
402
|
@hash >= set.instance_variable_get(:@hash)
|
256
403
|
when set.is_a?(Set)
|
257
|
-
size >= set.size && set.all?
|
404
|
+
size >= set.size && set.all?(self)
|
258
405
|
else
|
259
406
|
raise ArgumentError, "value must be a set"
|
260
407
|
end
|
@@ -267,7 +414,7 @@ class Set
|
|
267
414
|
when set.instance_of?(self.class) && @hash.respond_to?(:>)
|
268
415
|
@hash > set.instance_variable_get(:@hash)
|
269
416
|
when set.is_a?(Set)
|
270
|
-
size > set.size && set.all?
|
417
|
+
size > set.size && set.all?(self)
|
271
418
|
else
|
272
419
|
raise ArgumentError, "value must be a set"
|
273
420
|
end
|
@@ -280,7 +427,7 @@ class Set
|
|
280
427
|
when set.instance_of?(self.class) && @hash.respond_to?(:<=)
|
281
428
|
@hash <= set.instance_variable_get(:@hash)
|
282
429
|
when set.is_a?(Set)
|
283
|
-
size <= set.size && all?
|
430
|
+
size <= set.size && all?(set)
|
284
431
|
else
|
285
432
|
raise ArgumentError, "value must be a set"
|
286
433
|
end
|
@@ -293,7 +440,7 @@ class Set
|
|
293
440
|
when set.instance_of?(self.class) && @hash.respond_to?(:<)
|
294
441
|
@hash < set.instance_variable_get(:@hash)
|
295
442
|
when set.is_a?(Set)
|
296
|
-
size < set.size && all?
|
443
|
+
size < set.size && all?(set)
|
297
444
|
else
|
298
445
|
raise ArgumentError, "value must be a set"
|
299
446
|
end
|
@@ -313,25 +460,35 @@ class Set
|
|
313
460
|
end
|
314
461
|
end
|
315
462
|
|
316
|
-
# Returns true if the set and the given
|
463
|
+
# Returns true if the set and the given enumerable have at least one
|
317
464
|
# element in common.
|
318
465
|
#
|
319
466
|
# Set[1, 2, 3].intersect? Set[4, 5] #=> false
|
320
467
|
# Set[1, 2, 3].intersect? Set[3, 4] #=> true
|
468
|
+
# Set[1, 2, 3].intersect? 4..5 #=> false
|
469
|
+
# Set[1, 2, 3].intersect? [3, 4] #=> true
|
321
470
|
def intersect?(set)
|
322
|
-
|
323
|
-
|
324
|
-
|
471
|
+
case set
|
472
|
+
when Set
|
473
|
+
if size < set.size
|
474
|
+
any?(set)
|
475
|
+
else
|
476
|
+
set.any?(self)
|
477
|
+
end
|
478
|
+
when Enumerable
|
479
|
+
set.any?(self)
|
325
480
|
else
|
326
|
-
|
481
|
+
raise ArgumentError, "value must be enumerable"
|
327
482
|
end
|
328
483
|
end
|
329
484
|
|
330
|
-
# Returns true if the set and the given
|
331
|
-
# common. This method is the opposite of `intersect?`.
|
485
|
+
# Returns true if the set and the given enumerable have
|
486
|
+
# no element in common. This method is the opposite of `intersect?`.
|
332
487
|
#
|
333
488
|
# Set[1, 2, 3].disjoint? Set[3, 4] #=> false
|
334
489
|
# Set[1, 2, 3].disjoint? Set[4, 5] #=> true
|
490
|
+
# Set[1, 2, 3].disjoint? [3, 4] #=> false
|
491
|
+
# Set[1, 2, 3].disjoint? 4..5 #=> true
|
335
492
|
def disjoint?(set)
|
336
493
|
!intersect?(set)
|
337
494
|
end
|
@@ -340,7 +497,7 @@ class Set
|
|
340
497
|
# the element as parameter. Returns an enumerator if no block is
|
341
498
|
# given.
|
342
499
|
def each(&block)
|
343
|
-
|
500
|
+
block_given? or return enum_for(__method__) { size }
|
344
501
|
@hash.each_key(&block)
|
345
502
|
self
|
346
503
|
end
|
@@ -415,7 +572,7 @@ class Set
|
|
415
572
|
# Equivalent to Set#delete_if, but returns nil if no changes were
|
416
573
|
# made. Returns an enumerator if no block is given.
|
417
574
|
def reject!(&block)
|
418
|
-
|
575
|
+
block_given? or return enum_for(__method__) { size }
|
419
576
|
n = size
|
420
577
|
delete_if(&block)
|
421
578
|
self if size != n
|
@@ -424,7 +581,7 @@ class Set
|
|
424
581
|
# Equivalent to Set#keep_if, but returns nil if no changes were
|
425
582
|
# made. Returns an enumerator if no block is given.
|
426
583
|
def select!(&block)
|
427
|
-
|
584
|
+
block_given? or return enum_for(__method__) { size }
|
428
585
|
n = size
|
429
586
|
keep_if(&block)
|
430
587
|
self if size != n
|
@@ -433,13 +590,15 @@ class Set
|
|
433
590
|
# Equivalent to Set#select!
|
434
591
|
alias filter! select!
|
435
592
|
|
436
|
-
# Merges the elements of the given enumerable
|
593
|
+
# Merges the elements of the given enumerable objects to the set and
|
437
594
|
# returns self.
|
438
|
-
def merge(
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
595
|
+
def merge(*enums, **nil)
|
596
|
+
enums.each do |enum|
|
597
|
+
if enum.instance_of?(self.class)
|
598
|
+
@hash.update(enum.instance_variable_get(:@hash))
|
599
|
+
else
|
600
|
+
do_with_enum(enum) { |o| add(o) }
|
601
|
+
end
|
443
602
|
end
|
444
603
|
|
445
604
|
self
|
@@ -667,13 +826,14 @@ class Set
|
|
667
826
|
alias to_s inspect
|
668
827
|
|
669
828
|
def pretty_print(pp) # :nodoc:
|
670
|
-
pp.
|
671
|
-
|
672
|
-
pp.
|
673
|
-
pp.
|
829
|
+
pp.group(1, sprintf('#<%s:', self.class.name), '>') {
|
830
|
+
pp.breakable
|
831
|
+
pp.group(1, '{', '}') {
|
832
|
+
pp.seplist(self) { |o|
|
833
|
+
pp.pp o
|
834
|
+
}
|
674
835
|
}
|
675
836
|
}
|
676
|
-
pp.text "}>"
|
677
837
|
end
|
678
838
|
|
679
839
|
def pretty_print_cycle(pp) # :nodoc:
|
@@ -686,7 +846,7 @@ module Enumerable
|
|
686
846
|
# Needs to `require "set"` to use this method.
|
687
847
|
def to_set(klass = Set, *args, &block)
|
688
848
|
klass.new(self, *args, &block)
|
689
|
-
end
|
849
|
+
end unless method_defined?(:to_set)
|
690
850
|
end
|
691
851
|
|
692
852
|
autoload :SortedSet, "#{__dir__}/set/sorted_set"
|
data/set.gemspec
CHANGED
@@ -1,14 +1,21 @@
|
|
1
|
+
name = File.basename(__FILE__, ".gemspec")
|
2
|
+
version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
|
3
|
+
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
|
4
|
+
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
|
5
|
+
end rescue nil
|
6
|
+
end
|
7
|
+
|
1
8
|
Gem::Specification.new do |spec|
|
2
|
-
spec.name =
|
3
|
-
spec.version =
|
9
|
+
spec.name = name
|
10
|
+
spec.version = version
|
4
11
|
spec.authors = ["Akinori MUSHA"]
|
5
12
|
spec.email = ["knu@idaemons.org"]
|
6
13
|
|
7
14
|
spec.summary = %q{Provides a class to deal with collections of unordered, unique values}
|
8
15
|
spec.description = %q{Provides a class to deal with collections of unordered, unique values}
|
9
16
|
spec.homepage = "https://github.com/ruby/set"
|
10
|
-
spec.
|
11
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
17
|
+
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
12
19
|
|
13
20
|
spec.metadata["homepage_uri"] = spec.homepage
|
14
21
|
spec.metadata["source_code_uri"] = spec.homepage
|
@@ -19,7 +26,5 @@ Gem::Specification.new do |spec|
|
|
19
26
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
27
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
28
|
end
|
22
|
-
spec.bindir = "exe"
|
23
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
29
|
spec.require_paths = ["lib"]
|
25
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akinori MUSHA
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Provides a class to deal with collections of unordered, unique values
|
14
14
|
email:
|
@@ -17,6 +17,8 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/CODEOWNERS"
|
21
|
+
- ".github/dependabot.yml"
|
20
22
|
- ".github/workflows/test.yml"
|
21
23
|
- ".gitignore"
|
22
24
|
- CHANGELOG.md
|
@@ -31,12 +33,13 @@ files:
|
|
31
33
|
- set.gemspec
|
32
34
|
homepage: https://github.com/ruby/set
|
33
35
|
licenses:
|
36
|
+
- Ruby
|
34
37
|
- BSD-2-Clause
|
35
38
|
metadata:
|
36
39
|
homepage_uri: https://github.com/ruby/set
|
37
40
|
source_code_uri: https://github.com/ruby/set
|
38
|
-
changelog_uri: https://github.com/ruby/set/blob/v1.0
|
39
|
-
post_install_message:
|
41
|
+
changelog_uri: https://github.com/ruby/set/blob/v1.1.0/CHANGELOG.md
|
42
|
+
post_install_message:
|
40
43
|
rdoc_options: []
|
41
44
|
require_paths:
|
42
45
|
- lib
|
@@ -44,15 +47,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
47
|
requirements:
|
45
48
|
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
50
|
+
version: 3.0.0
|
48
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
52
|
requirements:
|
50
53
|
- - ">="
|
51
54
|
- !ruby/object:Gem::Version
|
52
55
|
version: '0'
|
53
56
|
requirements: []
|
54
|
-
rubygems_version: 3.
|
55
|
-
signing_key:
|
57
|
+
rubygems_version: 3.4.10
|
58
|
+
signing_key:
|
56
59
|
specification_version: 4
|
57
60
|
summary: Provides a class to deal with collections of unordered, unique values
|
58
61
|
test_files: []
|