Sha256: a0aef22f5a218970dc5466ff955dac2106489890dac21b08faa0eedf52214c93

Contents?: true

Size: 547 Bytes

Versions: 4

Compression:

Stored size: 547 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 before_loop
    config[:history], @history = '~/.irb_history', []
    super
    at_exit { write_history }
    File.exists?(history_file) &&
      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
end
Ripl::Shell.send :include, Ripl::History

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ripl-0.2.3 lib/ripl/history.rb
ripl-0.2.2 lib/ripl/history.rb
ripl-0.2.1 lib/ripl/history.rb
ripl-0.2.0 lib/ripl/history.rb