set 1.1.0 → 1.1.2
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/push_gem.yml +46 -0
- data/.github/workflows/test.yml +8 -1
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/lib/set.rb +27 -16
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5e3ad73d3afccce9f6c298b42b634d06e4b8743c1ddeaaa40adf134a886e8f8
|
4
|
+
data.tar.gz: 60b95b5c217212cb5bcdee19b234169e02ed64c6037e0eb3f838352154df655a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b81c84e4fc585ed98f1508e3b15bd2140cdc097594a309932a9745576e6d4b7e057d94fb65eb96e5602402d2310fd3b8237ece68b6e08d2102150980d03a1546
|
7
|
+
data.tar.gz: 4d0a690e305abf7a6a49615586123214473066ae539385d8db542149af7058365ecdc1d189b463d7af2eda39b98ac73f5c031886e0af9a03d441118c2554edac
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Publish gem to rubygems.org
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- 'v*'
|
7
|
+
|
8
|
+
permissions:
|
9
|
+
contents: read
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
push:
|
13
|
+
if: github.repository == 'ruby/set'
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
|
16
|
+
environment:
|
17
|
+
name: rubygems.org
|
18
|
+
url: https://rubygems.org/gems/set
|
19
|
+
|
20
|
+
permissions:
|
21
|
+
contents: write
|
22
|
+
id-token: write
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- name: Harden Runner
|
26
|
+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
|
27
|
+
with:
|
28
|
+
egress-policy: audit
|
29
|
+
|
30
|
+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
31
|
+
|
32
|
+
- name: Set up Ruby
|
33
|
+
uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0
|
34
|
+
with:
|
35
|
+
bundler-cache: true
|
36
|
+
ruby-version: ruby
|
37
|
+
|
38
|
+
- name: Publish to RubyGems
|
39
|
+
uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
|
40
|
+
|
41
|
+
- name: Create GitHub release
|
42
|
+
run: |
|
43
|
+
tag_name="$(git describe --tags --abbrev=0)"
|
44
|
+
gh release create "${tag_name}" --verify-tag --generate-notes
|
45
|
+
env:
|
46
|
+
GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}
|
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
@@ -1,9 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if RUBY_VERSION >= '3.5'
|
4
|
+
if defined?(Set) && defined?(Set.[]) && Set.method(:[]).source_location.nil?
|
5
|
+
# Remove defined? ... conditional after Ruby 3.5.0-preview2
|
6
|
+
return
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
2
10
|
# :markup: markdown
|
3
11
|
#
|
4
12
|
# set.rb - defines the Set class
|
5
13
|
#
|
6
|
-
# Copyright (c) 2002-
|
14
|
+
# Copyright (c) 2002-2024 Akinori MUSHA <knu@iDaemons.org>
|
7
15
|
#
|
8
16
|
# Documentation by Akinori MUSHA and Gavin Sinclair.
|
9
17
|
#
|
@@ -216,7 +224,7 @@
|
|
216
224
|
# has been modified while an element in the set.
|
217
225
|
#
|
218
226
|
class Set
|
219
|
-
VERSION = "1.1.
|
227
|
+
VERSION = "1.1.2"
|
220
228
|
|
221
229
|
include Enumerable
|
222
230
|
|
@@ -335,7 +343,7 @@ class Set
|
|
335
343
|
end
|
336
344
|
end
|
337
345
|
|
338
|
-
#
|
346
|
+
# Returns an array containing all elements in the set.
|
339
347
|
#
|
340
348
|
# Set[1, 2].to_a #=> [1, 2]
|
341
349
|
# Set[1, 'c', :s].to_a #=> [1, "c", :s]
|
@@ -353,16 +361,19 @@ class Set
|
|
353
361
|
klass.new(self, *args, &block)
|
354
362
|
end
|
355
363
|
|
356
|
-
def flatten_merge(set, seen =
|
364
|
+
def flatten_merge(set, seen = {}) # :nodoc:
|
357
365
|
set.each { |e|
|
358
366
|
if e.is_a?(Set)
|
359
|
-
|
367
|
+
case seen[e_id = e.object_id]
|
368
|
+
when true
|
360
369
|
raise ArgumentError, "tried to flatten recursive Set"
|
370
|
+
when false
|
371
|
+
next
|
361
372
|
end
|
362
373
|
|
363
|
-
seen
|
374
|
+
seen[e_id] = true
|
364
375
|
flatten_merge(e, seen)
|
365
|
-
seen
|
376
|
+
seen[e_id] = false
|
366
377
|
else
|
367
378
|
add(e)
|
368
379
|
end
|
@@ -540,22 +551,22 @@ class Set
|
|
540
551
|
# Deletes every element of the set for which block evaluates to
|
541
552
|
# true, and returns self. Returns an enumerator if no block is
|
542
553
|
# given.
|
543
|
-
def delete_if
|
554
|
+
def delete_if(&block)
|
544
555
|
block_given? or return enum_for(__method__) { size }
|
545
|
-
# @hash.delete_if
|
546
|
-
#
|
547
|
-
select
|
556
|
+
# Instead of directly using @hash.delete_if, perform enumeration
|
557
|
+
# using self.each that subclasses may override.
|
558
|
+
select(&block).each { |o| @hash.delete(o) }
|
548
559
|
self
|
549
560
|
end
|
550
561
|
|
551
562
|
# Deletes every element of the set for which block evaluates to
|
552
563
|
# false, and returns self. Returns an enumerator if no block is
|
553
564
|
# given.
|
554
|
-
def keep_if
|
565
|
+
def keep_if(&block)
|
555
566
|
block_given? or return enum_for(__method__) { size }
|
556
|
-
# @hash.keep_if
|
557
|
-
#
|
558
|
-
reject
|
567
|
+
# Instead of directly using @hash.keep_if, perform enumeration
|
568
|
+
# using self.each that subclasses may override.
|
569
|
+
reject(&block).each { |o| @hash.delete(o) }
|
559
570
|
self
|
560
571
|
end
|
561
572
|
|
@@ -659,7 +670,7 @@ class Set
|
|
659
670
|
# Set[1, 2] ^ Set[2, 3] #=> #<Set: {3, 1}>
|
660
671
|
# Set[1, 'b', 'c'] ^ ['b', 'd'] #=> #<Set: {"d", 1, "c"}>
|
661
672
|
def ^(enum)
|
662
|
-
n =
|
673
|
+
n = self.class.new(enum)
|
663
674
|
each { |o| n.add(o) unless n.delete?(o) }
|
664
675
|
n
|
665
676
|
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.2
|
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: 2025-05-12 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:
|
@@ -19,6 +19,7 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- ".github/CODEOWNERS"
|
21
21
|
- ".github/dependabot.yml"
|
22
|
+
- ".github/workflows/push_gem.yml"
|
22
23
|
- ".github/workflows/test.yml"
|
23
24
|
- ".gitignore"
|
24
25
|
- CHANGELOG.md
|
@@ -38,8 +39,8 @@ licenses:
|
|
38
39
|
metadata:
|
39
40
|
homepage_uri: https://github.com/ruby/set
|
40
41
|
source_code_uri: https://github.com/ruby/set
|
41
|
-
changelog_uri: https://github.com/ruby/set/blob/v1.1.
|
42
|
-
post_install_message:
|
42
|
+
changelog_uri: https://github.com/ruby/set/blob/v1.1.2/CHANGELOG.md
|
43
|
+
post_install_message:
|
43
44
|
rdoc_options: []
|
44
45
|
require_paths:
|
45
46
|
- lib
|
@@ -54,8 +55,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
55
|
- !ruby/object:Gem::Version
|
55
56
|
version: '0'
|
56
57
|
requirements: []
|
57
|
-
rubygems_version: 3.
|
58
|
-
signing_key:
|
58
|
+
rubygems_version: 3.5.11
|
59
|
+
signing_key:
|
59
60
|
specification_version: 4
|
60
61
|
summary: Provides a class to deal with collections of unordered, unique values
|
61
62
|
test_files: []
|