Sha256: c10262f9549de4cd36cdeb329881305c34a943be39fc398c03c2408cf91b7971

Contents?: true

Size: 791 Bytes

Versions: 4

Compression:

Stored size: 791 Bytes

Contents

module Pronto
  module Git
    Patch = Struct.new(:patch, :repo) do
      extend Forwardable

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

      def additions
        stat[0]
      end

      def deletions
        stat[1]
      end

      def blame(lineno)
        repo.blame(new_file_path, 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(new_file_path)
      end

      def new_file_path
        delta.new_file[:path]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pronto-0.11.3 lib/pronto/git/patch.rb
pronto-0.11.2 lib/pronto/git/patch.rb
pronto-0.11.1 lib/pronto/git/patch.rb
pronto-0.11.0 lib/pronto/git/patch.rb