tilia-event 2.0.2 → 2.0.2.1

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: ebd104e4bd4fad29c5d9b324e24c1947e488411d
4
- data.tar.gz: 30025c76c470a73c763b392a9b773079ccbd3cc2
3
+ metadata.gz: dd62eda4d7ad27d38ac0646a1ed55ced5d1f7a36
4
+ data.tar.gz: a62e52f647e8e57f96cb3d71f565b14884724f05
5
5
  SHA512:
6
- metadata.gz: 4fb4120ef5c5c4c9fd815254811821f0923dd49256068cae465b331f6b36f9a5795a231203a1ddc841a19f149d8882fa287cb346db58211fc651e5a8d3dfc9c5
7
- data.tar.gz: 71dc762483506d3320b0c88a7c1d42657ab8410ff492ed0da39b4e15a6f1a5a073f39e379381a26f1aaa5e50719e656ef33951012c48075354537822108f3a8a
6
+ metadata.gz: 6ed6f9171f2a35753e2478444efde70bd8e31342038dbd482a70b134876be432d084e4f2a0a8200a50d1277c21f35e857c5c1141cd510021be286d12c3dfe21a
7
+ data.tar.gz: 2d98457d04bf88779e1275201004a1e613e7437a853392a178e6f6a046658774d958af5ceecd9cb9821b2f8e2d9316a0d604eb3eb4b2abad2862bed97b60b63a
data/.simplecov CHANGED
@@ -1,4 +1,4 @@
1
1
  SimpleCov.start do
2
- add_filter "/spec/"
2
+ add_filter "/test/"
3
3
  end
4
4
 
data/Gemfile CHANGED
@@ -1,11 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # External dependencies
4
- gem 'activesupport', '~> 4.2'
3
+ gemspec
5
4
 
6
5
  # Testing
7
6
  gem 'rake'
8
7
  gem 'minitest', '~> 5.8'
9
8
  gem 'simplecov', '~> 0.10'
10
- gem 'rubocop', '~> 0.34'
9
+ gem 'rubocop', '~> 0.36'
11
10
  gem 'yard', '~> 0.8'
@@ -1,30 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tilia-event (2.0.2.1)
5
+ activesupport (>= 4.0)
6
+
1
7
  GEM
2
8
  remote: https://rubygems.org/
3
9
  specs:
4
- activesupport (4.2.4)
10
+ activesupport (4.2.5.1)
5
11
  i18n (~> 0.7)
6
12
  json (~> 1.7, >= 1.7.7)
7
13
  minitest (~> 5.1)
8
14
  thread_safe (~> 0.3, >= 0.3.4)
9
15
  tzinfo (~> 1.1)
10
- ast (2.1.0)
11
- astrolabe (1.3.1)
12
- parser (~> 2.2)
16
+ ast (2.2.0)
13
17
  docile (1.1.5)
14
18
  i18n (0.7.0)
15
19
  json (1.8.3)
16
20
  minitest (5.8.1)
17
- parser (2.2.3.0)
18
- ast (>= 1.1, < 3.0)
21
+ parser (2.3.0.2)
22
+ ast (~> 2.2)
19
23
  powerpack (0.1.1)
20
- rainbow (2.0.0)
24
+ rainbow (2.1.0)
21
25
  rake (10.4.2)
22
- rubocop (0.34.2)
23
- astrolabe (~> 1.3)
24
- parser (>= 2.2.2.5, < 3.0)
26
+ rubocop (0.36.0)
27
+ parser (>= 2.3.0.0, < 3.0)
25
28
  powerpack (~> 0.1)
26
29
  rainbow (>= 1.99.1, < 3.0)
27
- ruby-progressbar (~> 1.4)
30
+ ruby-progressbar (~> 1.7)
28
31
  ruby-progressbar (1.7.5)
29
32
  simplecov (0.10.0)
30
33
  docile (~> 1.1.0)
@@ -40,11 +43,11 @@ PLATFORMS
40
43
  ruby
41
44
 
42
45
  DEPENDENCIES
43
- activesupport (~> 4.2)
44
46
  minitest (~> 5.8)
