Class: RSCM::AbstractLogParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rscm/abstract_log_parser.rb

Overview

NOTE: It is recommended to use the Parser class in parser.rb as a basis for new SCM parsers

Some utilities for log-parsers TODO: make this a module and remove the attr_reader

Direct Known Subclasses

CvsLogParser

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ AbstractLogParser

Returns a new instance of AbstractLogParser.



10
11
12
# File 'lib/rscm/abstract_log_parser.rb', line 10

def initialize(io)
  @io = io
end

Instance Method Details

#convert_all_slashes_to_forward_slashes(file) ⇒ Object



29
30
31
# File 'lib/rscm/abstract_log_parser.rb', line 29

def convert_all_slashes_to_forward_slashes(file)
  file.gsub(/\\/, "/")
end

#read_until_matching_line(regexp) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rscm/abstract_log_parser.rb', line 14

def read_until_matching_line(regexp)
  return nil if @io.eof?
  result = ""
  @io.each_line do |line|
    line.gsub!(/\r\n$/, "\n")
    break if line =~ regexp
    result << line
  end
  if result.strip == ""
    read_until_matching_line(regexp) 
  else
    result
  end
end