Sha256: 18235deb3f9a23f496854a8decaac46f12d92368ff316291bf081155f3e7d28a

Contents?: true

Size: 603 Bytes

Versions: 14

Compression:

Stored size: 603 Bytes

Contents

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

      def parse(diff)
        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 << PseudoResource.new(Regexp.last_match[:path])
          when /^@@/
            in_patch = true
          end

          files.last.patch << line if in_patch
        end

        files
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
rubocop-git2-0.1.4 lib/rubocop/git/diff_parser.rb
cs-rubocop-git-0.1.4 lib/rubocop/git/diff_parser.rb
rubocop-git-0.1.3 lib/rubocop/git/diff_parser.rb
rubocop-git-kjanoudi-0.1.4 lib/rubocop/git/diff_parser.rb
rubocop-git-kjanoudi-0.1.3 lib/rubocop/git/diff_parser.rb
rubocop-git-kjanoudi-0.1.2 lib/rubocop/git/diff_parser.rb
rubocop-git-0.1.2 lib/rubocop/git/diff_parser.rb
rubocop-git-0.1.1 lib/rubocop/git/diff_parser.rb
rubocop-git-0.1.0 lib/rubocop/git/diff_parser.rb
rubocop-git-0.0.6 lib/rubocop/git/diff_parser.rb
rubocop-git-0.0.5 lib/rubocop/git/diff_parser.rb
rubocop-git-0.0.4 lib/rubocop/git/diff_parser.rb
rubocop-git-0.0.3 lib/rubocop/git/diff_parser.rb
rubocop-git-0.0.2 lib/rubocop/git/diff_parser.rb