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.



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

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.



12
13
14
# File 'lib/guard/rubocop.rb', line 12

def failed_paths
  @failed_paths
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/guard/rubocop.rb', line 12

def options
  @options
end

Instance Method Details

#reloadObject



45
46
47
# File 'lib/guard/rubocop.rb', line 45

def reload
  @failed_paths = []
end

#run_allObject



32
33
34
35
# File 'lib/guard/rubocop.rb', line 32

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

#run_on_additions(paths) ⇒ Object



37
38
39
# File 'lib/guard/rubocop.rb', line 37

def run_on_additions(paths)
  run_partially(paths)
end

#run_on_modifications(paths) ⇒ Object



41
42
43
# File 'lib/guard/rubocop.rb', line 41

def run_on_modifications(paths)
  run_partially(paths)
end

#startObject



28
29
30
# File 'lib/guard/rubocop.rb', line 28

def start
  run_all if @options[:all_on_start]
end