resugan 0.1.2 → 0.1.4

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: fd8a5dc134721f2feeff657ce31578f650431f66
4
- data.tar.gz: 7767063fecb01571465c205054dfe5a51d7bc7c0
3
+ metadata.gz: 16c94f13ca5e42a153322de77d1823e1989bea02
4
+ data.tar.gz: 9a9d847bc40016e0e112ed811ae7b8ed1eef4f41
5
5
  SHA512:
6
- metadata.gz: 9f20caf6056410567a1b6ea5537c2d26d13cfa22339c4cc241c9854e7bc59272c998957ad206b13b49d6f37accfb414230dc39529653616abebd44fa8459657e
7
- data.tar.gz: fa5ce6c2d39521b1a025b84d955905fb4b28d2feb2095714f9a6a38f216b237583d646667176ad0c3093542aea73afa7e562015f6638743c0a4b5f6cd74f6884
6
+ metadata.gz: 7a5aad719ad1290e86ff7943dfdc9fd85de5af47a236f2f9cf0d3854ea8dc131df6f02f5083e0a909e4cf57128b06ead7bb2bba7ce9162206ba2896e36c89c22
7
+ data.tar.gz: a7e03d9ce263b7ef90a8cfe7682d8efeadd3b1322f15d9b6f2fd5ab83ec265ec89db6807c8f566fa6a342f1c67aa918190f649d2e63703ea1cf151734bc6ee59
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Resugan
2
2
 
3
- Simple, powerful and unobstrusive observer pattern framework for ruby. This gem provides
4
- a base framework in order to build a more powerful event based system on top of it.
3
+ Simple, powerful and unobstrusive event driven architecture framework for ruby. This gem provides
4
+ a base framework in order to build a more powerful event based system on top of it. Events cuts across multiple objects and allows you to cleanly separate business logic to other cross cutting concerns like analytics and logging. Multiple events are consolidated allowing you to efficiently batch related operations together.
5
5
 
6
6
  ## Installation
7
7
 
@@ -45,6 +45,8 @@ resugan {
45
45
  }
46
46
  ```
47
47
 
48
+ Note that events don't have to be fired at the top level of the block, even objects used inside the block can invoke fire to generate an event.
49
+
48
50
  The two events should fire and should print:
49
51
 
50
52
  ```
@@ -53,10 +55,35 @@ hello! someone said hay!
53
55
  ```
54
56
 
55
57
  Note that your listener will be executed once even if an event has been fired
56
- multiple times. However params will contain the payload of both events.
58
+ multiple times. However params will contain the payload of both events. This allows you to batch together requests and efficiently dispatch them as a group.
57
59
 
58
60
  Please see spec/resugan_spec.rb for more examples and details.
59
61
 
62
+ ## namespaces
63
+
64
+ Resugan supports namespaces, allowing you to group listeners and trigger them separately
65
+
66
+
67
+ ```ruby
68
+ listener :event1, namespace: "group1" do |params|
69
+ puts "hello! event 2 has been called!"
70
+ end
71
+
72
+ listener :event1, namespace: "group2" do |params|
73
+ puts "hello! someone said hay!"
74
+ end
75
+
76
+ resugan "group1" do
77
+ fire :event1
78
+ end
79
+
80
+ resugan "group2" do
81
+ fire :event1
82
+ end
83
+ ```
84
+
85
+ Behavior is as is expected. events under group1 will only be handled by listeners under group1 and so on.
86
+
60
87
  ## Development
61
88
 
62
89
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,8 +1,16 @@
1
1
  module Resugan
2
2
  class Kernel
3
+ def self.set_default_dispatcher(dispatcher)
4
+ @default_dispatcher ||= dispatcher.new
5
+ end
6
+
7
+ def self.default_dispatcher
8
+ @default_dispatcher || Resugan::Engine::InlineDispatcher.new
9
+ end
10
+
3
11
  def self.dispatcher_for(namespace = '')
4
12
  @dispatchers = {} unless @dispatchers
5
- @dispatchers[namespace] || Resugan::Engine::InlineDispatcher.new
13
+ @dispatchers[namespace] || default_dispatcher
6
14
  end
7
15
 
8
16
  def self.register_dispatcher(dispatcher, namespace = '')
@@ -1,3 +1,3 @@
1
1
  module Resugan
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resugan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Emmanuel Dayo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-14 00:00:00.000000000 Z
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.5.1
116
+ rubygems_version: 2.4.5.1
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: simple, powerful and unobstrusive observer pattern framework for ruby