Sha256: 7a35dc6a7ac2a1419065dc0a5a7cc3ba1190d7d31326b71cfb0edf21a9138931

Contents?: true

Size: 728 Bytes

Versions: 6

Compression:

Stored size: 728 Bytes

Contents

module Pronto
  module Git
    class Patch < Struct.new(:patch, :repo)
      extend Forwardable

      def_delegators :patch, :delta, :hunks, :stat

      def additions
        stat[0]
      end

      def deletions
        stat[1]
      end

      def blame(lineno)
        repo.blame(self, lineno)
      end

      def lines
        @lines ||= begin
          hunks.flat_map do |hunk|
            hunk.lines.map { |line| Line.new(line, self, hunk) }
          end
        end
      end

      def added_lines
        lines.select(&:addition?)
      end

      def deleted_lines
        lines.select(&:deletion?)
      end

      def new_file_full_path
        repo.path.join(delta.new_file[:path])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pronto-0.4.1 lib/pronto/git/patch.rb
pronto-0.4.0 lib/pronto/git/patch.rb
pronto-0.3.3 lib/pronto/git/patch.rb
pronto-0.3.2 lib/pronto/git/patch.rb
pronto-0.3.1 lib/pronto/git/patch.rb
pronto-0.3.0 lib/pronto/git/patch.rb