Class: BigBrother::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/big_brother/reader.rb

Class Method Summary collapse

Class Method Details

.lines_from_history_file(filename) ⇒ Object



2
3
4
5
# File 'lib/big_brother/reader.rb', line 2

def self.lines_from_history_file(filename)
  File.readlines(filename).map(&:strip).reject(&:empty?)
  .map { |line| line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') }
end

.move_history_fileObject



7
8
9
10
11
12
13
# File 'lib/big_brother/reader.rb', line 7

def self.move_history_file
  hist_file     = BigBrother::Settings.get("history_file")
  old_hist_file = BigBrother::Settings.get("history_file") + ".old"
  history = File.read hist_file
  File.write old_hist_file, history
  File.open(hist_file, "w") {}
end