Sha256: 5cbeba7b1b04d7d6d32ac95ec1d8bd887e9ab1d4cdc3358989a116cd4a1cb916

Contents?: true

Size: 434 Bytes

Versions: 3

Compression:

Stored size: 434 Bytes

Contents

module Danger
  # Identify inline todos in a set of diffs
  class DiffInlineTodoFinder
    def initialize(keywords)
      @keywords = keywords
    end

    def call(diffs)
      diffs.map do |diff|
        diff.patch.scan(/\+ .{3,}(#{keywords})[\s:]{1}(.+)$/).map do |match|
          Todo.new(diff.path, match[1].strip)
        end
      end.flatten
    end

    private

    def keywords
      @keywords.join("|")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danger-todoist-2.0.1 lib/todoist/diff_inline_todo_finder.rb
danger-todoist-2.0.0 lib/todoist/diff_inline_todo_finder.rb
danger-todoist-1.3.0 lib/todoist/diff_inline_todo_finder.rb