zaikio-loom 0.1.1 → 0.2.0

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
  SHA256:
3
- metadata.gz: 2bb7acebd728d686d9b6ca9d7db2906da8321f996f5c091413828edfc057aeb2
4
- data.tar.gz: a27a74f63adcc90f63ee16209686c6224d5fe0ed136f52728547122e07ef75b8
3
+ metadata.gz: 7116806b8e6e82be413f8f163f7b5b8c785c9218e8a03a7e9f798d76032b2eab
4
+ data.tar.gz: e5d303f87cb2dd1ee94823f8ae61f6b4ebf2eff0cf130121f885e541b5d58668
5
5
  SHA512:
6
- metadata.gz: cfb47c5ecafaf51967105805b79d8bf367420035d4cb0fc5c87c4c7755d19ba08ace93f9386a410d699a41b8834b81bd82e819d19f933a7c034fe48744f23c6a
7
- data.tar.gz: 8394db45c7038a37f684a0839362604c3760402e4ba144b055631610f2173de0304b2afe7e70c42c193a04d1f041e2525dc5bcfc30f4be07eed0e621d6752173
6
+ metadata.gz: 0351fa33b725e6198a3685a3135098586348cdeb14729d0227ccee426ea70ee4c3909c92fed543799b092f7b6533ff5f268ddb5fc0295c9686681b30e9b9ee6c
7
+ data.tar.gz: 2af0e36488855e2098bd950b5284d35505d06709f2c3dde8e30903f48e0b0627b0435c0d1dc29fd468266f80d4a85f3c1d5d88ea6a837fdb419734a331de19f0
@@ -0,0 +1,33 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: circleci/ruby:2.6.5
6
+ - image: circleci/redis:3.2-alpine
7
+
8
+ working_directory: ~/repo
9
+
10
+ steps:
11
+ - checkout
12
+
13
+ - restore_cache:
14
+ keys:
15
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
16
+ # fallback to using the latest cache if no exact match is found
17
+ - v1-dependencies-
18
+
19
+ - run:
20
+ name: install dependencies
21
+ command: |
22
+ gem install bundler:2.1.4 && bundle install --jobs=4 --retry=3 --path vendor/bundle
23
+
24
+ - save_cache:
25
+ paths:
26
+ - ./vendor/bundle
27
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
28
+
29
+ # run tests!
30
+ - run:
31
+ name: run tests
32
+ command: |
33
+ bundle exec rake test
data/.gitignore CHANGED
@@ -6,3 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .gem
10
+ .DS_Store
11
+ test/dummy/tmp
12
+ test/dummy/log
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Zaikio Loom Ruby Gem Changelog
2
2
 
3
+ ## 0.2.0 - 2020-03-30
4
+
5
+ - Events are now fired in background with ActiveJob.
6
+
3
7
  ## 0.1.1 – 2020-01-29
4
8
 
5
9
  - Fixes an issue with URLS build on staging and in the sandbox
data/Gemfile.lock CHANGED
@@ -1,25 +1,133 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zaikio-loom (0.1.0)
4
+ zaikio-loom (0.2.0)
5
5
  oj
6
+ rails (~> 6.0, >= 6.0.2.2)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
11
+ actioncable (6.0.2.2)
12
+ actionpack (= 6.0.2.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.0.2.2)
16
+ actionpack (= 6.0.2.2)
17
+ activejob (= 6.0.2.2)
18
+ activerecord (= 6.0.2.2)
19
+ activestorage (= 6.0.2.2)
20
+ activesupport (= 6.0.2.2)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.0.2.2)
23
+ actionpack (= 6.0.2.2)
24
+ actionview (= 6.0.2.2)
25
+ activejob (= 6.0.2.2)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.0.2.2)
29
+ actionview (= 6.0.2.2)
30
+ activesupport (= 6.0.2.2)
31
+ rack (~> 2.0, >= 2.0.8)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.0.2.2)
36
+ actionpack (= 6.0.2.2)
37
+ activerecord (= 6.0.2.2)
38
+ activestorage (= 6.0.2.2)
39
+ activesupport (= 6.0.2.2)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.0.2.2)
42
+ activesupport (= 6.0.2.2)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.0.2.2)
48
+ activesupport (= 6.0.2.2)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.0.2.2)
51
+ activesupport (= 6.0.2.2)
52
+ activerecord (6.0.2.2)
53
+ activemodel (= 6.0.2.2)
54
+ activesupport (= 6.0.2.2)
55
+ activestorage (6.0.2.2)
56
+ actionpack (= 6.0.2.2)
57
+ activejob (= 6.0.2.2)
58
+ activerecord (= 6.0.2.2)
59
+ marcel (~> 0.3.1)
60
+ activesupport (6.0.2.2)
61
+ concurrent-ruby (~> 1.0, >= 1.0.2)
62
+ i18n (>= 0.7, < 2)
63
+ minitest (~> 5.1)
64
+ tzinfo (~> 1.1)
65
+ zeitwerk (~> 2.2)
10
66
  addressable (2.7.0)