45
47
  rake
46
- rubocop (~> 0.34)
48
+ rubocop (~> 0.36)
47
49
  simplecov (~> 0.10)
50
+ tilia-event!
48
51
  yard (~> 0.8)
49
52
 
50
53
  BUNDLED WITH
@@ -6,11 +6,6 @@ module Tilia
6
6
  class EventEmitter
7
7
  include EventEmitterInterface
8
8
  include EventEmitterTrait
9
-
10
- # TODO: document
11
- def initialize
12
- initialize_event_emitter_trait
13
- end
14
9
  end
15
10
  end
16
11
  end
@@ -7,20 +7,20 @@ module Tilia
7
7
  module EventEmitterInterface
8
8
  # Subscribe to an event.
9
9
  #
10
- # @param [String] _event_name
11
- # @param [Proc, Method] _call_back
12
- # @param [Fixnum] _priority
10
+ # @param event_name
11
+ # @param [#call] call_back
12
+ # @param [Fixnum] priority
13
13
  # @return [void]
14
- def on(_event_name, _call_back, _priority = 100)
14
+ def on(event_name, call_back, priority = 100)
15
15
  end
16
16
 
17
17
  # Subscribe to an event exactly once.
18
18
  #
19
- # @param [String] _event_name
20
- # @param [Proc, Method] _call_back
21
- # @param [Fixnum] _priority
19
+ # @param event_name
20
+ # @param [#call] call_back
21
+ # @param [Fixnum] priority
22
22
  # @return [void]
23
- def once(_event_name, _call_back, _priority = 100)
23
+ def once(event_name, call_back, priority = 100)
24
24
  end
25
25
 
26
26
  # Emits an event.
@@ -43,11 +43,11 @@ module Tilia
43
43
  # Lastly, if there are 5 event handlers for an event. The continueCallback
44
44
  # will be called at most 4 times.
45
45
  #
46
- # @param [String] _event_name
47
- # @param [Array] _arguments
48
- # @param [Proc, Method] _continue_call_back
46
+ # @param event_name
47
+ # @param [Array] arguments
48
+ # @param [#call, nil] continue_call_back
49
49
  # @return [Boolean]
50
- def emit(_event_name, _arguments = [], _continue_call_back = nil)
50
+ def emit(event_name, arguments = [], continue_call_back = nil)
51
51
  end
52
52
 
53
53
  # Returns the list of listeners for an event.
@@ -55,9 +55,9 @@ module Tilia
55
55
  # The list is returned as an array, and the list of events are sorted by
56
56
  # their priority.
57
57
  #
58
- # @param [String] _event_name
59
- # @return [Array<Proc, Method>]
60
- def listeners(_event_name)
58
+ # @param event_name
59
+ # @return [Array<#call>]
60
+ def listeners(event_name)
61
61
  end
62
62
 
63
63
  # Removes a specific listener from an event.
@@ -65,10 +65,10 @@ module Tilia
65
65
  # If the listener could not be found, this method will return false. If it
66
66
  # was removed it will return true.
67
67
  #
68
- # @param [String] _event_name
69
- # @param [Proc, Method] _listener
68
+ # @param event_name
69
+ # @param [#call] listener
70
70
  # @return [Boolean]
71
- def remove_listener(_event_name, _listener)
71
+ def remove_listener(event_name, listener)
72
72
  end
73
73
 
74
74
  # Removes all listeners.
@@ -77,9 +77,9 @@ module Tilia
77
77
  # removed. If it is not specified, every listener for every event is
78
78
  # removed.
79
79
  #
80
- # @param [String] _event_name
80
+ # @param event_name
81
81
  # @return [void]
82
- def remove_all_listeners(_event_name = nil)
82
+ def remove_all_listeners(event_name = nil)
83
83
  end
84
84
  end
85
85
  end
@@ -8,17 +8,16 @@ module Tilia
8
8
  # Using the trait + interface allows you to add EventEmitter capabilities
9
9
  # without having to change your base-class.
10
10
  module EventEmitterTrait
11
- # The list of listeners
11
+ # Initializes the instance variables of the trait
12
12
  #
