From a88d7718f427acdd040f7b978e0514f0fea0b1d8 Mon Sep 17 00:00:00 2001 From: git Date: Sun, 9 Nov 2025 06:50:26 +0000 Subject: [PATCH 01/13] Update bundled gems list as of 2025-11-09 --- NEWS.md | 2 +- gems/bundled_gems | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9bd78dd6b3a168..37bf4bcd2372c2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -218,7 +218,7 @@ The following bundled gems are added. The following bundled gems are updated. -* minitest 5.26.0 +* minitest 5.26.1 * power_assert 3.0.1 * rake 13.3.1 * test-unit 3.7.1 diff --git a/gems/bundled_gems b/gems/bundled_gems index 114e2f4e6c2de5..67385af0a6222b 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -6,7 +6,7 @@ # - revision: revision in repository-url to test # if `revision` is not given, "v"+`version` or `version` will be used. -minitest 5.26.0 https://github.com/minitest/minitest +minitest 5.26.1 https://github.com/minitest/minitest power_assert 3.0.1 https://github.com/ruby/power_assert rake 13.3.1 https://github.com/ruby/rake test-unit 3.7.1 https://github.com/test-unit/test-unit From a4dff09be79b52288a47658964d25e5aa84fc960 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 15:17:56 +0900 Subject: [PATCH 02/13] [Bug #21673] Fix resolving refined module-defined method A method defined in a module has no `defined_class`, use the ICLASS for it as the `defined_class`. --- test/ruby/test_refinement.rb | 12 ++++++++++++ vm_method.c | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 6ce434790be13b..bd61ccfe1d579a 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -2712,6 +2712,18 @@ def test INPUT end + def test_refined_module_method + m = Module.new { + x = Module.new {def qux;end} + refine(x) {def qux;end} + break x + } + extend m + meth = method(:qux) + assert_equal m, meth.owner + assert_equal :qux, meth.name + end + private def eval_using(mod, s) diff --git a/vm_method.c b/vm_method.c index 506a2919b77cd0..bf04140cb7fd19 100644 --- a/vm_method.c +++ b/vm_method.c @@ -2005,7 +2005,12 @@ resolve_refined_method(VALUE refinements, const rb_method_entry_t *me, VALUE *de tmp_me = me->def->body.refined.orig_me; if (tmp_me) { - if (defined_class_ptr) *defined_class_ptr = tmp_me->defined_class; + if (!tmp_me->defined_class) { + VM_ASSERT_TYPE(tmp_me->owner, T_MODULE); + } + else if (defined_class_ptr) { + *defined_class_ptr = tmp_me->defined_class; + } return tmp_me; } From f08030e9dccf38d9ea5c9505203fe26484dc28d8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 20:16:22 +0900 Subject: [PATCH 03/13] [ruby/optparse] [DOC] A constant for compatibility https://github.com/ruby/optparse/commit/0125cb4918 --- lib/optparse.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/optparse.rb b/lib/optparse.rb index 0a3d04b09a6813..c66c84270a1517 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -427,7 +427,8 @@ class OptionParser # The version string VERSION = "0.8.0" - Version = VERSION # for compatibility + # An alias for compatibility + Version = VERSION # :stopdoc: NoArgument = [NO_ARGUMENT = :NONE, nil].freeze From 44d19928b6b6af945b79415fcff4ffc731e99173 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 17:59:42 +0900 Subject: [PATCH 04/13] [ruby/net-protocol] Exclude unneeded files https://github.com/ruby/net-protocol/commit/8286341e8c --- lib/net/net-protocol.gemspec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/net/net-protocol.gemspec b/lib/net/net-protocol.gemspec index f9fd83f12b05f2..2d911a966cbf05 100644 --- a/lib/net/net-protocol.gemspec +++ b/lib/net/net-protocol.gemspec @@ -25,9 +25,8 @@ Gem::Specification.new do |spec| # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - end + excludes = %W[/.git* /bin /test /*file /#{File.basename(__FILE__)}] + spec.files = IO.popen(%W[git -C #{__dir__} ls-files -z --] + excludes.map {|e| ":^#{e}"}, &:read).split("\x0") spec.require_paths = ["lib"] spec.add_dependency "timeout" From 2bf82c627494e785737037bbaf9a6b98f3c6354c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 18:15:58 +0900 Subject: [PATCH 05/13] [ruby/net-protocol] [DOC] Suppress documentation for internals https://github.com/ruby/net-protocol/commit/6c5734dc1e --- lib/net/protocol.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index 197ea090890f76..1443f3e8b71966 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -57,6 +57,7 @@ def ssl_socket_connect(s, timeout) end + # :stopdoc: class ProtocolError < StandardError; end class ProtoSyntaxError < ProtocolError; end class ProtoFatalError < ProtocolError; end @@ -66,6 +67,7 @@ class ProtoAuthError < ProtocolError; end class ProtoCommandError < ProtocolError; end class ProtoRetriableError < ProtocolError; end ProtocRetryError = ProtoRetriableError + # :startdoc: ## # OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot @@ -78,6 +80,7 @@ class OpenTimeout < Timeout::Error; end # response cannot be read within the read_timeout. class ReadTimeout < Timeout::Error + # :stopdoc: def initialize(io = nil) @io = io end @@ -97,6 +100,7 @@ def message # response cannot be written within the write_timeout. Not raised on Windows. class WriteTimeout < Timeout::Error + # :stopdoc: def initialize(io = nil) @io = io end @@ -484,6 +488,7 @@ def buffer_filling(buf, src) # The writer adapter class # class WriteAdapter + # :stopdoc: def initialize(writer) @writer = writer end From 001890b851cd058b2b9980709139070af27e3612 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 18:38:47 +0900 Subject: [PATCH 06/13] [ruby/net-http] Exclude unneeded files https://github.com/ruby/net-http/commit/89e1ecb556 --- lib/net/http/net-http.gemspec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/net/http/net-http.gemspec b/lib/net/http/net-http.gemspec index 70528d58cb34af..e4d26c9b3a634c 100644 --- a/lib/net/http/net-http.gemspec +++ b/lib/net/http/net-http.gemspec @@ -30,9 +30,8 @@ Gem::Specification.new do |spec| # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.git)}) } - end + excludes = %W[/.git* /bin /test /*file /#{File.basename(__FILE__)}] + spec.files = IO.popen(%W[git -C #{__dir__} ls-files -z --] + excludes.map {|e| ":^#{e}"}, &:read).split("\x0") spec.bindir = "exe" spec.require_paths = ["lib"] From 155cdce539a95b510a80a19e3840cde6b293cd4d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 18:50:23 +0900 Subject: [PATCH 07/13] [ruby/net-http] [DOC] Suppress documentation for internals https://github.com/ruby/net-http/commit/e4d80bd609 --- lib/net/http.rb | 35 ++++++++++------- lib/net/http/exceptions.rb | 3 +- lib/net/http/generic_request.rb | 2 + lib/net/http/header.rb | 12 ++++-- lib/net/http/requests.rb | 16 +++++++- lib/net/http/response.rb | 3 +- lib/net/http/responses.rb | 67 +++++++++++++++++++++++++++++++++ 7 files changed, 117 insertions(+), 21 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 6cacc556037993..43e3349ac0e1b1 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1321,6 +1321,9 @@ def response_body_encoding=(value) # Sets the proxy password; # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server]. attr_writer :proxy_pass + + # Sets wheter the proxy uses SSL; + # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server]. attr_writer :proxy_use_ssl # Returns the IP address for the connection. @@ -1632,6 +1635,21 @@ def start # :yield: http self end + # Finishes the \HTTP session: + # + # http = Net::HTTP.new(hostname) + # http.start + # http.started? # => true + # http.finish # => nil + # http.started? # => false + # + # Raises IOError if not in a session. + def finish + raise IOError, 'HTTP session not yet started' unless started? + do_finish + end + + # :stopdoc: def do_start connect @started = true @@ -1758,20 +1776,6 @@ def on_connect end private :on_connect - # Finishes the \HTTP session: - # - # http = Net::HTTP.new(hostname) - # http.start - # http.started? # => true - # http.finish # => nil - # http.started? # => false - # - # Raises IOError if not in a session. - def finish - raise IOError, 'HTTP session not yet started' unless started? - do_finish - end - def do_finish @started = false @socket.close if @socket @@ -1915,6 +1919,7 @@ def proxy_pass alias proxyport proxy_port #:nodoc: obsolete private + # :stopdoc: def unescape(value) require 'cgi/escape' @@ -2397,6 +2402,8 @@ def send_entity(path, data, initheader, dest, type, &block) res end + # :stopdoc: + IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/ # :nodoc: def transport_request(req) diff --git a/lib/net/http/exceptions.rb b/lib/net/http/exceptions.rb index ceec8f7b0a3822..4342cfc0ef4be3 100644 --- a/lib/net/http/exceptions.rb +++ b/lib/net/http/exceptions.rb @@ -3,7 +3,7 @@ module Net # Net::HTTP exception class. # You cannot use Net::HTTPExceptions directly; instead, you must use # its subclasses. - module HTTPExceptions + module HTTPExceptions # :nodoc: def initialize(msg, res) #:nodoc: super msg @response = res @@ -12,6 +12,7 @@ def initialize(msg, res) #:nodoc: alias data response #:nodoc: obsolete end + # :stopdoc: class HTTPError < ProtocolError include HTTPExceptions end diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb index c92004e5578b38..d9a4c4fef05ad5 100644 --- a/lib/net/http/generic_request.rb +++ b/lib/net/http/generic_request.rb @@ -264,6 +264,8 @@ def update_uri(addr, port, ssl) # :nodoc: internal use only private + # :stopdoc: + class Chunker #:nodoc: def initialize(sock) @sock = sock diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index f6c36f1b5e78e7..5dcdcc7d74051c 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -179,7 +179,9 @@ # - #each_value: Passes each string field value to the block. # module Net::HTTPHeader + # The maximum length of HTTP header keys. MAX_KEY_LENGTH = 1024 + # The maximum length of HTTP header values. MAX_FIELD_LENGTH = 65536 def initialize_http_header(initheader) #:nodoc: @@ -267,6 +269,7 @@ def add_field(key, val) end end + # :stopdoc: private def set_field(key, val) case val when Enumerable @@ -294,6 +297,7 @@ def add_field(key, val) ary.push val end end + # :startdoc: # Returns the array field value for the given +key+, # or +nil+ if there is no such field; @@ -490,7 +494,7 @@ def each_capitalized alias canonical_each each_capitalized - def capitalize(name) + def capitalize(name) # :nodoc: name.to_s.split('-'.freeze).map {|s| s.capitalize }.join('-'.freeze) end private :capitalize @@ -957,12 +961,12 @@ def proxy_basic_auth(account, password) @header['proxy-authorization'] = [basic_encode(account, password)] end - def basic_encode(account, password) + def basic_encode(account, password) # :nodoc: 'Basic ' + ["#{account}:#{password}"].pack('m0') end private :basic_encode -# Returns whether the HTTP session is to be closed. + # Returns whether the HTTP session is to be closed. def connection_close? token = /(?:\A|,)\s*close\s*(?:\z|,)/i @header['connection']&.grep(token) {return true} @@ -970,7 +974,7 @@ def connection_close? false end -# Returns whether the HTTP session is to be kept alive. + # Returns whether the HTTP session is to be kept alive. def connection_keep_alive? token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i @header['connection']&.grep(token) {return true} diff --git a/lib/net/http/requests.rb b/lib/net/http/requests.rb index e58057adf1664c..939d413f91961c 100644 --- a/lib/net/http/requests.rb +++ b/lib/net/http/requests.rb @@ -29,6 +29,7 @@ # - Net::HTTP#get: sends +GET+ request, returns response object. # class Net::HTTP::Get < Net::HTTPRequest + # :stopdoc: METHOD = 'GET' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -60,6 +61,7 @@ class Net::HTTP::Get < Net::HTTPRequest # - Net::HTTP#head: sends +HEAD+ request, returns response object. # class Net::HTTP::Head < Net::HTTPRequest + # :stopdoc: METHOD = 'HEAD' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = false @@ -95,6 +97,7 @@ class Net::HTTP::Head < Net::HTTPRequest # - Net::HTTP#post: sends +POST+ request, returns response object. # class Net::HTTP::Post < Net::HTTPRequest + # :stopdoc: METHOD = 'POST' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -130,6 +133,7 @@ class Net::HTTP::Post < Net::HTTPRequest # - Net::HTTP#put: sends +PUT+ request, returns response object. # class Net::HTTP::Put < Net::HTTPRequest + # :stopdoc: METHOD = 'PUT' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -162,6 +166,7 @@ class Net::HTTP::Put < Net::HTTPRequest # - Net::HTTP#delete: sends +DELETE+ request, returns response object. # class Net::HTTP::Delete < Net::HTTPRequest + # :stopdoc: METHOD = 'DELETE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -193,6 +198,7 @@ class Net::HTTP::Delete < Net::HTTPRequest # - Net::HTTP#options: sends +OPTIONS+ request, returns response object. # class Net::HTTP::Options < Net::HTTPRequest + # :stopdoc: METHOD = 'OPTIONS' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -224,6 +230,7 @@ class Net::HTTP::Options < Net::HTTPRequest # - Net::HTTP#trace: sends +TRACE+ request, returns response object. # class Net::HTTP::Trace < Net::HTTPRequest + # :stopdoc: METHOD = 'TRACE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -258,6 +265,7 @@ class Net::HTTP::Trace < Net::HTTPRequest # - Net::HTTP#patch: sends +PATCH+ request, returns response object. # class Net::HTTP::Patch < Net::HTTPRequest + # :stopdoc: METHOD = 'PATCH' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -285,6 +293,7 @@ class Net::HTTP::Patch < Net::HTTPRequest # - Net::HTTP#propfind: sends +PROPFIND+ request, returns response object. # class Net::HTTP::Propfind < Net::HTTPRequest + # :stopdoc: METHOD = 'PROPFIND' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -308,6 +317,7 @@ class Net::HTTP::Propfind < Net::HTTPRequest # - Net::HTTP#proppatch: sends +PROPPATCH+ request, returns response object. # class Net::HTTP::Proppatch < Net::HTTPRequest + # :stopdoc: METHOD = 'PROPPATCH' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -331,6 +341,7 @@ class Net::HTTP::Proppatch < Net::HTTPRequest # - Net::HTTP#mkcol: sends +MKCOL+ request, returns response object. # class Net::HTTP::Mkcol < Net::HTTPRequest + # :stopdoc: METHOD = 'MKCOL' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -354,6 +365,7 @@ class Net::HTTP::Mkcol < Net::HTTPRequest # - Net::HTTP#copy: sends +COPY+ request, returns response object. # class Net::HTTP::Copy < Net::HTTPRequest + # :stopdoc: METHOD = 'COPY' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -377,6 +389,7 @@ class Net::HTTP::Copy < Net::HTTPRequest # - Net::HTTP#move: sends +MOVE+ request, returns response object. # class Net::HTTP::Move < Net::HTTPRequest + # :stopdoc: METHOD = 'MOVE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -400,6 +413,7 @@ class Net::HTTP::Move < Net::HTTPRequest # - Net::HTTP#lock: sends +LOCK+ request, returns response object. # class Net::HTTP::Lock < Net::HTTPRequest + # :stopdoc: METHOD = 'LOCK' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -423,8 +437,8 @@ class Net::HTTP::Lock < Net::HTTPRequest # - Net::HTTP#unlock: sends +UNLOCK+ request, returns response object. # class Net::HTTP::Unlock < Net::HTTPRequest + # :stopdoc: METHOD = 'UNLOCK' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true end - diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index 40de96386804f3..8804a99c9e5269 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -153,6 +153,7 @@ def read_new(sock) #:nodoc: internal use only end private + # :stopdoc: def read_status_line(sock) str = sock.readline @@ -259,7 +260,7 @@ def body_encoding=(value) # header. attr_accessor :ignore_eof - def inspect + def inspect # :nodoc: "#<#{self.class} #{@code} #{@message} readbody=#{@read}>" end diff --git a/lib/net/http/responses.rb b/lib/net/http/responses.rb index 5e2f8ce1aa176a..2fa01e2c0c3f33 100644 --- a/lib/net/http/responses.rb +++ b/lib/net/http/responses.rb @@ -5,6 +5,7 @@ module Net class HTTPUnknownResponse < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPError # end @@ -19,6 +20,7 @@ class HTTPUnknownResponse < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_informational_response]. # class HTTPInformation < HTTPResponse + # :stopdoc: HAS_BODY = false EXCEPTION_TYPE = HTTPError # end @@ -34,6 +36,7 @@ class HTTPInformation < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_success]. # class HTTPSuccess < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPError # end @@ -49,6 +52,7 @@ class HTTPSuccess < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection]. # class HTTPRedirection < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPRetriableError # end @@ -63,6 +67,7 @@ class HTTPRedirection < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_client_errors]. # class HTTPClientError < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPClientException # end @@ -77,6 +82,7 @@ class HTTPClientError < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors]. # class HTTPServerError < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPFatalError # end @@ -94,6 +100,7 @@ class HTTPServerError < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100]. # class HTTPContinue < HTTPInformation + # :stopdoc: HAS_BODY = false end @@ -111,6 +118,7 @@ class HTTPContinue < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101]. # class HTTPSwitchProtocol < HTTPInformation + # :stopdoc: HAS_BODY = false end @@ -127,6 +135,7 @@ class HTTPSwitchProtocol < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102]. # class HTTPProcessing < HTTPInformation + # :stopdoc: HAS_BODY = false end @@ -145,6 +154,7 @@ class HTTPProcessing < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103]. # class HTTPEarlyHints < HTTPInformation + # :stopdoc: HAS_BODY = false end @@ -162,6 +172,7 @@ class HTTPEarlyHints < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200]. # class HTTPOK < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -179,6 +190,7 @@ class HTTPOK < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201]. # class HTTPCreated < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -196,6 +208,7 @@ class HTTPCreated < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202]. # class HTTPAccepted < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -215,6 +228,7 @@ class HTTPAccepted < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203]. # class HTTPNonAuthoritativeInformation < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -232,6 +246,7 @@ class HTTPNonAuthoritativeInformation < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204]. # class HTTPNoContent < HTTPSuccess + # :stopdoc: HAS_BODY = false end @@ -250,6 +265,7 @@ class HTTPNoContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205]. # class HTTPResetContent < HTTPSuccess + # :stopdoc: HAS_BODY = false end @@ -268,6 +284,7 @@ class HTTPResetContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206]. # class HTTPPartialContent < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -285,6 +302,7 @@ class HTTPPartialContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207]. # class HTTPMultiStatus < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -304,6 +322,7 @@ class HTTPMultiStatus < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208]. # class HTTPAlreadyReported < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -321,6 +340,7 @@ class HTTPAlreadyReported < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226]. # class HTTPIMUsed < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -338,6 +358,7 @@ class HTTPIMUsed < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300]. # class HTTPMultipleChoices < HTTPRedirection + # :stopdoc: HAS_BODY = true end HTTPMultipleChoice = HTTPMultipleChoices @@ -356,6 +377,7 @@ class HTTPMultipleChoices < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301]. # class HTTPMovedPermanently < HTTPRedirection + # :stopdoc: HAS_BODY = true end @@ -373,6 +395,7 @@ class HTTPMovedPermanently < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302]. # class HTTPFound < HTTPRedirection + # :stopdoc: HAS_BODY = true end HTTPMovedTemporarily = HTTPFound @@ -390,6 +413,7 @@ class HTTPFound < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303]. # class HTTPSeeOther < HTTPRedirection + # :stopdoc: HAS_BODY = true end @@ -407,6 +431,7 @@ class HTTPSeeOther < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304]. # class HTTPNotModified < HTTPRedirection + # :stopdoc: HAS_BODY = false end @@ -423,6 +448,7 @@ class HTTPNotModified < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305]. # class HTTPUseProxy < HTTPRedirection + # :stopdoc: HAS_BODY = false end @@ -440,6 +466,7 @@ class HTTPUseProxy < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307]. # class HTTPTemporaryRedirect < HTTPRedirection + # :stopdoc: HAS_BODY = true end @@ -456,6 +483,7 @@ class HTTPTemporaryRedirect < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308]. # class HTTPPermanentRedirect < HTTPRedirection + # :stopdoc: HAS_BODY = true end @@ -472,6 +500,7 @@ class HTTPPermanentRedirect < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400]. # class HTTPBadRequest < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -488,6 +517,7 @@ class HTTPBadRequest < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401]. # class HTTPUnauthorized < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -504,6 +534,7 @@ class HTTPUnauthorized < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402]. # class HTTPPaymentRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -521,6 +552,7 @@ class HTTPPaymentRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403]. # class HTTPForbidden < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -537,6 +569,7 @@ class HTTPForbidden < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404]. # class HTTPNotFound < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -553,6 +586,7 @@ class HTTPNotFound < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405]. # class HTTPMethodNotAllowed < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -570,6 +604,7 @@ class HTTPMethodNotAllowed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406]. # class HTTPNotAcceptable < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -586,6 +621,7 @@ class HTTPNotAcceptable < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407]. # class HTTPProxyAuthenticationRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -602,6 +638,7 @@ class HTTPProxyAuthenticationRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408]. # class HTTPRequestTimeout < HTTPClientError + # :stopdoc: HAS_BODY = true end HTTPRequestTimeOut = HTTPRequestTimeout @@ -619,6 +656,7 @@ class HTTPRequestTimeout < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409]. # class HTTPConflict < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -636,6 +674,7 @@ class HTTPConflict < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410]. # class HTTPGone < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -653,6 +692,7 @@ class HTTPGone < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411]. # class HTTPLengthRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -670,6 +710,7 @@ class HTTPLengthRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412]. # class HTTPPreconditionFailed < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -686,6 +727,7 @@ class HTTPPreconditionFailed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413]. # class HTTPPayloadTooLarge < HTTPClientError + # :stopdoc: HAS_BODY = true end HTTPRequestEntityTooLarge = HTTPPayloadTooLarge @@ -703,6 +745,7 @@ class HTTPPayloadTooLarge < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414]. # class HTTPURITooLong < HTTPClientError + # :stopdoc: HAS_BODY = true end HTTPRequestURITooLong = HTTPURITooLong @@ -721,6 +764,7 @@ class HTTPURITooLong < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415]. # class HTTPUnsupportedMediaType < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -737,6 +781,7 @@ class HTTPUnsupportedMediaType < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416]. # class HTTPRangeNotSatisfiable < HTTPClientError + # :stopdoc: HAS_BODY = true end HTTPRequestedRangeNotSatisfiable = HTTPRangeNotSatisfiable @@ -754,6 +799,7 @@ class HTTPRangeNotSatisfiable < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417]. # class HTTPExpectationFailed < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -774,6 +820,7 @@ class HTTPExpectationFailed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421]. # class HTTPMisdirectedRequest < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -790,6 +837,7 @@ class HTTPMisdirectedRequest < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422]. # class HTTPUnprocessableEntity < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -805,6 +853,7 @@ class HTTPUnprocessableEntity < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423]. # class HTTPLocked < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -821,6 +870,7 @@ class HTTPLocked < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424]. # class HTTPFailedDependency < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -840,6 +890,7 @@ class HTTPFailedDependency < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426]. # class HTTPUpgradeRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -856,6 +907,7 @@ class HTTPUpgradeRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428]. # class HTTPPreconditionRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -872,6 +924,7 @@ class HTTPPreconditionRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429]. # class HTTPTooManyRequests < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -889,6 +942,7 @@ class HTTPTooManyRequests < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431]. # class HTTPRequestHeaderFieldsTooLarge < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -906,6 +960,7 @@ class HTTPRequestHeaderFieldsTooLarge < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451]. # class HTTPUnavailableForLegalReasons < HTTPClientError + # :stopdoc: HAS_BODY = true end # 444 No Response - Nginx @@ -926,6 +981,7 @@ class HTTPUnavailableForLegalReasons < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500]. # class HTTPInternalServerError < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -943,6 +999,7 @@ class HTTPInternalServerError < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501]. # class HTTPNotImplemented < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -960,6 +1017,7 @@ class HTTPNotImplemented < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502]. # class HTTPBadGateway < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -977,6 +1035,7 @@ class HTTPBadGateway < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503]. # class HTTPServiceUnavailable < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -994,6 +1053,7 @@ class HTTPServiceUnavailable < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504]. # class HTTPGatewayTimeout < HTTPServerError + # :stopdoc: HAS_BODY = true end HTTPGatewayTimeOut = HTTPGatewayTimeout @@ -1011,6 +1071,7 @@ class HTTPGatewayTimeout < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505]. # class HTTPVersionNotSupported < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -1027,6 +1088,7 @@ class HTTPVersionNotSupported < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506]. # class HTTPVariantAlsoNegotiates < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -1043,6 +1105,7 @@ class HTTPVariantAlsoNegotiates < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507]. # class HTTPInsufficientStorage < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -1059,6 +1122,7 @@ class HTTPInsufficientStorage < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508]. # class HTTPLoopDetected < HTTPServerError + # :stopdoc: HAS_BODY = true end # 509 Bandwidth Limit Exceeded - Apache bw/limited extension @@ -1076,6 +1140,7 @@ class HTTPLoopDetected < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510]. # class HTTPNotExtended < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -1092,12 +1157,14 @@ class HTTPNotExtended < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511]. # class HTTPNetworkAuthenticationRequired < HTTPServerError + # :stopdoc: HAS_BODY = true end end class Net::HTTPResponse + # :stopdoc: CODE_CLASS_TO_OBJ = { '1' => Net::HTTPInformation, '2' => Net::HTTPSuccess, From 6cac64348725b4961a70597a4aa202f9e0c3c120 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 7 Nov 2025 11:24:42 +0900 Subject: [PATCH 08/13] [ruby/win32-registry] [DOC] Convert documents from RD2 https://github.com/ruby/win32-registry/commit/8680eedd43 --- ext/win32/lib/win32/registry.rb | 251 +++++++++++++++++--------------- 1 file changed, 134 insertions(+), 117 deletions(-) diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb index 8e2c8b2e1ab135..734d6987a2518a 100644 --- a/ext/win32/lib/win32/registry.rb +++ b/ext/win32/lib/win32/registry.rb @@ -2,83 +2,74 @@ require 'fiddle/import' module Win32 - -=begin rdoc -= Win32 Registry - -win32/registry is registry accessor library for Win32 platform. -It uses importer to call Win32 Registry APIs. - -== example - Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg| - value = reg['foo'] # read a value - value = reg['foo', Win32::Registry::REG_SZ] # read a value with type - type, value = reg.read('foo') # read a value - reg['foo'] = 'bar' # write a value - reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value with type - reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value - - reg.each_value { |name, type, data| ... } # Enumerate values - reg.each_key { |key, wtime| ... } # Enumerate subkeys - - reg.delete_value(name) # Delete a value - reg.delete_key(name) # Delete a subkey - reg.delete_key(name, true) # Delete a subkey recursively - end - -= Reference - -== Win32::Registry class - ---- info - ---- num_keys - ---- max_key_length - ---- num_values - ---- max_value_name_length - ---- max_value_length - ---- descriptor_length - ---- wtime - Returns an item of key information. - -=== constants ---- HKEY_CLASSES_ROOT - ---- HKEY_CURRENT_USER - ---- HKEY_LOCAL_MACHINE - ---- HKEY_PERFORMANCE_DATA - ---- HKEY_CURRENT_CONFIG - ---- HKEY_DYN_DATA - - Win32::Registry object whose key is predefined key. -For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/predefined_keys.asp] article. - -=end rdoc - + # :stopdoc: WCHAR = Encoding::UTF_16LE WCHAR_NUL = "\0".encode(WCHAR).freeze WCHAR_CR = "\r".encode(WCHAR).freeze WCHAR_SIZE = WCHAR_NUL.bytesize LOCALE = Encoding::UTF_8 + # :startdoc: + + # win32/registry is registry accessor library for Win32 platform. + # It uses importer to call Win32 Registry APIs. + # + # == example + # Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg| + # value = reg['foo'] # read a value + # value = reg['foo', Win32::Registry::REG_SZ] # read a value with type + # type, value = reg.read('foo') # read a value + # reg['foo'] = 'bar' # write a value + # reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value with type + # reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value + # + # reg.each_value { |name, type, data| ... } # Enumerate values + # reg.each_key { |key, wtime| ... } # Enumerate subkeys + # + # reg.delete_value(name) # Delete a value + # reg.delete_key(name) # Delete a subkey + # reg.delete_key(name, true) # Delete a subkey recursively + # end + # + # == Predefined keys + # + # * +HKEY_CLASSES_ROOT+ + # * +HKEY_CURRENT_USER+ + # * +HKEY_LOCAL_MACHINE+ + # * +HKEY_PERFORMANCE_DATA+ + # * +HKEY_CURRENT_CONFIG+ + # * +HKEY_DYN_DATA+ + # + # Win32::Registry object whose key is predefined key. + # For detail, see the article[https://learn.microsoft.com/en-us/windows/win32/sysinfo/predefined-keys]. + # + # == Value types + # + # * +REG_NONE+ + # * +REG_SZ+ + # * +REG_EXPAND_SZ+ + # * +REG_BINARY+ + # * +REG_DWORD+ + # * +REG_DWORD_BIG_ENDIAN+ + # * +REG_LINK+ + # * +REG_MULTI_SZ+ + # * +REG_RESOURCE_LIST+ + # * +REG_FULL_RESOURCE_DESCRIPTOR+ + # * +REG_RESOURCE_REQUIREMENTS_LIST+ + # * +REG_QWORD+ + # + # For detail, see the article[https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types]. + # class Registry + # :stopdoc: + # # For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/registry.asp]. # # --- HKEY_* # - # Predefined key ((*handle*)). + # Predefined key *handle*. # These are Integer, not Win32::Registry. # # --- REG_* @@ -100,6 +91,7 @@ class Registry # If the key is created newly or opened existing key. # See also Registry#disposition method. module Constants + # :stopdoc: HKEY_CLASSES_ROOT = 0x80000000 HKEY_CURRENT_USER = 0x80000001 HKEY_LOCAL_MACHINE = 0x80000002 @@ -115,7 +107,6 @@ module Constants REG_EXPAND_SZ = 2 REG_BINARY = 3 REG_DWORD = 4 - REG_DWORD_LITTLE_ENDIAN = 4 REG_DWORD_BIG_ENDIAN = 5 REG_LINK = 6 REG_MULTI_SZ = 7 @@ -163,16 +154,23 @@ module Constants end include Constants include Enumerable + # :startdoc: # # Error # class Error < ::StandardError + # :stopdoc: module Kernel32 extend Fiddle::Importer dlload "kernel32.dll" end FormatMessageW = Kernel32.extern "int FormatMessageW(int, void *, int, int, void *, int, void *)", :stdcall + # :startdoc: + + # new(code) -> error object + # + # Initializes the message for Win32 API error +code+. def initialize(code) @code = code buff = WCHAR_NUL * 1024 @@ -190,6 +188,8 @@ def initialize(code) end super msg end + + # Win32 API error code. attr_reader :code end @@ -197,6 +197,7 @@ def initialize(code) # Predefined Keys # class PredefinedKey < Registry + # :stopdoc: def initialize(hkey, keyname) @hkey = Fiddle::Pointer.new(hkey) @parent = nil @@ -224,6 +225,7 @@ def class # Win32 APIs # module API + # :stopdoc: include Constants extend Fiddle::Importer dlload "advapi32.dll" @@ -367,12 +369,14 @@ def QueryInfoKey(hkey) unpackdw(secdescs), unpackqw(wtime) ] end end + # :startdoc: # - # Replace %\w+% into the environment value of what is contained between the %'s + # Replace %-enclosed substrings in +str+ into the + # environment value of what is contained between the %s. # This method is used for REG_EXPAND_SZ. # - # For detail, see expandEnvironmentStrings[https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-expandenvironmentstringsa] \Win32 \API. + # For detail, see ExpandEnvironmentStrings[https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-expandenvironmentstringsw] \Win32 \API. # def self.expand_environ(str) str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) { @@ -392,21 +396,21 @@ def self.expand_environ(str) end.freeze # - # Convert registry type value to readable string. + # Convert registry type value +type+ to readable string. # def self.type2name(type) @@type2name[type] || type.to_s end # - # Convert 64-bit FILETIME integer into Time object. + # Convert 64-bit FILETIME integer +wtime+ into Time object. # def self.wtime2time(wtime) Time.at((wtime - 116444736000000000) / 10000000) end # - # Convert Time object or Integer object into 64-bit FILETIME. + # Convert Time object or Integer object +time+ into 64-bit FILETIME. # def self.time2wtime(time) time.to_i * 10000000 + 116444736000000000 @@ -418,16 +422,19 @@ def self.time2wtime(time) private_class_method :new # - # --- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) + # call-seq: + # open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) + # open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |reg| ... } # - # --- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |reg| ... } + # Open the registry key +subkey+ under +key+. + # +key+ is Win32::Registry object of parent key. + # You can use {predefined key}[rdoc-ref:Win32::Registry@Predefined+keys] +HKEY_+*. + # +desired+ and +opt+ is access mask and key option. # - # Open the registry key subkey under key. - # key is Win32::Registry object of parent key. - # You can use predefined key HKEY_* (see Constants) - # desired and opt is access mask and key option. # For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp]. - # If block is given, the key is closed automatically. + # + # If block is given, the key +reg+ is yielded and closed + # automatically after the block exists. def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) subkey = subkey.chomp('\\') newkey = API.OpenKey(hkey.instance_variable_get(:@hkey), subkey, opt, desired) @@ -444,17 +451,19 @@ def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) end # - # --- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) - # - # --- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| ... } + # call-seq: + # create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) + # create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| ... } # - # Create or open the registry key subkey under key. - # You can use predefined key HKEY_* (see Constants) + # Create or open the registry key +subkey+ under +key+. + # You can use {predefined key}[rdoc-ref:Win32::Registry@Predefined+keys] +HKEY_+*. + # +desired+ and +opt+ is access mask and key option. # - # If subkey is already exists, key is opened and Registry#created? + # If +subkey+ is already exists, key is opened and Registry#created? # method will return false. # - # If block is given, the key is closed automatically. + # If block is given, the key +reg+ is yielded and closed + # automatically after the block exists. # def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) newkey, disp = API.CreateKey(hkey.instance_variable_get(:@hkey), subkey, opt, desired) @@ -476,7 +485,9 @@ def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVE @@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } } # - # initialize + # :nodoc: + # + # Use self.open, self.create, #open and #create. # def initialize(hkey, parent, keyname, disposition) @hkey = Fiddle::Pointer.new(hkey) @@ -501,7 +512,7 @@ def hkey end # - # Returns if key is created ((*newly*)). + # Returns +true+ if key is created *newly*. # (see Registry.create) -- basically you call create # then when you call created? on the instance returned # it will tell if it was successful or not @@ -518,7 +529,7 @@ def open? end # - # Full path of key such as 'HKEY_CURRENT_USER\SOFTWARE\foo\bar'. + # Full path of key such as 'HKEY_CURRENT_USER\SOFTWARE\foo\bar'. # def name parent = self @@ -529,6 +540,9 @@ def name name end + # + # Retruns inspected string + # def inspect "\#" end @@ -541,14 +555,14 @@ def _dump(depth) end # - # Same as Win32::Registry.open (self, subkey, desired, opt) + # Same as Win32::Registry.open(self, subkey, desired, opt) # def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk) self.class.open(self, subkey, desired, opt, &blk) end # - # Same as Win32::Registry.create (self, subkey, desired, opt) + # Same as Win32::Registry.create(self, subkey, desired, opt) # def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk) self.class.create(self, subkey, desired, opt, &blk) @@ -571,7 +585,7 @@ def close # For each value it yields key, type and data. # # key is a String which contains name of key. - # type is a type constant kind of Win32::Registry::REG_* + # type is a type constant kind of +Win32::Registry::REG_+* # data is the value of this key. # def each_value @@ -640,21 +654,23 @@ def keys end # Read a registry value named name and return array of - # [ type, data ]. - # When name is nil, the `default' value is read. - # type is value type. (see Win32::Registry::Constants module) - # data is value data, its class is: - # :REG_SZ, REG_EXPAND_SZ + # [ type, data ]. + # When name is +nil+, the `default' value is read. + # + # +type+ is {value type}[rdoc-ref:Win32::Registry@Value+types]. + # + # +data+ is value data, its class is: + # REG_SZ, REG_EXPAND_SZ:: # String - # :REG_MULTI_SZ + # REG_MULTI_SZ:: # Array of String - # :REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD + # REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD:: # Integer - # :REG_BINARY, REG_NONE + # REG_BINARY, REG_NONE:: # String (contains binary data) # - # When rtype is specified, the value type must be included by - # rtype array, or TypeError is raised. + # When _rtype_ is specified, the value type must be included by + # _rtype_ array, or +TypeError+ is raised. def read(name, *rtype) type, data = API.QueryValue(@hkey, name) unless rtype.empty? or rtype.include?(type) @@ -687,9 +703,9 @@ def read(name, *rtype) # If the value type is REG_EXPAND_SZ, returns value data whose environment # variables are replaced. # If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD, - # REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised. + # REG_DWORD_BIG_ENDIAN, nor REG_QWORD, +TypeError+ is raised. # - # The meaning of rtype is the same as for the #read method. + # The meaning of _rtype_ is the same as for the #read method. # def [](name, *rtype) type, data = read(name, *rtype) @@ -706,7 +722,7 @@ def [](name, *rtype) # Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin) # registry value named name. # - # If the values type does not match, TypeError is raised. + # If the values type does not match, +TypeError+ is raised. def read_s(name) read(name, REG_SZ)[1] end @@ -715,7 +731,7 @@ def read_s(name) # Read a REG_SZ or REG_EXPAND_SZ registry value named name. # # If the value type is REG_EXPAND_SZ, environment variables are replaced. - # Unless the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised. + # Unless the value type is REG_SZ or REG_EXPAND_SZ, +TypeError+ is raised. # def read_s_expand(name) type, data = read(name, REG_SZ, REG_EXPAND_SZ) @@ -730,7 +746,7 @@ def read_s_expand(name) # Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin) # registry value named name. # - # If the values type does not match, TypeError is raised. + # If the values type does not match, +TypeError+ is raised. # def read_i(name) read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1] @@ -740,7 +756,7 @@ def read_i(name) # Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin) # registry value named name. # - # If the values type does not match, TypeError is raised. + # If the values type does not match, +TypeError+ is raised. # def read_bin(name) read(name, REG_BINARY)[1] @@ -750,7 +766,7 @@ def read_bin(name) # Write data to a registry value named name. # When name is nil, write to the `default' value. # - # type is type value. (see Registry::Constants module) + # +type+ is {value type}[rdoc-ref:Win32::Registry@Value+types]. # Class of data must be same as which #read # method returns. # @@ -779,11 +795,12 @@ def write(name, type, data) # # If wtype is specified, the value type is it. # Otherwise, the value type is depend on class of value: - # :Integer + # + # Integer:: # REG_DWORD - # :String + # String:: # REG_SZ - # :Array + # Array:: # REG_MULTI_SZ # def []=(name, rtype, value = nil) @@ -880,19 +897,19 @@ def flush # # Returns key information as Array of: - # :num_keys + # num_keys:: # The number of subkeys. - # :max_key_length + # max_key_length:: # Maximum length of name of subkeys. - # :num_values + # num_values:: # The number of values. - # :max_value_name_length + # max_value_name_length:: # Maximum length of name of values. - # :max_value_length + # max_value_length:: # Maximum length of value of values. - # :descriptor_length + # descriptor_length:: # Length of security descriptor. - # :wtime + # wtime:: # Last write time as FILETIME(64-bit integer) # # For detail, see RegQueryInfoKey[http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp] Win32 API. From f23fab66c294ab39f822587432f1e8d1b6da2e3a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 21:21:06 +0900 Subject: [PATCH 09/13] [ruby/ipaddr] gemspec files does not need to be included in spec.files https://github.com/ruby/ipaddr/commit/ada04589fe --- lib/ipaddr.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ipaddr.gemspec b/lib/ipaddr.gemspec index 5719f83fc44c46..cabc9161ba71c0 100644 --- a/lib/ipaddr.gemspec +++ b/lib/ipaddr.gemspec @@ -29,7 +29,7 @@ Both IPv4 and IPv6 are supported. spec.homepage = "https://github.com/ruby/ipaddr" spec.licenses = ["Ruby", "BSD-2-Clause"] - spec.files = ["LICENSE.txt", "README.md", "ipaddr.gemspec", "lib/ipaddr.rb"] + spec.files = ["LICENSE.txt", "README.md", "lib/ipaddr.rb"] spec.require_paths = ["lib"] spec.required_ruby_version = ">= 2.4" From 79342334e0d1be3101568a0eb695414e5b0d3801 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 21:23:05 +0900 Subject: [PATCH 10/13] [ruby/ipaddr] [DOC] Stop documentation for internals https://github.com/ruby/ipaddr/commit/cb9f561883 --- lib/ipaddr.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb index fca75deff95ebf..513b7778a92f0b 100644 --- a/lib/ipaddr.rb +++ b/lib/ipaddr.rb @@ -40,6 +40,7 @@ # p ipaddr3 #=> # class IPAddr + # The version string VERSION = "1.2.7" # 32 bit mask for IPv4 @@ -353,7 +354,7 @@ def ipv4_compat? _ipv4_compat? end - def _ipv4_compat? + def _ipv4_compat? # :nodoc: if !ipv6? || (@addr >> 32) != 0 return false end @@ -545,6 +546,7 @@ def zone_id=(zid) end protected + # :stopdoc: def begin_addr @addr & @mask_addr @@ -560,6 +562,7 @@ def end_addr raise AddressFamilyError, "unsupported address family" end end + #:startdoc: # Set +@addr+, the internal stored ip address, to given +addr+. The # parameter +addr+ is validated using the first +family+ member, @@ -701,6 +704,7 @@ def initialize(addr = '::', family = Socket::AF_UNSPEC) end end + # :stopdoc: def coerce_other(other) case other when IPAddr @@ -812,7 +816,7 @@ class Socket < BasicSocket class << IPSocket private - def valid_v6?(addr) + def valid_v6?(addr) # :nodoc: case addr when IPAddr::RE_IPV6ADDRLIKE_FULL if $2 From 063aea8ce47162e8cf0abc48e00bdbbc5dfcbea2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 21:39:38 +0900 Subject: [PATCH 11/13] [ruby/resolv] Exclude unneeded files https://github.com/ruby/resolv/commit/60bf151a1d --- lib/resolv.gemspec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/resolv.gemspec b/lib/resolv.gemspec index bfa2f9ff31f957..66aed34e01bef7 100644 --- a/lib/resolv.gemspec +++ b/lib/resolv.gemspec @@ -21,9 +21,8 @@ Gem::Specification.new do |spec| spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = spec.homepage - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - end + excludes = %W[/.git* /bin /test /*file /#{File.basename(__FILE__)}] + spec.files = IO.popen(%W[git -C #{__dir__} ls-files -z --] + excludes.map {|e| ":^#{e}"}, &:read).split("\x0") spec.bindir = "exe" spec.executables = [] spec.require_paths = ["lib"] From d79ff407825352953293ea7c399cd3a94aef021f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 21:30:03 +0900 Subject: [PATCH 12/13] [ruby/resolv] Require win32/resolv just once And Use Win32::Resolv instead of a constant `WINDOWS`. https://github.com/ruby/resolv/commit/b2c775cd80 --- lib/resolv.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/resolv.rb b/lib/resolv.rb index fce5092d0e9cb7..b7ed1dcb7aff18 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -174,21 +174,18 @@ class ResolvError < StandardError; end class ResolvTimeout < Timeout::Error; end - WINDOWS = /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM || ::RbConfig::CONFIG['host_os'] =~ /mswin/ - private_constant :WINDOWS - ## # Resolv::Hosts is a hostname resolver that uses the system hosts file. class Hosts - if WINDOWS + if /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM || ::RbConfig::CONFIG['host_os'] =~ /mswin/ begin require 'win32/resolv' unless defined?(Win32::Resolv) - DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL + hosts = Win32::Resolv.get_hosts_path || IO::NULL rescue LoadError end end - DefaultFileName ||= '/etc/hosts' + DefaultFileName = hosts || '/etc/hosts' ## # Creates a new Resolv::Hosts, using +filename+ for its data source. @@ -1022,8 +1019,7 @@ def Config.parse_resolv_conf(filename) def Config.default_config_hash(filename="/etc/resolv.conf") if File.exist? filename Config.parse_resolv_conf(filename) - elsif WINDOWS - require 'win32/resolv' unless defined?(Win32::Resolv) + elsif defined?(Win32::Resolv) search, nameserver = Win32::Resolv.get_resolv_info config_hash = {} config_hash[:nameserver] = nameserver if nameserver From bf29ba452aa946bc6791b9d04b69003ae41c42cb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 21:32:23 +0900 Subject: [PATCH 13/13] [ruby/resolv] [DOC] Fix documentations https://github.com/ruby/resolv/commit/d8b8d36f63 --- lib/resolv.rb | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/resolv.rb b/lib/resolv.rb index b7ed1dcb7aff18..34749afb674af7 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -34,6 +34,7 @@ class Resolv + # The version string VERSION = "0.6.3" ## @@ -185,6 +186,7 @@ class Hosts rescue LoadError end end + # The default file name for host names DefaultFileName = hosts || '/etc/hosts' ## @@ -523,6 +525,8 @@ def each_resource(name, typeclass, &proc) } end + # :stopdoc: + def fetch_resource(name, typeclass) lazy_initialize truncated = {} @@ -2923,15 +2927,21 @@ class HTTPS < ServiceBinding class IPv4 - ## - # Regular expression IPv4 addresses must match. - Regex256 = /0 |1(?:[0-9][0-9]?)? |2(?:[0-4][0-9]?|5[0-5]?|[6-9])? - |[3-9][0-9]?/x + |[3-9][0-9]?/x # :nodoc: + + ## + # Regular expression IPv4 addresses must match. Regex = /\A(#{Regex256})\.(#{Regex256})\.(#{Regex256})\.(#{Regex256})\z/ + ## + # Creates a new IPv4 address from +arg+ which may be: + # + # IPv4:: returns +arg+. + # String:: +arg+ must match the IPv4::Regex constant + def self.create(arg) case arg when IPv4 @@ -3247,6 +3257,8 @@ module LOC class Size + # Regular expression LOC size must match. + Regex = /^(\d+\.*\d*)[m]$/ ## @@ -3272,6 +3284,7 @@ def self.create(arg) end end + # Internal use; use self.create. def initialize(scalar) @scalar = scalar end @@ -3309,6 +3322,8 @@ def hash # :nodoc: class Coord + # Regular expression LOC Coord must match. + Regex = /^(\d+)\s(\d+)\s(\d+\.\d+)\s([NESW])$/ ## @@ -3338,6 +3353,7 @@ def self.create(arg) end end + # Internal use; use self.create. def initialize(coordinates,orientation) unless coordinates.kind_of?(String) raise ArgumentError.new("Coord must be a 32bit unsigned integer in hex format: #{coordinates.inspect}") @@ -3400,6 +3416,8 @@ def hash # :nodoc: class Alt + # Regular expression LOC Alt must match. + Regex = /^([+-]*\d+\.*\d*)[m]$/ ## @@ -3425,6 +3443,7 @@ def self.create(arg) end end + # Internal use; use self.create. def initialize(altitude) @altitude = altitude end