Class: Perforce2Svn::Mapping::BranchMapping

Inherits:
Operation
  • Object
show all
Defined in:
lib/perforce2svn/mapping/branch_mapping.rb

Instance Attribute Summary collapse

Attributes inherited from Operation

#line_number

Instance Method Summary collapse

Constructor Details

#initialize(tok, p4_path, svn_path) ⇒ BranchMapping

Returns a new instance of BranchMapping.



8
9
10
11
12
13
# File 'lib/perforce2svn/mapping/branch_mapping.rb', line 8

def initialize(tok, p4_path, svn_path)
  super(tok)
  @p4_path = p4_path
  @svn_path = svn_path
  @path_match = /^#{@p4_path}/
end

Instance Attribute Details

#p4_pathObject (readonly)

Returns the value of attribute p4_path.



6
7
8
# File 'lib/perforce2svn/mapping/branch_mapping.rb', line 6

def p4_path
  @p4_path
end

#svn_pathObject (readonly)

Returns the value of attribute svn_path.



6
7
8
# File 'lib/perforce2svn/mapping/branch_mapping.rb', line 6

def svn_path
  @svn_path
end

Instance Method Details

#matches_perforce_path?(other_p4_path) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/perforce2svn/mapping/branch_mapping.rb', line 19

def matches_perforce_path?(other_p4_path)
  (other_p4_path =~ @path_match) != nil
end

#p4_dottedObject



15
16
17
# File 'lib/perforce2svn/mapping/branch_mapping.rb', line 15

def p4_dotted
  @p4_path + '...'
end

#to_svn_path(other_p4_path) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/perforce2svn/mapping/branch_mapping.rb', line 23

def to_svn_path(other_p4_path)
  opath = other_p4_path.gsub(p4_path, svn_path)
  opath.gsub!("%40", "@")
  opath.gsub!("%23", "#")
  opath.gsub!("%2a", "*")
  opath.gsub!("%25", "%")
  opath
end