Skip to content

Commit a5abae1

Browse files
Merge pull request #8332 from rubygems/deivid-rodriguez/update-vendored-gems
Update vendored timeout and securerandom (cherry picked from commit 089b236)
1 parent 8f63246 commit a5abae1

File tree

8 files changed

+48
-25
lines changed

8 files changed

+48
-25
lines changed

bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
module Bundler::SecureRandom
4242

4343
# The version
44-
VERSION = "0.4.0"
44+
VERSION = "0.4.1"
4545

4646
class << self
4747
# Returns a random binary string containing +size+ bytes.
@@ -51,6 +51,12 @@ def bytes(n)
5151
return gen_random(n)
5252
end
5353

54+
# Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
55+
def alphanumeric(n = nil, chars: ALPHANUMERIC)
56+
n = 16 if n.nil?
57+
choose(chars, n)
58+
end if RUBY_VERSION < '3.3'
59+
5460
private
5561

5662
# :stopdoc:

lib/rubygems/vendor/securerandom/lib/securerandom.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
module Gem::SecureRandom
4242

4343
# The version
44-
VERSION = "0.4.0"
44+
VERSION = "0.4.1"
4545

4646
class << self
4747
# Returns a random binary string containing +size+ bytes.
@@ -51,6 +51,12 @@ def bytes(n)
5151
return gen_random(n)
5252
end
5353

54+
# Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
55+
def alphanumeric(n = nil, chars: ALPHANUMERIC)
56+
n = 16 if n.nil?
57+
choose(chars, n)
58+
end if RUBY_VERSION < '3.3'
59+
5460
private
5561

5662
# :stopdoc:

lib/rubygems/vendor/timeout/lib/timeout.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
module Gem::Timeout
2222
# The version
23-
VERSION = "0.4.2"
23+
VERSION = "0.4.3"
2424

2525
# Internal error raised to when a timeout is triggered.
2626
class ExitException < Exception
@@ -141,9 +141,10 @@ def self.ensure_timeout_thread_created
141141
# Perform an operation in a block, raising an error if it takes longer than
142142
# +sec+ seconds to complete.
143143
#
144-
# +sec+:: Number of seconds to wait for the block to terminate. Any number
145-
# may be used, including Floats to specify fractional seconds. A
144+
# +sec+:: Number of seconds to wait for the block to terminate. Any non-negative number
145+
# or nil may be used, including Floats to specify fractional seconds. A
146146
# value of 0 or +nil+ will execute the block without any timeout.
147+
# Any negative number will raise an ArgumentError.
147148
# +klass+:: Exception Class to raise if the block fails to terminate
148149
# in +sec+ seconds. Omitting will use the default, Gem::Timeout::Error
149150
# +message+:: Error message to raise with Exception Class.
@@ -165,6 +166,7 @@ def self.ensure_timeout_thread_created
165166
# a module method, so you can call it directly as Gem::Timeout.timeout().
166167
def timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+
167168
return yield(sec) if sec == nil or sec.zero?
169+
raise ArgumentError, "Timeout sec must be a non-negative number" if 0 > sec
168170

169171
message ||= "execution expired"
170172

tool/automatiek/timeout-v0.4.1.patch

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/lib/rubygems/vendor/timeout/lib/timeout.rb b/lib/rubygems/vendor/timeout/lib/timeout.rb
2+
index cc5d05ce670..455c504f470 100644
3+
--- a/lib/rubygems/vendor/timeout/lib/timeout.rb
4+
+++ b/lib/rubygems/vendor/timeout/lib/timeout.rb
5+
@@ -1,5 +1,5 @@
6+
# frozen_string_literal: true
7+
-# Gem::Timeout long-running blocks
8+
+# Timeout long-running blocks
9+
#
10+
# == Synopsis
11+
#
12+
@@ -166,7 +166,7 @@ def self.ensure_timeout_thread_created
13+
# a module method, so you can call it directly as Gem::Timeout.timeout().
14+
def timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+
15+
return yield(sec) if sec == nil or sec.zero?
16+
- raise ArgumentError, "Gem::Timeout sec must be a non-negative number" if 0 > sec
17+
+ raise ArgumentError, "Timeout sec must be a non-negative number" if 0 > sec
18+
19+
message ||= "execution expired"
20+