13
- # @return [Hash]
14
- attr_accessor :listeners
13
+ # Do not forget to call super when initializing classes including this
14
+ # module
15
+ def initialize(*args)
16
+ @listeners = {}
17
+ super
18
+ end
15
19
 
16
- # Subscribe to an event.
17
- #
18
- # @param [String] event_name
19
- # @param [Proc, Method] call_back
20
- # @param [Fixnum] priority
21
- # @return [void]
20
+ # (see EventEmitterInterface#on)
22
21
  def on(event_name, call_back, priority = 100)
23
22
  @listeners[event_name] ||= [false, [], []]
24
23
 
@@ -27,12 +26,7 @@ module Tilia
27
26
  @listeners[event_name][2] << call_back
28
27
  end
29
28
 
30
- # Subscribe to an event exactly once.
31
- #
32
- # @param [String] event_name
33
- # @param [Proc, Method] call_back
34
- # @param [Fixnum] priority
35
- # @return [void]
29
+ # (see EventEmitterInterface#once)
36
30
  def once(event_name, call_back, priority = 100)
37
31
  wrapper = nil
38
32
  wrapper = lambda do |*arguments|
@@ -43,30 +37,7 @@ module Tilia
43
37
  on(event_name, wrapper, priority)
44
38
  end
45
39
 
46
- # Emits an event.
47
- #
48
- # This method will return true if 0 or more listeners were succesfully
49
- # handled. false is returned if one of the events broke the event chain.
50
- #
51
- # If the continueCallBack is specified, this callback will be called every
52
- # time before the next event handler is called.
53
- #
54
- # If the continueCallback returns false, event propagation stops. This
55
- # allows you to use the eventEmitter as a means for listeners to implement
56
- # functionality in your application, and break the event loop as soon as
57
- # some condition is fulfilled.
58
- #
59
- # Note that returning false from an event subscriber breaks propagation
60
- # and returns false, but if the continue-callback stops propagation, this
61
- # is still considered a 'successful' operation and returns true.
62
- #
63
- # Lastly, if there are 5 event handlers for an event. The continueCallback
64
- # will be called at most 4 times.
65
- #
66
- # @param [String] event_name
67
- # @param [Array] arguments
68
- # @param [Proc, method] continue_call_back
69
- # @return [Boolean]
40
+ # (see EventEmitterInterface#emit)
70
41
  def emit(event_name, arguments = [], continue_call_back = nil)
71
42
  if !continue_call_back.is_a?(Proc)
72
43
 
@@ -91,13 +62,7 @@ module Tilia
91
62
  true
92
63
  end
93
64
 
94
- # Returns the list of listeners for an event.
95
- #
96
- # The list is returned as an array, and the list of events are sorted by
97
- # their priority.
98
- #
99
- # @param [String] event_name
100
- # @return [Array<Proc, Method>]
65
+ # (see EventEmitterInterface#listeners)
101
66
  def listeners(event_name)
102
67
  return [] unless @listeners.key? event_name
103
68
 
@@ -123,14 +88,7 @@ module Tilia
123
88
  @listeners[event_name][2]
124
89
  end
125
90
 
126
- # Removes a specific listener from an event.
127
- #
128
- # If the listener could not be found, this method will return false. If it
129
- # was removed it will return true.
130
- #
131
- # @param [String] event_name
132
- # @param [Proc, Method] listener
133
- # @return [Boolean]
91
+ # (see EventEmitterInterface#remove_listener)
134
92
  def remove_listener(event_name, listener)
135
93
  return false unless @listeners.key?(event_name)
136
94
 
@@ -144,26 +102,14 @@ module Tilia
144
102
  false
145
103
  end
146
104
 
147
- # Removes all listeners.
148
- #
149
- # If the eventName argument is specified, all listeners for that event are
150
- # removed. If it is not specified, every listener for every event is
151
- # removed.
152
- #
153
- # @param [String] event_name
154
- # @return [void]
105
+ # (see EventEmitterInterface#remove_all_listeners)
155
106
  def remove_all_listeners(event_name = nil)
