Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby30/share/ruby
File: objspace.rb
# frozen_string_literal: true
[0] Fix | Delete
[1] Fix | Delete
require 'objspace.so'
[2] Fix | Delete
[3] Fix | Delete
module ObjectSpace
[4] Fix | Delete
class << self
[5] Fix | Delete
private :_dump
[6] Fix | Delete
private :_dump_all
[7] Fix | Delete
end
[8] Fix | Delete
[9] Fix | Delete
module_function
[10] Fix | Delete
[11] Fix | Delete
# call-seq:
[12] Fix | Delete
# ObjectSpace.dump(obj[, output: :string]) # => "{ ... }"
[13] Fix | Delete
# ObjectSpace.dump(obj, output: :file) # => #<File:/tmp/rubyobj20131125-88733-1xkfmpv.json>
[14] Fix | Delete
# ObjectSpace.dump(obj, output: :stdout) # => nil
[15] Fix | Delete
#
[16] Fix | Delete
# Dump the contents of a ruby object as JSON.
[17] Fix | Delete
#
[18] Fix | Delete
# This method is only expected to work with C Ruby.
[19] Fix | Delete
# This is an experimental method and is subject to change.
[20] Fix | Delete
# In particular, the function signature and output format are
[21] Fix | Delete
# not guaranteed to be compatible in future versions of ruby.
[22] Fix | Delete
def dump(obj, output: :string)
[23] Fix | Delete
out = case output
[24] Fix | Delete
when :file, nil
[25] Fix | Delete
require 'tempfile'
[26] Fix | Delete
Tempfile.create(%w(rubyobj .json))
[27] Fix | Delete
when :stdout
[28] Fix | Delete
STDOUT
[29] Fix | Delete
when :string
[30] Fix | Delete
+''
[31] Fix | Delete
when IO
[32] Fix | Delete
output
[33] Fix | Delete
else
[34] Fix | Delete
raise ArgumentError, "wrong output option: #{output.inspect}"
[35] Fix | Delete
end
[36] Fix | Delete
[37] Fix | Delete
ret = _dump(obj, out)
[38] Fix | Delete
return nil if output == :stdout
[39] Fix | Delete
ret
[40] Fix | Delete
end
[41] Fix | Delete
[42] Fix | Delete
[43] Fix | Delete
# call-seq:
[44] Fix | Delete
# ObjectSpace.dump_all([output: :file]) # => #<File:/tmp/rubyheap20131125-88469-laoj3v.json>
[45] Fix | Delete
# ObjectSpace.dump_all(output: :stdout) # => nil
[46] Fix | Delete
# ObjectSpace.dump_all(output: :string) # => "{...}\n{...}\n..."
[47] Fix | Delete
# ObjectSpace.dump_all(output:
[48] Fix | Delete
# File.open('heap.json','w')) # => #<File:heap.json>
[49] Fix | Delete
# ObjectSpace.dump_all(output: :string,
[50] Fix | Delete
# since: 42) # => "{...}\n{...}\n..."
[51] Fix | Delete
#
[52] Fix | Delete
# Dump the contents of the ruby heap as JSON.
[53] Fix | Delete
#
[54] Fix | Delete
# _since_ must be a non-negative integer or +nil+.
[55] Fix | Delete
#
[56] Fix | Delete
# If _since_ is a positive integer, only objects of that generation and
[57] Fix | Delete
# newer generations are dumped. The current generation can be accessed using
[58] Fix | Delete
# GC::count.
[59] Fix | Delete
#
[60] Fix | Delete
# Objects that were allocated without object allocation tracing enabled
[61] Fix | Delete
# are ignored. See ::trace_object_allocations for more information and
[62] Fix | Delete
# examples.
[63] Fix | Delete
#
[64] Fix | Delete
# If _since_ is omitted or is +nil+, all objects are dumped.
[65] Fix | Delete
#
[66] Fix | Delete
# This method is only expected to work with C Ruby.
[67] Fix | Delete
# This is an experimental method and is subject to change.
[68] Fix | Delete
# In particular, the function signature and output format are
[69] Fix | Delete
# not guaranteed to be compatible in future versions of ruby.
[70] Fix | Delete
def dump_all(output: :file, full: false, since: nil)
[71] Fix | Delete
out = case output
[72] Fix | Delete
when :file, nil
[73] Fix | Delete
require 'tempfile'
[74] Fix | Delete
Tempfile.create(%w(rubyheap .json))
[75] Fix | Delete
when :stdout
[76] Fix | Delete
STDOUT
[77] Fix | Delete
when :string
[78] Fix | Delete
+''
[79] Fix | Delete
when IO
[80] Fix | Delete
output
[81] Fix | Delete
else
[82] Fix | Delete
raise ArgumentError, "wrong output option: #{output.inspect}"
[83] Fix | Delete
end
[84] Fix | Delete
[85] Fix | Delete
ret = _dump_all(out, full, since)
[86] Fix | Delete
return nil if output == :stdout
[87] Fix | Delete
ret
[88] Fix | Delete
end
[89] Fix | Delete
end
[90] Fix | Delete
[91] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function