jsonapi_publisher 0.2.3 → 0.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: a9429a3a332bf152085f217782f721725cf70efc
4
- data.tar.gz: f1b3df5d3e68d7785604c6797c100c5d3f16afc9
3
+ metadata.gz: 7e243fa70f3cb2b2807f75f1e12619ffa731d93a
4
+ data.tar.gz: 28550854aef07d3dc296e4984af381ef17d4d870
5
5
  SHA512:
6
- metadata.gz: 0df4592bac40b2f5b56f4d950468b5825536b59738723d50c88292a9bde2ab8a2ba5d71fed23d079525b9248fd60bf3a8f2a04c27e7c4b48f8a6f3d6c7192db1
7
- data.tar.gz: 73c17c9e43ef752cf9ffe699555c92c2ba6cefdb424e94c8f246d91a0041102291a9f78edfb59be4478c6021d614a8c277a1b9021a13375424eb676373c2eba9
6
+ metadata.gz: 2c89bf1a4aab0b5815d7ea5138ec86a56517a8860009199527dc55cc2eee967f59dcfc7f2cde38c2139f29a8d4251209854d31052cbb3e4fb07fae0dfa3fd917
7
+ data.tar.gz: 4d56139a53742da28ff37f82a51b1e6712b78caaec35b13e0fc0bebf959b7bc01c773d0d457d176dd35c998b1f5c538f4e3ae7c1751e54e7a1d499db28d12a6e
@@ -19,9 +19,7 @@ module JsonapiPublisher
19
19
  if message.is_a?(ActiveRecord::Base)
20
20
  message = ActiveModelSerializers::SerializableResource.new(message).as_json
21
21
  end
22
- if event.present?
23
- message = { event: event }.merge(message)
24
- end
22
+ message = { event: event }.merge(message) if event.present?
25
23
  if configuration.qservice == 'rmq'
26
24
  x = channel.topic(ENV['EVENT_TOPIC'] || 'events')
27
25
  x.publish(message.to_json, routing_key: routing_key)
@@ -39,22 +37,24 @@ module JsonapiPublisher
39
37
  if configuration.qservice == 'rmq'
40
38
  @channel ||= connection.create_channel
41
39
  elsif configuration.qservice == 'sqs'
42
- @channel ||= connection.create_queue({
43
- queue_name: ENV['EVENT_TOPIC'],
44
- attributes: {
45
- "FifoQueue" => "true"
46
- }
47
- })
40
+ @channel ||= connection.create_queue(queue_name: ENV['EVENT_TOPIC'],
41
+ attributes: {
42
+ 'FifoQueue' => 'true'
43
+ })
48
44
  end
49
45
  end
50
46
 
51
47
  def self.connection
52
48
  if configuration.qservice == 'rmq'
53
- @connection ||= Bunny.new(host: ENV['RABBITMQ_HOST'] || 'localhost', user: ENV['RABBITMQ_USER'] || 'guest', pass: ENV['RABBITMQ_PASS'] || 'guest').tap do |c|
54
- c.start
55
- end
49
+ @connection ||= Bunny.new(host: ENV['RABBITMQ_HOST'] || 'localhost', user: ENV['RABBITMQ_USER'] || 'guest', pass: ENV['RABBITMQ_PASS'] || 'guest').tap(&:start)
56
50
  elsif configuration.qservice == 'sqs'
57
- @connection ||= Aws::SQS::Client.new(endpoint: ENV['AWS_SQS_ENDPOINT'], region: ENV['AWS_REGION'] || 'eu-west-1', secret_access_key: ENV['AWS_ACCESS_KEY_ID'], access_key_id: ENV['AWS_SECRET_ACCESS_KEY'])
51
+ options = {
52
+ region: ENV['AWS_REGION'] || 'eu-west-1'
53
+ }
54
+ options[:endpoint] = ENV['AWS_SQS_ENDPOINT'] if ENV['AWS_SQS_ENDPOINT']
55
+ options[:access_key_id] = ENV['AWS_ACCESS_KEY_ID'] if ENV['AWS_ACCESS_KEY_ID']
56
+ options[:access_key_id] = ENV['AWS_SECRET_ACCESS_KEY'] if ENV['AWS_SECRET_ACCESS_KEY']
57
+ @connection ||= Aws::SQS::Client.new(options)
58
58
  end
59
59
  end
60
60
 
@@ -1,3 +1,3 @@
1
1
  module JsonapiPublisher
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michele Finotto