Class: Git::DiffPathStatus

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/git/diff_path_status.rb

Overview

The files and their status (e.g., added, modified, deleted) between two commits

Instance Method Summary collapse

Constructor Details

#initialize(base, from, to, path_limiter = nil) ⇒ DiffPathStatus

Returns a new instance of DiffPathStatus.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/git/diff_path_status.rb', line 9

def initialize(base, from, to, path_limiter = nil)
  # Eagerly check for invalid arguments
  [from, to].compact.each do |arg|
    raise ArgumentError, "Invalid argument: '#{arg}'" if arg.start_with?('-')
  end

  @base = base
  @from = from
  @to = to
  @path_limiter = path_limiter
  @path_status = nil
end

Instance Method Details

#each {|path, status| ... }

Iterates over each file's status.

Yields:

  • (path, status)


25
26
27
# File 'lib/git/diff_path_status.rb', line 25

def each(&)
  fetch_path_status.each(&)
end

#to_hHash<String, String>

Returns the name-status report as a Hash.

Returns:

  • (Hash<String, String>)

    A hash where keys are file paths and values are their status codes.



33
34
35
# File 'lib/git/diff_path_status.rb', line 33

def to_h
  fetch_path_status
end