Class: BoxtRubyStyleGuide::GitDiff
- Inherits:
-
Object
- Object
- BoxtRubyStyleGuide::GitDiff
- 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
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Instance Method Summary collapse
-
#all ⇒ Object
A list of the local file paths of Ruby files with committed changes.
-
#initialize(base:) ⇒ GitDiff
constructor
A new instance of GitDiff.
Constructor Details
#initialize(base:) ⇒ GitDiff
18 19 20 |
# File 'lib/boxt_ruby_style_guide/git_diff.rb', line 18 def initialize(base:) @base = base end |
Instance Attribute Details
#base ⇒ Object (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
#all ⇒ Object
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 |