|
|
@ -13,14 +13,16 @@ class StoredHistory
|
|
13
|
13
|
@history = hist_file
|
|
14
|
14
|
@src = hist_src
|
|
15
|
15
|
|
|
16
|
|
last_history = File.read @history rescue ""
|
|
17
|
|
last_history.lines.each do |line|
|
|
18
|
|
@src.push line.strip
|
|
|
16
|
@last_history = File.read(@history).lines.map &:strip rescue []
|
|
|
17
|
@last_history.each do |line|
|
|
|
18
|
@src.push line
|
|
19
|
19
|
end
|
|
20
|
20
|
|
|
21
|
21
|
at_exit do
|
|
22
|
|
puts "Writing history back to #{@history}"
|
|
23
|
|
File.write @history, @src.to_a.uniq.reduce { |x,y| "#{x}\n#{y}" }
|
|
|
22
|
unless @last_history == @src.to_a.uniq
|
|
|
23
|
puts "Writing changed history back to #{@history}"
|
|
|
24
|
File.write @history, @src.to_a.uniq.reduce { |x,y| "#{x}\n#{y}" }
|
|
|
25
|
end
|
|
24
|
26
|
end
|
|
25
|
27
|
end
|
|
26
|
28
|
end
|