156
- if !event_name.nil?
107
+ if event_name
157
108
  @listeners.delete(event_name)
158
109
  else
159
110
  @listeners = {}
160
111
  end
161
112
  end
162
-
163
- # TODO: document
164
- def initialize_event_emitter_trait
165
- @listeners = {}
166
- end
167
113
  end
168
114
  end
169
115
  end
@@ -14,27 +14,6 @@ module Tilia
14
14
  # The promise was rejected. The operation failed.
15
15
  REJECTED = 2
16
16
 
17
- protected
18
-
19
- # The current state of this promise.
20
- #
21
- # @return [Fixnum]
22
- attr_accessor :state
23
-
24
- # A list of subscribers. Subscribers are the callbacks that want us to let
25
- # them know if the callback was fulfilled or rejected.
26
- #
27
- # @return [Array]
28
- attr_accessor :subscribers
29
-
30
- # The result of the promise.
31
- #
32
- # If the promise was fulfilled, this will be the result value. If the
33
- # promise was rejected, this is most commonly an exception.
34
- attr_accessor :value
35
-
36
- public
37
-
38
17
  # Creates the promise.
39
18
  #
40
19
  # The passed argument is the executor. The executor is automatically
@@ -43,7 +22,7 @@ module Tilia
43
22
  # Each are callbacks that map to self.fulfill and self.reject.
44
23
  # Using the executor is optional.
45
24
  #
46
- # @param [Proc, Method] executor
25
+ # @param [#call, nil] executor
47
26
  # @return [void]
48
27
  def initialize(executor = nil)
49
28
  @state = PENDING
@@ -71,11 +50,11 @@ module Tilia
71
50
  # If either of the callbacks throw an exception, the returned promise will
72
51
  # be rejected and the exception will be passed back.
73
52
  #
74
- # @param [Proc, Method] on_fulfilled
75
- # @param [Proc, Method] on_rejected
53
+ # @param [#call, nil] on_fulfilled
54
+ # @param [#call, nil] on_rejected
76
55
  # @return [Promise]
77
56
  def then(on_fulfilled = nil, on_rejected = nil)
78
- sub_promise = self.class.new
57
+ sub_promise = Promise.new
79
58
  case @state
80
59
  when PENDING
81
60
  @subscribers << [sub_promise, on_fulfilled, on_rejected]
@@ -92,7 +71,7 @@ module Tilia
92
71
  # I would have used the word 'catch', but it's a reserved word in PHP, so
93
72
  # we're not allowed to call our function that.
94
73
  #
95
- # @param [Proc, Method] on_rejected
74
+ # @param [#call] on_rejected
96
75
  # @return [Promise]
97
76
  def error(on_rejected)
98
77
  self.then(nil, on_rejected)
@@ -169,13 +148,13 @@ module Tilia
169
148
  # rejected.
170
149
  #
171
150
  # @param [Promise] sub_promise
172
- # @param [Proc, Method] call_back
151
+ # @param [#call, nil] call_back
173
152
  # @return [void]
174
153
  def invoke_callback(sub_promise, call_back = nil)
175
154
  if call_back.is_a?(Proc) || call_back.is_a?(Method)
176
155
  begin
177
156
  result = call_back.call(@value)
178
- if result.is_a?(self.class)
157
+ if result.is_a?(Promise)
179
158
  result.then(sub_promise.method(:fulfill), sub_promise.method(:reject))
180
159
  else
181
160
  sub_promise.fulfill(result)
@@ -183,12 +162,10 @@ module Tilia
183
162
  rescue => e
184
163
  sub_promise.reject(e.to_s)
185
164
  end
165
+ elsif @state == FULFILLED
166
+ sub_promise.fulfill(@value)
186
167
  else
187
- if @state == FULFILLED
188
- sub_promise.fulfill(@value)
189
- else
190
- sub_promise.reject(@value)
191
- end
168
+ sub_promise.reject(@value)
192
169
  end
193
170
  end
194
171
  end
@@ -2,7 +2,7 @@ module Tilia
2
2
  module Event