tool/automatiek/vendor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def require_target
8989
VendoredGem.new(name: "optparse", namespace: "OptionParser", prefix: "Gem", vendor_lib: "lib/rubygems/vendor/optparse", license_path: "COPYING", extra_dependencies: %w[uri/lib/rubygems/vendor/uri], patch_name: "optparse-v0.4.0.patch"),
9090
VendoredGem.new(name: "resolv", namespace: "Resolv", prefix: "Gem", vendor_lib: "lib/rubygems/vendor/resolv", license_path: "COPYING", extra_dependencies: %w[securerandom/lib/rubygems/vendor/securerandom timeout], patch_name: "resolv-v0.6.0.patch"),
9191
VendoredGem.new(name: "securerandom", namespace: "SecureRandom", prefix: "Gem", vendor_lib: "lib/rubygems/vendor/securerandom", license_path: "COPYING"),
92-
VendoredGem.new(name: "timeout", namespace: "Timeout", prefix: "Gem", vendor_lib: "lib/rubygems/vendor/timeout", license_path: "COPYING", patch_name: "timeout-v0.4.1.patch"),
92+
VendoredGem.new(name: "timeout", namespace: "Timeout", prefix: "Gem", vendor_lib: "lib/rubygems/vendor/timeout", license_path: "COPYING", patch_name: "timeout-v0.4.3.patch"),
9393
VendoredGem.new(name: "tsort", namespace: "TSort", prefix: "Gem", vendor_lib: "lib/rubygems/vendor/tsort", license_path: "LICENSE.txt"),
9494
VendoredGem.new(name: "uri", namespace: "URI", prefix: "Gem", vendor_lib: "lib/rubygems/vendor/uri", license_path: "COPYING"),
9595
# Bundler

tool/bundler/vendor_gems.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
gem "optparse", "0.6.0"
1111
gem "pub_grub", github: "jhawthorn/pub_grub"
1212
gem "resolv", "0.6.0"
13-
gem "securerandom", "0.4.0"
14-
gem "timeout", "0.4.2"
13+
gem "securerandom", "0.4.1"
14+
gem "timeout", "0.4.3"
1515
gem "thor", "1.3.2"
1616
gem "tsort", "0.2.0"
1717
gem "uri", "1.0.2"

tool/bundler/vendor_gems.rb.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ GEM
2323
timeout
2424
optparse (0.6.0)
2525
resolv (0.6.0)
26-
securerandom (0.4.0)
26+
securerandom (0.4.1)
2727
thor (1.3.2)
28-
timeout (0.4.2)
28+
timeout (0.4.3)
2929
tsort (0.2.0)
3030
uri (1.0.2)
3131

@@ -46,9 +46,9 @@ DEPENDENCIES
4646
optparse (= 0.6.0)
4747
pub_grub!
4848
resolv (= 0.6.0)
49-
securerandom (= 0.4.0)
49+
securerandom (= 0.4.1)
5050
thor (= 1.3.2)
51-
timeout (= 0.4.2)
51+
timeout (= 0.4.3)
5252
tsort (= 0.2.0)
5353
uri (= 1.0.2)
5454

@@ -62,9 +62,9 @@ CHECKSUMS
6262
optparse (0.6.0) sha256=25e90469c1cd44048a89dc01c1dde9d5f0bdf717851055fb18237780779b068c
6363
pub_grub (0.5.0)
6464
resolv (0.6.0) sha256=b8b73f7734d4102ef9f75bad281d8fd1c434f8588b6aba17832ddc16fe679fab
65-
securerandom (0.4.0) sha256=37a844aa4fe4dac8e47c5bc35f91531d4dc636ccee54a1ba1629087dda0a53a8
65+
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
6666
thor (1.3.2) sha256=eef0293b9e24158ccad7ab383ae83534b7ad4ed99c09f96f1a6b036550abbeda
67-
timeout (0.4.2) sha256=8aca2d5ff98eb2f7a501c03f8c3622065932cc58bc58f725cd50a09e63b4cc19
67+
timeout (0.4.3) sha256=9509f079b2b55fe4236d79633bd75e34c1c1e7e3fb4b56cb5fda61f80a0fe30e
6868
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
6969
uri (1.0.2) sha256=b303504ceb7e5905771fa7fa14b649652fa949df18b5880d69cfb12494791e27
7070

0 commit comments

Comments
 (0)