mantle 2.2.3 → 2.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bea93772109072eac177b79107122a828e288dc
4
- data.tar.gz: 3abead22d9e5cf9718d171bbc85bb25353dcc92f
3
+ metadata.gz: 5b063e0fab15144d55d5a71c69de66fffe6c5f87
4
+ data.tar.gz: 81caadf6fb95b73451c39e3cc59a3ba211179a53
5
5
  SHA512:
6
- metadata.gz: e52e458802f5aea6809d7506fd15429b3cdb9d843f0aee5f6477cb084f4408c1e15a86d704576e636c319c8f9477895703c6a08b3f54c7722b5e851f15f773d1
7
- data.tar.gz: fd1bace5c38c680f746dcdeaf129ecc781d687a77847a98bb3790977e551c85d7601a63108790607958b02f82ce37f7cdb9422dd3a42b5a61e06ef7fc6480018
6
+ metadata.gz: a508daa877cca134a8bdedcdb656564867f2e1ed768a4db94dd5e579b3fc36c161d287a94ed799fb6dfe80392335eba8d82585cef383fe7b3598be29d23d010d
7
+ data.tar.gz: 81df67beed7ec2e8d6846cbc9765f8177a2325330d2519998f875b25690b89e31411d487a1d1b9f17629bcc9de32537e1459f14ea035d624473e796c1794a41e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 2.2.4
2
+ -----------
3
+
4
+ - Add `whoami` to mantle config so an app can tag published messages
5
+ - Add `message_source` as a `__MANTLE__` payload so consumers can identify sender
6
+
1
7
  2.2.3
2
8
  -----------
3
9
 
@@ -2,7 +2,8 @@ module Mantle
2
2
  class Configuration
3
3
  attr_accessor :message_bus_redis,
4
4
  :logger,
5
- :redis_namespace
5
+ :redis_namespace,
6
+ :whoami
6
7
 
7
8
  attr_reader :message_handlers
8
9
 
@@ -10,6 +10,7 @@ module Mantle
10
10
  end
11
11
 
12
12
  def publish(message)
13
+ message = message.merge(__MANTLE__: { message_source: whoami }) if whoami
13
14
  message_bus.publish(channel, message)
14
15
  catch_up.add_message(channel, message)
15
16
  end
@@ -17,5 +18,9 @@ module Mantle
17
18
  private
18
19
 
19
20
  attr_reader :message_bus, :catch_up
21
+
22
+ def whoami
23
+ Mantle.configuration.whoami
24
+ end
20
25
  end
21
26
  end
@@ -1,3 +1,3 @@
1
1
  module Mantle
2
- VERSION = '2.2.3'
2
+ VERSION = '2.2.4'
3
3
  end
data/mantle.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'mantle/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "mantle"
8
8
  gem.version = Mantle::VERSION
9
- gem.authors = ["Grant Ammons", "Brandon Hilkert"]
10
- gem.email = ["gammons@gmail.com", "brandonhilkert@gmail.com"]
9
+ gem.authors = ["Grant Ammons", "Brandon Hilkert", "Scott Gibson", "Frank Hmeidan"]
10
+ gem.email = ["gammons@gmail.com", "brandonhilkert@gmail.com", "sevgibson@gmail.com", "frank.hmeidan@gmail.com"]
11
11
  gem.description = %q{Ruby application message bus subscriptions with Sidekiq and Redis Pubsub.}
12
12
  gem.summary = %q{Ruby application message bus subscriptions with Sidekiq and Redis Pubsub.}
13
13
  gem.homepage = "https://github.com/PipelineDeals/mantle"
@@ -14,6 +14,12 @@ describe Mantle::Configuration do
14
14
  expect(config.message_handlers).to eq({'a_channel' => 'FakeHandler'})
15
15
  end
16
16
 
17
+ it 'can set/get whoami' do
18
+ config = Mantle::Configuration.new
19
+ config.whoami = 'SantaClaus'
20
+ expect(config.whoami).to eq('SantaClaus')
21
+ end
22
+
17
23
  it 'configures default message handler' do
18
24
  config = Mantle::Configuration.new
19
25
  expect(config.message_handlers).to be_instance_of(Mantle::MessageHandlers)
@@ -12,12 +12,34 @@ describe Mantle::Message do
12
12
  mantle_message.message_bus = bus
13
13
  mantle_message.catch_up = catch_up
14
14
 
15
- expect(bus).to receive(:publish).with(channel, message)
16
- expect(catch_up).to receive(:add_message).with(channel, message)
15
+ allow(bus).to receive(:publish)
16
+ allow(catch_up).to receive(:add_message)
17
17
 
18
18
  mantle_message.publish(message)
19
+
20
+ expect(bus).to have_received(:publish).with(channel, message)
21
+ expect(catch_up).to have_received(:add_message).with(channel, message)
19
22
  end
20
- end
21
- end
22
23
 
24
+ it "published message includes message_source" do
25
+ Mantle.configure { |config| config.whoami = 'SantaClaus' }
26
+ bus = double("message bus")
27
+ catch_up = double("catch up")
28
+ channel = "create:person"
29
+ message = { id: 1 }
30
+ actual_message = message.merge(__MANTLE__: { message_source: 'SantaClaus' })
23
31
 
32
+ mantle_message = Mantle::Message.new(channel)
33
+ mantle_message.message_bus = bus
34
+ mantle_message.catch_up = catch_up
35
+
36
+ allow(bus).to receive(:publish)
37
+ allow(catch_up).to receive(:add_message)
38
+
39
+ mantle_message.publish(message)
40
+
41
+ expect(bus).to have_received(:publish).with(channel, actual_message)
42
+ expect(catch_up).to have_received(:add_message).with(channel, actual_message)
43
+ end
44
+ end
45
+ end
metadata CHANGED
@@ -1,15 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mantle
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Ammons
8
8
  - Brandon Hilkert
9
+ - Scott Gibson
10
+ - Frank Hmeidan
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
12
- date: 2016-03-18 00:00:00.000000000 Z
14
+ date: 2017-06-20 00:00:00.000000000 Z
13
15
  dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
17
  name: redis
@@ -71,6 +73,8 @@ description: Ruby application message bus subscriptions with Sidekiq and Redis P
71
73
  email:
72
74
  - gammons@gmail.com
73
75
  - brandonhilkert@gmail.com
76
+ - sevgibson@gmail.com
77
+ - frank.hmeidan@gmail.com
74
78
  executables:
75
79
  - mantle
76
80
  extensions: []
@@ -140,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
144
  version: '0'
141
145
  requirements: []
142
146
  rubyforge_project:
143
- rubygems_version: 2.5.1
147
+ rubygems_version: 2.4.8
144
148
  signing_key:
145
149
  specification_version: 4
146
150
  summary: Ruby application message bus subscriptions with Sidekiq and Redis Pubsub.