artsy-eventservice 1.0.8 → 1.0.9

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
  SHA1:
3
- metadata.gz: b57886405d5d5d74bc384e16ad8ba63229665cb9
4
- data.tar.gz: 3735eb18d6c4ceb84ce01c81902673031d2931bb
3
+ metadata.gz: 9c8662b50032c8b09290c4f31520b4a0f009be08
4
+ data.tar.gz: 76312d3024e20c9a291b272c118b226768256468
5
5
  SHA512:
6
- metadata.gz: e39e3b5ada09e10aa556b087c56ba20cfa1f6f6f263e4a8c9f9eb096cf1114f0d2b489c0eda41c45b88e5518c437d59650d9a14f509697ee784a3b8a1afe1c93
7
- data.tar.gz: 0f6b44839fb093d5094c2236c5d7efdad0344a2a9490df774a9b4661823004baf1504c1052e405b9b077cefe768c614ee6b307725aeb21b29f061af80b912c94
6
+ metadata.gz: 4944fb73e5a0d848dd1a2796a5356bf9873f4ad3d205c8cca86470c9822ea3ee7706f14db471e0ae1a2fbf278ba3686aa17dcc254102c52982f32d22526cc18f
7
+ data.tar.gz: 14e0753f34d2e8dc8364b2705bdccda7c78271ae004e023f3f5aef5e3efc105101b7e54bb6ea4af136bddbcce2377e6eb5ff051f5d3ebbbfde8b3ea8cc103314
@@ -1,3 +1,5 @@
1
+ ### 0.1.9
2
+ * Add `to_json` to `BaseEvent` and deprecate `json` - [@ashkan18](https://github.com/ashkan18)
1
3
  ### 0.1.5 (3/24/17)
2
4
  * Add initializer-style configuration block
3
5
  ### 0.1.2 (3/23/17)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artsy-eventservice (1.0.8)
4
+ artsy-eventservice (1.0.9)
5
5
  bunny
6
6
 
7
7
  GEM
@@ -78,4 +78,4 @@ RUBY VERSION
78
78
  ruby 2.3.0p0
79
79
 
80
80
  BUNDLED WITH
81
- 1.16.1
81
+ 1.16.2
data/README.md CHANGED
@@ -10,7 +10,7 @@ gem 'artsy-eventservice'
10
10
 
11
11
  ## Configuration
12
12
 
13
- Add `artsy_eventservice.rb under config/initializers. `Artsy::EventService` uses [Bunny](http://rubybunny.info/) to connect to RabbitMQ. Here is a sample of configuration:
13
+ Add artsy_eventservice.rb within config/initializers. `Artsy::EventService` uses [Bunny](http://rubybunny.info/) to connect to RabbitMQ. Here is a sample of configuration:
14
14
 
15
15
  ```ruby
16
16
  # config/initializers/artsy_eventservice.rb
@@ -70,9 +70,9 @@ Few examples:
70
70
  - Topic: `conversations`, routing key: `conversation.created`
71
71
  - Topic: `conversations`, routing key: `conversation.dismissed`
72
72
  - Topic: `invoices`, routing key: `invoice.paid`
73
- - Topic: `invoices`, routing key: `merchant_account.created`
73
+ - Topic: `invoices`, routing key: `merchantaccount.created`
74
74
 
75
- `BaseEvent` provides `routing_key` method by default which follows the same pattern mention above, you can override `routing_key` when calling `post_event`.
75
+ `BaseEvent` provides `routing_key` method by default which follows the same pattern mention above, you can override `routing_key` when calling `post_event`. In the default routing key we use `to_s.downcase.gsub('::', '-')` on class name of the `@object` so an instance of `Artsy::UserRequest` with action being `test` will lead to `artsy-userrequest.test`.
76
76
 
77
77
  ### Update to Version 1.0
78
78
  In previous versions this gem was using Environment variables for configuration. On version 1.0, configuration step is now mandatory and it will no longer read environment variables directly. Make sure to go to configuration step.
@@ -30,7 +30,7 @@ module Artsy
30
30
  raise 'Event missing topic or verb.' if event.verb.to_s.empty? || topic.to_s.empty?
31
31
  post_data(
32
32
  topic: topic,
33
- data: event.json,
33
+ data: event.to_json,
34
34
  routing_key: routing_key || event.verb,
35
35
  headers: headers
36
36
  )
@@ -3,12 +3,13 @@ require 'json'
3
3
 
4
4
  module Events
5
5
  class BaseEvent
6
+ extend Gem::Deprecate
6
7
  attr_reader :verb, :subject, :object, :properties
8
+
7
9
  def initialize(user: nil, action:, model:)
8
10
  @subject = user
9
11
  @verb = action
10
12
  @object = model
11
- @properties = nil
12
13
  end
13
14
 
14
15
  def subject
@@ -30,13 +31,19 @@ module Events
30
31
  end
31
32
  end
32
33
 
33
- def json
34
+ def to_json
34
35
  JSON.generate(verb: @verb,
35
36
  subject: subject,
36
37
  object: object,
37
38
  properties: properties)
38
39
  end
39
40
 
41
+ def json
42
+ # Deprecated, switch to to_json
43
+ to_json
44
+ end
45
+ deprecate :json, :to_json, 2019, 12
46
+
40
47
  def routing_key
41
48
  "#{@object.class.to_s.downcase.gsub('::', '-')}.#{@verb}"
42
49
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Artsy
3
3
  module EventService
4
- VERSION = '1.0.8'
4
+ VERSION = '1.0.9'
5
5
  end
6
6
  end
@@ -13,7 +13,7 @@ describe Artsy::EventService::Publisher do
13
13
  end
14
14
  allow(event).to receive_messages(
15
15
  verb: 'testing',
16
- json: JSON.generate(hello: true)
16
+ to_json: JSON.generate(hello: true)
17
17
  )
18
18
  end
19
19
 
@@ -17,7 +17,7 @@ describe Events::BaseEvent do
17
17
  end
18
18
  describe '#json' do
19
19
  it 'returns proper json' do
20
- expect(JSON.parse(event.json)).to match(
20
+ expect(JSON.parse(event.to_json)).to match(
21
21
  'verb' => 'test',
22
22
  'subject' => {
23
23
  'id' => 'user-1',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artsy-eventservice
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashkan Nasseri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-30 00:00:00.000000000 Z
11
+ date: 2019-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny