module Chake::Readline

Public Class Methods

finish() click to toggle source
# File lib/chake/readline.rb, line 22
def finish
  history = ::Readline::HISTORY.map { |line| line }
  File.open(history_file, 'w') do |f|
    history.last(500).each do |line|
      f.puts(line)
    end
  end
end
history_file() click to toggle source
# File lib/chake/readline.rb, line 10
def history_file
  File.join(Dir.home, '.chake_history')
end
init() click to toggle source
# File lib/chake/readline.rb, line 14
def init
  return if !File.exists?(history_file)
  File.readlines(history_file).each do |line|
    @last = line.strip
    ::Readline::HISTORY.push(@last)
  end
end
readline() click to toggle source
# File lib/chake/readline.rb, line 31
def readline
  input = ::Readline.readline('$ ')
  if input && input.strip != '' && input != @last
    ::Readline::HISTORY.push(input)
  end
  input
end