eventmapper 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/lib/eventmapper/version.rb +1 -1
- data/lib/eventmapper.rb +28 -3
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8b52b560b245651ae474b2f392a25943976cb0b
|
4
|
+
data.tar.gz: a47890521c18c9a2f6cce1245f07844cedd2962c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6954f486eb9516a907457f4b0c522e2e1c72fdc3329578016f8d260abbb5dc780f98100ef65512ddee29d065adafc85622c78be80b7d8baf67262f779c1b8a3
|
7
|
+
data.tar.gz: a8e54785cd70fa6a6c53f72db5c4a327cd75aae5c6782b4d8e374803bd9e7425b7c5a22efc87ce928e87fb53b530565c764d59e6699371a01385a3346efae1c2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# EventMapper
|
2
2
|
|
3
|
-
EventMapper is just a small event library for Ruby I'm writing for a small side project. It's pretty simple and works pretty much the way you'd expect events to work in JavaScript.
|
3
|
+
EventMapper is just a small, threaded event library for Ruby I'm writing for a small side project. It's pretty simple and works pretty much the way you'd expect events to work in JavaScript with the exception of being threaded.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -22,6 +22,9 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
class Thing
|
24
24
|
include EventMapper
|
25
|
+
|
26
|
+
# threading_disabled
|
27
|
+
# threading_enabled
|
25
28
|
end
|
26
29
|
|
27
30
|
thing = Thing.new
|
@@ -42,7 +45,7 @@ Or install it yourself as:
|
|
42
45
|
|
43
46
|
## Contributing
|
44
47
|
|
45
|
-
1. Fork it ( https://github.com/
|
48
|
+
1. Fork it ( https://github.com/C0deMaver1ck/EventMapper/fork )
|
46
49
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
50
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
51
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/eventmapper/version.rb
CHANGED
data/lib/eventmapper.rb
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'eventmapper/version'
|
2
2
|
|
3
3
|
module EventMapper
|
4
|
+
|
5
|
+
def set_event_blocking(bool)
|
6
|
+
@event_blocks = bool
|
7
|
+
end
|
8
|
+
|
9
|
+
def event_blocks?
|
10
|
+
if @event_blocks.nil?
|
11
|
+
@event_blocks = true
|
12
|
+
else
|
13
|
+
@event_blocks
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
4
17
|
def on(event, &block)
|
5
18
|
if @events.nil?
|
6
19
|
@events = { event => [block] }
|
@@ -12,13 +25,25 @@ module EventMapper
|
|
12
25
|
end
|
13
26
|
|
14
27
|
def fire(event, *args)
|
28
|
+
if @event_blocks.nil?
|
29
|
+
@event_blocks = true
|
30
|
+
end
|
31
|
+
|
15
32
|
if args.empty?
|
16
33
|
@events[event].each do |proc|
|
17
|
-
|
34
|
+
if @event_blocks
|
35
|
+
proc.call
|
36
|
+
else
|
37
|
+
Thread.new { proc.call }
|
38
|
+
end
|
18
39
|
end
|
19
40
|
else
|
20
41
|
@events[event].each do |proc|
|
21
|
-
|
42
|
+
if @event_blocks
|
43
|
+
proc.call *args
|
44
|
+
else
|
45
|
+
Thread.new { proc.call *args }
|
46
|
+
end
|
22
47
|
end
|
23
48
|
end
|
24
49
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventmapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caleb Albritton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: EventMapper is just a small event library for Ruby I'm writing for a
|
@@ -75,7 +75,7 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- .gitignore
|
78
|
+
- ".gitignore"
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
@@ -95,17 +95,17 @@ require_paths:
|
|
95
95
|
- lib
|
96
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.2.2
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: EventMapper is just a small event library
|