Sha256: f1f814abfbb9506c9938f6c204ae14fa3e3e33c8193cda35175334e6bed2adca

Contents?: true

Size: 601 Bytes

Versions: 2

Compression:

Stored size: 601 Bytes

Contents

module Ripl::History
  def history_file
    @history_file ||= File.expand_path(config[:history])
  end

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

  def get_input
    (@history << super)[-1]
  end

  def read_history
    File.exists?(history_file) && history.empty? &&
      IO.readlines(history_file).each {|e| history << e.chomp }
  end

  def write_history
    File.open(history_file, 'w') {|f| f.write Array(history).join("\n") }
  end
  def before_loop() super; read_history end
  def after_loop() super; write_history end
end
Ripl::Shell.include Ripl::History
Ripl.config[:history] = '~/.irb_history'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ripl-0.6.0 lib/ripl/history.rb
ripl-0.5.1 lib/ripl/history.rb