watchable 0.0.0 → 0.0.1
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/lib/watchable.rb +7 -7
- data/test/watchable_test.rb +0 -5
- data/watchable.gemspec +1 -1
- metadata +3 -3
data/lib/watchable.rb
CHANGED
@@ -4,24 +4,24 @@ module Watchable
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def fire event, *args
|
7
|
-
watchers[event].each { |w| w
|
8
|
-
watchers[:all].each
|
7
|
+
watchers[event].each { |w| w.call *args }
|
8
|
+
watchers[:all].each { |w| w.call event, *args }
|
9
9
|
|
10
10
|
self
|
11
11
|
end
|
12
12
|
|
13
|
-
def on event, callable =
|
14
|
-
watchers[event] <<
|
13
|
+
def on event, callable = Proc.new
|
14
|
+
watchers[event] << callable
|
15
15
|
|
16
16
|
self
|
17
17
|
end
|
18
18
|
|
19
|
-
def once event, callable =
|
19
|
+
def once event, callable = Proc.new
|
20
20
|
wrapper = lambda do |*args|
|
21
21
|
off event, wrapper
|
22
|
-
|
22
|
+
callable.call *args
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
on event, wrapper
|
26
26
|
end
|
27
27
|
|
data/test/watchable_test.rb
CHANGED
data/watchable.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.test_files = `git ls-files -- test/*`.split "\n"
|
10
10
|
gem.name = "watchable"
|
11
11
|
gem.require_paths = ["lib"]
|
12
|
-
gem.version = "0.0.
|
12
|
+
gem.version = "0.0.1"
|
13
13
|
|
14
14
|
gem.add_development_dependency "minitest"
|
15
15
|
gem.add_development_dependency "mocha"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watchable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Barnette
|