class Guard::SlimLint
Attributes
all_on_start[RW]
notify_on[RW]
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
# File lib/guard/slimlint.rb, line 8 def initialize(options = {}) @notify_on = options.fetch(:notify_on, :failure) @all_on_start = options.fetch(:all_on_start, true) super end
Public Instance Methods
run_all()
click to toggle source
# File lib/guard/slimlint.rb, line 18 def run_all run end
run_on_additions(paths)
click to toggle source
# File lib/guard/slimlint.rb, line 26 def run_on_additions(paths) run(paths) end
run_on_modifications(paths)
click to toggle source
# File lib/guard/slimlint.rb, line 22 def run_on_modifications(paths) run(paths) end
start()
click to toggle source
# File lib/guard/slimlint.rb, line 14 def start run_all if all_on_start end
Private Instance Methods
check_and_notify(result)
click to toggle source
# File lib/guard/slimlint.rb, line 51 def check_and_notify(result) notify(result) if notification_allowed?(result) end
image(result)
click to toggle source
# File lib/guard/slimlint.rb, line 55 def image(result) result ? :success : :failed end
message(result)
click to toggle source
# File lib/guard/slimlint.rb, line 59 def message(result) result ? 'No slim offences' : 'Slim offences detected' end
notification_allowed?(result)
click to toggle source
# File lib/guard/slimlint.rb, line 42 def notification_allowed?(result) case notify_on when :failure then !result when :success then result when :both then true when :none then false end end
notify(result)
click to toggle source
# File lib/guard/slimlint.rb, line 63 def notify(result) Notifier.notify(message(result), title: 'Slim-lint results', image: image(result)) end
run(paths = ['.'])
click to toggle source
# File lib/guard/slimlint.rb, line 32 def run(paths = ['.']) result = system "slim-lint #{paths.join(' ')}" if result UI.info 'No Slim offences detected'.green else UI.info 'Slim offences has been detected'.red end check_and_notify(result) end