smparkes-watchr 0.5.7.6 → 0.5.7.7

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.
data/bin/watchr CHANGED
@@ -66,6 +66,10 @@ opts = OptionParser.new do |opts|
66
66
  end
67
67
  }
68
68
 
69
+ opts.on('-1', '--once', "Run load patterns and then exit") {
70
+ Watchr.options.once = true
71
+ }
72
+
69
73
  opts.on_tail('-h', '--help', "Print inline help") { puts opts; exit }
70
74
  opts.on_tail('-v', '--version', "Print version" ) { puts Watchr::Bin.version; exit }
71
75
 
data/lib/watchr.rb CHANGED
@@ -46,8 +46,9 @@ module Watchr
46
46
  #--
47
47
  # On first use, initialize the options struct and default option values.
48
48
  def options
49
- @options ||= Struct.new(:debug).new
49
+ @options ||= Struct.new(:debug,:once).new
50
50
  @options.debug ||= false
51
+ @options.once.nil? and @options.once = false
51
52
  @options
52
53
  end
53
54
 
@@ -126,6 +126,12 @@ module Watchr
126
126
  @watchers = {}
127
127
  ::EM.run do
128
128
  attach
129
+ if Watchr.options.once
130
+ Watchr.batches.each do |k,v|
131
+ k.deliver
132
+ end
133
+ return
134
+ end
129
135
  end
130
136
  end
131
137
  end
data/lib/watchr/script.rb CHANGED
@@ -1,5 +1,12 @@
1
1
  module Watchr
2
2
 
3
+ class << self
4
+ def batches
5
+ @batches ||= {}
6
+ end
7
+
8
+ end
9
+
3
10
  # A script object wraps a script file, and is used by a controller.
4
11
  #
5
12
  # ===== Examples
@@ -23,7 +30,9 @@ module Watchr
23
30
  end
24
31
  @timer = EM::Timer.new(0.001) do
25
32
  deliver
33
+ Watchr.batches.delete self
26
34
  end
35
+ Watchr.batches[self] = self
27
36
  @events << [ data, event ]
28
37
  end
29
38
 
@@ -52,7 +61,11 @@ module Watchr
52
61
  self.batch ||= Batch.new self
53
62
  batch.call data, event
54
63
  else
55
- action.call data, event
64
+ if action.arity == 1
65
+ action.call data
66
+ else
67
+ action.call data, event
68
+ end
56
69
  end
57
70
  end
58
71
 
data/watchr.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'smparkes-watchr'
4
- s.version = '0.5.7.6'
4
+ s.version = '0.5.7.7'
5
5
  s.summary = "Modern continious testing (flexible alternative to autotest)"
6
6
  s.description = "Modern continious testing (flexible alternative to autotest)."
7
7
  s.author = "mynyml"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smparkes-watchr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7.6
4
+ version: 0.5.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - mynyml