Sha256: c38c68707f87671a9aae528ecc886b1751fedfe8d1cf8ed09b83ff404fb99359

Contents?: true

Size: 806 Bytes

Versions: 19

Compression:

Stored size: 806 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

      private

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pronto-0.10.0 lib/pronto/git/patch.rb
pronto-0.9.5 lib/pronto/git/patch.rb
pronto-0.9.4 lib/pronto/git/patch.rb
pronto-0.9.3 lib/pronto/git/patch.rb
pronto-0.9.2 lib/pronto/git/patch.rb
pronto-0.9.1 lib/pronto/git/patch.rb
pronto-0.9.0 lib/pronto/git/patch.rb
pronto-0.8.2 lib/pronto/git/patch.rb
pronto-0.8.1 lib/pronto/git/patch.rb
pronto-0.8.0 lib/pronto/git/patch.rb
pronto-0.7.1 lib/pronto/git/patch.rb
pronto-0.7.0 lib/pronto/git/patch.rb
pronto-0.6.0 lib/pronto/git/patch.rb
pronto-0.5.3 lib/pronto/git/patch.rb
pronto-0.5.2 lib/pronto/git/patch.rb
pronto-0.5.1 lib/pronto/git/patch.rb
pronto-0.5.0 lib/pronto/git/patch.rb
pronto-0.4.3 lib/pronto/git/patch.rb
pronto-0.4.2 lib/pronto/git/patch.rb