11
67
  public_suffix (>= 2.0.2, < 5.0)
12
68
  ast (2.4.0)
69
+ builder (3.2.4)
70
+ concurrent-ruby (1.1.6)
13
71
  crack (0.4.3)
14
72
  safe_yaml (~> 1.0.0)
73
+ crass (1.0.6)
74
+ erubi (1.9.0)
75
+ globalid (0.4.2)
76
+ activesupport (>= 4.2.0)
15
77
  hashdiff (1.0.0)
78
+ i18n (1.8.2)
79
+ concurrent-ruby (~> 1.0)
16
80
  jaro_winkler (1.5.4)
81
+ loofah (2.4.0)
82
+ crass (~> 1.0.2)
83
+ nokogiri (>= 1.5.9)
84
+ mail (2.7.1)
85
+ mini_mime (>= 0.1.1)
86
+ marcel (0.3.3)
87
+ mimemagic (~> 0.3.2)
88
+ method_source (1.0.0)
89
+ mimemagic (0.3.4)
90
+ mini_mime (1.0.2)
91
+ mini_portile2 (2.4.0)
17
92
  minitest (5.14.0)
18
- oj (3.10.1)
93
+ mocha (1.11.2)
94
+ nio4r (2.5.2)
95
+ nokogiri (1.10.9)
96
+ mini_portile2 (~> 2.4.0)
97
+ oj (3.10.5)
19
98
  parallel (1.19.1)
20
99
  parser (2.7.0.2)
21
100
  ast (~> 2.4.0)
22
101
  public_suffix (4.0.3)
102
+ rack (2.2.2)
103
+ rack-test (1.1.0)
104
+ rack (>= 1.0, < 3)
105
+ rails (6.0.2.2)
106
+ actioncable (= 6.0.2.2)
107
+ actionmailbox (= 6.0.2.2)
108
+ actionmailer (= 6.0.2.2)
109
+ actionpack (= 6.0.2.2)
110
+ actiontext (= 6.0.2.2)
111
+ actionview (= 6.0.2.2)
112
+ activejob (= 6.0.2.2)
113
+ activemodel (= 6.0.2.2)
114
+ activerecord (= 6.0.2.2)
115
+ activestorage (= 6.0.2.2)
116
+ activesupport (= 6.0.2.2)
117
+ bundler (>= 1.3.0)
118
+ railties (= 6.0.2.2)
119
+ sprockets-rails (>= 2.0.0)
120
+ rails-dom-testing (2.0.3)
121
+ activesupport (>= 4.2.0)
122
+ nokogiri (>= 1.6)
123
+ rails-html-sanitizer (1.3.0)
124
+ loofah (~> 2.3)
125
+ railties (6.0.2.2)
126
+ actionpack (= 6.0.2.2)
127
+ activesupport (= 6.0.2.2)
128
+ method_source
129
+ rake (>= 0.8.7)
130
+ thor (>= 0.20.3, < 2.0)
23
131
  rainbow (3.0.0)
24
132
  rake (13.0.1)
25
133
  rubocop (0.79.0)
@@ -33,11 +141,26 @@ GEM
33
141
  rubocop (>= 0.71.0)
34
142
  ruby-progressbar (1.10.1)
35
143
  safe_yaml (1.0.5)
