Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../opt/alt/ruby31/share/ruby
File: pp.rb
# frozen_string_literal: true
[0] Fix | Delete
[1] Fix | Delete
require 'prettyprint'
[2] Fix | Delete
[3] Fix | Delete
##
[4] Fix | Delete
# A pretty-printer for Ruby objects.
[5] Fix | Delete
#
[6] Fix | Delete
##
[7] Fix | Delete
# == What PP Does
[8] Fix | Delete
#
[9] Fix | Delete
# Standard output by #p returns this:
[10] Fix | Delete
# #<PP:0x81fedf0 @genspace=#<Proc:0x81feda0>, @group_queue=#<PrettyPrint::GroupQueue:0x81fed3c @queue=[[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], []]>, @buffer=[], @newline="\n", @group_stack=[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], @buffer_width=0, @indent=0, @maxwidth=79, @output_width=2, @output=#<IO:0x8114ee4>>
[11] Fix | Delete
#
[12] Fix | Delete
# Pretty-printed output returns this:
[13] Fix | Delete
# #<PP:0x81fedf0
[14] Fix | Delete
# @buffer=[],
[15] Fix | Delete
# @buffer_width=0,
[16] Fix | Delete
# @genspace=#<Proc:0x81feda0>,
[17] Fix | Delete
# @group_queue=
[18] Fix | Delete
# #<PrettyPrint::GroupQueue:0x81fed3c
[19] Fix | Delete
# @queue=
[20] Fix | Delete
# [[#<PrettyPrint::Group:0x81fed78 @break=false, @breakables=[], @depth=0>],
[21] Fix | Delete
# []]>,
[22] Fix | Delete
# @group_stack=
[23] Fix | Delete
# [#<PrettyPrint::Group:0x81fed78 @break=false, @breakables=[], @depth=0>],
[24] Fix | Delete
# @indent=0,
[25] Fix | Delete
# @maxwidth=79,
[26] Fix | Delete
# @newline="\n",
[27] Fix | Delete
# @output=#<IO:0x8114ee4>,
[28] Fix | Delete
# @output_width=2>
[29] Fix | Delete
#
[30] Fix | Delete
##
[31] Fix | Delete
# == Usage
[32] Fix | Delete
#
[33] Fix | Delete
# pp(obj) #=> obj
[34] Fix | Delete
# pp obj #=> obj
[35] Fix | Delete
# pp(obj1, obj2, ...) #=> [obj1, obj2, ...]
[36] Fix | Delete
# pp() #=> nil
[37] Fix | Delete
#
[38] Fix | Delete
# Output <tt>obj(s)</tt> to <tt>$></tt> in pretty printed format.
[39] Fix | Delete
#
[40] Fix | Delete
# It returns <tt>obj(s)</tt>.
[41] Fix | Delete
#
[42] Fix | Delete
##
[43] Fix | Delete
# == Output Customization
[44] Fix | Delete
#
[45] Fix | Delete
# To define a customized pretty printing function for your classes,
[46] Fix | Delete
# redefine method <code>#pretty_print(pp)</code> in the class.
[47] Fix | Delete
#
[48] Fix | Delete
# <code>#pretty_print</code> takes the +pp+ argument, which is an instance of the PP class.
[49] Fix | Delete
# The method uses #text, #breakable, #nest, #group and #pp to print the
[50] Fix | Delete
# object.
[51] Fix | Delete
#
[52] Fix | Delete
##
[53] Fix | Delete
# == Pretty-Print JSON
[54] Fix | Delete
#
[55] Fix | Delete
# To pretty-print JSON refer to JSON#pretty_generate.
[56] Fix | Delete
#
[57] Fix | Delete
##
[58] Fix | Delete
# == Author
[59] Fix | Delete
# Tanaka Akira <akr@fsij.org>
[60] Fix | Delete
[61] Fix | Delete
class PP < PrettyPrint
[62] Fix | Delete
# Returns the usable width for +out+.
[63] Fix | Delete
# As the width of +out+:
[64] Fix | Delete
# 1. If +out+ is assigned to a tty device, its width is used.
[65] Fix | Delete
# 2. Otherwise, or it could not get the value, the +COLUMN+
[66] Fix | Delete
# environment variable is assumed to be set to the width.
[67] Fix | Delete
# 3. If +COLUMN+ is not set to a non-zero number, 80 is assumed.
[68] Fix | Delete
#
[69] Fix | Delete
# And finally, returns the above width value - 1.
[70] Fix | Delete
# * This -1 is for Windows command prompt, which moves the cursor to
[71] Fix | Delete
# the next line if it reaches the last column.
[72] Fix | Delete
def PP.width_for(out)
[73] Fix | Delete
begin
[74] Fix | Delete
require 'io/console'
[75] Fix | Delete
_, width = out.winsize
[76] Fix | Delete
rescue LoadError, NoMethodError, SystemCallError
[77] Fix | Delete
end
[78] Fix | Delete
(width || ENV['COLUMNS']&.to_i&.nonzero? || 80) - 1
[79] Fix | Delete
end
[80] Fix | Delete
[81] Fix | Delete
# Outputs +obj+ to +out+ in pretty printed format of
[82] Fix | Delete
# +width+ columns in width.
[83] Fix | Delete
#
[84] Fix | Delete
# If +out+ is omitted, <code>$></code> is assumed.
[85] Fix | Delete
# If +width+ is omitted, the width of +out+ is assumed (see
[86] Fix | Delete
# width_for).
[87] Fix | Delete
#
[88] Fix | Delete
# PP.pp returns +out+.
[89] Fix | Delete
def PP.pp(obj, out=$>, width=width_for(out))
[90] Fix | Delete
q = PP.new(out, width)
[91] Fix | Delete
q.guard_inspect_key {q.pp obj}
[92] Fix | Delete
q.flush
[93] Fix | Delete
#$pp = q
[94] Fix | Delete
out << "\n"
[95] Fix | Delete
end
[96] Fix | Delete
[97] Fix | Delete
# Outputs +obj+ to +out+ like PP.pp but with no indent and
[98] Fix | Delete
# newline.
[99] Fix | Delete
#
[100] Fix | Delete
# PP.singleline_pp returns +out+.
[101] Fix | Delete
def PP.singleline_pp(obj, out=$>)
[102] Fix | Delete
q = SingleLine.new(out)
[103] Fix | Delete
q.guard_inspect_key {q.pp obj}
[104] Fix | Delete
q.flush
[105] Fix | Delete
out
[106] Fix | Delete
end
[107] Fix | Delete
[108] Fix | Delete
# :stopdoc:
[109] Fix | Delete
def PP.mcall(obj, mod, meth, *args, &block)
[110] Fix | Delete
mod.instance_method(meth).bind_call(obj, *args, &block)
[111] Fix | Delete
end
[112] Fix | Delete
# :startdoc:
[113] Fix | Delete
[114] Fix | Delete
if defined? ::Ractor
[115] Fix | Delete
class << self
[116] Fix | Delete
# Returns the sharing detection flag as a boolean value.
[117] Fix | Delete
# It is false (nil) by default.
[118] Fix | Delete
def sharing_detection
[119] Fix | Delete
Ractor.current[:pp_sharing_detection]
[120] Fix | Delete
end
[121] Fix | Delete
# Sets the sharing detection flag to b.
[122] Fix | Delete
def sharing_detection=(b)
[123] Fix | Delete
Ractor.current[:pp_sharing_detection] = b
[124] Fix | Delete
end
[125] Fix | Delete
end
[126] Fix | Delete
else
[127] Fix | Delete
@sharing_detection = false
[128] Fix | Delete
class << self
[129] Fix | Delete
# Returns the sharing detection flag as a boolean value.
[130] Fix | Delete
# It is false by default.
[131] Fix | Delete
attr_accessor :sharing_detection
[132] Fix | Delete
end
[133] Fix | Delete
end
[134] Fix | Delete
[135] Fix | Delete
module PPMethods
[136] Fix | Delete
[137] Fix | Delete
# Yields to a block
[138] Fix | Delete
# and preserves the previous set of objects being printed.
[139] Fix | Delete
def guard_inspect_key
[140] Fix | Delete
if Thread.current[:__recursive_key__] == nil
[141] Fix | Delete
Thread.current[:__recursive_key__] = {}.compare_by_identity
[142] Fix | Delete
end
[143] Fix | Delete
[144] Fix | Delete
if Thread.current[:__recursive_key__][:inspect] == nil
[145] Fix | Delete
Thread.current[:__recursive_key__][:inspect] = {}.compare_by_identity
[146] Fix | Delete
end
[147] Fix | Delete
[148] Fix | Delete
save = Thread.current[:__recursive_key__][:inspect]
[149] Fix | Delete
[150] Fix | Delete
begin
[151] Fix | Delete
Thread.current[:__recursive_key__][:inspect] = {}.compare_by_identity
[152] Fix | Delete
yield
[153] Fix | Delete
ensure
[154] Fix | Delete
Thread.current[:__recursive_key__][:inspect] = save
[155] Fix | Delete
end
[156] Fix | Delete
end
[157] Fix | Delete
[158] Fix | Delete
# Check whether the object_id +id+ is in the current buffer of objects
[159] Fix | Delete
# to be pretty printed. Used to break cycles in chains of objects to be
[160] Fix | Delete
# pretty printed.
[161] Fix | Delete
def check_inspect_key(id)
[162] Fix | Delete
Thread.current[:__recursive_key__] &&
[163] Fix | Delete
Thread.current[:__recursive_key__][:inspect] &&
[164] Fix | Delete
Thread.current[:__recursive_key__][:inspect].include?(id)
[165] Fix | Delete
end
[166] Fix | Delete
[167] Fix | Delete
# Adds the object_id +id+ to the set of objects being pretty printed, so
[168] Fix | Delete
# as to not repeat objects.
[169] Fix | Delete
def push_inspect_key(id)
[170] Fix | Delete
Thread.current[:__recursive_key__][:inspect][id] = true
[171] Fix | Delete
end
[172] Fix | Delete
[173] Fix | Delete
# Removes an object from the set of objects being pretty printed.
[174] Fix | Delete
def pop_inspect_key(id)
[175] Fix | Delete
Thread.current[:__recursive_key__][:inspect].delete id
[176] Fix | Delete
end
[177] Fix | Delete
[178] Fix | Delete
# Adds +obj+ to the pretty printing buffer
[179] Fix | Delete
# using Object#pretty_print or Object#pretty_print_cycle.
[180] Fix | Delete
#
[181] Fix | Delete
# Object#pretty_print_cycle is used when +obj+ is already
[182] Fix | Delete
# printed, a.k.a the object reference chain has a cycle.
[183] Fix | Delete
def pp(obj)
[184] Fix | Delete
# If obj is a Delegator then use the object being delegated to for cycle
[185] Fix | Delete
# detection
[186] Fix | Delete
obj = obj.__getobj__ if defined?(::Delegator) and obj.is_a?(::Delegator)
[187] Fix | Delete
[188] Fix | Delete
if check_inspect_key(obj)
[189] Fix | Delete
group {obj.pretty_print_cycle self}
[190] Fix | Delete
return
[191] Fix | Delete
end
[192] Fix | Delete
[193] Fix | Delete
begin
[194] Fix | Delete
push_inspect_key(obj)
[195] Fix | Delete
group {obj.pretty_print self}
[196] Fix | Delete
ensure
[197] Fix | Delete
pop_inspect_key(obj) unless PP.sharing_detection
[198] Fix | Delete
end
[199] Fix | Delete
end
[200] Fix | Delete
[201] Fix | Delete
# A convenience method which is same as follows:
[202] Fix | Delete
#
[203] Fix | Delete
# group(1, '#<' + obj.class.name, '>') { ... }
[204] Fix | Delete
def object_group(obj, &block) # :yield:
[205] Fix | Delete
group(1, '#<' + obj.class.name, '>', &block)
[206] Fix | Delete
end
[207] Fix | Delete
[208] Fix | Delete
# A convenience method, like object_group, but also reformats the Object's
[209] Fix | Delete
# object_id.
[210] Fix | Delete
def object_address_group(obj, &block)
[211] Fix | Delete
str = Kernel.instance_method(:to_s).bind_call(obj)
[212] Fix | Delete
str.chomp!('>')
[213] Fix | Delete
group(1, str, '>', &block)
[214] Fix | Delete
end
[215] Fix | Delete
[216] Fix | Delete
# A convenience method which is same as follows:
[217] Fix | Delete
#
[218] Fix | Delete
# text ','
[219] Fix | Delete
# breakable
[220] Fix | Delete
def comma_breakable
[221] Fix | Delete
text ','
[222] Fix | Delete
breakable
[223] Fix | Delete
end
[224] Fix | Delete
[225] Fix | Delete
# Adds a separated list.
[226] Fix | Delete
# The list is separated by comma with breakable space, by default.
[227] Fix | Delete
#
[228] Fix | Delete
# #seplist iterates the +list+ using +iter_method+.
[229] Fix | Delete
# It yields each object to the block given for #seplist.
[230] Fix | Delete
# The procedure +separator_proc+ is called between each yields.
[231] Fix | Delete
#
[232] Fix | Delete
# If the iteration is zero times, +separator_proc+ is not called at all.
[233] Fix | Delete
#
[234] Fix | Delete
# If +separator_proc+ is nil or not given,
[235] Fix | Delete
# +lambda { comma_breakable }+ is used.
[236] Fix | Delete
# If +iter_method+ is not given, :each is used.
[237] Fix | Delete
#
[238] Fix | Delete
# For example, following 3 code fragments has similar effect.
[239] Fix | Delete
#
[240] Fix | Delete
# q.seplist([1,2,3]) {|v| xxx v }
[241] Fix | Delete
#
[242] Fix | Delete
# q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v }
[243] Fix | Delete
#
[244] Fix | Delete
# xxx 1
[245] Fix | Delete
# q.comma_breakable
[246] Fix | Delete
# xxx 2
[247] Fix | Delete
# q.comma_breakable
[248] Fix | Delete
# xxx 3
[249] Fix | Delete
def seplist(list, sep=nil, iter_method=:each) # :yield: element
[250] Fix | Delete
sep ||= lambda { comma_breakable }
[251] Fix | Delete
first = true
[252] Fix | Delete
list.__send__(iter_method) {|*v|
[253] Fix | Delete
if first
[254] Fix | Delete
first = false
[255] Fix | Delete
else
[256] Fix | Delete
sep.call
[257] Fix | Delete
end
[258] Fix | Delete
RUBY_VERSION >= "3.0" ? yield(*v, **{}) : yield(*v)
[259] Fix | Delete
}
[260] Fix | Delete
end
[261] Fix | Delete
[262] Fix | Delete
# A present standard failsafe for pretty printing any given Object
[263] Fix | Delete
def pp_object(obj)
[264] Fix | Delete
object_address_group(obj) {
[265] Fix | Delete
seplist(obj.pretty_print_instance_variables, lambda { text ',' }) {|v|
[266] Fix | Delete
breakable
[267] Fix | Delete
v = v.to_s if Symbol === v
[268] Fix | Delete
text v
[269] Fix | Delete
text '='
[270] Fix | Delete
group(1) {
[271] Fix | Delete
breakable ''
[272] Fix | Delete
pp(obj.instance_eval(v))
[273] Fix | Delete
}
[274] Fix | Delete
}
[275] Fix | Delete
}
[276] Fix | Delete
end
[277] Fix | Delete
[278] Fix | Delete
# A pretty print for a Hash
[279] Fix | Delete
def pp_hash(obj)
[280] Fix | Delete
group(1, '{', '}') {
[281] Fix | Delete
seplist(obj, nil, :each_pair) {|k, v|
[282] Fix | Delete
group {
[283] Fix | Delete
pp k
[284] Fix | Delete
text '=>'
[285] Fix | Delete
group(1) {
[286] Fix | Delete
breakable ''
[287] Fix | Delete
pp v
[288] Fix | Delete
}
[289] Fix | Delete
}
[290] Fix | Delete
}
[291] Fix | Delete
}
[292] Fix | Delete
end
[293] Fix | Delete
end
[294] Fix | Delete
[295] Fix | Delete
include PPMethods
[296] Fix | Delete
[297] Fix | Delete
class SingleLine < PrettyPrint::SingleLine # :nodoc:
[298] Fix | Delete
include PPMethods
[299] Fix | Delete
end
[300] Fix | Delete
[301] Fix | Delete
module ObjectMixin # :nodoc:
[302] Fix | Delete
# 1. specific pretty_print
[303] Fix | Delete
# 2. specific inspect
[304] Fix | Delete
# 3. generic pretty_print
[305] Fix | Delete
[306] Fix | Delete
# A default pretty printing method for general objects.
[307] Fix | Delete
# It calls #pretty_print_instance_variables to list instance variables.
[308] Fix | Delete
#
[309] Fix | Delete
# If +self+ has a customized (redefined) #inspect method,
[310] Fix | Delete
# the result of self.inspect is used but it obviously has no
[311] Fix | Delete
# line break hints.
[312] Fix | Delete
#
[313] Fix | Delete
# This module provides predefined #pretty_print methods for some of
[314] Fix | Delete
# the most commonly used built-in classes for convenience.
[315] Fix | Delete
def pretty_print(q)
[316] Fix | Delete
umethod_method = Object.instance_method(:method)
[317] Fix | Delete
begin
[318] Fix | Delete
inspect_method = umethod_method.bind_call(self, :inspect)
[319] Fix | Delete
rescue NameError
[320] Fix | Delete
end
[321] Fix | Delete
if inspect_method && inspect_method.owner != Kernel
[322] Fix | Delete
q.text self.inspect
[323] Fix | Delete
elsif !inspect_method && self.respond_to?(:inspect)
[324] Fix | Delete
q.text self.inspect
[325] Fix | Delete
else
[326] Fix | Delete
q.pp_object(self)
[327] Fix | Delete
end
[328] Fix | Delete
end
[329] Fix | Delete
[330] Fix | Delete
# A default pretty printing method for general objects that are
[331] Fix | Delete
# detected as part of a cycle.
[332] Fix | Delete
def pretty_print_cycle(q)
[333] Fix | Delete
q.object_address_group(self) {
[334] Fix | Delete
q.breakable
[335] Fix | Delete
q.text '...'
[336] Fix | Delete
}
[337] Fix | Delete
end
[338] Fix | Delete
[339] Fix | Delete
# Returns a sorted array of instance variable names.
[340] Fix | Delete
#
[341] Fix | Delete
# This method should return an array of names of instance variables as symbols or strings as:
[342] Fix | Delete
# +[:@a, :@b]+.
[343] Fix | Delete
def pretty_print_instance_variables
[344] Fix | Delete
instance_variables.sort
[345] Fix | Delete
end
[346] Fix | Delete
[347] Fix | Delete
# Is #inspect implementation using #pretty_print.
[348] Fix | Delete
# If you implement #pretty_print, it can be used as follows.
[349] Fix | Delete
#
[350] Fix | Delete
# alias inspect pretty_print_inspect
[351] Fix | Delete
#
[352] Fix | Delete
# However, doing this requires that every class that #inspect is called on
[353] Fix | Delete
# implement #pretty_print, or a RuntimeError will be raised.
[354] Fix | Delete
def pretty_print_inspect
[355] Fix | Delete
if Object.instance_method(:method).bind_call(self, :pretty_print).owner == PP::ObjectMixin
[356] Fix | Delete
raise "pretty_print is not overridden for #{self.class}"
[357] Fix | Delete
end
[358] Fix | Delete
PP.singleline_pp(self, ''.dup)
[359] Fix | Delete
end
[360] Fix | Delete
end
[361] Fix | Delete
end
[362] Fix | Delete
[363] Fix | Delete
class Array # :nodoc:
[364] Fix | Delete
def pretty_print(q) # :nodoc:
[365] Fix | Delete
q.group(1, '[', ']') {
[366] Fix | Delete
q.seplist(self) {|v|
[367] Fix | Delete
q.pp v
[368] Fix | Delete
}
[369] Fix | Delete
}
[370] Fix | Delete
end
[371] Fix | Delete
[372] Fix | Delete
def pretty_print_cycle(q) # :nodoc:
[373] Fix | Delete
q.text(empty? ? '[]' : '[...]')
[374] Fix | Delete
end
[375] Fix | Delete
end
[376] Fix | Delete
[377] Fix | Delete
class Hash # :nodoc:
[378] Fix | Delete
def pretty_print(q) # :nodoc:
[379] Fix | Delete
q.pp_hash self
[380] Fix | Delete
end
[381] Fix | Delete
[382] Fix | Delete
def pretty_print_cycle(q) # :nodoc:
[383] Fix | Delete
q.text(empty? ? '{}' : '{...}')
[384] Fix | Delete
end
[385] Fix | Delete
end
[386] Fix | Delete
[387] Fix | Delete
class << ENV # :nodoc:
[388] Fix | Delete
def pretty_print(q) # :nodoc:
[389] Fix | Delete
h = {}
[390] Fix | Delete
ENV.keys.sort.each {|k|
[391] Fix | Delete
h[k] = ENV[k]
[392] Fix | Delete
}
[393] Fix | Delete
q.pp_hash h
[394] Fix | Delete
end
[395] Fix | Delete
end
[396] Fix | Delete
[397] Fix | Delete
class Struct # :nodoc:
[398] Fix | Delete
def pretty_print(q) # :nodoc:
[399] Fix | Delete
q.group(1, sprintf("#<struct %s", PP.mcall(self, Kernel, :class).name), '>') {
[400] Fix | Delete
q.seplist(PP.mcall(self, Struct, :members), lambda { q.text "," }) {|member|
[401] Fix | Delete
q.breakable
[402] Fix | Delete
q.text member.to_s
[403] Fix | Delete
q.text '='
[404] Fix | Delete
q.group(1) {
[405] Fix | Delete
q.breakable ''
[406] Fix | Delete
q.pp self[member]
[407] Fix | Delete
}
[408] Fix | Delete
}
[409] Fix | Delete
}
[410] Fix | Delete
end
[411] Fix | Delete
[412] Fix | Delete
def pretty_print_cycle(q) # :nodoc:
[413] Fix | Delete
q.text sprintf("#<struct %s:...>", PP.mcall(self, Kernel, :class).name)
[414] Fix | Delete
end
[415] Fix | Delete
end
[416] Fix | Delete
[417] Fix | Delete
class Range # :nodoc:
[418] Fix | Delete
def pretty_print(q) # :nodoc:
[419] Fix | Delete
q.pp self.begin
[420] Fix | Delete
q.breakable ''
[421] Fix | Delete
q.text(self.exclude_end? ? '...' : '..')
[422] Fix | Delete
q.breakable ''
[423] Fix | Delete
q.pp self.end if self.end
[424] Fix | Delete
end
[425] Fix | Delete
end
[426] Fix | Delete
[427] Fix | Delete
class String # :nodoc:
[428] Fix | Delete
def pretty_print(q) # :nodoc:
[429] Fix | Delete
lines = self.lines
[430] Fix | Delete
if lines.size > 1
[431] Fix | Delete
q.group(0, '', '') do
[432] Fix | Delete
q.seplist(lines, lambda { q.text ' +'; q.breakable }) do |v|
[433] Fix | Delete
q.pp v
[434] Fix | Delete
end
[435] Fix | Delete
end
[436] Fix | Delete
else
[437] Fix | Delete
q.text inspect
[438] Fix | Delete
end
[439] Fix | Delete
end
[440] Fix | Delete
end
[441] Fix | Delete
[442] Fix | Delete
class File < IO # :nodoc:
[443] Fix | Delete
class Stat # :nodoc:
[444] Fix | Delete
def pretty_print(q) # :nodoc:
[445] Fix | Delete
require 'etc'
[446] Fix | Delete
q.object_group(self) {
[447] Fix | Delete
q.breakable
[448] Fix | Delete
q.text sprintf("dev=0x%x", self.dev); q.comma_breakable
[449] Fix | Delete
q.text "ino="; q.pp self.ino; q.comma_breakable
[450] Fix | Delete
q.group {
[451] Fix | Delete
m = self.mode
[452] Fix | Delete
q.text sprintf("mode=0%o", m)
[453] Fix | Delete
q.breakable
[454] Fix | Delete
q.text sprintf("(%s %c%c%c%c%c%c%c%c%c)",
[455] Fix | Delete
self.ftype,
[456] Fix | Delete
(m & 0400 == 0 ? ?- : ?r),
[457] Fix | Delete
(m & 0200 == 0 ? ?- : ?w),
[458] Fix | Delete
(m & 0100 == 0 ? (m & 04000 == 0 ? ?- : ?S) :
[459] Fix | Delete
(m & 04000 == 0 ? ?x : ?s)),
[460] Fix | Delete
(m & 0040 == 0 ? ?- : ?r),
[461] Fix | Delete
(m & 0020 == 0 ? ?- : ?w),
[462] Fix | Delete
(m & 0010 == 0 ? (m & 02000 == 0 ? ?- : ?S) :
[463] Fix | Delete
(m & 02000 == 0 ? ?x : ?s)),
[464] Fix | Delete
(m & 0004 == 0 ? ?- : ?r),
[465] Fix | Delete
(m & 0002 == 0 ? ?- : ?w),
[466] Fix | Delete
(m & 0001 == 0 ? (m & 01000 == 0 ? ?- : ?T) :
[467] Fix | Delete
(m & 01000 == 0 ? ?x : ?t)))
[468] Fix | Delete
}
[469] Fix | Delete
q.comma_breakable
[470] Fix | Delete
q.text "nlink="; q.pp self.nlink; q.comma_breakable
[471] Fix | Delete
q.group {
[472] Fix | Delete
q.text "uid="; q.pp self.uid
[473] Fix | Delete
begin
[474] Fix | Delete
pw = Etc.getpwuid(self.uid)
[475] Fix | Delete
rescue ArgumentError
[476] Fix | Delete
end
[477] Fix | Delete
if pw
[478] Fix | Delete
q.breakable; q.text "(#{pw.name})"
[479] Fix | Delete
end
[480] Fix | Delete
}
[481] Fix | Delete
q.comma_breakable
[482] Fix | Delete
q.group {
[483] Fix | Delete
q.text "gid="; q.pp self.gid
[484] Fix | Delete
begin
[485] Fix | Delete
gr = Etc.getgrgid(self.gid)
[486] Fix | Delete
rescue ArgumentError
[487] Fix | Delete
end
[488] Fix | Delete
if gr
[489] Fix | Delete
q.breakable; q.text "(#{gr.name})"
[490] Fix | Delete
end
[491] Fix | Delete
}
[492] Fix | Delete
q.comma_breakable
[493] Fix | Delete
q.group {
[494] Fix | Delete
q.text sprintf("rdev=0x%x", self.rdev)
[495] Fix | Delete
if self.rdev_major && self.rdev_minor
[496] Fix | Delete
q.breakable
[497] Fix | Delete
q.text sprintf('(%d, %d)', self.rdev_major, self.rdev_minor)
[498] Fix | Delete
end
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function