3
3
  # This exception is thrown when the user tried to reject or fulfill a promise,
4
4
  # after either of these actions were already performed.
5
- class PromiseAlreadyResolvedException < RuntimeError
5
+ class PromiseAlreadyResolvedException < StandardError
6
6
  end
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@ module Tilia
3
3
  # This class contains the version number for this package.
4
4
  class Version
5
5
  # Full version number
6
- VERSION = '2.0.2'
6
+ VERSION = '2.0.2.1'.freeze
7
7
  end
8
8
  end
9
9
  end
@@ -11,13 +11,13 @@ module Tilia
11
11
  handler_counter += 1
12
12
  end
13
13
 
14
- ee.on('foo', bla)
15
- ee.on('foo', bla)
16
- ee.on('foo', bla)
14
+ ee.on(:foo, bla)
15
+ ee.on(:foo, bla)
16
+ ee.on(:foo, bla)
17
17
 
18
18
  continue_counter = 0
19
19
  r = ee.emit(
20
- 'foo',
20
+ :foo,
21
21
  [],
22
22
  lambda do
23
23
  continue_counter += 1
@@ -38,13 +38,13 @@ module Tilia
38
38
  handler_counter += 1
39
39
  end
40
40
 
41
- ee.on('foo', bla)
42
- ee.on('foo', bla)
43
- ee.on('foo', bla)
41
+ ee.on(:foo, bla)
42
+ ee.on(:foo, bla)
43
+ ee.on(:foo, bla)
44
44
 
45
45
  continue_counter = 0
46
46
  r = ee.emit(
47
- 'foo',
47
+ :foo,
48
48
  [],
49
49
  lambda do
50
50
  continue_counter += 1
@@ -66,13 +66,13 @@ module Tilia
66
66
  false
67
67
  end
68
68
 
69
- ee.on('foo', bla)
70
- ee.on('foo', bla)
71
- ee.on('foo', bla)
69
+ ee.on(:foo, bla)
70
+ ee.on(:foo, bla)
71
+ ee.on(:foo, bla)
72
72
 
73
73
  continue_counter = 0
74
74
  r = ee.emit(
75
- 'foo',
75
+ :foo,
76
76
  [],
77
77
  lambda do
78
78
  continue_counter += 1
@@ -12,19 +12,19 @@ module Tilia
12
12
  ee = EventEmitter.new
13
13
  callback1 = -> {}
14
14
  callback2 = -> {}
15
- ee.on('foo', callback1, 200)
16
- ee.on('foo', callback2, 100)
15
+ ee.on(:foo, callback1, 200)
16
+ ee.on(:foo, callback2, 100)
17
17
 
18
- assert_equal([callback2, callback1], ee.listeners('foo'))
18
+ assert_equal([callback2, callback1], ee.listeners(:foo))
19
19
  end
20
20
 
21
21
  def test_handle_event
22
22
  arg_result = nil
23
23
 
24
24
  ee = EventEmitter.new
25
- ee.on('foo', ->(arg) { arg_result = arg })
25
+ ee.on(:foo, ->(arg) { arg_result = arg })
26
26
 
27
- assert(ee.emit('foo', ['bar']))
27
+ assert(ee.emit(:foo, ['bar']))
28
28
  assert_equal('bar', arg_result)
29
29
  end
30
30
 
@@ -33,15 +33,15 @@ module Tilia
33
33
 
34
34
  ee = EventEmitter.new
35
35
  ee.on(
36
- 'foo',
36
+ :foo,
37
37
  lambda do |_|
38
38
  arg_result = 1
39
39
  false
40
40
  end
41
41
  )
42
- ee.on('foo', ->(_) { arg_result = 2 })
42
+ ee.on(:foo, ->(_) { arg_result = 2 })
43
43
 
44
- refute(ee.emit('foo', ['bar']))
44
+ refute(ee.emit(:foo, ['bar']))
45
45
  assert_equal(1, arg_result)
46
46
  end
47
47
 
@@ -50,14 +50,14 @@ module Tilia
50
50
 
51
51
  ee = EventEmitter.new
52
52
  ee.on(
53
- 'foo',
53
+ :foo,
54
54
  lambda do |_|
55
55
  arg_result = 1
56
56
  false
57
57
  end
58
58
  )
59
59
  ee.on(
60
- 'foo',
60
+ :foo,
61
61
  lambda do |_|
62
62
  arg_result = 2
63
63
  false
@@ -65,7 +65,7 @@ module Tilia
65
65
  1
66
66
  )
67
67
 
68
- refute(ee.emit('foo', ['bar']))
68
+ refute(ee.emit(:foo, ['bar']))
69
69
  assert_equal(2, arg_result)
70
70
  end
71
71
 
@@ -73,12 +73,12 @@ module Tilia
73
73
  result = []
74
74
  ee = EventEmitter.new
75
75
 
76
- ee.on('foo', -> { result << 'a' }, 200)
77
- ee.on('foo', -> { result << 'b' }, 50)
78
- ee.on('foo', -> { result << 'c' }, 300)
79
- ee.on('foo', -> { result << 'd' })
76
+ ee.on(:foo, -> { result << 'a' }, 200)
77
+ ee.on(:foo, -> { result << 'b' }, 50)
78
+ ee.on(:foo, -> { result << 'c' }, 300)
79
+ ee.on(:foo, -> { result << 'd' })
80
80
 
81
- ee.emit('foo')
81
+ ee.emit(:foo)
82
82
  assert_equal(%w(b d a c), result)
83
83
  end
84
84
 
@@ -89,15 +89,15 @@ module Tilia
89
89
 
90
90
  ee = EventEmitter.new
91
91
 
92
- ee.on('foo', call_back)
93
- ee.emit('foo')
92
+ ee.on(:foo, call_back)
93
+ ee.emit(:foo)
94
94
 
95
95
  assert(result)
96
96
  result = false
97
97
 
98
- assert(ee.remove_listener('foo', call_back))
98
+ assert(ee.remove_listener(:foo, call_back))
99
99
 
100
- ee.emit('foo')
100
+ ee.emit(:foo)
101
101
  refute(result)
102
102
  end
103
103
 
@@ -108,15 +108,15 @@ module Tilia
108
108
 
109
109
  ee = EventEmitter.new
110
110
 
111
- ee.on('foo', call_back)
112
- ee.emit('foo')
111
+ ee.on(:foo, call_back)
112
+ ee.emit(:foo)
113
113
 
114
114
  assert(result)
115
115
  result = false
116
116
 
117
117
  refute(ee.remove_listener('bar', call_back))
118
118
 
119
- ee.emit('foo')
119
+ ee.emit(:foo)
120
120
  assert(result)
121
121
  end
122
122
 
@@ -127,16 +127,16 @@ module Tilia
127
127
 
128
128
  ee = EventEmitter.new
129
129
 
130
- ee.on('foo', call_back)
131
- ee.emit('foo')
130
+ ee.on(:foo, call_back)
131
+ ee.emit(:foo)
132
132
 
133
133
  assert(result)
134
134
  result = false
135
135
 
136
- assert(ee.remove_listener('foo', call_back))
137
- refute(ee.remove_listener('foo', call_back))
136
+ assert(ee.remove_listener(:foo, call_back))
137
+ refute(ee.remove_listener(:foo, call_back))
138
138
 
139
- ee.emit('foo')
139
+ ee.emit(:foo)
140
140
  refute(result)
141
141
  end
142
142
 
@@ -147,15 +147,15 @@ module Tilia
147
147
 
148
148
  ee = EventEmitter.new
149
149
 
150
- ee.on('foo', call_back)
151
- ee.emit('foo')
150
+ ee.on(:foo, call_back)
151
+ ee.emit(:foo)
152
152
 
153
153
  assert(result)
154
154
  result = false
155
155
 
156
- ee.remove_all_listeners('foo')
156
+ ee.remove_all_listeners(:foo)
157
157
 
158
- ee.emit('foo')
158
+ ee.emit(:foo)
159
159
  refute(result)
160
160
  end
161
161
 
@@ -166,15 +166,15 @@ module Tilia
166
166
 
167
167
  ee = EventEmitter.new
168
168
 
169
- ee.on('foo', call_back)
170
- ee.emit('foo')
169
+ ee.on(:foo, call_back)
170
+ ee.emit(:foo)
171
171
 
172
172
  assert(result)
173
173
  result = false
174
174
 
175
175
  ee.remove_all_listeners
176
176
 
177
- ee.emit('foo')
177
+ ee.emit(:foo)
178
178
  refute(result)
179
179
  end
180
180
 
@@ -184,10 +184,10 @@ module Tilia
184
184
  call_back = -> { result += 1 }
185
185
 
186
186
  ee = EventEmitter.new
187
- ee.once('foo', call_back)
187
+ ee.once(:foo, call_back)
188
188
 
189
- ee.emit('foo')
190
- ee.emit('foo')
189
+ ee.emit(:foo)
190
+ ee.emit(:foo)
191
191
 
192
192
  assert_equal(1, result)
193
193
  end
@@ -197,14 +197,14 @@ module Tilia
197
197
 
198
198
  ee = EventEmitter.new
199
199
  ee.once(
200
- 'foo',
200
+ :foo,
201
201
  lambda do |_|
202
202
  arg_result = 1
203
203
  false
204
204
  end
205
205
  )
206
206
  ee.once(
207
- 'foo',
207
+ :foo,
208
208
  lambda do |_|
209
209
  arg_result = 2
210
210
  false
@@ -212,7 +212,7 @@ module Tilia
212
212
  1
213
213
  )
214
214
 
215
- refute(ee.emit('foo', ['bar']))
215
+ refute(ee.emit(:foo, ['bar']))
216
216
  assert_equal(2, arg_result)
217
217
  end
218
218
  end
@@ -75,8 +75,8 @@ module Tilia
75
75
 
76
76
  def test_executor_success
77
77
  real_result = ''
78
- _promise = (
79
- Promise.new(->(success, _failing) { success.call('hi') })
78
+ Promise.new(
79
+ ->(success, _failing) { success.call('hi') }
80
80
  ).then(
81
81
  ->(result) { real_result = result }
82
82
  )
@@ -86,8 +86,8 @@ module Tilia
86
86
 
87
87
  def test_executor_fail
88
88
  real_result = ''
89
- _promise = (
90
- Promise.new(->(_success, failing) { failing.call('hi') })
89
+ Promise.new(
90
+ ->(_success, failing) { failing.call('hi') }
91
91
  ).then(
92
92
  ->(_result) { real_result = 'incorrect' },
93
93
  ->(reason) { real_result = reason }
@@ -113,7 +113,7 @@ module Tilia
113
113
  promise = Promise.new
114
114
  promise.error(
115
115
  lambda do |reason|
116
- assert_equal('foo', reason)
116
+ assert_equal(:foo, reason)
117
117
  fail 'hi'
118
118
  end
119
119
  ).then(
@@ -122,7 +122,7 @@ module Tilia
122
122
  )
123
123
 
124
124
  assert_equal(0, ok)
125
- promise.reject('foo')
125
+ promise.reject(:foo)
126
126
  assert_equal(1, ok)
127
127
  end
128
128
 
@@ -148,7 +148,7 @@ module Tilia
148
148
  final_value = 0
149
149
  Promise.all([promise1, promise2]).then(
150
150
  lambda do |_value|
151
- final_value = 'foo'
151
+ final_value = :foo
152
152
  'test'
153
153
  end,
154
154
  ->(value) { final_value = value }
@@ -9,5 +9,5 @@ Gem::Specification.new do |s|
9
9
  s.email = 'tilia@jakobsack.de'
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.homepage = 'https://github.com/tilia/tilia-event'
12
- s.add_runtime_dependency 'activesupport', '~> 4.2'
12
+ s.add_runtime_dependency 'activesupport', '>= 4.0'
13
13
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilia-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Sack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.2'
26
+ version: '4.0'
27
27
  description: tilia-event is a library for lightweight event-based programming.
28
28
  email: tilia@jakobsack.de
29
29
  executables: []