mimi-messaging 0.1.1 → 0.1.2

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: 0f372a9f357c460683c5be1e6a4da12e17c628a8
4
- data.tar.gz: 4949e060f16f06515a14db225fb629d6e1b7a05d
3
+ metadata.gz: efb706ab9b5c7aabdc045daae8c0bc853ec90ee0
4
+ data.tar.gz: f2fea72a66862098269be871477f8944eee32057
5
5
  SHA512:
6
- metadata.gz: 2f03dd1c4f51d39abcaeaa6edf11f4a3d00a71f27cf504eab966e33eda20f47869f6724a23a11d7f9c708b2cb0ad3de49f49806b00ecc4b97ba9bcb9b0d27008
7
- data.tar.gz: db39cd12d196d7932e1a8f8fbb79b4bd12c949fa06b30393edeffcc0f8244992f566ffc2c79c1002cb59b1d2014ab16609d6d71dcaae62f0cfc54b27f98f4777
6
+ metadata.gz: 19175272ba5d1668275ae9393c57aeec3da1910c8cb26c7680337639d8735824396655cf5fe0d8497a92a62984f901c5a9c0cbea46c4f60aa7dcf879bede40ff
7
+ data.tar.gz: 53f9d5d8f5d5b74e96f8be48016a0ae693ba42fecd2d58550bf1ee25ee84e8cdfd711f434bae10b38c50a9442eaa0591b2da6fcfdb56aab62b2c34fcf4a09594
@@ -20,7 +20,7 @@ module Mimi
20
20
  end
21
21
 
22
22
  def canonical_name
23
- "#{type.to_s.upcase} #{request_processor.resource_name}\##{method_name}"
23
+ "#{type.to_s.upcase} #{request_processor.resource_name}/#{method_name}"
24
24
  end
25
25
 
26
26
  def params_symbolized
@@ -1,5 +1,5 @@
1
1
  module Mimi
2
2
  module Messaging
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.1.2'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,6 @@
1
+ # Install console helpers
2
+ task :console_helpers do
3
+ require_relative 'console_helpers'
4
+ end
5
+
6
+ task console: :console_helpers
@@ -0,0 +1,47 @@
1
+ # Mimi::Messaging development console helpers
2
+ #
3
+ # get 'provider.name/method' [{param1: ..., param2: ...}]
4
+ # post 'provider.name/method' [{param1: ..., param2: ...}]
5
+ # listen 'notification.name'
6
+ # broadcast 'notification.name/method' [{param1: ..., param2: ...}]
7
+ #
8
+ def message_class_for(queue_name)
9
+ message_class = Class.new(Mimi::Messaging::Message)
10
+ message_class.queue(queue_name)
11
+ message_class
12
+ end
13
+
14
+ def get(queue_and_method_name, params = {})
15
+ queue_name, method_name = queue_and_method_name.split('/')
16
+ message_class = message_class_for(queue_name)
17
+ puts "GET #{queue_name}/#{method_name}: #{params}"
18
+ ts = Time.now
19
+ result = message_class.get(method_name, params)
20
+ puts 'Completed in %.1fms' % ((Time.now - ts) * 1000.0)
21
+ result
22
+ end
23
+
24
+ def post(queue_and_method_name, params = {})
25
+ queue_name, method_name = queue_and_method_name.split('/')
26
+ message_class = message_class_for(queue_name)
27
+ puts "POST #{queue_name}/#{method_name}: #{params}"
28
+ message_class.post(method_name, params)
29
+ end
30
+
31
+ def listen(notification_name)
32
+ listener_class = Class.new(Mimi::Messaging::Listener)
33
+ listener_class.notification(notification_name)
34
+ listener_class.before do
35
+ logger.info "** #{request.canonical_name}: #{params}"
36
+ end
37
+ puts "Listener for '#{notification_name}' installed"
38
+ end
39
+
40
+ def broadcast(notification_and_method_name, params = {})
41
+ notification_name, method_name = notification_and_method_name.split('/')
42
+ notification_class = Class.new(Mimi::Messaging::Notification)
43
+ notification_class.notification(notification_name)
44
+ puts "BROADCAST #{notification_name}/#{method_name}: #{params}"
45
+ notification_class.broadcast(method_name, params)
46
+ nil
47
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimi-messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kukushkin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mimi-core
@@ -140,6 +140,8 @@ files:
140
140
  - lib/mimi/messaging/request_processor/context.rb
141
141
  - lib/mimi/messaging/request_processor/dsl.rb
142
142
  - lib/mimi/messaging/version.rb
143
+ - lib/tasks/console_ext.rake
144
+ - lib/tasks/console_helpers.rb
143
145
  - mimi-messaging.gemspec
144
146
  homepage: https://github.com/kukushkin/mimi-messaging
145
147
  licenses: