Class: RSCM::SubversionLogEntryParser

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

Constant Summary collapse

STATES =
{"M" => RevisionFile::MODIFIED, "A" => RevisionFile::ADDED, "D" => RevisionFile::DELETED}

Instance Method Summary collapse

Constructor Details

#initialize(url, path = nil) ⇒ SubversionLogEntryParser

Returns a new instance of SubversionLogEntryParser.



49
50
51
52
53
# File 'lib/rscm/scm/subversion_log_parser.rb', line 49

def initialize(url, path=nil)
  super(/^------------------------------------------------------------------------/)
  @url = url
  @path = path
end

Instance Method Details

#parse(io, skip_line_parsing = false, &line_proc) ⇒ Object



55
56
57
58
59
60
# File 'lib/rscm/scm/subversion_log_parser.rb', line 55

def parse(io, skip_line_parsing=false, &line_proc)
  # We have to trim off the last newline - it's not meant to be part of the message
  revision = super
  revision.message = revision.message[0..-2] if revision
  revision
end

#relative_path(url, path_from_root) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rscm/scm/subversion_log_parser.rb', line 62

def relative_path(url, path_from_root)
  path_from_root = path_from_root.chomp
  url_tokens = url.split('/')
  path_from_root_tokens = path_from_root.split('/')
  
  max_similar = path_from_root_tokens.length
  while(max_similar > 0)
    url = url_tokens[-max_similar..-1]
    path = path_from_root_tokens[0..max_similar-1]
    if(url == path)
      break
    end
    max_similar -= 1
  end

  if(max_similar == 0) 
    if(@path.nil? || @path == "")
      path_from_root
    else
      nil
    end
  else
    path_from_root_tokens[max_similar..-1].join("/")
  end
end