module MissCleo::DiffDetector

Public Instance Methods

exclude_from_map?(file_name) click to toggle source
# File lib/miss_cleo/diff_detector.rb, line 28
def exclude_from_map?(file_name)
  # Let's add a configuration for ignored files
  file_name == "db/structure.sql"
end
lines_changed() click to toggle source
# File lib/miss_cleo/diff_detector.rb, line 4
def lines_changed
  Set.new.tap do |changed_lines|
    repo = Rugged::Repository.new '.'
    repo.index.diff.each_patch do |patch|
      file = patch.delta.old_file[:path]

      patch.each_hunk do |hunk|
        hunk.each_line do |line|
          case line.line_origin
          when :addition
            changed_lines << [file, line.new_lineno] unless exclude_from_map?(file)
          when :deletion
            changed_lines << [file, line.old_lineno] unless exclude_from_map?(file)
          when :context
            # do nothing
          end
        end
      end
    end

  end
end