Class: RSCM::SubversionLogParser

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

Instance Method Summary collapse

Constructor Details

#initialize(io, url, exclude_below_and_including = nil, exclude_above_and_including = nil, path = nil) ⇒ SubversionLogParser

Returns a new instance of SubversionLogParser.



10
11
12
13
14
15
# File 'lib/rscm/scm/subversion_log_parser.rb', line 10

def initialize(io, url, exclude_below_and_including=nil, exclude_above_and_including=nil, path=nil)
  @io = io
  @revision_parser = SubversionLogEntryParser.new(url, path)
  @exclude_below_and_including = exclude_below_and_including
  @exclude_above_and_including = exclude_above_and_including
end

Instance Method Details

#parse_revisions(&line_proc) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rscm/scm/subversion_log_parser.rb', line 17

def parse_revisions(&line_proc)
  # skip over the first ------
  @revision_parser.parse(@io, true, &line_proc)
  revisions = Revisions.new
  while(!@io.eof?)
    revision = @revision_parser.parse(@io, &line_proc)
    unless(revision.nil?)
      # Filter out the lower bound to avoid inclusiveness of the lower bound (see contract)
      # We're doing this instead of increasing the from_identifer with 1, since that causes an error.
      too_low = false
      too_high = false
      next if revision.time.nil?
      if(@exclude_below_and_including.is_a? Time)
        too_low = revision.time <= @exclude_below_and_including
      elsif(@exclude_below_and_including.is_a? Numeric)
        too_low = revision.identifier <= @exclude_below_and_including
      end

      if(@exclude_above_and_including.is_a? Time)
        too_high = revision.time >= @exclude_above_and_including
      elsif(@exclude_above_and_including.is_a? Numeric)
        too_high = revision.identifier >= @exclude_above_and_including
      end
      revisions.add(revision) unless too_low || too_high
    end
  end
  revisions
end