zaikio-loom 0.2.1 → 0.3.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: 5ec2697f1050c963fe99c522c105ce3543c76b2ef60bdf4c3083c357ad71c57f
4
- data.tar.gz: 7f978e19c8cf577a417084dfa10b984172a3d012372aa334573ec092ac242fe7
3
+ metadata.gz: 83b8f848c42ce893f17ea2fcc965f607cbb2582de13d2cb6a5082937f4035d66
4
+ data.tar.gz: dcc33304f16d8e5b223ddd62d4edb339fc087cfb8f25b61a464a76e2f2a03a0c
5
5
  SHA512:
6
- metadata.gz: d72fe92f72f0230fe26cdbc4a46a556f8ef8001e32ec0b08a1ab6120d13414fd35a4ed5a7e8e41f7e30f17c0f4138a1725220a7b0399994bef984ab0099f2dd4
7
- data.tar.gz: 0eb3cb77f32d721658959daaedf3a699e19bd6024d5d63768f8fad7f0e6be118d497afeb7c6f06180439b93b2a1ddaffb6c850da04d16900c5b58e9b731f1544
6
+ metadata.gz: 3f123c3dd9b2356b118593d3de86f78b7ef9307c0118b174a84b44b77acff372660e39b9bbe218c19ca19f3602c98e0d9fc6159d54a50314d7688a2d12322ea0
7
+ data.tar.gz: c612160d9ff55ebd84d2bc75d3d42549dfe6b0510f6dc57f43706cc4f5f2a3750fe7bb210a90fe898a36a15bcbf85076ac12dad73723d6483341dbca8be8934f
data/.rubocop.yml CHANGED
@@ -2,6 +2,7 @@ AllCops:
2
2
  TargetRubyVersion: 2.6
3
3
  Exclude:
4
4
  - test/**/*.rb
5
+ NewCops: enable
5
6
 
6
7
  require:
7
8
  - rubocop-performance
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Zaikio Loom Ruby Gem Changelog
2
2
 
3
+ ## 0.3.0 - 2020-04-22
4
+
5
+ - Do not send events to Loom in development or staging environment
6
+
3
7
  ## 0.2.1 - 2020-03-30
4
8
 
5
9
  - Fix bug with event serialization
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zaikio-loom (0.2.1)
4
+ zaikio-loom (0.3.0)
5
5
  oj
6
6
  rails (~> 6.0, >= 6.0.2.2)
7
7
 
@@ -74,11 +74,11 @@ GEM
74
74
  erubi (1.9.0)
75
75
  globalid (0.4.2)
76
76
  activesupport (>= 4.2.0)
77
- hashdiff (1.0.0)
77
+ hashdiff (1.0.1)
78
78
  i18n (1.8.2)
79
79
  concurrent-ruby (~> 1.0)
80
80
  jaro_winkler (1.5.4)
81
- loofah (2.4.0)
81
+ loofah (2.5.0)
82
82
  crass (~> 1.0.2)
83
83
  nokogiri (>= 1.5.9)
84
84
  mail (2.7.1)
@@ -94,11 +94,11 @@ GEM
94
94
  nio4r (2.5.2)
95
95
  nokogiri (1.10.9)
96
96
  mini_portile2 (~> 2.4.0)
97
- oj (3.10.5)
97
+ oj (3.10.6)
98
98
  parallel (1.19.1)
99
- parser (2.7.0.2)
99
+ parser (2.7.1.1)
100
100
  ast (~> 2.4.0)
101
- public_suffix (4.0.3)
101
+ public_suffix (4.0.4)
102
102
  rack (2.2.2)
103
103
  rack-test (1.1.0)
104
104
  rack (>= 1.0, < 3)
@@ -130,13 +130,15 @@ GEM
130
130
  thor (>= 0.20.3, < 2.0)
131
131
  rainbow (3.0.0)
132
132
  rake (13.0.1)
133
- rubocop (0.79.0)
133
+ rexml (3.2.4)
134
+ rubocop (0.82.0)
134
135
  jaro_winkler (~> 1.5.1)
135
136
  parallel (~> 1.10)
136
137
  parser (>= 2.7.0.1)
137
138
  rainbow (>= 2.2.2, < 4.0)
139
+ rexml
138
140
  ruby-progressbar (~> 1.7)
139
- unicode-display_width (>= 1.4.0, < 1.7)
141
+ unicode-display_width (>= 1.4.0, < 2.0)
140
142
  rubocop-performance (1.5.2)
141
143
  rubocop (>= 0.71.0)
142
144
  ruby-progressbar (1.10.1)
@@ -150,10 +152,10 @@ GEM
150
152
  sprockets (>= 3.0.0)
151
153
  thor (1.0.1)
