diff options
author | keiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-13 15:27:09 +0000 |
---|---|---|
committer | keiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-13 15:27:09 +0000 |
commit | 622b522047ea7bdb716ec87131d08400ba41e8b7 (patch) | |
tree | 44dc0e11d46e0083f3f1b0a5b1789051f2b07e13 /lib/irb/init.rb | |
parent | c56355fbdcaac7a55319f63416fcc19fbad89670 (diff) |
* bin/irb lib/irb.rb lib/irb/...: IRB 0.9.5.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb/init.rb')
-rw-r--r-- | lib/irb/init.rb | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/lib/irb/init.rb b/lib/irb/init.rb index ad53a303f8..ad46a0afdc 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -1,9 +1,9 @@ # # irb/init.rb - irb initialize module -# $Release Version: 0.9$ +# $Release Version: 0.9.5$ # $Revision$ # $Date$ -# by Keiju ISHITSUKA([email protected]) +# by Keiju ISHITSUKA([email protected]) # # -- # @@ -54,36 +54,43 @@ module IRB @CONF[:VERBOSE] = nil @CONF[:EVAL_HISTORY] = nil + @CONF[:SAVE_HISTORY] = nil @CONF[:BACK_TRACE_LIMIT] = 16 @CONF[:PROMPT] = { :NULL => { :PROMPT_I => nil, + :PROMPT_N => nil, :PROMPT_S => nil, :PROMPT_C => nil, :RETURN => "%s\n" }, :DEFAULT => { :PROMPT_I => "%N(%m):%03n:%i> ", + :PROMPT_N => "%N(%m):%03n:%i> ", :PROMPT_S => "%N(%m):%03n:%i%l ", :PROMPT_C => "%N(%m):%03n:%i* ", :RETURN => "=> %s\n" }, :CLASSIC => { :PROMPT_I => "%N(%m):%03n:%i> ", + :PROMPT_N => "%N(%m):%03n:%i> ", :PROMPT_S => "%N(%m):%03n:%i%l ", :PROMPT_C => "%N(%m):%03n:%i* ", :RETURN => "%s\n" }, :SIMPLE => { :PROMPT_I => ">> ", + :PROMPT_N => ">> ", :PROMPT_S => nil, :PROMPT_C => "?> ", :RETURN => "=> %s\n" }, :INF_RUBY => { :PROMPT_I => "%N(%m):%03n:%i> ", +# :PROMPT_N => "%N(%m):%03n:%i> ", + :PROMPT_N => nil, :PROMPT_S => nil, :PROMPT_C => nil, :RETURN => "%s\n", @@ -91,6 +98,7 @@ module IRB }, :XMP => { :PROMPT_I => nil, + :PROMPT_N => nil, :PROMPT_S => nil, :PROMPT_C => nil, :RETURN => " ==>%s\n" @@ -183,35 +191,46 @@ module IRB end end - # enumerate possible rc files - def IRB.rc_files(rc) - yield File.expand_path("~/.irb#{rc}") if ENV.key?("HOME") - yield ".irb#{rc}" - yield "irb#{rc.sub(/\A_?/, '.')}" - yield "_irb#{rc}" - yield "$irb#{rc}" - end - # running config def IRB.run_config if @CONF[:RC] - catch(:EXIT) do - rc_files("rc") do |rc| - begin - load rc - throw :EXIT - rescue LoadError, Errno::ENOENT - rescue - print "load error: #{rc}\n" - print $!.class, ": ", $!, "\n" - for err in $@[0, [email protected] - 2] - print "\t", err, "\n" - end - throw :EXIT - end + begin + load rc_file + rescue LoadError, Errno::ENOENT + rescue + print "load error: #{rc_file}\n" + print $!.class, ": ", $!, "\n" + for err in $@[0, [email protected] - 2] + print "\t", err, "\n" + end + end + end + end + + IRBRC_EXT = "rc" + def IRB.rc_file(ext = IRBRC_EXT) + if !@CONF[:RC_NAME_GENERATOR] + rc_file_generators do |rcgen| + @CONF[:RC_NAME_GENERATOR] ||= rcgen + if File.exist?(rcgen.call(IRBRC_EXT)) + @CONF[:RC_NAME_GENERATOR] = rcgen + break end end end + @CONF[:RC_NAME_GENERATOR].call ext + end + + # enumerate possible rc-file base name generators + def IRB.rc_file_generators + if home = ENV["HOME"] + yield proc{|rc| home+"/.irb#{rc}"} + end + home = Dir.pwd + yield proc{|rc| home+"/.irb#{rc}"} + yield proc{|rc| home+"/irb#{rc.sub(/\A_?/, '.')}"} + yield proc{|rc| home+"/_irb#{rc}"} + yield proc{|rc| home+"/$irb#{rc}"} end # loading modules |