zaikio-loom 1.3.1 → 1.4.0

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: f1726071bcfc562e515cb666886cd6c2f1115a8e45e936a0cba4f24369a61c7c
4
- data.tar.gz: 221fac1ee2179ef715cb0c00dfd4600e018d7c501339c10bb1dcae44396bb5c4
3
+ metadata.gz: 4c40d59217b146b0a725bb2c1eff33cd3964654b0ff448912a8835f0f008d74d
4
+ data.tar.gz: 3d7efdbff7c06ebb2cc31f21b86dd601ada4729b053119537e7e3cd6cd649e73
5
5
  SHA512:
6
- metadata.gz: c0913c9a4e144f94467f57ec49f30ee7fe9dde081c9cb67de2bc0fc89678c4f3632848806cb35b0f12237502f2ade6060a62a9f6f4b3113bf4b6b36d0a7f832f
7
- data.tar.gz: 505627a9530b3b2f7dd299f886f674c81344ce2fef1fb11dce2dee0c3fe95220111e9e7b915fda1ec59eb4ffb410ba18e0ab6c507580eb7b39303e5af0a0f141
6
+ metadata.gz: 3b9b9956472ffe125ef01cfc90177ec7353e95e24cbe8f63917cd8701667b0b584af2c8ced74041b8c747aa1f13365e747d40be970379b0e9a3462bcddb73f6e
7
+ data.tar.gz: 4ce68659710a41f514651bfd491704012dd9ad826d9e9967c2415c1e48790d4c0195cdc79a9f42c16ad0940b3f96079fe995ac64cef4ca20e0000d7da4d87b38
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.7
2
+ TargetRubyVersion: 3.2
3
3
  Exclude:
4
4
  - test/**/*.rb
5
5
  NewCops: enable
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 1.4.0 - 2023-01-26
6
+
7
+ - Support `staging` environment to allow internal testing
8
+ - Require ruby > 3.0.0
9
+
5
10
  ## 1.3.1 - 2022-01-07
6
11
 
7
12
  - Permit Rails 7
data/Gemfile CHANGED
@@ -6,4 +6,3 @@ gemspec
6
6
  gem "actionpack"
7
7
  gem "actionview"
8
8
  gem "activemodel"
9
- gem "sprockets-rails"
data/README.md CHANGED
@@ -1,72 +1,51 @@
1
- # Zaikio Loom Ruby Gem
1
+ # Zaikio Loom ruby gem
2
2
 
