io-watch 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '099aa403649b5214390198ad846a1d16819133b59b89389ef0a794641cf25c7a'
4
- data.tar.gz: e39d0a107c35541524a0288334308292d09ed241a308db8afb9871ec5e696294
3
+ metadata.gz: 0fc26487e8282e4fb61d521424ea49b98606676fb04768fbe94e5244a44b4642
4
+ data.tar.gz: '08666b566a234b2e64c49ea40ff878070d12cb53398cf3b883bff22ef1542bbb'
5
5
  SHA512:
6
- metadata.gz: 72ee830e50e5f1475017af8e812c01ae3090a88c24c8628bdd06a2e5349dd24026f2ca0aef3c6212facc4f1e42b4fb31ad515024f2368fcbe2d7cc7f48aeed1a
7
- data.tar.gz: 7c2132304930f5a1a7b403ae94ce41e8dc0993fedecb797b6e7d9fce3316b1846ecad15f8ecdaa166a360973e527155dcb87f37f7f3a809f8d3f9550bac023ac
6
+ metadata.gz: 51ee161b28baae33c5745658a77a82dd01bca7b6b350a60af90a19d38c3bbb329b00c242a81ae58134ea91445101c719f6b6b2a85013bb668390f31c52d7580c
7
+ data.tar.gz: 9224e4d78d0509c987aba237df97babd0ed6caef5cc1f7012b4151c3ac84cd81ba2f67aa473163ce542d6325cbbf79c87ffeffb53b43de2c1142d5bc4596d618
checksums.yaml.gz.sig CHANGED
Binary file
data/bin/io-watch CHANGED
@@ -12,22 +12,41 @@ if command.first =~ /TERM|INT|KILL|QUIT|HUP/
12
12
  end
13
13
 
14
14
  if split = command.index('--')
15
- roots = command.pop(split)
16
- command.pop
15
+ roots = command.shift(split)
16
+ command.shift
17
17
  else
18
18
  roots = [Dir.pwd]
19
19
  end
20
20
 
21
+ Console.debug(self, "Watching", roots: roots, command: command, signal: signal)
22
+
23
+ if command.empty?
24
+ Console.error(self, "No command given")
25
+ exit 1
26
+ end
27
+
28
+ if roots.empty?
29
+ Console.error(self, "No roots given")
30
+ exit 1
31
+ end
32
+
21
33
  monitor = IO::Watch::Monitor.new(roots)
22
34
 
23
- monitor.run do
24
- if pid
25
- Console.info(self, "Killing command...", pid: pid)
26
- Process.kill(signal, pid)
27
- Process.wait(pid)
35
+ begin
36
+ monitor.run do
37
+ if pid
38
+ Console.debug(self, "Killing command...", pid: pid)
39
+ Process.kill(signal, pid)
40
+ Process.wait(pid)
41
+ end
42
+
43
+ Console.debug(self, "Starting command...")
44
+ pid = Process.spawn(*command)
45
+ Console.debug(self, "Started command", pid: pid)
28
46
  end
29
-
30
- Console.info(self, "Starting command...")
31
- pid = Process.spawn(*command)
32
- Console.info(self, "Started command", pid: pid)
47
+ rescue Interrupt
48
+ # Ignore.
49
+ ensure
50
+ Process.kill('TERM', pid)
51
+ Process.wait(pid)
33
52
  end
@@ -27,7 +27,7 @@ class IO
27
27
  #
28
28
  # @parameter roots [Array(String)] The list of root directories to watch. Changes to these directories, and their children, recursively, will be reported.
29
29
  # @parameter latency [Float] The latency to use when watching the filesystem.
30
- def initialize(roots, latency = 0.1)
30
+ def initialize(roots, latency: nil)
31
31
  @roots = roots
32
32
  @latency = latency
33
33
  end
@@ -42,7 +42,11 @@ class IO
42
42
  # @yields {|event| ...} Yielded for each event that occurs.
43
43
  # @parameter event [Hash] The event that occurred.
44
44
  def run
45
- environment = {'IO_WATCH_LATENCY' => @latency.to_s}
45
+ environment = {}
46
+ if @latency
47
+ environment['IO_WATCH_LATENCY'] = @latency.to_s
48
+ end
49
+
46
50
  IO.pipe do |input, output|
47
51
  pid = Process.spawn(environment, self.class.command_path, *@roots, out: output)
48
52
  output.close
@@ -5,6 +5,6 @@
5
5
 
6
6
  class IO
7
7
  module Watch
8
- VERSION = '0.4.0'
8
+ VERSION = '0.5.0'
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-watch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- �!6u<J��5m�̹�D���uؖ1��ܺ��Vj.�뱪�V;���K�47 7z6h*�^Z*�q��b��Tj[�=���J�݂��|nT���/��� /̏�@BsUC����Pz�N�X.!4��;!m8 ���"�7��4��1P,�yij �+e�Nq6���54��q��ln���'��q��$����a1^�T��������y���O���>�.�,����.V�K���,������C��ص9i����!����,�jT��!V/rt��'h��:�/Ԅx�D�V%�dO�ܲ~9�Ј=<`�!���g��F
2
- [�0�4.�Fa77n���
1
+ A"�:~gI�Щ҈��W���{h1g-4(Lw~�+��9���څW�wɫ�?E�^%��5 H'��D6G5���Ϙ�e]��>���6ٯ�������������KH}Pv�mU 7�F���x��M)�0ʙ��$+������
2
+ O�$ ^�����