guard-konacha 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ require 'childprocess'
2
+
1
3
  module Guard
2
4
  class Konacha
3
5
  class Runner
@@ -18,27 +20,19 @@ module Guard
18
20
 
19
21
  def launch_konacha(action)
20
22
  UI.info "#{action}ing Konacha", :reset => true
21
- spawn_konacha(spawn_konacha_command)
23
+ spawn_konacha
22
24
  end
23
25
 
24
26
  def kill_konacha
25
- return unless @konacha_pid
26
-
27
- Process.kill(:INT, @konacha_pid)
28
-
29
- begin
30
- unless Process.waitpid(@konacha_pid, Process::WNOHANG)
31
- Process.kill(:KILL, @konacha_pid)
32
- end
33
- rescue Errno::ECHILD
27
+ if @process
28
+ @process.stop(5)
29
+ UI.info "Konacha Stopped", :reset => true
34
30
  end
35
- UI.info "Konacha Stopped", :reset => true
36
31
  end
37
32
 
38
33
  def run(paths=[])
39
34
  UI.info "Konacha Running: #{paths.join(' ')}"
40
35
  result = run_command(konacha_command(paths))
41
- UI.info "Konacha Results: #{result}"
42
36
 
43
37
  if @options[:notification]
44
38
  last_line = result.split("\n").last
@@ -55,8 +49,9 @@ module Guard
55
49
 
56
50
  private
57
51
 
58
- def run_command(command)
59
- `#{command}`
52
+ def run_command(cmd)
53
+ puts result = `#{cmd}`
54
+ result
60
55
  end
61
56
 
62
57
  def spawn_konacha_command
@@ -78,10 +73,10 @@ module Guard
78
73
  cmd_parts.join(' ').strip
79
74
  end
80
75
 
81
- def spawn_konacha(cmd)
82
- @konacha_pid = fork do
83
- exec "#{spawn_konacha_command}"
84
- end
76
+ def spawn_konacha
77
+ @process = ChildProcess.build(spawn_konacha_command)
78
+ @process.io.inherit! if ::Guard.respond_to?(:options) && ::Guard.options && ::Guard.options[:verbose]
79
+ @process.start
85
80
  end
86
81
 
87
82
  def bundler?
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module KonachaVersion
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-konacha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
12
+ date: 2012-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard