class Rfix::File::Tracked

Constants

ID

Public Instance Methods

absolute_path() click to toggle source
# File lib/rfix/file/tracked.rb, line 20
def absolute_path
  repository.path.join(path)
end
exists?() click to toggle source
# File lib/rfix/file/tracked.rb, line 24
def exists?
  true
end
key() click to toggle source
# File lib/rfix/file/tracked.rb, line 16
def key
  absolute_path.to_s
end
lines() click to toggle source
# File lib/rfix/file/tracked.rb, line 50
def lines
  Diff.new(repository: repository, options: {
    paths: [path.to_path],
    disable_pathspec_match: true
  }).lines.lazy.map(&:new_lineno).select(&:positive?)
end
to_s() click to toggle source
# File lib/rfix/file/tracked.rb, line 32
def to_s
  "%s:%s" % [path, to_str_range]
end
to_str_range() click to toggle source
# File lib/rfix/file/tracked.rb, line 36
def to_str_range
  lines
    .to_a
    .sort
    .chunk_while { |i, j| i + 1 == j }
    .map { |a| a.length < 3 ? a : "#{a.first}-#{a.last}" }
    .join(",")
    .then { |res| res.empty? ? "-" : res }
end
to_table() click to toggle source
# File lib/rfix/file/tracked.rb, line 46
def to_table
  [path, to_str_range]
end
tracked?() click to toggle source
# File lib/rfix/file/tracked.rb, line 28
def tracked?
  true
end