pluggaloid 1.4.0 → 1.4.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
  SHA256:
3
- metadata.gz: 076d2f155418730ea29519ce8d7281343146dab271b2db4458fbf2c6db600ef9
4
- data.tar.gz: 42e8f0dcb752dcc4535a4d7c797f99f3864c738d06cb4f55a99ec15dadb92212
3
+ metadata.gz: 670ba6d6f6ed8b67776d57d76f9954d67e3b85a65b500220230f028568024c6e
4
+ data.tar.gz: 69f51e222382308669431a9bb7d60829b930f29ed5040b0c44ea230ba71fde67
5
5
  SHA512:
6
- metadata.gz: 2b6ad3377a18ea67c24c063a1c844f098401844cb46bda2df9db4db51ca3d8e225344d4703ba90ce622b9f1dbf99245ae6fb33c4dd4cf8cf77385dac6e0be222
7
- data.tar.gz: 5e45e8b7eb9dbfd2335502ddd225cea420dfd980593ebdb1fc830840274a3d2442da05c5ca06a774a74202a0465428276b1f7a7eb8d7ad468a7af59e9765b100
6
+ metadata.gz: 960b96120d905ae85cb11248607ca0e09442298641a23e37fcc6e9a8feea2295c9b9bf56e615f93a7a3005a1f7daabf07992026fa4f597f24b371615efb20815
7
+ data.tar.gz: c2966163091558506da0a11c82f30524a169ec554c23c0ed50d970bc6ae3d080af599be3764b27439b11dd3d933408ae7db935ee6f3fd5edf3267398a0bf6db7
@@ -13,15 +13,15 @@ module Pluggaloid
13
13
  end
14
14
 
15
15
  def add(*v)
16
- rewind do |privitive|
17
- privitive + v
16
+ rewind do |primitive|
17
+ primitive + v
18
18
  end
19
19
  end
20
20
  alias_method :<<, :add
21
21
 
22
22
  def delete(*v)
23
- rewind do |privitive|
24
- privitive - v
23
+ rewind do |primitive|
24
+ primitive - v
25
25
  end
26
26
  end
27
27
 
@@ -12,5 +12,7 @@ module Pluggaloid
12
12
 
13
13
  class DuplicateListenerSlugError < Error; end
14
14
 
15
+ class UndefinedStreamIndexError < Error; end
16
+
15
17
  class UndefinedCollectionIndexError < Error; end
16
18
  end
@@ -12,9 +12,10 @@ class Pluggaloid::Subscriber < Pluggaloid::Handler
12
12
  # [tags:] Pluggaloid::HandlerTag|Array リスナのタグ
13
13
  # [&callback] コールバック
14
14
  def initialize(event, *specs, **kwrest, &callback)
15
+ raise Pluggaloid::UndefinedStreamIndexError, 'To call subscribe(), it must define prototype arguments include `Pluggaloid::STREAM\'.' unless event.stream_index
15
16
  super(event, **kwrest)
16
17
  @callback = callback
17
- @accepted_hash = @event.argument_hash(specs, @event.stream_index)
18
+ @accepted_hash = @event.argument_hash(specs, nil)
18
19
  event.add_listener(self)
19
20
  end
20
21
 
@@ -1,3 +1,3 @@
1
1
  module Pluggaloid
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
@@ -32,9 +32,33 @@ describe(Pluggaloid::Plugin) do
32
32
  assert_equal(%i[one], sum)
33
33
  end
34
34
 
35
- it "subscribe?" do
35
+ it "subscribe 2" do
36
36
  sum = []
37
37
 
38
+ Pluggaloid::Plugin.create(:event) do
39
+ defevent :increase, prototype: [Pluggaloid::STREAM, Integer]
40
+ subscribe(:increase, 1) do |v|
41
+ sum = v
42
+ end
43
+ end
44
+
45
+ eval_all_events do
46
+ Pluggaloid::Event[:increase].call([:one], 1)
47
+ Pluggaloid::Event[:increase].call([:two], 2)
48
+ end
49
+
50
+ assert_equal(%i[one], sum)
51
+ end
52
+
53
+ it "raises subscribe without definition" do
54
+ assert_raises Pluggaloid::UndefinedStreamIndexError do
55
+ Pluggaloid::Plugin.create(:event) do
56
+ subscribe(:increase, 1) { ; }
57
+ end
58
+ end
59
+ end
60
+
61
+ it "subscribe?" do
38
62
  Pluggaloid::Plugin.create(:event) do
39
63
  defevent :increase, prototype: [Integer, Pluggaloid::STREAM]
40
64
  subscribe(:increase, 1) do |v|
@@ -46,8 +70,6 @@ describe(Pluggaloid::Plugin) do
46
70
  end
47
71
 
48
72
  it "subscribe? returns always true if plugin listener exist" do
49
- sum = []
50
-
51
73
  Pluggaloid::Plugin.create(:event) do
52
74
  defevent :increase, prototype: [Integer, Pluggaloid::STREAM]
53
75
  on_increase do |i, y|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluggaloid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiaki Asai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-01 00:00:00.000000000 Z
11
+ date: 2020-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: delayer