osbourne 1.1.0 → 1.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
  SHA256:
3
- metadata.gz: 4429d66869ecd9cbceac02b613ed4b7e7f1de032a3cc5d2f027934371b4ebce1
4
- data.tar.gz: 9ebdca21583fadc61f7101f4a87c3768ea7e390c3fe9719d3bde502fd31d9497
3
+ metadata.gz: '09d9c82e18577ae64d95aec4a5b96d5dfee791ae61e913149388a683677f9133'
4
+ data.tar.gz: e7f178533fc85a6b912fd7755e42b930121b8b093e777edf24e9603e265d9a36
5
5
  SHA512:
6
- metadata.gz: d05cc25e32195caf916507568a95bb354124695174cf056a955a8007d111852f92f66ba9f61310f8ae1ba0772b249098f18f37d81f8d85ca2cc23a86b602cb8e
7
- data.tar.gz: 2a6e4a78aabbd05e7650041b2c184085f55a5addcb73df0c528c0ae2a31d2cea33a77007813291d75b29c7ad2cb0afd7faf4d0fa411416bdb0c829595d00f5ed
6
+ metadata.gz: 8d8edb471d4cd35492270d3c90e2868f35b3b1c6703c6d50c3e3f55d9fe9c8e5f4cd2e6ed8dca36d15affd522e7157dd17fdcdcebaa82dd3ece036e6b8cb7a7b
7
+ data.tar.gz: c655b974afae2dc261b9e27a22ce7a34d2ee6fe309127502065e6ce896c4273a4723227140511235f5c0c6b4664129d098c04ed07ac1b24bd76fa3948d2744d9
@@ -6,11 +6,19 @@ module Osbourne
6
6
  class MockPubsub
7
7
  class << self
8
8
  def mock_publish(topic, message)
9
+ parsed_message = parse(message)
9
10
  Osbourne::WorkerBase.descendants.each do |worker|
10
- msg = Osbourne::Test::Message.new(topic: topic, body: message)
11
+ msg = Osbourne::Test::Message.new(topic: topic, body: parsed_message)
11
12
  worker.new.process(msg) if worker.config[:topic_names].include? topic
12
13
  end
13
14
  end
15
+
16
+ def parse(message)
17
+ return message if message.is_a?(String)
18
+ return message.to_json if message.respond_to?(:to_json)
19
+
20
+ raise ArgumentError, "Message must either be a string or respond to #to_json"
21
+ end
14
22
  end
15
23
  end
16
24
  end
@@ -14,10 +14,11 @@ module Osbourne
14
14
  end
15
15
 
16
16
  def publish(message)
17
+ parsed_message = parse(message)
17
18
  return if Osbourne.test_mode?
18
19
 
19
- Osbourne.logger.info "[PUB] TOPIC: `#{name}` MESSAGE: `#{message}`"
20
- sns.publish(topic_arn: arn, message: message.is_a?(String) ? message : message.to_json)
20
+ Osbourne.logger.info "[PUB] TOPIC: `#{name}` MESSAGE: `#{parsed_message}`"
21
+ sns.publish(topic_arn: arn, message: parsed_message)
21
22
  end
22
23
 
23
24
  private
@@ -34,5 +35,12 @@ module Osbourne
34
35
  def subscriptions_cache_key
35
36
  "existing_sqs_subscriptions_for_#{name}"
36
37
  end
38
+
39
+ def parse(message)
40
+ return message if message.is_a?(String)
41
+ return message.to_json if message.respond_to?(:to_json)
42
+
43
+ raise ArgumentError, "Message must either be a string or respond to #to_json"
44
+ end
37
45
  end
38
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osbourne
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osbourne
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-15 00:00:00.000000000 Z
11
+ date: 2018-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core