lib/rib/more/multiline_history_file.rb in rib-0.1.0 vs lib/rib/more/multiline_history_file.rb in rib-0.9.0
- old
+ new
@@ -3,21 +3,25 @@
module Rib::MultilineHistoryFile
include Rib::Plugin
Shell.use(self)
+ # --------------- Rib API ---------------
+
def before_loop
return super if MultilineHistoryFile.disabled?
config[:multiline_history_file_token] ||= ' '
super
end
+ # --------------- Plugin API ---------------
+
def read_history
return super if MultilineHistoryFile.disabled?
buffer = []
- File.exist?(history_file) && history.empty? &&
- IO.readlines(history_file).each{ |line|
+ 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...
-config[:multiline_history_file_token].size-1] + "\n"
else
@@ -27,10 +31,10 @@
}
end
def write_history
return super if MultilineHistoryFile.disabled?
- @history = history.to_a.map{ |line|
+ config[:history] = history.to_a.map{ |line|
line.gsub("\n", "#{config[:multiline_history_file_token]}\n")
}
super
end
end