Method: Fitting::Log.all

Defined in:
lib/fitting/log.rb

.allObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fitting/log.rb', line 10

def self.all
  logs = []
  Dir["log/fitting*.log"].each do |file_path|
    testlog = File.read(file_path)
    testlog.split("\n").select { |f| f.include?('incoming request ') }.each do |test|
      logs.push(new(JSON.load(test.split('incoming request ')[1]), 'incoming'))
    end
    testlog.split("\n").select { |f| f.include?('outgoing request ') }.each do |test|
      logs.push(new(JSON.load(test.split('outgoing request ')[1]), 'outgoing'))
    end
  end
  logs.sort { |a, b| b.path <=> a.path }
end