/usr/share/ruby
# frozen_string_literal: true require 'objspace.so' module ObjectSpace class << self private :_dump private :_dump_all end module_function # call-seq: # ObjectSpace.dump(obj[, output: :string]) # => "{ ... }" # ObjectSpace.dump(obj, output: :file) # => #<File:/tmp/rubyobj20131125-88733-1xkfmpv.json> # ObjectSpace.dump(obj, output: :stdout) # => nil # # Dump the contents of a ruby object as JSON. # # This method is only expected to work with C Ruby. # This is an experimental method and is subject to change. # In particular, the function signature and output format are # not guaranteed to be compatible in future versions of ruby. def dump(obj, output: :string) out = case output when :file, nil require 'tempfile' Tempfile.create(%w(rubyobj .json)) when :stdout STDOUT when :string +'' when IO output else raise ArgumentError, "wrong output option: #{output.inspect}" end ret = _dump(obj, out) return nil if output == :stdout ret end # call-seq: # ObjectSpace.dump_all([output: :file]) # => #<File:/tmp/rubyheap20131125-88469-laoj3v.json> # ObjectSpace.dump_all(output: :stdout) # => nil # ObjectSpace.dump_all(output: :string) # => "{...}\n{...}\n..." # ObjectSpace.dump_all(output: # File.open('heap.json','w')) # => #<File:heap.json> # ObjectSpace.dump_all(output: :string, # since: 42) # => "{...}\n{...}\n..." # # Dump the contents of the ruby heap as JSON. # # _since_ must be a non-negative integer or +nil+. # # If _since_ is a positive integer, only objects of that generation and # newer generations are dumped. The current generation can be accessed using # GC::count. # # Objects that were allocated without object allocation tracing enabled # are ignored. See ::trace_object_allocations for more information and # examples. # # If _since_ is omitted or is +nil+, all objects are dumped. # # This method is only expected to work with C Ruby. # This is an experimental method and is subject to change. # In particular, the function signature and output format are # not guaranteed to be compatible in future versions of ruby. def dump_all(output: :file, full: false, since: nil) out = case output when :file, nil require 'tempfile' Tempfile.create(%w(rubyheap .json)) when :stdout STDOUT when :string +'' when IO output else raise ArgumentError, "wrong output option: #{output.inspect}" end ret = _dump_all(out, full, since) return nil if output == :stdout ret end end
.
Edit
..
Edit
English.rb
Edit
abbrev.rb
Edit
base64.rb
Edit
benchmark
Edit
benchmark.rb
Edit
bigdecimal
Edit
bigdecimal.rb
Edit
cgi
Edit
cgi.rb
Edit
coverage.rb
Edit
csv
Edit
csv.rb
Edit
date.rb
Edit
debug.rb
Edit
delegate.rb
Edit
did_you_mean
Edit
did_you_mean.rb
Edit
digest
Edit
digest.rb
Edit
drb
Edit
drb.rb
Edit
erb.rb
Edit
expect.rb
Edit
fiddle
Edit
fiddle.rb
Edit
fileutils.rb
Edit
find.rb
Edit
forwardable
Edit
forwardable.rb
Edit
getoptlong.rb
Edit
io
Edit
ipaddr.rb
Edit
json
Edit
json.rb
Edit
kconv.rb
Edit
logger
Edit
logger.rb
Edit
matrix
Edit
matrix.rb
Edit
mkmf.rb
Edit
monitor.rb
Edit
mutex_m.rb
Edit
net
Edit
objspace.rb
Edit
observer.rb
Edit
open-uri.rb
Edit
open3.rb
Edit
openssl
Edit
openssl.rb
Edit
optionparser.rb
Edit
optparse
Edit
optparse.rb
Edit
ostruct.rb
Edit
pathname.rb
Edit
pp.rb
Edit
prettyprint.rb
Edit
prime.rb
Edit
pstore.rb
Edit
psych
Edit
psych.rb
Edit
racc
Edit
racc.rb
Edit
readline.rb
Edit
reline
Edit
reline.rb
Edit
resolv-replace.rb
Edit
resolv.rb
Edit
rinda
Edit
ripper
Edit
ripper.rb
Edit
securerandom.rb
Edit
set
Edit
set.rb
Edit
shellwords.rb
Edit
singleton.rb
Edit
socket.rb
Edit
syslog
Edit
tempfile.rb
Edit
time.rb
Edit
timeout.rb
Edit
tmpdir.rb
Edit
tracer.rb
Edit
tsort.rb
Edit
un.rb
Edit
unicode_normalize
Edit
uri
Edit
uri.rb
Edit
vendor_ruby
Edit
weakref.rb
Edit
yaml
Edit
yaml.rb
Edit