module Rib::MultilineHistoryFile
Public Instance Methods
before_loop()
click to toggle source
read_history()
click to toggle source
Calls superclass method
# File lib/rib/more/multiline_history_file.rb, line 18 def read_history return super if MultilineHistoryFile.disabled? buffer = [] File.exist?(history_file_path) && history.empty? && IO.readlines(history_file_path).each{ |line| if line.end_with?( "#{config[:multiline_history_file_token]}\n") buffer << line[0... -multiline_history_file_token.size-1] + "\n" else history << (buffer.join + line).chomp buffer = [] end } end
write_history()
click to toggle source
Calls superclass method
# File lib/rib/more/multiline_history_file.rb, line 34 def write_history return super if MultilineHistoryFile.disabled? # TODO: hisotroy.map is MRI 1.9+ config[:history] = history.to_a.map{ |line| line.gsub("\n", "#{config[:multiline_history_file_token]}\n") } super end
Private Instance Methods
multiline_history_file_token()
click to toggle source
# File lib/rib/more/multiline_history_file.rb, line 46 def multiline_history_file_token config[:multiline_history_file_token] ||= ' ' end