Class: Guard::RuboCop

Inherits:
Plugin
  • Object
show all
Defined in:
lib/guard/rubocop.rb,
lib/guard/rubocop/runner.rb

Overview

This class gets API calls from guard and runs rubocop command via Runner. An instance of this class stays alive in a guard command session.

Defined Under Namespace

Classes: Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RuboCop

Returns a new instance of RuboCop.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/guard/rubocop.rb', line 12

def initialize(options = {})
  super

  @options = {
    all_on_start: true,
    keep_failed:  true,
    notification: :failed,
    cli: nil,
    hide_stdout: false
  }.merge(options)

  @failed_paths = []
end

Instance Attribute Details

#failed_pathsObject (readonly)

Returns the value of attribute failed_paths.



10
11
12
# File 'lib/guard/rubocop.rb', line 10

def failed_paths
  @failed_paths
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/guard/rubocop.rb', line 10

def options
  @options
end

Instance Method Details

#reloadObject



43
44
45
# File 'lib/guard/rubocop.rb', line 43

def reload
  @failed_paths = []
end

#run_allObject



30
31
32
33
# File 'lib/guard/rubocop.rb', line 30

def run_all
  UI.info 'Inspecting Ruby code style of all files'
  inspect_with_rubocop
end

#run_on_additions(paths) ⇒ Object



35
36
37
# File 'lib/guard/rubocop.rb', line 35

def run_on_additions(paths)
  run_partially(paths)
end

#run_on_modifications(paths) ⇒ Object



39
40
41
# File 'lib/guard/rubocop.rb', line 39

def run_on_modifications(paths)
  run_partially(paths)
end

#startObject



26
27
28
# File 'lib/guard/rubocop.rb', line 26

def start
  run_all if @options[:all_on_start]
end