3
- The Zaikio Loom Ruby Gem simplifies publishing events on the Zaikio Loom event system.
3
+ The Zaikio Loom ruby gem simplifies publishing events on the [Zaikio Loom event system](https://docs.zaikio.com/guide/loom/).
4
4
 
5
- Applications can only publish events to Zaikio Loom which have been configured in the Zaikio Directory. With a developer account in the Zaikio Directory you will find the list of provided events in your App's configuration in the Directory.
5
+ Applications can only publish events to Loom which have been configured in the
6
+ Zaikio Hub, on the "Provided events" tab under your App configuration.
6
7
 
7
8
  ## Installation
8
9
 
9
- Add this line to your application's Gemfile:
10
+ Install the gem and add to the application's Gemfile by executing:
10
11
 
11
- ```ruby
12
- gem 'zaikio-loom'
12
+ ```
13
+ $ bundle add zaikio-loom
13
14
  ```
14
15
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
16
+ If bundler is not being used to manage dependencies, install the gem by executing:
20
17
 
21
18
  $ gem install zaikio-loom
22
19
 
23
20
  ## Usage
24
21
 
25
- ### Configuration
26
-
27
- To configure the gem add an initializer to your application:
22
+ To configure the gem, first add an initializer to your application:
28
23
 
29
24
  ```ruby
30
- # in config/initializers/zaikio_loom.rb
31
- Zaikio::Loom.configure do |config|
32
- # Environment to which the gem should publish events to.
33
- # Possible values: :sandbox (default), :production
34
- config.environment = :sandbox
25
+ # config/initializers/zaikio_loom.rb
35
26
 
36
- # The name of your application like it is named in the directory of the
37
- # choosen enviroment.
38
- config.application 'my_application' do |app|
39
- # Your application's event password for the choosen environment
40
- # Do not add this password into version control.
41
- app.password = ENV.fetch('ZAIKIO_LOOM_PASSWORD')
42
- end
43
-
44
- # The version of the event's payload format and structure
45
- config.version = '1.0'
46
- end
47
- ```
48
-
49
- #### Multiple Clients
50
-
51
- ```ruby
52
- # in config/initializers/zaikio_loom.rb
53
27
  Zaikio::Loom.configure do |config|
54
- config.environment = :sandbox
55
- config.version = '1.0'
56
28
 
29
+ # Loom instance to receive the events. Only `:sandbox` and `:production` will actually emit
30
+ # events, all other environments will merely log the output, this can be controlled by
31
+ # setting `config.logger`.
32
+ config.environment = Rails.env
33
+
34
+ # The name of your application, matches the "technical identifier" in the Hub
57
35
  config.application 'my_application' do |app|
36
+
37
+ # Your application's event password for the chosen environment
38
+ # Do not commit this password to version control.
58
39
  app.password = ENV.fetch('ZAIKIO_LOOM_PASSWORD')
59
40
  end
60
41
 
61
- config.application 'my_other_app' do |app|
62
- app.password = ENV.fetch('ZAIKIO_LOOM_OTHER_APP_PASSWORD')
63
- end
42
+ # The version of the event payload, format and structure
43
+ config.version = '1.0'
64
44
  end
65
45
  ```
66
46
 
67
- ### Usage
68
-
69
- Firing events to Zaikio Loom:
47
+ You can use multiple clients at once, just add a `config.application(name, &block)` for
48
+ each one. Now, you can fire events at Zaikio Loom:
70
49
 
71
50
  ```ruby
72
51
  Zaikio::Loom.fire_event(
@@ -76,9 +55,9 @@ Zaikio::Loom.fire_event(
76
55
  )
77
56
  ```
78
57
 
79
- This example would publish an event (in the background) to Zaikio Loom with a random UUID and the current timestamp.
80
-
81
- If you want to publish the event for a specific client, you have to add it as part of the event name:
58
+ This example would publish an event (in the background) to Zaikio Loom with a random UUID
59
+ and the current timestamp. If you want to publish the event for a specific client, you
60
+ have to include it as part of the event name:
82
61
 
83
62
  ```rb
84
63
  Zaikio::Loom.fire_event(
@@ -90,11 +69,11 @@ Zaikio::Loom.fire_event(
90
69
 
91
70
  If you need more control over the published event, for example:
92
71
 
93
- - to provide a specific unique UUID or timestamp in the past or
94
- - you want to override the version for this specific event or
95
- - you want to check the Loom's response to this request
72
+ - to provide a specific unique UUID or timestamp in the past, or
73
+ - you want to override the version for this specific event, or
74
+ - you want to check Loom's response to this request
96
75
 
97
- then you can use the method:
76
+ then you can use the underlying `Event` constructor and call `#fire` on it:
98
77
 
99
78
  ```ruby
100
79
  event = Zaikio::Loom::Event.new(
@@ -106,7 +85,7 @@ event = Zaikio::Loom::Event.new(
106
85
  version: '1.1.beta'
107
86
  )
108
87
 
109
- unless event.fire # imaging the event_name does not exist
88
+ unless event.fire # imagine the event_name does not exist
110
89
  event.status_code # => 422
111
90
  event.response_body # => '{ "errors": { "name": ["excludes a valid event name"] } }'
112
91
  end
@@ -114,34 +93,47 @@ end
114
93
 
115
94
  ### Required arguments
116
95
 
117
- This gem is able to add some defaults or fallback values to the requests against the Loom API, for example
96
+ This gem is able to add some defaults or fallback values to the requests against the Loom
97
+ API, for example:
118
98
 
119
99
  - the app name,
120
100
  - an unique `id`,
121
101
  - the `version` or
122
102
  - the current `timestamp`.
123
103
 
124
- Nevertheless, the following arguments are required for every fired event and must follow the conventions described in the [Loom API Guide](https://docs.zaiku.com/guide/loom/posting-events.html#payload-requirements):
104
+ Nevertheless, the following arguments are required for every fired event and must follow
105
+ the conventions described in the
106
+ [Loom API Guide](https://docs.zaikio.com/guide/loom/posting-events.html#payload-requirements):
125
107
 
126
108
  - the name of the event
127
109
  - a `subject` that triggered the event
128
110
 
129
- Furtheremore, the payload can be omitted, but must be a hash when present.
111
+ Furthermore, the payload can be omitted, but must be set as a hash if given.
130
112
 
131
113
  ## Development
132
114
 
133
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
115
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
116
+ spec` to run the tests.
134
117
 
135
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
118
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a
119
+ new version, update the version number in `version.rb`, and then run `bundle exec rake
120
+ release`, which will create a git tag for the version, push git commits and tags, and push
121
+ the `.gem` file to [rubygems.org](https://rubygems.org).
136
122
 
137
123
  ## Contributing
138
124
 
139
- Bug reports and pull requests are welcome on GitHub at https://github.com/zaikio/zaikio-loom-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
125
+ Bug reports and pull requests are welcome on GitHub at
126
+ https://github.com/zaikio/zaikio-loom-ruby. This project is intended to be a safe,
127
+ welcoming space for collaboration, and contributors are expected to adhere to the
128
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
140
129
 
141
130
  ## License
142
131
 
143
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
132
+ The gem is available as open source under the terms of the
133
+ [MIT License](https://opensource.org/licenses/MIT).
144
134
 
145
135
  ## Code of Conduct
146
136
 
147
- Everyone interacting in the Zaikio Loom Ruby gem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/zaikio/zaikio-loom-ruby/blob/master/CODE_OF_CONDUCT.md).
137
+ Everyone interacting in the Zaikio Loom Ruby gem project’s codebases, issue trackers, chat
138
+ rooms and mailing lists is expected to follow the
139
+ [code of conduct](https://github.com/zaikio/zaikio-loom-ruby/blob/master/CODE_OF_CONDUCT.md).
@@ -5,6 +5,7 @@ module Zaikio
5
5
  class Configuration
6
6
  HOSTS = {
7
7
  test: "http://loom.zaikio.test",
8
+ staging: "https://loom.staging.zaikio.com",
8
9
  sandbox: "https://loom.sandbox.zaikio.com",
9
10
  production: "https://loom.zaikio.com"
10
11
  }.freeze
@@ -2,10 +2,10 @@ module Zaikio
2
2
  module Loom
3
3
  class Error < StandardError
4
4
  attr_reader :body, :status_code
5
-
5
+
6
6
  def initialize(message = nil, body:, status_code:)
7
7
  super(message)
8
-
8
+
9
9
  @body = body
10
10
  @status_code = status_code
11
11
  end
@@ -22,7 +22,7 @@ module Zaikio
22
22
  configuration.logger.error("Zaikio::Loom is disabled – event password is missing")
23
23
  end
24
24
 
25
- def fire # rubocop:disable Metrics/AbcSize
25
+ def fire # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
26
26
  log_event
27
27
 
28
28
  return false unless app_password && configuration.host
@@ -40,7 +40,7 @@ module Zaikio
40
40
  unless response.is_a?(Net::HTTPSuccess)
41
41
  raise Zaikio::Loom::Error.new(
42
42
  "Sending event failed (#{@status_code}): #{@response_body}",
43
- body: @response_body,
43
+ body: @response_body,
44
44
  status_code: @status_code
45
45
  )
46
46
  end
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module Loom
3
- VERSION = "1.3.1".freeze
3
+ VERSION = "1.4.0".freeze
4
4
  end
5
5
  end
data/zaikio-loom.gemspec CHANGED
@@ -24,10 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_dependency "activejob"
27
- spec.add_dependency "nokogiri", ">= 1.11.0"
28
27
  spec.add_dependency "railties", ">= 6.0.2.3", "< 8"
29
28
  spec.add_runtime_dependency "oj"
30
- spec.required_ruby_version = ">= 2.7.1"
29
+ spec.required_ruby_version = ">= 3.0.0"
31
30
 
32
31
  spec.add_development_dependency "bundler"
33
32
  spec.add_development_dependency "minitest"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-loom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - crispymtn
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-01-07 00:00:00.000000000 Z
12
+ date: 2023-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activejob
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: nokogiri
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 1.11.0
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: 1.11.0
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: railties
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -211,6 +197,7 @@ files:
211
197
  - ".github/dependabot.yml"
212
198
  - ".gitignore"
213
199
  - ".rubocop.yml"
200
+ - ".ruby-version"
214
201
  - CHANGELOG.md
215
202
  - CODE_OF_CONDUCT.md
216
203
  - Gemfile
@@ -246,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
246
233
  requirements:
247
234
  - - ">="
248
235
  - !ruby/object:Gem::Version
249
- version: 2.7.1
236
+ version: 3.0.0
250
237
  required_rubygems_version: !ruby/object:Gem::Requirement
251
238
  requirements:
252
239
  - - ">="