qwrapper 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qwrapper.rb +1 -0
- data/lib/qwrapper/message.rb +36 -0
- data/lib/qwrapper/queues/rabbitmq.rb +8 -6
- data/lib/qwrapper/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd93f9625eadb6c8e0e1be07c6cd8b6fbbfbca5
|
4
|
+
data.tar.gz: 0ba2c2ef4ae15690166701bc369fd9c04e26ecfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96ad304c4cf690a04e1093ef244f03c104aad2c1e5963996cab147b54938d3a7d87d708d64274a113d9a1fa900ca3d572c78a3e0bc08fb8e7619c781edf45f9a
|
7
|
+
data.tar.gz: a1c75746abb0ab55c960b231f0937623464ca8f6a97f3e7665d6a19a9d85afcf212314139ea15c46f7959efb81325d744d47231d94accdcac8dbec941ca9de64
|
data/lib/qwrapper.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Qwrapper
|
2
|
+
class Message
|
3
|
+
|
4
|
+
include Loggable
|
5
|
+
|
6
|
+
attr_reader :original_body, :hash
|
7
|
+
|
8
|
+
def initialize(body)
|
9
|
+
raise ArgumentError.new "Message body cannot be blank" if body.blank?
|
10
|
+
@original_body = body
|
11
|
+
begin
|
12
|
+
@hash = eval(body.to_s) rescue JSON.parse(body.to_s)
|
13
|
+
logger.info "Message evaluated: #{@hash}"
|
14
|
+
rescue => ex
|
15
|
+
logger.error "Message body cannot be evaluated: #{body}"
|
16
|
+
raise ex
|
17
|
+
end
|
18
|
+
validate!
|
19
|
+
end
|
20
|
+
|
21
|
+
def action
|
22
|
+
((hash[:action] || hash["action"])).to_sym
|
23
|
+
end
|
24
|
+
|
25
|
+
def method_missing(m, *args, &block)
|
26
|
+
hash[m.to_s] || hash[m.to_s.to_sym]
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def validate!
|
32
|
+
# TODO: Raise NotImplementedError? Client should implement their own custom error
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -61,26 +61,28 @@ module Qwrapper
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def connection
|
64
|
-
|
64
|
+
#@conn ||= begin
|
65
65
|
Bunny.new(connection_details).tap do |c|
|
66
66
|
c.start
|
67
67
|
end
|
68
|
-
end
|
68
|
+
#end
|
69
69
|
end
|
70
70
|
|
71
71
|
def connection_details
|
72
|
-
bunny_logger = logger
|
73
|
-
bunny_logger = logger.duplicate("bunny") if logger.respond_to?(:duplicate)
|
74
72
|
{
|
75
73
|
host: config[:host] || "localhost",
|
76
74
|
port: config[:port] || 5672,
|
77
|
-
logger:
|
75
|
+
logger: dup_logger,
|
78
76
|
keepalive: config[:keepalive] || true
|
79
77
|
}
|
80
78
|
end
|
81
79
|
|
80
|
+
def dup_logger
|
81
|
+
logger.respond_to?(:duplicate) ? logger.duplicate("bunny") : logger
|
82
|
+
end
|
83
|
+
|
82
84
|
end
|
83
85
|
|
84
86
|
end
|
85
87
|
|
86
|
-
end
|
88
|
+
end
|
data/lib/qwrapper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qwrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nirmit Patel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- README.md
|
139
139
|
- Rakefile
|
140
140
|
- lib/qwrapper.rb
|
141
|
+
- lib/qwrapper/message.rb
|
141
142
|
- lib/qwrapper/queues.rb
|
142
143
|
- lib/qwrapper/queues/base.rb
|
143
144
|
- lib/qwrapper/queues/rabbitmq.rb
|