Class: Guard::RebarCompile

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/rebar-compile.rb

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of RebarCompile.



6
7
8
9
# File 'lib/guard/rebar-compile.rb', line 6

def initialize(watchers = [], options = {})
  super
  options[:skip_deps] = true if options[:skip_deps].nil?
end

Instance Method Details

#directory_nameObject



49
50
51
# File 'lib/guard/rebar-compile.rb', line 49

def directory_name
  "#{File.basename(Dir.pwd)}"
end

#handle_output(output, suite = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/guard/rebar-compile.rb', line 30

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_depsObject



41
42
43
# File 'lib/guard/rebar-compile.rb', line 41

def handle_skip_deps
  options[:skip_deps] ? "skip_deps=true " : ""
end

#run_allObject



15
16
17
18
19
# File 'lib/guard/rebar-compile.rb', line 15

def run_all
  cmd = "rebar compile #{handle_skip_deps}"
  UI.info "#{cmd}"
  handle_output(`#{cmd}`)
end

#run_on_change(paths = []) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/guard/rebar-compile.rb', line 21

def run_on_change(paths = [])
  paths.each do |path|
    UI.info "changed: #{path}"
  end
  cmd = "rebar compile #{handle_skip_deps}"
  UI.info "#{cmd}"
  handle_output(`#{cmd}`)
end

#startObject



11
12
13
# File 'lib/guard/rebar-compile.rb', line 11

def start
  run_all if options[:all_on_start]
end

#titleObject



45
46
47
# File 'lib/guard/rebar-compile.rb', line 45

def title
  "Rebar Compile: #{directory_name}"
end