set 1.1.0 → 1.1.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/.github/workflows/test.yml +8 -1
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/lib/set.rb +19 -16
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c589eb5330bd847b4d8c3dc01648971ccfba64b7c7e44bdf6fd8e982c7f8f1b2
|
4
|
+
data.tar.gz: 2c592861e01df2d0e3eab083c808694e01f9edaa649c593dcde4db29acbbc28b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d9472b2ab8509ec1772d0c935ae0fc8bfa0df5a6ffd263cefc65b39e24a430aab43863d55393b95df61d83a6dea9943f2a50d1dfa6bafc7b0b672d66f3c4a4b
|
7
|
+
data.tar.gz: 11b76695b6ac8d0a362c350c7a6575c04ff72159fa9fcb6a4277fc5a9a7437a986cc4f9dcb0c728f500c6e68e6e5e09ed016cd9dbf0ab629d6e10bcddc4b8b37
|
data/.github/workflows/test.yml
CHANGED
@@ -3,11 +3,18 @@ name: test
|
|
3
3
|
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
|
+
ruby-versions:
|
7
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
8
|
+
with:
|
9
|
+
engine: cruby
|
10
|
+
min_version: 3.0
|
11
|
+
|
6
12
|
build:
|
13
|
+
needs: ruby-versions
|
7
14
|
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
15
|
strategy:
|
9
16
|
matrix:
|
10
|
-
ruby:
|
17
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
11
18
|
os: [ ubuntu-latest, macos-latest ]
|
12
19
|
runs-on: ${{ matrix.os }}
|
13
20
|
steps:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Set Changelog
|
2
2
|
|
3
|
+
# 1.1.1 (2024-11-29)
|
4
|
+
|
5
|
+
* Enhancements
|
6
|
+
* Fix Set#^ to respect subclasses [#38][] ([@kyanagi][])
|
7
|
+
* Speed up Set#flatten [#39][] ([@kyanagi][])
|
8
|
+
|
3
9
|
# 1.1.0 (2023-12-23)
|
4
10
|
|
5
11
|
* Optimize for and require Ruby >=3
|
@@ -48,6 +54,8 @@ This is the first release of set as a gem. Here lists the changes since the ver
|
|
48
54
|
[#20]: https://github.com/ruby/set/pull/20
|
49
55
|
[#29]: https://github.com/ruby/set/pull/29
|
50
56
|
[#30]: https://github.com/ruby/set/pull/30
|
57
|
+
[#38]: https://github.com/ruby/set/pull/38
|
58
|
+
[#39]: https://github.com/ruby/set/pull/39
|
51
59
|
[Feature #17838]: https://bugs.ruby-lang.org/issues/17838
|
52
60
|
[Feature #16989]: https://bugs.ruby-lang.org/issues/16989
|
53
61
|
|
@@ -56,4 +64,5 @@ This is the first release of set as a gem. Here lists the changes since the ver
|
|
56
64
|
[@jeremyevans]: https://github.com/jeremyevans
|
57
65
|
[@k-tsj]: https://github.com/k-tsj
|
58
66
|
[@knu]: https://github.com/knu
|
67
|
+
[@kyanagi]: https://github.com/kyanagi
|
59
68
|
[@marcandre]: https://github.com/marcandre
|
data/LICENSE.txt
CHANGED
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-2024 Akinori MUSHA <knu@iDaemons.org>
|
7
7
|
#
|
8
8
|
# Documentation by Akinori MUSHA and Gavin Sinclair.
|
9
9
|
#
|
@@ -216,7 +216,7 @@
|
|
216
216
|
# has been modified while an element in the set.
|
217
217
|
#
|
218
218
|
class Set
|
219
|
-
VERSION = "1.1.
|
219
|
+
VERSION = "1.1.1"
|
220
220
|
|
221
221
|
include Enumerable
|
222
222
|
|
@@ -335,7 +335,7 @@ class Set
|
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
|
-
#
|
338
|
+
# Returns an array containing all elements in the set.
|
339
339
|
#
|
340
340
|
# Set[1, 2].to_a #=> [1, 2]
|
341
341
|
# Set[1, 'c', :s].to_a #=> [1, "c", :s]
|
@@ -353,16 +353,19 @@ class Set
|
|
353
353
|
klass.new(self, *args, &block)
|
354
354
|
end
|
355
355
|
|
356
|
-
def flatten_merge(set, seen =
|
356
|
+
def flatten_merge(set, seen = {}) # :nodoc:
|
357
357
|
set.each { |e|
|
358
358
|
if e.is_a?(Set)
|
359
|
-
|
359
|
+
case seen[e_id = e.object_id]
|
360
|
+
when true
|
360
361
|
raise ArgumentError, "tried to flatten recursive Set"
|
362
|
+
when false
|
363
|
+
next
|
361
364
|
end
|
362
365
|
|
363
|
-
seen
|
366
|
+
seen[e_id] = true
|
364
367
|
flatten_merge(e, seen)
|
365
|
-
seen
|
368
|
+
seen[e_id] = false
|
366
369
|
else
|
367
370
|
add(e)
|
368
371
|
end
|
@@ -540,22 +543,22 @@ class Set
|
|
540
543
|
# Deletes every element of the set for which block evaluates to
|
541
544
|
# true, and returns self. Returns an enumerator if no block is
|
542
545
|
# given.
|
543
|
-
def delete_if
|
546
|
+
def delete_if(&block)
|
544
547
|
block_given? or return enum_for(__method__) { size }
|
545
|
-
# @hash.delete_if
|
546
|
-
#
|
547
|
-
select
|
548
|
+
# Instead of directly using @hash.delete_if, perform enumeration
|
549
|
+
# using self.each that subclasses may override.
|
550
|
+
select(&block).each { |o| @hash.delete(o) }
|
548
551
|
self
|
549
552
|
end
|
550
553
|
|
551
554
|
# Deletes every element of the set for which block evaluates to
|
552
555
|
# false, and returns self. Returns an enumerator if no block is
|
553
556
|
# given.
|
554
|
-
def keep_if
|
557
|
+
def keep_if(&block)
|
555
558
|
block_given? or return enum_for(__method__) { size }
|
556
|
-
# @hash.keep_if
|
557
|
-
#
|
558
|
-
reject
|
559
|
+
# Instead of directly using @hash.keep_if, perform enumeration
|
560
|
+
# using self.each that subclasses may override.
|
561
|
+
reject(&block).each { |o| @hash.delete(o) }
|
559
562
|
self
|
560
563
|
end
|
561
564
|
|
@@ -659,7 +662,7 @@ class Set
|
|
659
662
|
# Set[1, 2] ^ Set[2, 3] #=> #<Set: {3, 1}>
|
660
663
|
# Set[1, 'b', 'c'] ^ ['b', 'd'] #=> #<Set: {"d", 1, "c"}>
|
661
664
|
def ^(enum)
|
662
|
-
n =
|
665
|
+
n = self.class.new(enum)
|
663
666
|
each { |o| n.add(o) unless n.delete?(o) }
|
664
667
|
n
|
665
668
|
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.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akinori MUSHA
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-29 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:
|
@@ -38,8 +38,8 @@ licenses:
|
|
38
38
|
metadata:
|
39
39
|
homepage_uri: https://github.com/ruby/set
|
40
40
|
source_code_uri: https://github.com/ruby/set
|
41
|
-
changelog_uri: https://github.com/ruby/set/blob/v1.1.
|
42
|
-
post_install_message:
|
41
|
+
changelog_uri: https://github.com/ruby/set/blob/v1.1.1/CHANGELOG.md
|
42
|
+
post_install_message:
|
43
43
|
rdoc_options: []
|
44
44
|
require_paths:
|
45
45
|
- lib
|
@@ -54,8 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
requirements: []
|
57
|
-
rubygems_version: 3.
|
58
|
-
signing_key:
|
57
|
+
rubygems_version: 3.5.23
|
58
|
+
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: Provides a class to deal with collections of unordered, unique values
|
61
61
|
test_files: []
|