Sha256: 1163c8d7270819e756e30dffc5b3bfec2a22ccd079a7176c993df5faa036d35d

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 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

1 entries across 1 versions & 1 rubygems

Version Path
ripl-0.6.1 lib/ripl/history.rb