152
154
  thread_safe (0.3.6)
153
- tzinfo (1.2.6)
155
+ tzinfo (1.2.7)
154
156
  thread_safe (~> 0.1)
155
- unicode-display_width (1.6.1)
156
- webmock (3.8.0)
157
+ unicode-display_width (1.7.0)
158
+ webmock (3.8.3)
157
159
  addressable (>= 2.3.6)
158
160
  crack (>= 0.3.2)
159
161
  hashdiff (>= 0.4.0, < 2.0.0)
data/bin/test CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- $: << File.expand_path("../test", __dir__)
2
+ $LOAD_PATH << File.expand_path("../test", __dir__)
3
3
 
4
4
  require "bundler/setup"
5
5
  require "rails/plugin/test"
@@ -4,11 +4,9 @@ module Zaikio
4
4
  module Loom
5
5
  class Configuration
6
6
  HOSTS = {
7
- development: "http://loom.zaikio.test",
8
- test: "http://loom.zaikio.test",
9
- staging: "https://loom.staging.zaikio.com",
10
- sandbox: "https://loom.sandbox.zaikio.com",
11
- production: "https://loom.zaikio.com"
7
+ test: "http://loom.zaikio.test",
8
+ sandbox: "https://loom.sandbox.zaikio.com",
9
+ production: "https://loom.zaikio.com"
12
10
  }.freeze
13
11
 
14
12
  attr_accessor :app_name, :password, :version
@@ -25,15 +23,7 @@ module Zaikio
25
23
 
26
24
  def environment=(env)
27
25
  @environment = env.to_sym
28
- @host = host_for(environment)
29
- end
30
-
31
- private
32
-
33
- def host_for(environment)
34
- HOSTS.fetch(environment) do
35
- raise StandardError.new, "Invalid Zaikio::Loom environment '#{environment}'"
36
- end
26
+ @host = HOSTS[environment]
37
27
  end
38
28
  end
39
29
  end
@@ -5,7 +5,7 @@ require "securerandom"
5
5
  module Zaikio
6
6
  module Loom
7
7
  class Event
8
- attr_reader :status_code, :response_body
8
+ attr_reader :id, :status_code, :response_body
9
9
 
10
10
  def initialize(name, subject:, id: nil, link: nil, payload: nil, receiver: nil, timestamp: nil, version: nil) # rubocop:disable Metrics/ParameterLists
11
11
  @event_name = "#{configuration.app_name}.#{name}"
@@ -23,6 +23,8 @@ module Zaikio
23
23
  end
24
24
 
25
25
  def fire # rubocop:disable Metrics/AbcSize
26
+ log_event
27
+
26
28
  return false unless configuration.password && configuration.host
27
29
 
28
30
  uri = URI("#{configuration.host}/api/v1/events")
@@ -68,7 +70,11 @@ module Zaikio
68
70
  end
69
71
 
70
72
  def event_as_json
71
- Oj.dump({ event: to_h }, mode: :compat)
73
+ @event_as_json ||= Oj.dump({ event: to_h }, mode: :compat)
74
+ end
75
+
76
+ def log_event
77
+ configuration.logger.info("Zaikio::Loom event\n#{event_as_json}")
72
78
  end
73
79
  end
74
80
  end
@@ -10,10 +10,10 @@ module Zaikio
10
10
  end
11
11
 
12
12
  def deserialize(hash)
13
- name = hash.delete('name').split('.').last
14
- timestamp = DateTime.parse(hash.delete('timestamp'))
15
- hash.delete('_aj_serialized')
16
- Event.new(name, hash.symbolize_keys.merge(timestamp: timestamp))
13
+ name = hash.delete("name").split(".").last
14
+ timestamp = DateTime.parse(hash.delete("timestamp"))
15
+ hash.delete("_aj_serialized")
16
+ Event.new(name, **hash.symbolize_keys.merge(timestamp: timestamp))
17
17
  end
18
18
  end
19
19
  end
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module Loom
3
- VERSION = "0.2.1".freeze
3
+ VERSION = "0.3.0".freeze
4
4
  end
5
5
  end
data/zaikio-loom.gemspec CHANGED
@@ -24,7 +24,7 @@ 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
+ spec.add_dependency "rails", "~> 6.0", ">= 6.0.2.2"
28
28
 
29
29
  spec.add_development_dependency "bundler"
30
30
  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: 0.2.1
4
+ version: 0.3.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-03-30 00:00:00.000000000 Z
12
+ date: 2020-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oj
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  requirements: []
198
- rubygems_version: 3.0.1
198
+ rubygems_version: 3.1.2
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: The Zaikio Loom Ruby Gem simplifies publishing events on the Zaikio Loom