wires 0.6.1 → 0.6.2

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: f6ef896589b7b29bffcde2800b2a0205c993bf70
4
- data.tar.gz: 849f9147f51646922d9148fdae2d592dc3998fc2
3
+ metadata.gz: cb41c46e8299e103ed2d71b4221c33f3eff95da9
4
+ data.tar.gz: b3a0e06ef17d3291ad4afb5ade9b1391cc889967
5
5
  SHA512:
6
- metadata.gz: a27d75fe9e4020189e732e04e93cc6e22493390b7b28ebe616d31420a97d18e1a3c56a43b940a2030f75dfba27e396ea0762965dad59f47496bc0f2d8c40b6d9
7
- data.tar.gz: ba4092b89082a0fd4f6da1af2aa7664eca682a6017e6cb5ebaa00b7d8e8804305b6f1f26107fb2eba318807456a08353f09ca5c34b7d5feef88ed316b022adec
6
+ metadata.gz: 9654a5fa03c9dfb448c07ce179b37165d8e6754e568ff758404e2d881c4ed8f7fe9f5e049a17ac89ae572c2d9986e61f8373471725ee678f45ce231fb571c06e
7
+ data.tar.gz: 98b4ae7b01efba5a6a9cf005be0f3ab4ee48569ba9e38957df8d034cc30e1073d208ad2a71436de88ae1177a4193abfda765d91aac712a5c9163fddb508e3399
@@ -56,3 +56,4 @@ loader.call 'base/channel/sync_helper'
56
56
  loader.call 'base/time_scheduler_item'
57
57
  loader.call 'base/time_scheduler'
58
58
  loader.call 'base/convenience'
59
+ loader.call 'base/actor'
@@ -3,12 +3,12 @@ module Wires.current_network::Namespace
3
3
 
4
4
  module Convenience
5
5
 
6
- def on(events, channels=self, &codeblock)
6
+ def on(events, channels=self, **kwargs, &codeblock)
7
7
  channels = [channels] unless channels.is_a? Array
8
8
  channels.each do |channel|
9
9
  channel=Channel.new(channel) unless channel.is_a? Channel
10
10
 
11
- channel.register(*events, &codeblock)
11
+ channel.register(*events, **kwargs, &codeblock)
12
12
  end
13
13
  codeblock
14
14
  end
@@ -1,35 +1,45 @@
1
1
 
2
- # Add Numeric => Numeric time-factor converters
3
- {
4
- [:second, :seconds] => '1',
5
- [:minute, :minutes] => '60',
6
- [:hour, :hours] => '3600',
7
- [:day, :days] => '24.hours',
8
- [:week, :weeks] => '7.days',
9
- [:fortnight, :fortnights] => '2.weeks',
10
- }.each_pair do |k,v|
11
- ::Numeric.class_eval <<-CODE
12
- def #{k.last}
13
- self * #{v}
14
- end
15
- alias #{k.first.inspect} #{k.last.inspect}
16
- CODE
17
- end
18
-
19
-
20
- # Add Numeric => Time converters with implicit anonymous fire
21
- {
22
- [:from_now, :since] => '+',
23
- [:until, :ago] => '-',
24
- }.each_pair do |k,v|
25
- ::Numeric.class_eval <<-CODE
26
- def #{k.last}(time = ::Time.now, &block)
27
- if block
28
- Wires::Channel[block.object_id].register :time_scheduler_anon, &block
29
- self.#{k.last}(time).fire(:time_scheduler_anon, block.object_id)
2
+ module Wires.current_network::Namespace
3
+
4
+ module CoreExt
5
+ module Numeric
6
+
7
+ # Add Numeric => Numeric time-factor converters
8
+ {
9
+ [:second, :seconds] => 1,
10
+ [:minute, :minutes] => 60,
11
+ [:hour, :hours] => 60*60,
12
+ [:day, :days] => 60*60*24,
13
+ [:week, :weeks] => 60*60*24*7,
14
+ [:fortnight, :fortnights] => 60*60*24*7*2,
15
+ }.each_pair do |symbols, multiplier|
16
+ define_method(symbols.last) { self * multiplier }
17
+
18
+ alias_method symbols.first, symbols.last
19
+ end
20
+
21
+ # Add Numeric => Time converters with implicit anonymous fire
22
+ {
23
+ [:from_now, :since] => :+,
24
+ [:until, :ago] => :-,
25
+ }.each_pair do |symbols, operator|
26
+ channel = Channel[TimeScheduler]
27
+
28
+ define_method symbols.last do |time = ::Time.now, &block|
29
+ if block
30
+ event = Event.new block: block, type: :time_scheduler_anon
31
+ channel.register event, &block
32
+ self.send(symbols.last, time).fire(event, channel)
33
+ end
34
+ time.send operator, self
35
+ end
36
+
37
+ alias_method symbols.first, symbols.last
30
38
  end
31
- time #{v} self
39
+
32
40
  end
33
- alias #{k.first.inspect} #{k.last.inspect}
34
- CODE
41
+ end
42
+
43
+ ::Numeric.prepend CoreExt::Numeric
44
+
35
45
  end
@@ -1,11 +1,20 @@
1
1
 
2
- # Add implicit conversion of symbol into an event
3
- class ::Symbol
4
- # Create a Wires::Event from any symbol with a payload of arguments
5
- def [](*args, **kwargs, &block)
6
- Wires::Event.new(*args, **kwargs, type:self, &block)
2
+ module Wires.current_network::Namespace
3
+
4
+ module CoreExt
5
+ module Symbol
6
+
7
+ # Create a Wires::Event from any symbol with a payload of arguments
8
+ def [](*args, **kwargs, &block)
9
+ Event.new(*args, **kwargs, type:self, &block)
10
+ end
11
+
12
+ # Convert to a Wires::Event; returns an empty event with type:self
13
+ def to_wires_event; self.[]; end
14
+
15
+ end
7
16
  end
8
17
 
9
- # Convert to a Wires::Event; returns an empty event with type:self
10
- def to_wires_event; self.[]; end
18
+ ::Symbol.prepend CoreExt::Symbol
19
+
11
20
  end
@@ -1,7 +1,17 @@
1
1
 
2
- # Add Time#fire for timed firing of events
3
- class ::Time
4
- def fire(events, channel, **kwargs)
5
- Wires::TimeScheduler.add(self, events, channel, **kwargs)
2
+ module Wires.current_network::Namespace
3
+
4
+ module CoreExt
5
+ module Time
6
+
7
+ # Timed firing of events
8
+ def fire(events, channel, **kwargs)
9
+ TimeScheduler.add(self, events, channel, **kwargs)
10
+ end
11
+
12
+ end
6
13
  end
14
+
15
+ ::Time.prepend CoreExt::Time
16
+
7
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wires
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: threadlock
@@ -110,6 +110,34 @@ dependencies:
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.99'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.99'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-its
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: fivemat
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ">="
@@ -123,7 +151,7 @@ dependencies:
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
- name: fivemat
154
+ name: timecop
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
157
  - - ">="
@@ -137,7 +165,7 @@ dependencies:
137
165
  - !ruby/object:Gem::Version
138
166
  version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
- name: timecop
168
+ name: yard
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
171
  - - ">="
@@ -151,7 +179,7 @@ dependencies:
151
179
  - !ruby/object:Gem::Version
152
180
  version: '0'
153
181
  - !ruby/object:Gem::Dependency
154
- name: yard
182
+ name: yard-wires
155
183
  requirement: !ruby/object:Gem::Requirement
156
184
  requirements:
157
185
  - - ">="