Sha256: 84faa811db463fc24504352cdf5f821e2e4de3a4ee9181f93a631a61e7570da0

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

class RuboCop::Git::DiffParser
  def self.parse(diff)
    new.parse(diff)
  end

  def parse(diff) # rubocop:disable Metrics/MethodLength
    files    = []
    in_patch = false

    diff.each_line do |line|
      case line
      when /^diff --git/
        in_patch = false
      when %r{^\+{3} b/(?<path>[^\t\n\r]+)}
        files << RuboCop::Git::PseudoResource.new(Regexp.last_match[:path])
      when /^@@/
        in_patch = true
      end

      files.last.patch << line if in_patch
    end

    files
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-git2-0.1.6 lib/rubocop/git/diff_parser.rb
rubocop-git2-0.1.5 lib/rubocop/git/diff_parser.rb