Module: Ripl::Rc::SqueezeHistory

Includes:
U
Defined in:
lib/ripl/rc/squeeze_history.rb

Defined Under Namespace

Modules: Imp

Instance Method Summary collapse

Methods included from U

included

Methods included from Imp

#squeeze_history

Methods included from Ripl::Rc::StripBacktrace::Imp

#cwd, #home, #snip, #strip_backtrace

Methods included from Anchor::Imp

#short_inspect

Methods included from Color::Imp

#black, #blue, #color, #colors, #cyan, #find_color, #green, #magenta, #red, #reset, #white, #yellow

Instance Method Details

#before_loopObject



28
29
30
31
# File 'lib/ripl/rc/squeeze_history.rb', line 28

def before_loop
  return super if SqueezeHistory.disabled?
  super if history.empty?
end

#eval_input(input) ⇒ Object

squeeze history on memory too



21
22
23
24
25
26
# File 'lib/ripl/rc/squeeze_history.rb', line 21

def eval_input input
  return super if SqueezeHistory.disabled?
  history.pop if input.strip == '' ||
                (history.size > 1 && input == history[-2])
  super
end

#historyObject

avoid some complicated conditions…



8
9
10
# File 'lib/ripl/rc/squeeze_history.rb', line 8

def history
  super || (@history ||= [])
end

#write_historyObject

write squeezed history



13
14
15
16
17
18
# File 'lib/ripl/rc/squeeze_history.rb', line 13

def write_history
  return super if SqueezeHistory.disabled?
  File.open(history_file, 'w'){ |f|
    f.puts U.squeeze_history(history).join("\n")
  }
end