spud 0.1.8 → 0.1.9

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: 11082937f67da737d314d222eccb34f438de26fa5d0bb94186b1f99d89d29705
4
- data.tar.gz: 4f6965f11798cb8af28f4f298954efd5ba831e8c8387ce63f642f02cd112e7c6
3
+ metadata.gz: a9b52bb3b0a406042b1c0feaf8c6952974992b1c79586eb372417c03253367db
4
+ data.tar.gz: 366ce2813f418f1b0a5795a28c73f37128ef3a82c0dff95809877ab5dca5783e
5
5
  SHA512:
6
- metadata.gz: fd4916032c22a3ea7268b38e418742fc265c7ef87c55acb2571cbfb74d7897035e2b819c945dde94c26931cd2766ef39e81cf9e5141745e26b430c096a9483d6
7
- data.tar.gz: 9667b5d3c7f3baf7b0bdce2f2886ee501e00595478b76c40b7bd3106c6d5825eae4a28f8aaae941a759ff8f7e67b35f71a08220c96bfbe252b46b8f914e684d2
6
+ metadata.gz: 1fe21ca0d2b91d02c995deb4515382e5a59ee54160bcee71af23608cb634962b3beb16c764193ee9ff46314d8f7251d5fdc40ae1a535a5646362ba208784c7a7
7
+ data.tar.gz: e7f16245115ca30d84585c5fee030e1be064dff6e38fd67196f5423501699242a132f7dab0e58885d7f6d24c54f16828960a23b7cba9e65dfc648bfe835e8f02
@@ -22,7 +22,7 @@ module Spud
22
22
  case arg
23
23
  when '-h', '--help' then [options.merge(help: true), index + 1]
24
24
  when '-v', '--version' then [options.merge(version: true), index + 1]
25
- when '-w', '--watch' then [options.merge(watches: options[:watches] + [args[index + 1]]), index + 2]
25
+ #when '-w', '--watch' then [options.merge(watches: options[:watches] + [args[index + 1]]), index + 2]
26
26
  when '--debug' then [options.merge(debug: true), index + 1]
27
27
  else raise Error, "invalid option '#{arg}'"
28
28
  end
@@ -28,10 +28,7 @@ module Spud::BuildTools
28
28
  raise Spud::Error, "invocation of '#{@name}' missing required #{arguments} #{names}"
29
29
  end
30
30
 
31
- unless key_params?
32
- RuleContext.new(@spud, @file_context).instance_exec(*args, &@block)
33
- return
34
- end
31
+ return RuleContext.new(@spud, @file_context).instance_exec(*args, &@block) unless key_params?
35
32
 
36
33
  begin
37
34
  RuleContext.new(@spud, @file_context).instance_exec(*args, **kwargs, &@block)
@@ -5,14 +5,21 @@ require_relative '../../error'
5
5
  module Spud::BuildTools
6
6
  module SpudBuild
7
7
  class RuleContext
8
+ attr_reader :__process
9
+
8
10
  def initialize(spud, file_context)
9
- @spud = spud
11
+ @__spud = spud
12
+ @__process = nil
10
13
 
11
14
  file_context.singleton_methods.each do |method_name|
12
15
  define_singleton_method(method_name, &file_context.method(method_name))
13
16
  end
14
17
  end
15
18
 
19
+ def __shell(cmd, params = {})
20
+ @__process = Spud::Shell.new(cmd, params)
21
+ end
22
+
16
23
  def sh(cmd)
17
24
  out = sh?(cmd)
18
25
  raise ShellError unless out.status.exitstatus.zero?
@@ -22,7 +29,7 @@ module Spud::BuildTools
22
29
 
23
30
  def sh?(cmd)
24
31
  puts cmd
25
- Spud::Shell.new(cmd)
32
+ __shell(cmd)
26
33
  end
27
34
 
28
35
  def shh(cmd)
@@ -33,7 +40,7 @@ module Spud::BuildTools
33
40
  end
34
41
 
35
42
  def shh?(cmd)
36
- Spud::Shell.new(cmd)
43
+ __shell(cmd)
37
44
  end
38
45
 
39
46
  def shhh(cmd)
@@ -44,11 +51,11 @@ module Spud::BuildTools
44
51
  end
45
52
 
46
53
  def shhh?(cmd)
47
- Spud::Shell.new(cmd, silent: true)
54
+ __shell(cmd, silent: true)
48
55
  end
49
56
 
50
57
  def invoke(name, *args, **kwargs)
51
- @spud.invoke(name, *args, **kwargs)
58
+ @__spud.invoke(name, *args, **kwargs)
52
59
  end
53
60
  end
54
61
  end
@@ -50,6 +50,7 @@ module Spud
50
50
  rule = rules[name.to_s]
51
51
  raise Error, "no rule found for '#{name}'" unless rule
52
52
 
53
+ thread = nil
53
54
  timestamps = {}
54
55
  loop do
55
56
  begin
@@ -60,13 +61,16 @@ module Spud
60
61
 
61
62
  if !old_timestamp || new_timestamp > old_timestamp
62
63
  timestamps[filename] = new_timestamp
63
- invoke(name, *args, **kwargs)
64
+
65
+ thread.kill if thread
66
+ thread = Thread.new { invoke(name, *args, **kwargs) }
64
67
  break
65
68
  end
66
69
  end
67
70
 
68
71
  sleep 0.1
69
72
  rescue Interrupt
73
+ thread.kill if thread
70
74
  break
71
75
  end
72
76
  end
@@ -1,3 +1,3 @@
1
1
  module Spud
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Booth