Class: BoxtRubyStyleGuide::GitDiff

Inherits:
Object
  • Object
show all
Defined in:
lib/boxt_ruby_style_guide/git_diff.rb

Overview

Returns a list of files that have changed, as detected by ‘git-diff`

TODO: Write tests for this to ensure we’re pulling the desired diff files see: github.com/ruby-git/ruby-git

Constant Summary collapse

TEST_STATUSES =

List of Git statuses we should test See: git-scm.com/docs/git-status#_short_format

%w[M A U].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base:) ⇒ GitDiff

Returns a new instance of GitDiff.



18
19
20
# File 'lib/boxt_ruby_style_guide/git_diff.rb', line 18

def initialize(base:)
  @base = base
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



16
17
18
# File 'lib/boxt_ruby_style_guide/git_diff.rb', line 16

def base
  @base
end

Instance Method Details

#allObject

A list of the local file paths of Ruby files with committed changes.

Returns Array



26
27
28
# File 'lib/boxt_ruby_style_guide/git_diff.rb', line 26

def all
  @all ||= git.diff(base).name_status.select { |_, stat| TEST_STATUSES.include?(stat) }.keys
end