event_store_client 0.2.1 → 0.2.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: 4ac08f67c434906de0ac0d2d0647754ef150fd1d5b42b0651661717898860c2b
4
- data.tar.gz: 8609930f8a77830f6da8b6867b05c26167a1aec86a92c455087bd0571f5e3b79
3
+ metadata.gz: c833953b7c234efb592ba1c80b0b1ad920d6edfa38f712b4e0bd666c1a600a16
4
+ data.tar.gz: 56236d43242019d752ecf48243df4b077974deb41161017e5ecddbf60a120a45
5
5
  SHA512:
6
- metadata.gz: 4e5a3e4e96e8a91be17517abaf58310665c9946e628a9603cda257b54f1a187dc60b014b38b667d335ebe82e706cf36059370685bf5f82ba2b990f436685add9
7
- data.tar.gz: be2a99a2355854da0c4db2865a95e36e9ab44ad890d7a06c1aee2d71d7808f003dfecab1d3d622e472ae22b4a552e59bd9c833150d8bd188ade55c53bfe763a8
6
+ metadata.gz: 544fa64532df3c80581d1c972e96cb31d7c2cce68a056dc59165eff59df19f607e62b4b28b61eeb6ba88449a3a739227d0e1c6ffe32327ca0abe89aac325ac07
7
+ data.tar.gz: 597a9a467cf339289cea538953f42ca065324b755a8d7f3d01fa401b96bf4f567254956a66f8dec89020b86fb13423bec2925507c004147c097e7cf3e1ec054e
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ ![Run tests](https://github.com/yousty/event_store_client/workflows/Run%20tests/badge.svg?branch=master&event=push)
2
+ [![Gem Version](https://badge.fury.io/rb/event_store_client.svg)](https://badge.fury.io/rb/event_store_client)
3
+
1
4
  # EventStoreClient
2
5
 
3
6
  An easy-to use API client for connecting ruby applications with https://eventstore.org/
@@ -252,6 +255,11 @@ Do you want to contribute? Welcome!
252
255
  2. Create Issue
253
256
  3. Create PR ;)
254
257
 
258
+ ### Publishing new version
259
+
260
+ 1. Push commit with updated `version.rb` file to the `release` branch. The new version will be automatically pushed to [rubygems](https://rubygems.org).
261
+ 2. Create release on github including change log.
262
+
255
263
  ## License
256
264
 
257
265
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -28,7 +28,7 @@ module EventStoreClient
28
28
 
29
29
  def decrypt_attributes(key:, data:, attributes:)
30
30
  decrypted_text = key_repository.decrypt(
31
- key_id: key.id, text: data[:es_encrypted], cipher: key.cipher, iv: key.iv
31
+ key_id: key.id, text: data['es_encrypted'], cipher: key.cipher, iv: key.iv
32
32
  )
33
33
  decrypted = JSON.parse(decrypted_text).transform_keys(&:to_s)
34
34
  decrypted.each { |key, value| data[key] = value if data.key?(key) }
@@ -11,7 +11,7 @@ module EventStoreClient
11
11
  encrypt_attributes(
12
12
  key: key,
13
13
  data: encrypted_data,
14
- attributes: encryption_metadata[:attributes]
14
+ attributes: encryption_metadata[:attributes].map(&:to_s)
15
15
  )
16
16
  end
17
17
 
@@ -17,7 +17,7 @@ module EventStoreClient
17
17
  attr_reader :data, :schema
18
18
 
19
19
  def initialize(data:, schema:)
20
- @data = data
20
+ @data = data.transform_keys(&:to_sym)
21
21
  @schema = schema
22
22
  end
23
23
  end
@@ -26,13 +26,13 @@ module EventStoreClient
26
26
  event.class.respond_to?(:encryption_schema) &&
27
27
  event.class.encryption_schema
28
28
  )
29
- encryptor = DataEncryptor.new(
29
+ encryptor = EventStoreClient::DataEncryptor.new(
30
30
  data: event.data,
31
31
  schema: encryption_schema,
32
32
  repository: key_repository
33
33
  )
34
34
  encryptor.call
35
- Event.new(
35
+ EventStoreClient::Event.new(
36
36
  data: serializer.serialize(encryptor.encrypted_data),
37
37
  metadata: serializer.serialize(
38
38
  event.metadata.merge(encryption: encryptor.encryption_metadata)
@@ -52,7 +52,7 @@ module EventStoreClient
52
52
  def deserialize(event)
53
53
  metadata = serializer.deserialize(event.metadata)
54
54
  encryption_schema = serializer.deserialize(event.metadata)['encryption']
55
- decrypted_data = DataDecryptor.new(
55
+ decrypted_data = EventStoreClient::DataDecryptor.new(
56
56
  data: serializer.deserialize(event.data),
57
57
  schema: encryption_schema,
58
58
  repository: key_repository
@@ -115,11 +115,12 @@ module EventStoreClient
115
115
 
116
116
  private
117
117
 
118
- attr_reader :endpoint, :per_page
118
+ attr_reader :endpoint, :per_page, :connection_options
119
119
 
120
- def initialize(host:, port:, per_page: 20)
120
+ def initialize(host:, port:, per_page: 20, connection_options: {})
121
121
  @endpoint = Endpoint.new(host: host, port: port)
122
122
  @per_page = per_page
123
+ @connection_options = connection_options
123
124
  end
124
125
 
125
126
  def build_events_data(events)
@@ -153,7 +154,7 @@ module EventStoreClient
153
154
  end
154
155
 
155
156
  def connection
156
- @connection ||= Api::Connection.new(endpoint).call
157
+ @connection ||= Api::Connection.new(endpoint, connection_options).call
157
158
  end
158
159
 
159
160
  def validate_response(resp, expected_version)
@@ -8,8 +8,10 @@ module EventStoreClient
8
8
  class Connection
9
9
  def call
10
10
  Faraday.new(
11
- url: endpoint.url,
12
- headers: DEFAULT_HEADERS
11
+ {
12
+ url: endpoint.url,
13
+ headers: DEFAULT_HEADERS
14
+ }.merge(options)
13
15
  ) do |conn|
14
16
  conn.basic_auth(ENV['EVENT_STORE_USER'], ENV['EVENT_STORE_PASSWORD'])
15
17
  conn.adapter Faraday.default_adapter
@@ -18,11 +20,12 @@ module EventStoreClient
18
20
 
19
21
  private
20
22
 
21
- def initialize(endpoint)
23
+ def initialize(endpoint, options = {})
22
24
  @endpoint = endpoint
25
+ @options = options
23
26
  end
24
27
 
25
- attr_reader :endpoint
28
+ attr_reader :endpoint, :options
26
29
 
27
30
  DEFAULT_HEADERS = {
28
31
  'Content-Type' => 'application/vnd.eventstore.events+json'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventStoreClient
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_store_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Wilgosz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-29 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-schema
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.0.6
151
+ rubygems_version: 3.0.4
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Ruby integration for https://eventstore.org