Module: Ripl::Rc::MultilineHistoryFile
- Includes:
- U
- Defined in:
- lib/ripl/rc/multiline_history_file.rb
Instance Method Summary collapse
Methods included from U
Methods included from SqueezeHistory::Imp
Methods included from StripBacktrace::Imp
#cwd, #home, #snip, #strip_backtrace
Methods included from Anchor::Imp
Methods included from Color::Imp
#black, #blue, #color, #colors, #cyan, #find_color, #green, #magenta, #red, #reset, #white, #yellow
Instance Method Details
#before_loop ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ripl/rc/multiline_history_file.rb', line 15 def before_loop return super if MultilineHistoryFile.disabled? super # this would initilaize @history to [], nothing we can do here buffer = [] File.exist?(history_file) && IO.readlines(history_file).each{ |line| if line.end_with?( "#{Ripl.config[:rc_multiline_history_file_token]}\n") buffer << line[0... -Ripl.config[:rc_multiline_history_file_token].size-1] + "\n" else history << (buffer.join + line).chomp buffer = [] end } end |
#write_history ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/ripl/rc/multiline_history_file.rb', line 7 def write_history return super if MultilineHistoryFile.disabled? @history = history.to_a.map{ |line| line.gsub("\n", "#{Ripl.config[:rc_multiline_history_file_token]}\n") } super end |