Class: TodoAgent::Parsers::Ruby

Inherits:
Object
  • Object
show all
Defined in:
lib/todo_agent/parsers/ruby.rb

Class Method Summary collapse

Class Method Details

.parse(file) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/todo_agent/parsers/ruby.rb', line 10

def self.parse(file)
  regex_str = TodoAgent::Parsers::RegexBuilder.regex
  regexp = Regexp.new("^\\s*##{regex_str}$", Regexp::MULTILINE | Regexp::IGNORECASE)
  comments = []

  # TODO: This logic belongs out of the specific ruby parser
  # This only matches single line.
  IO.foreach(file) do |line|
    match = regexp.match(line)
    comments << TodoAgent::Comment.new(match, file, $INPUT_LINE_NUMBER) if match
  end

  comments
end