144
+ sprockets (4.0.0)
145
+ concurrent-ruby (~> 1.0)
146
+ rack (> 1, < 3)
147
+ sprockets-rails (3.2.1)
148
+ actionpack (>= 4.0)
149
+ activesupport (>= 4.0)
150
+ sprockets (>= 3.0.0)
151
+ thor (1.0.1)
152
+ thread_safe (0.3.6)
153
+ tzinfo (1.2.6)
154
+ thread_safe (~> 0.1)
36
155
  unicode-display_width (1.6.1)
37
156
  webmock (3.8.0)
38
157
  addressable (>= 2.3.6)
39
158
  crack (>= 0.3.2)
40
159
  hashdiff (>= 0.4.0, < 2.0.0)
160
+ websocket-driver (0.7.1)
161
+ websocket-extensions (>= 0.1.0)
162
+ websocket-extensions (0.1.4)
163
+ zeitwerk (2.3.0)
41
164
 
42
165
  PLATFORMS
43
166
  ruby
@@ -45,6 +168,7 @@ PLATFORMS
45
168
  DEPENDENCIES
46
169
  bundler
47
170
  minitest
171
+ mocha
48
172
  rake
49
173
  rubocop
50
174
  rubocop-performance
@@ -52,4 +176,4 @@ DEPENDENCIES
52
176
  zaikio-loom!
53
177
 
54
178
  BUNDLED WITH
55
- 2.1.2
179
+ 2.1.4
data/README.md CHANGED
@@ -58,7 +58,7 @@ Zaikio::Loom.fire_event(
58
58
  )
