lib/bones/annotation_extractor.rb
# Extract any annotations from the given _file_ using the regular
# expression _pattern_ provided.
#
Extract any annotations from the given _file_ using the regular
expression _pattern_ provided.
Extract any annotations from the given _file_ using the regular expression _pattern_ provided .
def extract_annotations_from( file, pattern )
    lineno = 0
    result = File.readlines(file).inject([]) do |list, line|
      lineno += 1
      next list unless m = pattern.match(line)
      next list << Annotation.new(lineno, m[1], m[2]) unless id
      text = m[2]
      if text =~ @id_rgxp
        text.gsub!(@id_rgxp) {|str| Console::ANSICode.green(str)} if HAVE_COLOR
        list << Annotation.new(lineno, m[1], text)
      end
      list
    end
    result.empty? ? {} : { file => result }
  end
def extract_annotations_from ( file , pattern ) lineno = 0 result = File . readlines ( file ) . inject ( [ ] ) do | list , line | lineno += 1 next list unless m = pattern . match ( line ) next list << Annotation . new ( lineno , m [ 1 ] , m [ 2 ] ) unless id text = m [ 2 ] if text =~ @id_rgxp text . gsub! ( @id_rgxp ) { | str | Console :: ANSICode . green ( str ) } if HAVE_COLOR list << Annotation . new ( lineno , m [ 1 ] , text ) end list end result . empty? ? { } : { file => result } end
Extract any annotations from the given _file_ using the regular
expression _pattern_ provided.
Extract any annotations from the given _file_ using the regular expression _pattern_ provided .
file
<not_specific>
pattern
<not_specific>