Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/string_extensions.rb,
app/reporters/subversion_reporter.rb

Instance Method Summary collapse

Instance Method Details

#medializeObject



22
23
24
# File 'lib/string_extensions.rb', line 22

def medialize
  MediaCloth::wiki_to_html self
end

#to_rev_numObject



25
26
27
# File 'app/reporters/subversion_reporter.rb', line 25

def to_rev_num
  self.match(/\d+/)[0]
end

#xml_splitObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/string_extensions.rb', line 26

def xml_split
  remainder = self
  words = []
  while(md = remainder.match(/<([^>]+)(\s+[^>]+)?(>.*?<\/\1>|\/>)|[^\s<]+/m))
    word = md[0]
    remainder = md.post_match
    while word.match(/<\/#{md[1]}/) &&
          word.scan(/<#{md[1]}/).size > word.scan(/<\/#{md[1]}/).size
      m = remainder.match(/<\/#{md[1]}>/)
      word << m.pre_match << m[0]
      remainder = m.post_match
    end
    words << word
  end
  words
end