philotic 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/philotic/config/defaults.rb +1 -0
- data/lib/philotic/connection.rb +2 -2
- data/lib/philotic/message.rb +14 -0
- data/lib/philotic/version.rb +1 -1
- data/spec/philotic/message_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b524277f78a63e3afbcd2649eb0e82e9de78ffb
|
4
|
+
data.tar.gz: c4cc2b51a95698aa90a18c5cdbf83e314c5a4e2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3374f872ddc36c952277c06e20e0133b85eb342eee2d9fed8063d69b518d5f5d54f03eb134661b9ca7009514ed898a20b82a1c9ce8ce7c1a80ae1f046db8d3e3
|
7
|
+
data.tar.gz: 24db814982d903080bd8d8f2b647a962b2e530a7ed338f1914365466b23c45ac39d032d0cd47d7352e984cf2dac42433e309acd8f31ee84e722ffaa5213a1f0a
|
@@ -16,6 +16,7 @@ module Philotic
|
|
16
16
|
RABBIT_VHOST = '%2f' # '/'
|
17
17
|
RABBIT_URL = "#{RABBIT_SCHEME}://#{RABBIT_USER}:#{RABBIT_PASSWORD}@#{RABBIT_HOST}:#{RABBIT_PORT}/#{RABBIT_VHOST}"
|
18
18
|
EXCHANGE_NAME = 'philotic.headers'
|
19
|
+
EXCHANGE_TYPE = 'headers'
|
19
20
|
ROUTING_KEY = nil
|
20
21
|
PERSISTENT = false
|
21
22
|
IMMEDIATE = false
|
data/lib/philotic/connection.rb
CHANGED
@@ -104,7 +104,7 @@ module Philotic
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def exchange
|
107
|
-
@exchange ||= channel.
|
107
|
+
@exchange ||= channel.send(config.exchange_type, config.exchange_name, durable: true)
|
108
108
|
end
|
109
109
|
|
110
110
|
def set_exchange_return_handler!
|
@@ -148,7 +148,7 @@ module Philotic
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def exchange_from_config(config)
|
151
|
-
config[:exchange] ? channel.
|
151
|
+
config[:exchange] ? channel.send(self.config.exchange_type, config[:exchange], durable: true) : exchange
|
152
152
|
end
|
153
153
|
|
154
154
|
def queue_from_config(queue_name, config)
|
data/lib/philotic/message.rb
CHANGED
@@ -121,6 +121,7 @@ module Philotic
|
|
121
121
|
|
122
122
|
def _set_routables_or_payloads(type, attrs)
|
123
123
|
attrs.each do |key, value|
|
124
|
+
key = _normalize_attr_name(key)
|
124
125
|
if self.respond_to?(:"#{key}=")
|
125
126
|
send(:"#{key}=", value)
|
126
127
|
elsif _is_anonymous_message?
|
@@ -135,21 +136,34 @@ module Philotic
|
|
135
136
|
end
|
136
137
|
|
137
138
|
def _set_message_attribute_accessor(attr, value)
|
139
|
+
attr = _normalize_attr_name(attr)
|
138
140
|
_set_message_attribute_getter(attr)
|
139
141
|
_set_message_attribute_setter(attr)
|
140
142
|
self.send(:"#{attr}=", value)
|
141
143
|
end
|
142
144
|
|
143
145
|
def _set_message_attribute_getter(attr)
|
146
|
+
attr = _normalize_attr_name(attr)
|
144
147
|
self.define_singleton_method :"#{attr}" do
|
145
148
|
instance_variable_get(:"@#{attr}")
|
146
149
|
end
|
147
150
|
end
|
148
151
|
|
149
152
|
def _set_message_attribute_setter(attr)
|
153
|
+
attr = _normalize_attr_name(attr)
|
150
154
|
self.define_singleton_method :"#{attr}=" do |v|
|
151
155
|
instance_variable_set(:"@#{attr}", v)
|
152
156
|
end
|
153
157
|
end
|
158
|
+
|
159
|
+
def _normalize_attr_name(attr)
|
160
|
+
%i[_underscore_attr_name].reduce(attr) do |attr, normalizer|
|
161
|
+
send(normalizer, attr)
|
162
|
+
end.to_sym
|
163
|
+
end
|
164
|
+
def _underscore_attr_name(attr)
|
165
|
+
attr.to_s.tr('-', '_')
|
166
|
+
|
167
|
+
end
|
154
168
|
end
|
155
169
|
end
|
data/lib/philotic/version.rb
CHANGED
@@ -237,4 +237,14 @@ describe Philotic::Message do
|
|
237
237
|
end
|
238
238
|
|
239
239
|
end
|
240
|
+
|
241
|
+
|
242
|
+
describe 'hyphenated attrs' do
|
243
|
+
let(:hyphenated_attr) { 'x-hyphenated-attr' }
|
244
|
+
let(:hyphenated_attr_value) { 'foo' }
|
245
|
+
let(:message) { Class.new(Philotic::Message).new(hyphenated_attr => hyphenated_attr_value) }
|
246
|
+
specify 'translate hyphens to underscores' do
|
247
|
+
expect(message.x_hyphenated_attr).to eq hyphenated_attr_value
|
248
|
+
end
|
249
|
+
end
|
240
250
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: philotic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Keyes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|