set 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/workflows/test.yml +2 -2
- data/CHANGELOG.md +15 -0
- data/lib/set.rb +17 -17
- data/set.gemspec +10 -3
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0553df841f04a61495ba77ce0545d0cf8fe2317a8d4113235bc0ffed4a798f9
|
4
|
+
data.tar.gz: a0f42b54d9f2d61932e9b781a8adc33e7fa28eef1e0fe646d51e4cb8a10aac9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96305ae873bfaf18381f91252201245ef4322ada12644358f0d8d310c54722dac39d6c79b26a270322931d9d4848955542acc3912ec57c75b57bca38994806c3
|
7
|
+
data.tar.gz: 77adbb45986b8203e9e11da2e0eea741b36903a2017c4d5d1898b9700b82ec19e1bbff27883e3c485e991cdc67b3f0bde9582605c0a84ed1fc9322409ddad284
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @knu
|
data/.github/workflows/test.yml
CHANGED
@@ -7,11 +7,11 @@ 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", 2.7, 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:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Set Changelog
|
2
2
|
|
3
|
+
# 1.0.4 (2023-12-08)
|
4
|
+
|
5
|
+
* Enhancements
|
6
|
+
* Avoid the `block or return` pattern to save Proc allocations [#29][] ([@casperisfine][])
|
7
|
+
* Set#merge takes many enumerable objects [#30][]
|
8
|
+
|
9
|
+
# 1.0.3 (2022-09-06)
|
10
|
+
|
11
|
+
* Enhancements
|
12
|
+
* Make Set a builtin feature \[[Feature #16989][]]
|
13
|
+
|
3
14
|
# 1.0.2 (2021-10-25)
|
4
15
|
|
5
16
|
* Enhancements
|
@@ -31,9 +42,13 @@ This is the first release of set as a gem. Here lists the changes since the ver
|
|
31
42
|
[#17]: https://github.com/ruby/set/pull/17
|
32
43
|
[#18]: https://github.com/ruby/set/pull/18
|
33
44
|
[#20]: https://github.com/ruby/set/pull/20
|
45
|
+
[#29]: https://github.com/ruby/set/pull/29
|
46
|
+
[#30]: https://github.com/ruby/set/pull/30
|
34
47
|
[Feature #17838]: https://bugs.ruby-lang.org/issues/17838
|
48
|
+
[Feature #16989]: https://bugs.ruby-lang.org/issues/16989
|
35
49
|
|
36
50
|
[@BurdetteLamar]: https://github.com/BurdetteLamar
|
51
|
+
[@casperisfine]: https://github.com/casperisfine
|
37
52
|
[@jeremyevans]: https://github.com/jeremyevans
|
38
53
|
[@k-tsj]: https://github.com/k-tsj
|
39
54
|
[@knu]: https://github.com/knu
|
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
|
@@ -156,7 +152,7 @@
|
|
156
152
|
# If the given object is not an element in the set,
|
157
153
|
# adds it and returns +self+; otherwise, returns +nil+.
|
158
154
|
# - \#merge:
|
159
|
-
#
|
155
|
+
# Merges the elements of each given enumerable object to the set; returns +self+.
|
160
156
|
# - \#replace:
|
161
157
|
# Replaces the contents of the set with the contents
|
162
158
|
# of a given enumerable.
|
@@ -220,6 +216,8 @@
|
|
220
216
|
# has been modified while an element in the set.
|
221
217
|
#
|
222
218
|
class Set
|
219
|
+
VERSION = "1.0.4"
|
220
|
+
|
223
221
|
include Enumerable
|
224
222
|
|
225
223
|
# Creates a new set containing the given objects.
|
@@ -507,7 +505,7 @@ class Set
|
|
507
505
|
# the element as parameter. Returns an enumerator if no block is
|
508
506
|
# given.
|
509
507
|
def each(&block)
|
510
|
-
|
508
|
+
block_given? or return enum_for(__method__) { size }
|
511
509
|
@hash.each_key(&block)
|
512
510
|
self
|
513
511
|
end
|
@@ -582,7 +580,7 @@ class Set
|
|
582
580
|
# Equivalent to Set#delete_if, but returns nil if no changes were
|
583
581
|
# made. Returns an enumerator if no block is given.
|
584
582
|
def reject!(&block)
|
585
|
-
|
583
|
+
block_given? or return enum_for(__method__) { size }
|
586
584
|
n = size
|
587
585
|
delete_if(&block)
|
588
586
|
self if size != n
|
@@ -591,7 +589,7 @@ class Set
|
|
591
589
|
# Equivalent to Set#keep_if, but returns nil if no changes were
|
592
590
|
# made. Returns an enumerator if no block is given.
|
593
591
|
def select!(&block)
|
594
|
-
|
592
|
+
block_given? or return enum_for(__method__) { size }
|
595
593
|
n = size
|
596
594
|
keep_if(&block)
|
597
595
|
self if size != n
|
@@ -600,13 +598,15 @@ class Set
|
|
600
598
|
# Equivalent to Set#select!
|
601
599
|
alias filter! select!
|
602
600
|
|
603
|
-
# Merges the elements of the given enumerable
|
601
|
+
# Merges the elements of the given enumerable objects to the set and
|
604
602
|
# returns self.
|
605
|
-
def merge(
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
603
|
+
def merge(*enums, **nil)
|
604
|
+
enums.each do |enum|
|
605
|
+
if enum.instance_of?(self.class)
|
606
|
+
@hash.update(enum.instance_variable_get(:@hash))
|
607
|
+
else
|
608
|
+
do_with_enum(enum) { |o| add(o) }
|
609
|
+
end
|
610
610
|
end
|
611
611
|
|
612
612
|
self
|
data/set.gemspec
CHANGED
@@ -1,6 +1,13 @@
|
|
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
|
|
@@ -8,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
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
17
|
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
11
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
12
19
|
|
13
20
|
spec.metadata["homepage_uri"] = spec.homepage
|
14
21
|
spec.metadata["source_code_uri"] = spec.homepage
|
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.0.4
|
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: 2023-12-08 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,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/CODEOWNERS"
|
20
21
|
- ".github/dependabot.yml"
|
21
22
|
- ".github/workflows/test.yml"
|
22
23
|
- ".gitignore"
|
@@ -37,8 +38,8 @@ licenses:
|
|
37
38
|
metadata:
|
38
39
|
homepage_uri: https://github.com/ruby/set
|
39
40
|
source_code_uri: https://github.com/ruby/set
|
40
|
-
changelog_uri: https://github.com/ruby/set/blob/v1.0.
|
41
|
-
post_install_message:
|
41
|
+
changelog_uri: https://github.com/ruby/set/blob/v1.0.4/CHANGELOG.md
|
42
|
+
post_install_message:
|
42
43
|
rdoc_options: []
|
43
44
|
require_paths:
|
44
45
|
- lib
|
@@ -46,15 +47,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
47
|
requirements:
|
47
48
|
- - ">="
|
48
49
|
- !ruby/object:Gem::Version
|
49
|
-
version: 2.
|
50
|
+
version: 2.7.0
|
50
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
53
|
- - ">="
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '0'
|
55
56
|
requirements: []
|
56
|
-
rubygems_version: 3.4.
|
57
|
-
signing_key:
|
57
|
+
rubygems_version: 3.4.10
|
58
|
+
signing_key:
|
58
59
|
specification_version: 4
|
59
60
|
summary: Provides a class to deal with collections of unordered, unique values
|
60
61
|
test_files: []
|