Sha256: 3b6ab581aedb8b619120c11063c3545953dafe45759c81ae61fbb5f9cebf7f16
Contents?: true
Size: 957 Bytes
Versions: 1
Compression:
Stored size: 957 Bytes
Contents
require 'ripl/rc/u' module Ripl::Rc::SqueezeHistory include Ripl::Rc::U # write squeezed history def write_history return super if SqueezeHistory.disabled? @history = [U.squeeze_history(history).join("\n") + "\n"] super end # squeeze history on memory too def eval_input input return super if SqueezeHistory.disabled? history.pop if input.strip == '' || (history.size > 1 && input == history.to_a[-2]) # EditLine is really broken, to_a is needed for it super end module Imp def squeeze_history history history.to_a.inject([]){ |result, item| if result.last == item result else result << item end }.last(Ripl.config[:rc_squeeze_history_size]) end end end module Ripl::Rc::U; extend Ripl::Rc::SqueezeHistory::Imp; end Ripl::Shell.include(Ripl::Rc::SqueezeHistory) Ripl.config[:rc_squeeze_history_size] ||= 500
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ripl-rc-0.2.4 | lib/ripl/rc/squeeze_history.rb |