wires 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fdeb24aaafdf868235513ef33e917af84f0b592
4
- data.tar.gz: cbc000d9911fd5e6cb76210468a7ff5e685e3f2a
3
+ metadata.gz: ba088fc39b2036139e5a89f2d89d57f76fa345c7
4
+ data.tar.gz: df9a99b434ea93b343142cae93583aac4e654128
5
5
  SHA512:
6
- metadata.gz: 32ffa931974f65688b1d3fad28f9b6700f0fea89db796a476148e9f30962c617fcc9954e7971f7cc8247da544edc281401071e4c7b5c56aa5b2c2b40af6daf0f
7
- data.tar.gz: c7ae3f0a167d127928ecce570c4f069c735f497f3803de97dde13e15ec8e8f4502190a2df58e65565ff51940d4e156fd385099cf10458264dada31bba0631455
6
+ metadata.gz: f684f5c1d7d636a9c57b2f6a65b912cfc6408a8a81f79747786705cb8248d68907f6ba6b02bb2c79d938f78431062310a0b97cd198fc755b18771167beecc073
7
+ data.tar.gz: 8b6b36cd2763e2a5a24516248cc87c510f67bf2833aa70d845745e30c346e8a32b9d8dc3f8aedff34df74a8667624e3aad25dbe1f2d90cc232e40feade372020
@@ -3,6 +3,8 @@ module Wires
3
3
 
4
4
  module Convenience
5
5
 
6
+ # @original_instance_methods =
7
+
6
8
  def on(events, channels='*', &codeblock)
7
9
  channels = [channels] unless channels.is_a? Array
8
10
  for channel in channels
@@ -25,6 +27,7 @@ module Wires
25
27
 
26
28
  def Channel(*args) Channel.new(*args) end
27
29
 
30
+
28
31
  class << self
29
32
  def prefix_methods(prefix)
30
33
 
@@ -40,6 +43,8 @@ module Wires
40
43
  remove_method thing
41
44
  end
42
45
 
46
+ # remove_method :prefix_methods
47
+
43
48
  end
44
49
  end
45
50
 
@@ -0,0 +1,49 @@
1
+
2
+ # Reopen the Time class and add the fire method to enable nifty syntax like:
3
+ # 32.minutes.from_now.fire :event
4
+ class ::Time
5
+ unless instance_methods.include? :fire
6
+ def fire(event, channel='*', **kwargs)
7
+ Wires::TimeScheduler << \
8
+ Wires::TimeSchedulerItem.new(self, event, channel, **kwargs)
9
+ end
10
+ end
11
+ end
12
+
13
+
14
+ # Reopen ActiveSupport::Duration to enable nifty syntax like:
15
+ # 32.minutes.from_now do some_stuff end
16
+ class ::ActiveSupport::Duration
17
+
18
+ unless instance_methods.include? :__original_since
19
+ alias_method :__original_since, :since
20
+ def since(*args, &block)
21
+
22
+ if block
23
+ on :time_scheduler_anon, block.object_id do |e| block.call(e) end
24
+ __original_since(*args).fire(:time_scheduler_anon,
25
+ block.object_id)
26
+ nil
27
+ else
28
+ __original_since(*args)
29
+ end
30
+ end
31
+ alias :from_now :since
32
+ end
33
+
34
+ unless instance_methods.include? :__original_ago
35
+ alias :__original_ago :ago
36
+ def ago(*args, &block)
37
+ if block
38
+ on :time_scheduler_anon, block.object_id do |e| block.call(e) end
39
+ __original_ago(*args).fire(:time_scheduler_anon,
40
+ block.object_id)
41
+ nil
42
+ else
43
+ __original_ago(*args)
44
+ end
45
+ end
46
+ alias :until :ago
47
+ end
48
+
49
+ end
data/lib/wires/hub.rb CHANGED
@@ -37,7 +37,7 @@ module Wires
37
37
  reset_neglect_procs
38
38
  reset_handler_exception_proc
39
39
 
40
- at_exit { (sleep 0.05 until dead?) unless $! }
40
+ # at_exit { (sleep 0.05 until dead?) unless $! }
41
41
 
42
42
  state_machine_init
43
43
 
data/lib/wires/time.rb CHANGED
@@ -195,60 +195,8 @@ module Wires
195
195
 
196
196
  end
197
197
 
198
- end # End Wires module.
199
-
200
- # Reopen the Time class and add the fire method to enable nifty syntax like:
201
- # 32.minutes.from_now.fire :event
202
- class Time
203
- def fire(event, channel='*', **kwargs)
204
- Wires::TimeScheduler << \
205
- Wires::TimeSchedulerItem.new(self, event, channel, **kwargs)
206
- end
207
- end
208
-
209
-
210
- # Reopen ActiveSupport::Duration to enable nifty syntax like:
211
- # 32.minutes.from_now do some_stuff end
212
- class ActiveSupport::Duration
213
-
214
- alias :__original_since :since
215
- def since(*args, &block)
216
- if block
217
- on :time_scheduler_anon, block.object_id do |e| block.call(e) end
218
- __original_since(*args).fire(:time_scheduler_anon,
219
- block.object_id)
220
- nil
221
- else
222
- __original_since(*args)
223
- end
224
- end
225
- alias :from_now :since
226
-
227
- alias :__original_ago :ago
228
- def ago(*args, &block)
229
- if block
230
- on :time_scheduler_anon, block.object_id do |e| block.call(e) end
231
- __original_ago(*args).fire(:time_scheduler_anon,
232
- block.object_id)
233
- nil
234
- else
235
- __original_ago(*args)
236
- end
237
- end
238
- alias :until :ago
239
-
240
198
  end
241
199
 
242
- module Wires
243
- module Convenience
244
-
245
- def fire_every(interval, event, channel='*', **kwargs)
246
- Wires::TimeScheduler << \
247
- Wires::TimeSchedulerItem.new(self, event, channel, **kwargs)
248
- end
249
-
250
- end
251
- end
252
200
 
253
201
  # TODO: Repeatable event sugar?
254
202
  # TODO: Tests for all new functionality
data/lib/wires.rb CHANGED
@@ -10,6 +10,7 @@ require 'wires/hub'
10
10
  require 'wires/channel'
11
11
  require 'wires/time'
12
12
 
13
+ require 'wires/core_ext'
13
14
  require 'wires/convenience'
14
15
  include Wires::Convenience # require 'wires/clean' to uninclude Convenience
15
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wires
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain
@@ -104,6 +104,7 @@ files:
104
104
  - lib/wires.rb
105
105
  - lib/wires/time.rb
106
106
  - lib/wires/hub.rb
107
+ - lib/wires/core_ext.rb
107
108
  - lib/wires/expect_type.rb
108
109
  - lib/wires/clean.rb
109
110
  - lib/wires/convenience.rb