Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/irb
File: init.rb
# frozen_string_literal: false
[0] Fix | Delete
#
[1] Fix | Delete
# irb/init.rb - irb initialize module
[2] Fix | Delete
# $Release Version: 0.9.6$
[3] Fix | Delete
# $Revision$
[4] Fix | Delete
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
[5] Fix | Delete
#
[6] Fix | Delete
# --
[7] Fix | Delete
#
[8] Fix | Delete
#
[9] Fix | Delete
#
[10] Fix | Delete
[11] Fix | Delete
module IRB # :nodoc:
[12] Fix | Delete
[13] Fix | Delete
# initialize config
[14] Fix | Delete
def IRB.setup(ap_path, argv: ::ARGV)
[15] Fix | Delete
IRB.init_config(ap_path)
[16] Fix | Delete
IRB.init_error
[17] Fix | Delete
IRB.parse_opts(argv: argv)
[18] Fix | Delete
IRB.run_config
[19] Fix | Delete
IRB.load_modules
[20] Fix | Delete
[21] Fix | Delete
unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
[22] Fix | Delete
fail UndefinedPromptMode, @CONF[:PROMPT_MODE]
[23] Fix | Delete
end
[24] Fix | Delete
end
[25] Fix | Delete
[26] Fix | Delete
# @CONF default setting
[27] Fix | Delete
def IRB.init_config(ap_path)
[28] Fix | Delete
# class instance variables
[29] Fix | Delete
@TRACER_INITIALIZED = false
[30] Fix | Delete
[31] Fix | Delete
# default configurations
[32] Fix | Delete
unless ap_path and @CONF[:AP_NAME]
[33] Fix | Delete
ap_path = File.join(File.dirname(File.dirname(__FILE__)), "irb.rb")
[34] Fix | Delete
end
[35] Fix | Delete
@CONF[:AP_NAME] = File::basename(ap_path, ".rb")
[36] Fix | Delete
[37] Fix | Delete
@CONF[:IRB_NAME] = "irb"
[38] Fix | Delete
@CONF[:IRB_LIB_PATH] = File.dirname(__FILE__)
[39] Fix | Delete
[40] Fix | Delete
@CONF[:RC] = true
[41] Fix | Delete
@CONF[:LOAD_MODULES] = []
[42] Fix | Delete
@CONF[:IRB_RC] = nil
[43] Fix | Delete
[44] Fix | Delete
@CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
[45] Fix | Delete
@CONF[:USE_COLORIZE] = true
[46] Fix | Delete
@CONF[:INSPECT_MODE] = true
[47] Fix | Delete
@CONF[:USE_TRACER] = false
[48] Fix | Delete
@CONF[:USE_LOADER] = false
[49] Fix | Delete
@CONF[:IGNORE_SIGINT] = true
[50] Fix | Delete
@CONF[:IGNORE_EOF] = false
[51] Fix | Delete
@CONF[:ECHO] = nil
[52] Fix | Delete
@CONF[:ECHO_ON_ASSIGNMENT] = nil
[53] Fix | Delete
@CONF[:OMIT_ON_ASSIGNMENT] = nil
[54] Fix | Delete
@CONF[:VERBOSE] = nil
[55] Fix | Delete
[56] Fix | Delete
@CONF[:EVAL_HISTORY] = nil
[57] Fix | Delete
@CONF[:SAVE_HISTORY] = 1000
[58] Fix | Delete
[59] Fix | Delete
@CONF[:BACK_TRACE_LIMIT] = 16
[60] Fix | Delete
[61] Fix | Delete
@CONF[:PROMPT] = {
[62] Fix | Delete
:NULL => {
[63] Fix | Delete
:PROMPT_I => nil,
[64] Fix | Delete
:PROMPT_N => nil,
[65] Fix | Delete
:PROMPT_S => nil,
[66] Fix | Delete
:PROMPT_C => nil,
[67] Fix | Delete
:RETURN => "%s\n"
[68] Fix | Delete
},
[69] Fix | Delete
:DEFAULT => {
[70] Fix | Delete
:PROMPT_I => "%N(%m):%03n:%i> ",
[71] Fix | Delete
:PROMPT_N => "%N(%m):%03n:%i> ",
[72] Fix | Delete
:PROMPT_S => "%N(%m):%03n:%i%l ",
[73] Fix | Delete
:PROMPT_C => "%N(%m):%03n:%i* ",
[74] Fix | Delete
:RETURN => "=> %s\n"
[75] Fix | Delete
},
[76] Fix | Delete
:CLASSIC => {
[77] Fix | Delete
:PROMPT_I => "%N(%m):%03n:%i> ",
[78] Fix | Delete
:PROMPT_N => "%N(%m):%03n:%i> ",
[79] Fix | Delete
:PROMPT_S => "%N(%m):%03n:%i%l ",
[80] Fix | Delete
:PROMPT_C => "%N(%m):%03n:%i* ",
[81] Fix | Delete
:RETURN => "%s\n"
[82] Fix | Delete
},
[83] Fix | Delete
:SIMPLE => {
[84] Fix | Delete
:PROMPT_I => ">> ",
[85] Fix | Delete
:PROMPT_N => ">> ",
[86] Fix | Delete
:PROMPT_S => "%l> ",
[87] Fix | Delete
:PROMPT_C => "?> ",
[88] Fix | Delete
:RETURN => "=> %s\n"
[89] Fix | Delete
},
[90] Fix | Delete
:INF_RUBY => {
[91] Fix | Delete
:PROMPT_I => "%N(%m):%03n:%i> ",
[92] Fix | Delete
:PROMPT_N => nil,
[93] Fix | Delete
:PROMPT_S => nil,
[94] Fix | Delete
:PROMPT_C => nil,
[95] Fix | Delete
:RETURN => "%s\n",
[96] Fix | Delete
:AUTO_INDENT => true
[97] Fix | Delete
},
[98] Fix | Delete
:XMP => {
[99] Fix | Delete
:PROMPT_I => nil,
[100] Fix | Delete
:PROMPT_N => nil,
[101] Fix | Delete
:PROMPT_S => nil,
[102] Fix | Delete
:PROMPT_C => nil,
[103] Fix | Delete
:RETURN => " ==>%s\n"
[104] Fix | Delete
}
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
@CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL)
[108] Fix | Delete
@CONF[:AUTO_INDENT] = true
[109] Fix | Delete
[110] Fix | Delete
@CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING
[111] Fix | Delete
@CONF[:SINGLE_IRB] = false
[112] Fix | Delete
[113] Fix | Delete
@CONF[:LC_MESSAGES] = Locale.new
[114] Fix | Delete
[115] Fix | Delete
@CONF[:AT_EXIT] = []
[116] Fix | Delete
end
[117] Fix | Delete
[118] Fix | Delete
def IRB.init_error
[119] Fix | Delete
@CONF[:LC_MESSAGES].load("irb/error.rb")
[120] Fix | Delete
end
[121] Fix | Delete
[122] Fix | Delete
# option analyzing
[123] Fix | Delete
def IRB.parse_opts(argv: ::ARGV)
[124] Fix | Delete
load_path = []
[125] Fix | Delete
while opt = argv.shift
[126] Fix | Delete
case opt
[127] Fix | Delete
when "-f"
[128] Fix | Delete
@CONF[:RC] = false
[129] Fix | Delete
when "-d"
[130] Fix | Delete
$DEBUG = true
[131] Fix | Delete
$VERBOSE = true
[132] Fix | Delete
when "-w"
[133] Fix | Delete
$VERBOSE = true
[134] Fix | Delete
when /^-W(.+)?/
[135] Fix | Delete
opt = $1 || argv.shift
[136] Fix | Delete
case opt
[137] Fix | Delete
when "0"
[138] Fix | Delete
$VERBOSE = nil
[139] Fix | Delete
when "1"
[140] Fix | Delete
$VERBOSE = false
[141] Fix | Delete
else
[142] Fix | Delete
$VERBOSE = true
[143] Fix | Delete
end
[144] Fix | Delete
when /^-r(.+)?/
[145] Fix | Delete
opt = $1 || argv.shift
[146] Fix | Delete
@CONF[:LOAD_MODULES].push opt if opt
[147] Fix | Delete
when /^-I(.+)?/
[148] Fix | Delete
opt = $1 || argv.shift
[149] Fix | Delete
load_path.concat(opt.split(File::PATH_SEPARATOR)) if opt
[150] Fix | Delete
when '-U'
[151] Fix | Delete
set_encoding("UTF-8", "UTF-8")
[152] Fix | Delete
when /^-E(.+)?/, /^--encoding(?:=(.+))?/
[153] Fix | Delete
opt = $1 || argv.shift
[154] Fix | Delete
set_encoding(*opt.split(':', 2))
[155] Fix | Delete
when "--inspect"
[156] Fix | Delete
if /^-/ !~ argv.first
[157] Fix | Delete
@CONF[:INSPECT_MODE] = argv.shift
[158] Fix | Delete
else
[159] Fix | Delete
@CONF[:INSPECT_MODE] = true
[160] Fix | Delete
end
[161] Fix | Delete
when "--noinspect"
[162] Fix | Delete
@CONF[:INSPECT_MODE] = false
[163] Fix | Delete
when "--singleline", "--readline", "--legacy"
[164] Fix | Delete
@CONF[:USE_SINGLELINE] = true
[165] Fix | Delete
when "--nosingleline", "--noreadline"
[166] Fix | Delete
@CONF[:USE_SINGLELINE] = false
[167] Fix | Delete
when "--multiline", "--reidline"
[168] Fix | Delete
@CONF[:USE_MULTILINE] = true
[169] Fix | Delete
when "--nomultiline", "--noreidline"
[170] Fix | Delete
@CONF[:USE_MULTILINE] = false
[171] Fix | Delete
when "--echo"
[172] Fix | Delete
@CONF[:ECHO] = true
[173] Fix | Delete
when "--noecho"
[174] Fix | Delete
@CONF[:ECHO] = false
[175] Fix | Delete
when "--echo-on-assignment"
[176] Fix | Delete
@CONF[:ECHO_ON_ASSIGNMENT] = true
[177] Fix | Delete
when "--noecho-on-assignment"
[178] Fix | Delete
@CONF[:ECHO_ON_ASSIGNMENT] = false
[179] Fix | Delete
when "--omit-on-assignment"
[180] Fix | Delete
@CONF[:OMIT_ON_ASSIGNMENT] = true
[181] Fix | Delete
when "--noomit-on-assignment"
[182] Fix | Delete
@CONF[:OMIT_ON_ASSIGNMENT] = false
[183] Fix | Delete
when "--verbose"
[184] Fix | Delete
@CONF[:VERBOSE] = true
[185] Fix | Delete
when "--noverbose"
[186] Fix | Delete
@CONF[:VERBOSE] = false
[187] Fix | Delete
when "--colorize"
[188] Fix | Delete
@CONF[:USE_COLORIZE] = true
[189] Fix | Delete
when "--nocolorize"
[190] Fix | Delete
@CONF[:USE_COLORIZE] = false
[191] Fix | Delete
when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
[192] Fix | Delete
opt = $1 || argv.shift
[193] Fix | Delete
prompt_mode = opt.upcase.tr("-", "_").intern
[194] Fix | Delete
@CONF[:PROMPT_MODE] = prompt_mode
[195] Fix | Delete
when "--noprompt"
[196] Fix | Delete
@CONF[:PROMPT_MODE] = :NULL
[197] Fix | Delete
when "--inf-ruby-mode"
[198] Fix | Delete
@CONF[:PROMPT_MODE] = :INF_RUBY
[199] Fix | Delete
when "--sample-book-mode", "--simple-prompt"
[200] Fix | Delete
@CONF[:PROMPT_MODE] = :SIMPLE
[201] Fix | Delete
when "--tracer"
[202] Fix | Delete
@CONF[:USE_TRACER] = true
[203] Fix | Delete
when /^--back-trace-limit(?:=(.+))?/
[204] Fix | Delete
@CONF[:BACK_TRACE_LIMIT] = ($1 || argv.shift).to_i
[205] Fix | Delete
when /^--context-mode(?:=(.+))?/
[206] Fix | Delete
@CONF[:CONTEXT_MODE] = ($1 || argv.shift).to_i
[207] Fix | Delete
when "--single-irb"
[208] Fix | Delete
@CONF[:SINGLE_IRB] = true
[209] Fix | Delete
when "-v", "--version"
[210] Fix | Delete
print IRB.version, "\n"
[211] Fix | Delete
exit 0
[212] Fix | Delete
when "-h", "--help"
[213] Fix | Delete
require_relative "help"
[214] Fix | Delete
IRB.print_usage
[215] Fix | Delete
exit 0
[216] Fix | Delete
when "--"
[217] Fix | Delete
if opt = argv.shift
[218] Fix | Delete
@CONF[:SCRIPT] = opt
[219] Fix | Delete
$0 = opt
[220] Fix | Delete
end
[221] Fix | Delete
break
[222] Fix | Delete
when /^-/
[223] Fix | Delete
fail UnrecognizedSwitch, opt
[224] Fix | Delete
else
[225] Fix | Delete
@CONF[:SCRIPT] = opt
[226] Fix | Delete
$0 = opt
[227] Fix | Delete
break
[228] Fix | Delete
end
[229] Fix | Delete
end
[230] Fix | Delete
load_path.collect! do |path|
[231] Fix | Delete
/\A\.\// =~ path ? path : File.expand_path(path)
[232] Fix | Delete
end
[233] Fix | Delete
$LOAD_PATH.unshift(*load_path)
[234] Fix | Delete
[235] Fix | Delete
end
[236] Fix | Delete
[237] Fix | Delete
# running config
[238] Fix | Delete
def IRB.run_config
[239] Fix | Delete
if @CONF[:RC]
[240] Fix | Delete
begin
[241] Fix | Delete
load rc_file
[242] Fix | Delete
rescue LoadError, Errno::ENOENT
[243] Fix | Delete
rescue # StandardError, ScriptError
[244] Fix | Delete
print "load error: #{rc_file}\n"
[245] Fix | Delete
print $!.class, ": ", $!, "\n"
[246] Fix | Delete
for err in $@[0, $@.size - 2]
[247] Fix | Delete
print "\t", err, "\n"
[248] Fix | Delete
end
[249] Fix | Delete
end
[250] Fix | Delete
end
[251] Fix | Delete
end
[252] Fix | Delete
[253] Fix | Delete
IRBRC_EXT = "rc"
[254] Fix | Delete
def IRB.rc_file(ext = IRBRC_EXT)
[255] Fix | Delete
if !@CONF[:RC_NAME_GENERATOR]
[256] Fix | Delete
rc_file_generators do |rcgen|
[257] Fix | Delete
@CONF[:RC_NAME_GENERATOR] ||= rcgen
[258] Fix | Delete
if File.exist?(rcgen.call(IRBRC_EXT))
[259] Fix | Delete
@CONF[:RC_NAME_GENERATOR] = rcgen
[260] Fix | Delete
break
[261] Fix | Delete
end
[262] Fix | Delete
end
[263] Fix | Delete
end
[264] Fix | Delete
case rc_file = @CONF[:RC_NAME_GENERATOR].call(ext)
[265] Fix | Delete
when String
[266] Fix | Delete
return rc_file
[267] Fix | Delete
else
[268] Fix | Delete
fail IllegalRCNameGenerator
[269] Fix | Delete
end
[270] Fix | Delete
end
[271] Fix | Delete
[272] Fix | Delete
# enumerate possible rc-file base name generators
[273] Fix | Delete
def IRB.rc_file_generators
[274] Fix | Delete
if irbrc = ENV["IRBRC"]
[275] Fix | Delete
yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
[276] Fix | Delete
end
[277] Fix | Delete
if xdg_config_home = ENV["XDG_CONFIG_HOME"]
[278] Fix | Delete
irb_home = File.join(xdg_config_home, "irb")
[279] Fix | Delete
unless File.exist? irb_home
[280] Fix | Delete
require 'fileutils'
[281] Fix | Delete
FileUtils.mkdir_p irb_home
[282] Fix | Delete
end
[283] Fix | Delete
yield proc{|rc| irb_home + "/irb#{rc}"}
[284] Fix | Delete
end
[285] Fix | Delete
if home = ENV["HOME"]
[286] Fix | Delete
yield proc{|rc| home+"/.irb#{rc}"}
[287] Fix | Delete
end
[288] Fix | Delete
current_dir = Dir.pwd
[289] Fix | Delete
yield proc{|rc| current_dir+"/.config/irb/irb#{rc}"}
[290] Fix | Delete
yield proc{|rc| current_dir+"/.irb#{rc}"}
[291] Fix | Delete
yield proc{|rc| current_dir+"/irb#{rc.sub(/\A_?/, '.')}"}
[292] Fix | Delete
yield proc{|rc| current_dir+"/_irb#{rc}"}
[293] Fix | Delete
yield proc{|rc| current_dir+"/$irb#{rc}"}
[294] Fix | Delete
end
[295] Fix | Delete
[296] Fix | Delete
# loading modules
[297] Fix | Delete
def IRB.load_modules
[298] Fix | Delete
for m in @CONF[:LOAD_MODULES]
[299] Fix | Delete
begin
[300] Fix | Delete
require m
[301] Fix | Delete
rescue LoadError => err
[302] Fix | Delete
warn "#{err.class}: #{err}", uplevel: 0
[303] Fix | Delete
end
[304] Fix | Delete
end
[305] Fix | Delete
end
[306] Fix | Delete
[307] Fix | Delete
[308] Fix | Delete
DefaultEncodings = Struct.new(:external, :internal)
[309] Fix | Delete
class << IRB
[310] Fix | Delete
private
[311] Fix | Delete
def set_encoding(extern, intern = nil, override: true)
[312] Fix | Delete
verbose, $VERBOSE = $VERBOSE, nil
[313] Fix | Delete
Encoding.default_external = extern unless extern.nil? || extern.empty?
[314] Fix | Delete
Encoding.default_internal = intern unless intern.nil? || intern.empty?
[315] Fix | Delete
[$stdin, $stdout, $stderr].each do |io|
[316] Fix | Delete
io.set_encoding(extern, intern)
[317] Fix | Delete
end
[318] Fix | Delete
if override
[319] Fix | Delete
@CONF[:LC_MESSAGES].instance_variable_set(:@override_encoding, extern)
[320] Fix | Delete
else
[321] Fix | Delete
@CONF[:LC_MESSAGES].instance_variable_set(:@encoding, extern)
[322] Fix | Delete
end
[323] Fix | Delete
ensure
[324] Fix | Delete
$VERBOSE = verbose
[325] Fix | Delete
end
[326] Fix | Delete
end
[327] Fix | Delete
end
[328] Fix | Delete
[329] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function