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 +4 -4
- data/lib/wires/base.rb +1 -0
- data/lib/wires/base/convenience.rb +2 -2
- data/lib/wires/core_ext/numeric.rb +41 -31
- data/lib/wires/core_ext/symbol.rb +16 -7
- data/lib/wires/core_ext/time.rb +14 -4
- metadata +33 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb41c46e8299e103ed2d71b4221c33f3eff95da9
|
4
|
+
data.tar.gz: b3a0e06ef17d3291ad4afb5ade9b1391cc889967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9654a5fa03c9dfb448c07ce179b37165d8e6754e568ff758404e2d881c4ed8f7fe9f5e049a17ac89ae572c2d9986e61f8373471725ee678f45ce231fb571c06e
|
7
|
+
data.tar.gz: 98b4ae7b01efba5a6a9cf005be0f3ab4ee48569ba9e38957df8d034cc30e1073d208ad2a71436de88ae1177a4193abfda765d91aac712a5c9163fddb508e3399
|
data/lib/wires/base.rb
CHANGED
@@ -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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
39
|
+
|
32
40
|
end
|
33
|
-
|
34
|
-
|
41
|
+
end
|
42
|
+
|
43
|
+
::Numeric.prepend CoreExt::Numeric
|
44
|
+
|
35
45
|
end
|
@@ -1,11 +1,20 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
10
|
-
|
18
|
+
::Symbol.prepend CoreExt::Symbol
|
19
|
+
|
11
20
|
end
|
data/lib/wires/core_ext/time.rb
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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.
|
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-
|
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:
|
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:
|
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
|
- - ">="
|