Class: Log::Analyzer::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/log-analyzer/log.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Log

Returns a new instance of Log.



3
4
5
# File 'lib/log-analyzer/log.rb', line 3

def initialize(path)
  @file = File.open(path)
end

Instance Method Details

#each_line(&block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/log-analyzer/log.rb', line 7

def each_line(&block)
  @file.each_line(separator) do |line|
    next unless md = line.scrub('').match(regexp)
    env = md.names.inject({'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest'}) do |hash, name|
            hash[name.upcase] = md[name]
            hash
          end
    block.call(ActionDispatch::Request.new(env))
  end
end