Sha256: 78f248f7efa8dd18d650816e18660d5b829d4a59ac9a0e0049cb40920154b229

Contents?: true

Size: 430 Bytes

Versions: 18

Compression:

Stored size: 430 Bytes

Contents

# frozen_string_literal: true

require "rfix/git_file"

class Rfix::TrackedFile < Rfix::GitFile
  def refresh!
    @ranges = git("--no-pager", "diff", *params, ref, path)
              .grep(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/) do
      Regexp.last_match(1).to_i...(Regexp.last_match(1).to_i + (Regexp.last_match(2) || 1).to_i)
    end
  end

  def include?(line)
    @ranges.any? { |range| range.include?(line) }
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rfix-1.0.8.pre.109 lib/rfix/tracked_file.rb
rfix-1.0.8.pre.108 lib/rfix/tracked_file.rb
rfix-1.0.7.pre.68 lib/rfix/tracked_file.rb
rfix-1.0.7.pre.67 lib/rfix/tracked_file.rb
rfix-1.0.7.pre.66 lib/rfix/tracked_file.rb
rfix-1.0.7.pre.65 lib/rfix/tracked_file.rb
rfix-1.0.7.pre.61 lib/rfix/tracked_file.rb
rfix-1.0.6.pre.60 lib/rfix/tracked_file.rb
rfix-1.0.7 lib/rfix/tracked_file.rb
rfix-1.0.5.pre.58 lib/rfix/tracked_file.rb
rfix-1.0.6 lib/rfix/tracked_file.rb
rfix-1.0.5.pre.pre.57 lib/rfix/tracked_file.rb
rfix-1.0.5 lib/rfix/tracked_file.rb
rfix-1.0.4 lib/rfix/tracked_file.rb
rfix-1.0.3 lib/rfix/tracked_file.rb
rfix-1.0.2 lib/rfix/tracked_file.rb
rfix-1.0.1 lib/rfix/tracked_file.rb
rfix-1.0.0 lib/rfix/tracked_file.rb