Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2709,29 +2709,34 @@ count_objects_i(VALUE obj, void *d)

/*
* call-seq:
* ObjectSpace.count_objects([result_hash]) -> hash
* ObjectSpace.count_objects(result_hash = {}) -> hash
*
* Counts all objects grouped by type.
* Counts the number of objects, grouped by type.
*
* It returns a hash, such as:
* {
* TOTAL: 10000,
* FREE: 3011,
* T_OBJECT: 6,
* T_CLASS: 404,
* # ...
* }
* It returns a hash that looks like:
*
* The contents of the returned hash are implementation specific.
* It may be changed in future.
* {
* TOTAL: 10000,
* FREE: 3011,
* T_OBJECT: 6,
* T_CLASS: 404,
* # ...
* }
*
* The keys starting with +:T_+ means live objects.
* The contents of the returned hash are implementation specific and
* may be changed in future versions without notice.
*
* The keys starting with +:T_+ are live objects of a particular type.
* For example, +:T_ARRAY+ is the number of arrays.
* +:FREE+ means object slots which is not used now.
* +:TOTAL+ means sum of above.
*
* The key +:FREE+ is the number of object slots which are empty.
*
* The key +:TOTAL+ is the total number of slots (which is the sum of
* all of the other values).
*
* If the optional argument +result_hash+ is given,
* it is overwritten and returned. This is intended to avoid probe effect.
* it is overwritten and returned.
* This is intended to avoid the probe effect.
*
* h = {}
* ObjectSpace.count_objects(h)
Expand Down
42 changes: 36 additions & 6 deletions pathname_builtin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,12 @@ def each_line(...) # :yield: line
#
def read(...) File.read(@path, ...) end

# See <tt>File.binread</tt>. Returns all the bytes from the file, or the first +N+
# if specified.
# call-seq:
# binread(length = nil, offset = 0) -> string or nil
#
# Behaves like #read, except that the file is opened in binary mode
# with ASCII-8BIT encoding.
#
def binread(...) File.binread(@path, ...) end

# See <tt>File.readlines</tt>. Returns all the lines from the file.
Expand Down Expand Up @@ -1152,9 +1156,11 @@ def sysopen(...) File.sysopen(@path, ...) end
#
def write(...) File.write(@path, ...) end

# Writes +contents+ to the file, opening it in binary mode.
# call-seq:
# binwrite(string, offset = 0, **opts) -> nonnegative_integer
#
# See File.binwrite.
# Behaves like #write, except that the file is opened in binary mode
# with ASCII-8BIT encoding.
def binwrite(...) File.binwrite(@path, ...) end

# call-seq:
Expand Down Expand Up @@ -1342,10 +1348,34 @@ def realdirpath(...) self.class.new(File.realdirpath(@path, ...)) end

class Pathname # * FileTest *

# See <tt>FileTest.blockdev?</tt>.
# call-seq:
# blockdev? => true or false
#
# Returns whether +self+ represents a block device
# (i.e., a random-access device):
#
# Pathname.new('/dev/nvme0n1').blockdev? # => true
# Pathname.new('/dev/loop0').blockdev? # => true
# Pathname.new('/dev/tty').blockdev? # => false
# Pathname.new('/dev/null').blockdev? # => false
# Pathname.new('nosuch').blockdev? # => false
#
# The returned value is OS-dependent; on Windows, almost always +false+.
def blockdev?() FileTest.blockdev?(@path) end

# See <tt>FileTest.chardev?</tt>.
# call-seq:
# chardev? => true or false
#
# Returns whether +self+ represents a character device
# (i.e., a sequential-access device):
#
# Pathname.new('/dev/tty').chardev? # => true
# Pathname.new('/dev/null').chardev? # => true
# Pathname.new('/dev/nvme0n1').chardev? # => false
# Pathname.new('/dev/loop0').chardev? # => false
# Pathname.new('nosuch').chardev? # => false
#
# The returned value is OS-dependent; on Windows, almost always +false+.
def chardev?() FileTest.chardev?(@path) end

# Tests the file is empty.
Expand Down
2 changes: 1 addition & 1 deletion test/io/wait/test_io_wait.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_wait
omit 'unstable on MinGW' if /mingw/ =~ RUBY_PLATFORM
assert_nil @r.wait(0)
@w.syswrite "."
sleep 0.1
IO.select([@r])
assert_equal @r, @r.wait(0)
end

Expand Down
14 changes: 1 addition & 13 deletions tool/sync_default_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ def lib((upstream, branch), gemspec_in_subdir: false)
]),
"open-uri": lib("ruby/open-uri"),
English: lib("ruby/English"),
cgi: repo("ruby/cgi", [
["ext/cgi", "ext/cgi"],
["lib/cgi/escape.rb", "lib/cgi/escape.rb"],
["test/cgi/test_cgi_escape.rb", "test/cgi/test_cgi_escape.rb"],
["test/cgi/update_env.rb", "test/cgi/update_env.rb"],
]),
date: repo("ruby/date", [
["doc/date", "doc/date"],
["ext/date", "ext/date"],
Expand Down Expand Up @@ -202,12 +196,6 @@ def lib((upstream, branch), gemspec_in_subdir: false)
optparse: lib("ruby/optparse", gemspec_in_subdir: true).tap {
it.mappings << ["doc/optparse", "doc/optparse"]
},
pathname: repo("ruby/pathname", [
["ext/pathname/pathname.c", "pathname.c"],
["lib/pathname_builtin.rb", "pathname_builtin.rb"],
["lib/pathname.rb", "lib/pathname.rb"],
["test/pathname", "test/pathname"],
]),
pp: lib("ruby/pp"),
prettyprint: lib("ruby/prettyprint"),
prism: repo(["ruby/prism", "main"], [
Expand Down Expand Up @@ -445,7 +433,7 @@ def sync_default_gems(gem)
end

def check_prerelease_version(gem)
return if ["rubygems", "mmtk", "cgi", "pathname", "Onigmo"].include?(gem)
return if ["rubygems", "mmtk", "Onigmo"].include?(gem)

require "net/https"
require "json"
Expand Down