Class: Guard::RebarEunit
Instance Method Summary collapse
- #directory_name ⇒ Object
- #handle_output(output, suite = nil) ⇒ Object
- #handle_skip_deps ⇒ Object
-
#initialize(watchers = [], options = {}) ⇒ RebarEunit
constructor
A new instance of RebarEunit.
- #run_all ⇒ Object
- #run_on_change(paths = []) ⇒ Object
- #start ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ RebarEunit
Returns a new instance of RebarEunit.
6 7 8 9 |
# File 'lib/guard/rebar-eunit.rb', line 6 def initialize(watchers = [], = {}) super [:skip_deps] = true if [:skip_deps].nil? end |
Instance Method Details
#directory_name ⇒ Object
55 56 57 |
# File 'lib/guard/rebar-eunit.rb', line 55 def directory_name "#{File.basename(Dir.pwd)}" end |
#handle_output(output, suite = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/guard/rebar-eunit.rb', line 36 def handle_output(output, suite = nil) suite = directory_name unless suite if $? == 0 Notifier.notify(suite, title: title, image: :success) UI.info output else Notifier.notify(suite, title: title, image: :failed) UI.error output end end |
#handle_skip_deps ⇒ Object
47 48 49 |
# File 'lib/guard/rebar-eunit.rb', line 47 def handle_skip_deps [:skip_deps] ? "skip_deps=true " : "" end |
#run_all ⇒ Object
15 16 17 18 19 |
# File 'lib/guard/rebar-eunit.rb', line 15 def run_all cmd = "rebar eunit #{handle_skip_deps}" UI.info "#{cmd}" handle_output(`#{cmd}`) end |
#run_on_change(paths = []) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/guard/rebar-eunit.rb', line 21 def run_on_change(paths = []) suites = [] paths.each do |path| UI.info "changed: #{path}" if suite = path.match(%r{.*?/([^.].*?)_tests?.erl$}) suites << suite[1] elsif suite = path.match(%r{.*?/([^.].*?)?.erl$}) suites << suite[1] end end cmd = "rebar eunit #{handle_skip_deps}suites=#{suites.join(",")}" UI.info "#{cmd}" handle_output(`#{cmd}`, suites.join(" ")) end |
#start ⇒ Object
11 12 13 |
# File 'lib/guard/rebar-eunit.rb', line 11 def start run_all if [:all_on_start] end |
#title ⇒ Object
51 52 53 |
# File 'lib/guard/rebar-eunit.rb', line 51 def title "Rebar EUnit: #{directory_name}" end |