Class: Guard::Simpleshell

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Simpleshell.



6
7
8
9
10
# File 'lib/guard/simple_shell.rb', line 6

def initialize(watchers=[], options={})
  @command = options[:command]
  @run_on_start = options[:run_on_start]
  super
end

Instance Method Details

#log(msg) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/guard/simple_shell.rb', line 28

def log(msg)
  name = @options[:name]
  output = "SHELL".color(:yellow).bright()
  output << "[" + name.color(:blue) + "]"
  output << " #{msg}"
  puts output
end

#run(command) ⇒ Object



23
24
25
26
# File 'lib/guard/simple_shell.rb', line 23

def run(command)
  log "running #{@command}"
  system @command
end

#run_on_changes(paths) ⇒ Object



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

def run_on_changes(paths)
  run @command
end

#startObject



16
17
18
# File 'lib/guard/simple_shell.rb', line 16

def start
  run @command if @run_on_start
end

#stopObject



20
21
# File 'lib/guard/simple_shell.rb', line 20

def stop
end