59
59
  ```
60
60
 
61
- This example would publish an event to Zaikio Loom with a random UUID and the current timestamp.
61
+ This example would publish an event (in the background) to Zaikio Loom with a random UUID and the current timestamp.
62
62
 
63
63
  If you need more control over the published event, for example:
64
64
 
@@ -0,0 +1,9 @@
1
+ module Zaikio
2
+ module Loom
3
+ class FireEventJob < ApplicationJob
4
+ def perform(event)
5
+ event.fire
6
+ end
7
+ end
8
+ end
9
+ end
data/bin/test ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path("../test", __dir__)
3
+
4
+ require "bundler/setup"
5
+ require "rails/plugin/test"
@@ -0,0 +1 @@
1
+ Rails.application.config.active_job.custom_serializers << Zaikio::Loom::EventSerializer
data/lib/zaikio/loom.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require "zaikio/loom/configuration"
2
2
  require "zaikio/loom/event"
3
+ require "zaikio/loom/event_serializer"
4
+ require "zaikio/loom/railtie"
5
+ require "zaikio/loom/engine"
3
6
  require "zaikio/loom/version"
4
7
 
5
8
  module Zaikio
@@ -15,7 +18,7 @@ module Zaikio
15
18
 
16
19
  def self.fire_event(name, **args)
17
20
  event = Event.new(name, **args)
18
- event.fire
21
+ FireEventJob.perform_later(event)
19
22
  end
20
23
  end
21
24
  end
@@ -0,0 +1,9 @@
1
+ module Zaikio
2
+ module Loom
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Zaikio::Loom
5
+ engine_name "zaikio_loom"
6
+ config.generators.api_only = true
7
+ end
8
+ end
9
+ end
@@ -38,6 +38,21 @@ module Zaikio
38
38
  response.is_a?(Net::HTTPSuccess)
39
39
  end
40
40
 
41
+ def to_h # rubocop:disable Metrics/MethodLength
42
+ timestamp = @timestamp || Time.now.getutc
43
+
44
+ {
45
+ id: @id,
46
+ name: @event_name,
47
+ subject: @subject,
48
+ timestamp: timestamp.iso8601,
49
+ receiver: @receiver,
50
+ version: @version,
51
+ payload: @payload,
52
+ link: @link
53
+ }.compact
54
+ end
55
+
41
56
  private
42
57
 
43
58
  def build_request(uri)
@@ -52,24 +67,8 @@ module Zaikio
52
67
  Zaikio::Loom.configuration
53
68
  end
54
69
 
55
- def event_as_json # rubocop:disable Metrics/MethodLength
56
- timestamp = @timestamp || Time.now.getutc
57
-
58
- Oj.dump(
59
- {
60
- event: {
61
- id: @id,
62
- name: @event_name,
63
- subject: @subject,
64
- timestamp: timestamp.iso8601,
65
- receiver: @receiver,
66
- version: @version,
67
- payload: @payload,
68
- link: @link
69
- }.compact
70
- },
71
- mode: :compat
72
- )
70
+ def event_as_json
71
+ Oj.dump({ event: to_h }, mode: :compat)
73
72
  end
74
73
  end
75
74
  end
@@ -0,0 +1,18 @@
1
+ module Zaikio
2
+ module Loom
3
+ class EventSerializer < ActiveJob::Serializers::ObjectSerializer
4
+ def serialize?(argument)
5
+ argument.is_a? Event
6
+ end
7
+
8
+ def serialize(event)
9
+ super(event.to_h)
10
+ end
11
+
12
+ def deserialize(hash)
13
+ name = hash.delete('name')
14
+ Event.new(name, hash)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,6 @@
1
+ module Zaikio
2
+ module Loom
3
+ class Railtie < ::Rails::Railtie
4
+ end
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module Loom
3
- VERSION = "0.1.1".freeze
3
+ VERSION = "0.2.0".freeze
4
4
  end
5
5
  end
data/zaikio-loom.gemspec CHANGED
@@ -24,9 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_runtime_dependency "oj"
27
+ spec.add_dependency "rails", '~> 6.0', '>= 6.0.2.2'
27
28
 
28
29
  spec.add_development_dependency "bundler"
29
30
  spec.add_development_dependency "minitest"
31
+ spec.add_development_dependency "mocha"
30
32
  spec.add_development_dependency "rake"
31
33
  spec.add_development_dependency "rubocop"
32
34
  spec.add_development_dependency "rubocop-performance"
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: 0.1.1
4
+ version: 0.2.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: 2020-01-29 00:00:00.000000000 Z
12
+ date: 2020-03-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oj
@@ -25,6 +25,26 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rails
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '6.0'
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 6.0.2.2
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: '6.0'
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 6.0.2.2
28
48
  - !ruby/object:Gem::Dependency
29
49
  name: bundler
30
50
  requirement: !ruby/object:Gem::Requirement
@@ -53,6 +73,20 @@ dependencies:
53
73
  - - ">="
54
74
  - !ruby/object:Gem::Version
55
75
  version: '0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: mocha
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
56
90
  - !ruby/object:Gem::Dependency
57
91
  name: rake
58
92
  requirement: !ruby/object:Gem::Requirement
@@ -117,9 +151,9 @@ executables: []
117
151
  extensions: []
118
152
  extra_rdoc_files: []
119
153
  files:
154
+ - ".circleci/config.yml"
120
155
  - ".gitignore"
121
156
  - ".rubocop.yml"
122
- - ".travis.yml"
123
157
  - CHANGELOG.md
124
158
  - CODE_OF_CONDUCT.md
125
159
  - Gemfile
@@ -127,10 +161,16 @@ files:
127
161
  - LICENSE.txt
128
162
  - README.md
129
163
  - Rakefile
164
+ - app/jobs/zaikio/loom/fire_event_job.rb
130
165
  - bin/setup
166
+ - bin/test
167
+ - config/initializers/register_zaikio_loom_event_serializer.rb
131
168
  - lib/zaikio/loom.rb
132
169
  - lib/zaikio/loom/configuration.rb
170
+ - lib/zaikio/loom/engine.rb
133
171
  - lib/zaikio/loom/event.rb
172
+ - lib/zaikio/loom/event_serializer.rb
173
+ - lib/zaikio/loom/railtie.rb
134
174
  - lib/zaikio/loom/version.rb
135
175
  - zaikio-loom.gemspec
136
176
  homepage: https://github.com/crispymtn/zai-loom-ruby
@@ -155,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
195
  - !ruby/object:Gem::Version
156
196
  version: '0'
157
197
  requirements: []
158
- rubygems_version: 3.1.2
198
+ rubygems_version: 3.0.1
159
199
  signing_key:
160
200
  specification_version: 4
161
201
  summary: The Zaikio Loom Ruby Gem simplifies publishing events on the Zaikio Loom
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.5
6
- - 2.7.0
7
-
8
- before_install: gem install bundler -v 2.0.2
9
-
10
- script:
11
- - bundle exec rspec
12
- - bundle exec rubocop