Permalink
Browse files

move read_history/write_history into core API, add guard for:

multiline_history_file for read_history too
  • Loading branch information...
godfat committed Aug 5, 2011
1 parent ce7f7a2 commit 53a175263b11e9e2bb90ae25c97cb9266d20125b
Showing with 3 additions and 7 deletions.
  1. +2 −0 lib/rib/api.rb
  2. +0 −7 lib/rib/core/history_file.rb
  3. +1 −0 lib/rib/more/multiline_history_file.rb
View
@@ -2,6 +2,7 @@
module Rib; end
module Rib::API
def before_loop
+ read_history
self
end
@@ -98,6 +99,7 @@ def format_result(result)
# Called after shell finishes looping.
def after_loop
+ write_history
self
end
end
@@ -11,13 +11,6 @@ def before_loop
config[:history_file] ||= '~/.config/rib/history.rb'
config[:history_size] ||= 500
FileUtils.mkdir_p(File.dirname(history_file))
- read_history
- super
- end
-
- def after_loop
- return super if HistoryFile.disabled?
- write_history
super
end
@@ -12,6 +12,7 @@ def before_loop
end
def read_history
+ return super if MultilineHistoryFile.disabled?
buffer = []
File.exist?(history_file) && history.empty? &&
IO.readlines(history_file).each{ |line|

0 comments on commit 53a1752

Please sign in to comment.