zaikio-loom 1.3.0 → 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: 0cbd1fc41bd69bf1024ee63542c4975302e79be1ac0af6e8f2fc38c17cbdc151
4
- data.tar.gz: a0880a07082f41503d223cfb200add6dfaa1a3854a6ea004c4a3a013ec4931bd
3
+ metadata.gz: 4c40d59217b146b0a725bb2c1eff33cd3964654b0ff448912a8835f0f008d74d
4
+ data.tar.gz: 3d7efdbff7c06ebb2cc31f21b86dd601ada4729b053119537e7e3cd6cd649e73
5
5
  SHA512:
6
- metadata.gz: a54007ad6ed771175a78f9a9b6e0202c94f1afa34162be8f0c4a842c0f0a0ac8e854e64c43937d640de61a003dba92283ff0c62b7e4cfd16818551b28c70fc7f
7
- data.tar.gz: 582bbe830956812890f09c4872cab016c80fcd7f4719bf982555d54e49f154a77eeb5a53b8d3eb1e312a0199286f7a818486a76b5ebcd5773bd113c79ba73142
6
+ metadata.gz: 3b9b9956472ffe125ef01cfc90177ec7353e95e24cbe8f63917cd8701667b0b584af2c8ced74041b8c747aa1f13365e747d40be970379b0e9a3462bcddb73f6e
7
+ data.tar.gz: 4ce68659710a41f514651bfd491704012dd9ad826d9e9967c2415c1e48790d4c0195cdc79a9f42c16ad0940b3f96079fe995ac64cef4ca20e0000d7da4d87b38
data/.circleci/config.yml CHANGED
@@ -1,9 +1,12 @@
1
- version: 2
1
+ version: 2.1
2
2
  jobs:
3
- build:
3
+ test:
4
4
  docker:
5
- - image: circleci/ruby:3.0.0
6
- - image: circleci/redis:3.2-alpine
5
+ - image: cimg/ruby:3.0.3
6
+ environment:
7
+ BUNDLE_JOBS: 4
8
+ BUNDLE_RETRY: 3
9
+ BUNDLE_PATH: vendor/bundle
7
10
 
8
11
  working_directory: ~/repo
9
12
 
@@ -12,22 +15,53 @@ jobs:
12
15
 
13
16
  - restore_cache:
14
17
  keys:
15
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
18
+ - v1-dependencies-{{ checksum "zaikio-loom.gemspec" }}
16
19
  # fallback to using the latest cache if no exact match is found
17
20
  - v1-dependencies-
18
21
 
19
22
  - run:
20
23
  name: install dependencies
21
- command: |
22
- gem install bundler:2.1.4 && bundle install --jobs=4 --retry=3 --path vendor/bundle
24
+ command: gem install bundler && bundle install
23
25
 
24
26
  - save_cache:
25
27
  paths:
26
28
  - ./vendor/bundle
27
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
29
+ key: v1-dependencies-{{ checksum "zaikio-loom.gemspec" }}
30
+
31
+ - run: bundle exec rake test
32
+
33
+ publish:
34
+ docker:
35
+ - image: cimg/ruby:3.0.3
36
+
37
+ working_directory: ~/repo
28
38
 
29
- # run tests!
39
+ steps:
40
+ - checkout
30
41
  - run:
31
- name: run tests
42
+ name: Build package
43
+ command: gem build zaikio-loom.gemspec
44
+ - run:
45
+ name: Push package
32
46
  command: |
33
- bundle exec rake test
47
+ VERSION=$(ruby -r "./lib/zaikio/loom/version.rb" -e "print Zaikio::Loom::VERSION")
48
+ gem push zaikio-loom-${VERSION}.gem
49
+
50
+ workflows:
51
+ default:
52
+ jobs:
53
+ - test:
54
+ filters:
55
+ tags:
56
+ only: /.*/
57
+ branches:
58
+ only: /.*/
59
+ - publish:
60
+ context:
61
+ - rubygems-push
62
+ requires: [test]
63
+ filters:
64
+ tags:
65
+ only: /^v.*/
66
+ branches:
67
+ ignore: /.*/
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,15 @@
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
+
10
+ ## 1.3.1 - 2022-01-07
11
+
12
+ - Permit Rails 7
13
+
5
14
  ## 1.3.0 - 2021-11-22
6
15
 
7
16
  - Support configuration of `queue` for FireEventJob
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.0".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
- spec.add_dependency "railties", "~> 6.0", ">= 6.0.2.3"
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.0
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: 2021-11-22 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,40 +25,26 @@ 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
45
31
  requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '6.0'
49
32
  - - ">="
50
33
  - !ruby/object:Gem::Version
51
34
  version: 6.0.2.3
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: '8'
52
38
  type: :runtime
53
39
  prerelease: false
54
40
  version_requirements: !ruby/object:Gem::Requirement
55
41
  requirements:
56
- - - "~>"
57
- - !ruby/object:Gem::Version
58
- version: '6.0'
59
42
  - - ">="
60
43
  - !ruby/object:Gem::Version
61
44
  version: 6.0.2.3
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '8'
62
48
  - !ruby/object:Gem::Dependency
63
49
  name: oj
64
50
  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,14 +233,14 @@ 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
  - - ">="
253
240
  - !ruby/object:Gem::Version
254
241
  version: '0'
255
242
  requirements: []
256
- rubygems_version: 3.1.4
243
+ rubygems_version: 3.2.32
257
244
  signing_key:
258
245
  specification_version: 4
259
246
  summary: The Zaikio Loom Ruby Gem simplifies publishing events on the Zaikio Loom