Class: Phare::Check
- Inherits:
-
Object
- Object
- Phare::Check
- Defined in:
- lib/phare/check.rb,
lib/phare/check/jscs.rb,
lib/phare/check/jshint.rb,
lib/phare/check/rubocop.rb,
lib/phare/check/scss_lint.rb
Defined Under Namespace
Classes: JSCS, JSHint, Rubocop, ScssLint
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
-
#initialize(_directory, options = {}) ⇒ Check
constructor
A new instance of Check.
- #run ⇒ Object
- #should_run? ⇒ Boolean
Constructor Details
#initialize(_directory, options = {}) ⇒ Check
Returns a new instance of Check.
5 6 7 |
# File 'lib/phare/check.rb', line 5 def initialize(_directory, = {}) @tree = Git.new(@extensions, ) end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
3 4 5 |
# File 'lib/phare/check.rb', line 3 def command @command end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/phare/check.rb', line 3 def status @status end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
3 4 5 |
# File 'lib/phare/check.rb', line 3 def tree @tree end |
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/phare/check.rb', line 9 def run if should_run? Phare.system(command) @status = Phare.last_exit_status if @status == 0 else end Phare.puts '' else @status = 0 end end |
#should_run? ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/phare/check.rb', line 27 def should_run? should_run = binary_exists? [:configuration_exists?, :arguments_exists?].each do |condition| should_run &&= send(condition) if respond_to?(condition, true) end if [:diff] # NOTE: If the tree hasn't changed or if there is no files # to check (e.g. they are all in the exclude list), # we skip the check. should_run &&= @tree.changed? && files_to_check.any? end should_run end |