Class: Danger::DiffTodoFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/todoist/diff_todo_finder.rb

Overview

Identify todos in a set of diffs

Instance Method Summary collapse

Constructor Details

#initialize(keywords) ⇒ DiffTodoFinder

Returns a new instance of DiffTodoFinder.



4
5
6
# File 'lib/todoist/diff_todo_finder.rb', line 4

def initialize(keywords)
  @keywords = keywords
end

Instance Method Details

#find_diffs_containing_todos(diffs) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/todoist/diff_todo_finder.rb', line 8

def find_diffs_containing_todos(diffs)
  todos = []
  regexp = todo_regexp
  diffs.each do |diff|
    matches = diff.patch.scan(regexp)
    next if matches.empty?

    matches.each do |match|
      todos << Danger::Todo.new(diff.path, clean_todo_text(match))
    end
  end
  todos
end