Class: Perforce2Svn::Mapping::Parser

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/perforce2svn/mapping/parser.rb

Instance Method Summary collapse

Methods included from Logging

configure, log, #log

Instance Method Details

#parse!(content, live_path) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/perforce2svn/mapping/parser.rb', line 10

def parse!(content, live_path)
  raise ArgumentError, "The content must respond to 'readlines'" unless content.respond_to? :readlines

  live_path = live_path.dup
  if !live_path.nil? && live_path !~ /\/$/
    live_path << '/'
  end

  ctx = {
    :failed => false, 
    :commands => [], 
    :mappings => [],
    :svn_prefix => '',
    :live_path => live_path,
    :author => 'Perforce2Svn Migration Tool',
    :message => 'Perforce Migration'
  }

  Lexer.new(content).each do |tok|
    handle(tok, ctx)
  end
  ctx
end