lib/todoist/plugin.rb in danger-todoist-1.2.3 vs lib/todoist/plugin.rb in danger-todoist-1.3.0

- old
+ new

@@ -94,11 +94,11 @@ def print_todos_per_file(file, todos) markdown("- #{file}") todos .select(&:text) - .each { |todo| markdown(" - #{todo.text}") } + .each { |todo| markdown(" - Line #{todo.line_number}: #{todo.text}") } end def call_method_for_todos(method) find_todos if @todos.nil? public_send(method, message, sticky: false) unless @todos.empty? @@ -106,12 +106,14 @@ def find_todos @todos = [] return if files_of_interest.empty? - @todos = DiffTodoFinder.new(keywords) - .find_diffs_containing_todos(diffs_of_interest) + @todos = finders + .map { |finder_class| finder_class.new(keywords) } + .map { |finder| finder.call(diffs_of_interest) } + .flatten end def keywords @keywords || DEFAULT_KEYWORDS end @@ -130,18 +132,22 @@ def diffs_of_interest files_of_interest.map do |file| diff = EmptyDiff.new begin diff = git.diff_for_file(file) - rescue + rescue NoMethodError log_unable_to_find_diff(file.inspect) end diff end end def log_unable_to_find_diff(file) markdown("* danger-todoist was unable to determine diff for \"#{file}\".") + end + + def finders + [DiffTodoFinder] end end # Null object incase a diff cannot be determined class EmptyDiff