Class: RailsLogConverter::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_log_converter/parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



12
13
14
# File 'lib/rails_log_converter/parser.rb', line 12

def initialize
  last_line = "not blank"
end

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



16
17
18
# File 'lib/rails_log_converter/parser.rb', line 16

def file_path
  @file_path
end

#last_lineObject

Returns the value of attribute last_line.



16
17
18
# File 'lib/rails_log_converter/parser.rb', line 16

def last_line
  @last_line
end

Class Method Details

.parse_file(file_path) ⇒ Object



4
5
6
7
8
9
# File 'lib/rails_log_converter/parser.rb', line 4

def parse_file(file_path)
  parser = self.new()
  parser.file_path = file_path
  parser.parse_file
  parser
end

Instance Method Details

#current_entryObject



18
19
20
# File 'lib/rails_log_converter/parser.rb', line 18

def current_entry
  @current_entry ||= RailsLogConverter::Entry.new()
end

#parse_fileObject



22
23
24
25
26
27
28
29
# File 'lib/rails_log_converter/parser.rb', line 22

def parse_file
  raise "File #{file_path} is missing" unless File.exists?(file_path)
  UI.puts "Parsing File #{file_path}"
  File.open(file_path, 'r').each_line do |line|
    parse_line line.dup.chomp.strip
  end
  current_entry.save unless current_entry.controller.nil?
end