Class: Guard::Reek

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/reek.rb

Overview

Guard::Reek class, it implements an guard for reek task

Constant Summary collapse

SUCCESS =
["Passed", { title: "Passed", image: :success }]
FAILED =
["Failed", { title: "Failed", image: :failed }]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(watchers = [], options = {}) ⇒ Reek

Returns a new instance of Reek.



12
13
14
15
16
17
18
19
# File 'lib/guard/reek.rb', line 12

def initialize(watchers = [], options = {})
  super
  @options = options
  @files = Dir["**/*"]
  @files.select! do |file|
    watchers.reduce(false) { |res, watcher| res || watcher.match(file) }
  end
end

Instance Attribute Details

#last_resultObject (readonly)

Returns the value of attribute last_result.



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

def last_result
  @last_result
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

.command(paths) ⇒ Object



44
45
46
# File 'lib/guard/reek.rb', line 44

def self.command paths
  "reek -n #{paths.uniq.join(' ')}"
end

.notify(result) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/guard/reek.rb', line 48

def self.notify result
  if result
    Notifier.notify(*SUCCESS)
  else
    Notifier.notify(*FAILED)
  end
end

.reek(paths) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/guard/reek.rb', line 36

def self.reek(paths)
  result = system command(paths)

  notify(result)
  @last_result = result
  result
end

Instance Method Details

#run_allObject



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

def run_all
  UI.info('Guard::Reek is running on all files')
  self.class.reek @files
end

#run_on_changes(path) ⇒ Object



31
32
33
34
# File 'lib/guard/reek.rb', line 31

def run_on_changes path
  UI.info("Guard::Reek is running on #{path.to_s}")
  self.class.reek path
end

#startObject



21
22
23
24
# File 'lib/guard/reek.rb', line 21

def start
  UI.info('Guard::Reek is starting')
  run_all
end