Class: PreCommit::Checks::Grep
- Defined in:
- lib/pre-commit/checks/grep.rb
Direct Known Subclasses
BeforeAll, ConsoleLog, Debugger, GemfilePath, MergeConflict, Pry, RspecFocus, RubySymbolHashrockets, Tabs
Defined Under Namespace
Classes: PaternNotSet
Instance Attribute Summary
Attributes inherited from Plugin
Instance Method Summary collapse
-
#call(staged_files) ⇒ Object
general code:.
- #extra_grep ⇒ Object
-
#files_filter(staged_files) ⇒ Object
overwrite those:.
- #message ⇒ Object
- #pattern ⇒ Object
Methods inherited from Plugin
Constructor Details
This class inherits a constructor from PreCommit::Checks::Plugin
Instance Method Details
#call(staged_files) ⇒ Object
general code:
33 34 35 36 37 38 39 |
# File 'lib/pre-commit/checks/grep.rb', line 33 def call(staged_files) staged_files = files_filter(staged_files).map(&:shellescape) return if staged_files.empty? errors = `#{grep} #{pattern} #{staged_files.join(" ")}#{extra_grep}` return unless $?.success? "#{message}#{errors}" end |
#extra_grep ⇒ Object
19 20 21 |
# File 'lib/pre-commit/checks/grep.rb', line 19 def extra_grep @extra_grep or "" end |
#files_filter(staged_files) ⇒ Object
overwrite those:
15 16 17 |
# File 'lib/pre-commit/checks/grep.rb', line 15 def files_filter(staged_files) staged_files end |
#message ⇒ Object
23 24 25 |
# File 'lib/pre-commit/checks/grep.rb', line 23 def or "" end |
#pattern ⇒ Object
27 28 29 |
# File 'lib/pre-commit/checks/grep.rb', line 27 def pattern @pattern or raise PaternNotSet.new end |