stoplight-sentry 0.1.0 → 1.0.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: c1fac56cd801c5b8be0848bee64cbcbaa5976b6b3c05ab3621592130d412daa0
4
- data.tar.gz: 45743013be1f9faaba15ac0370e827b14314d46a4cb1259e6f637605d00a1468
3
+ metadata.gz: e87b4206c4ce27888e5a3cdd74d93bf69fef50ecc1d5ddac52c517e46afe3324
4
+ data.tar.gz: d139bcb9189c6f4283586f2e4f9d0a1505f193d2c39f755027c18950ad917dc4
5
5
  SHA512:
6
- metadata.gz: 3877d10ea9d2001f23da0712ef822744476c1d51f8feffc2673a8a2cc95133905b86ee15660bbe5c9e891fe89ab3ea13e0a280ac50bec7794f6e4abf5650d138
7
- data.tar.gz: d4fdaeaddcf2a50a44d5496de33adf374f526876c93ac00b2093d9f7c572b25214ffbbe27dfe8269a653ee768131c6171b4ff5ce131e217bdfa290d7cde9befa
6
+ metadata.gz: 2b07f61e009db1a58ec8b436d907128cf5bc3672376a54cf28d9db00be3dcc06a7210069dcded65b5ac213be58e2bece90ca6c1c6a96b925bba1059b0e1ca8a8
7
+ data.tar.gz: 67072c6221ddb5c4fdff6d5e40e7025fa1d57150991d8a57e229614e81481d7df54cee5ac76c741f205874b46310ccaa35ff35b76b0f541a2470068d3b34d255
data/README.md CHANGED
@@ -26,18 +26,20 @@ Make sure you have the [sentry-ruby] gem installed before configuring Stoplight.
26
26
  require 'sentry-ruby'
27
27
 
28
28
  notifier = Stoplight::Sentry::Notifier.new(Sentry)
29
- # => #<Stoplight::Sentry::Notifier:...>
30
- Stoplight::Light.default_notifiers += [notifier]
31
- # => [#<Stoplight::Notifier::IO:...>, #<Stoplight::Sentry::Notifier:...>]
29
+
30
+ Stoplight.configure do |config|
31
+ config.notifiers += [notifier]
32
+ end
32
33
  ```
33
34
 
34
35
  you can configure notifier to add custom option to the notification:
35
36
 
36
37
  ```ruby
37
38
  notifier = Stoplight::Sentry::Notifier.new(Sentry, tags: {foo: 'bar'})
38
- # => #<Stoplight::Sentry::Notifier:...>
39
- Stoplight::Light.default_notifiers += [notifier]
40
- # => [#<Stoplight::Notifier::IO:...>, #<Stoplight::Sentry::Notifier:...>]
39
+
40
+ Stoplight.configure do |config|
41
+ config.notifiers += [notifier]
42
+ end
41
43
  ```
42
44
 
43
45
  ## Development
@@ -20,12 +20,19 @@ module Stoplight
20
20
  # @return [Hash]
21
21
  attr_reader :options
22
22
 
23
+ DEFAULT_FORMATTER = lambda do |light, from_color, to_color, error|
24
+ words = ["Switching", light.name, "from", from_color, "to", to_color]
25
+ words += ["because", error.class, error.message] if error
26
+ words.join(" ")
27
+ end
28
+ private_constant :DEFAULT_FORMATTER
29
+
23
30
  # @param sentry [::Sentry]
24
- # @param formatter [Proc, nil] (Stoplight::Default::FORMATTER)
31
+ # @param formatter [Proc, nil]
25
32
  # @param options [Hash] custom options for the +Sentry#capture_message+ method
26
33
  def initialize(sentry, formatter = nil, **options)
27
34
  @sentry = sentry
28
- @formatter = formatter || Stoplight::Default::FORMATTER
35
+ @formatter = formatter || DEFAULT_FORMATTER
29
36
  @options = options
30
37
  end
31
38
 
@@ -35,7 +42,7 @@ module Stoplight
35
42
  # @param error []StandardError]
36
43
  # @return [String]
37
44
  def notify(light, from_color, to_color, error)
38
- formatter.(light, from_color, to_color, error).tap do |message|
45
+ formatter.call(light, from_color, to_color, error).tap do |message|
39
46
  options.merge(backtrace: error&.backtrace).then do |sentry_options|
40
47
  sentry.capture_message(message, **sentry_options)
41
48
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Stoplight
4
4
  module Sentry
5
- VERSION = "0.1.0"
5
+ VERSION = "1.0.0"
6
6
  public_constant :VERSION
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,57 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stoplight-sentry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tëma Bolshakov
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-12-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: stoplight
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '3.0'
18
+ version: '5'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '3.0'
25
+ version: '5'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: sentry-ruby
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: '5.7'
32
+ version: '5'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - "~>"
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: '5.7'
41
- - !ruby/object:Gem::Dependency
42
- name: ruby_coding_standard
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 0.4.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 0.4.0
39
+ version: '5'
55
40
  description: Sentry notifier for Stoplight
56
41
  email:
57
42
  - either.free@gmail.com
@@ -64,9 +49,6 @@ files:
64
49
  - lib/stoplight/sentry.rb
65
50
  - lib/stoplight/sentry/notifier.rb
66
51
  - lib/stoplight/sentry/version.rb
67
- - spec/spec_helper.rb
68
- - spec/stoplight/sentry/notifier_spec.rb
69
- - spec/stoplight/sentry_spec.rb
70
52
  homepage: https://github.com/bolshakov/stoplight-sentry
71
53
  licenses:
72
54
  - MIT
@@ -74,7 +56,6 @@ metadata:
74
56
  homepage_uri: https://github.com/bolshakov/stoplight-sentry
75
57
  source_code_uri: https://github.com/bolshakov/stoplight-sentry
76
58
  changelog_uri: https://github.com/bolshakov/stoplight-sentry/releases
77
- post_install_message:
78
59
  rdoc_options: []
79
60
  require_paths:
80
61
  - lib
@@ -82,18 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
63
  requirements:
83
64
  - - ">="
84
65
  - !ruby/object:Gem::Version
85
- version: '2.7'
66
+ version: '3.2'
86
67
  required_rubygems_version: !ruby/object:Gem::Requirement
87
68
  requirements:
88
69
  - - ">="
89
70
  - !ruby/object:Gem::Version
90
71
  version: '0'
91
72
  requirements: []
92
- rubygems_version: 3.3.7
93
- signing_key:
73
+ rubygems_version: 3.6.9
94
74
  specification_version: 4
95
75
  summary: Sentry notifier for Stoplight
96
- test_files:
97
- - spec/spec_helper.rb
98
- - spec/stoplight/sentry/notifier_spec.rb
99
- - spec/stoplight/sentry_spec.rb
76
+ test_files: []
data/spec/spec_helper.rb DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "stoplight/sentry"
4
-
5
- RSpec.configure do |config|
6
- # Enable flags like --only-failures and --next-failure
7
- config.example_status_persistence_file_path = ".rspec_status"
8
-
9
- # Disable RSpec exposing methods globally on `Module` and `main`
10
- config.disable_monkey_patching!
11
-
12
- config.expect_with :rspec do |c|
13
- c.syntax = :expect
14
- end
15
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "securerandom"
4
-
5
- RSpec.describe Stoplight::Sentry::Notifier do
6
- subject(:notify) { notifier.notify(light, from_color, to_color, error) }
7
-
8
- let(:notifier) { described_class.new(sentry, formatter, **options) }
9
- let(:sentry) { class_double(Sentry) }
10
- let(:light) { instance_double(Stoplight::Light, name: "light-name") }
11
- let(:from_color) { Stoplight::Color::GREEN }
12
- let(:to_color) { Stoplight::Color::RED }
13
- let(:error) { StandardError.new("something went wrong").tap { _1.set_backtrace(backtrace) } }
14
- let(:backtrace) { ["foo", "bar"] }
15
- let(:options) { {} }
16
-
17
- context "when formatter is provided" do
18
- let(:formatter) { instance_double(Proc) }
19
- let(:message) { SecureRandom.uuid }
20
-
21
- before do
22
- expect(formatter).to receive(:call).with(light, from_color, to_color, error) { message }
23
- end
24
-
25
- it "notifies sentry" do
26
- expect(sentry).to receive(:capture_message).with(message, backtrace: backtrace)
27
-
28
- expect(notify).to eq(message)
29
- end
30
-
31
- context "with custom options" do
32
- let(:options) { { tags: { foo: "bar" }} }
33
-
34
- it "notifies sentry" do
35
- expect(sentry).to receive(:capture_message).with(message, backtrace: backtrace, tags: { foo: "bar" })
36
-
37
- expect(notify).to eq(message)
38
- end
39
- end
40
- end
41
-
42
- context "when formatter is not provided" do
43
- let(:formatter) { nil }
44
- let(:message) { "Switching light-name from green to red because StandardError something went wrong" }
45
-
46
- it "notifies sentry" do
47
- expect(sentry).to receive(:capture_message).with(message, backtrace: backtrace)
48
-
49
- notify
50
- end
51
-
52
- context "with custom options" do
53
- let(:options) { { tags: { foo: "bar" }} }
54
-
55
- it "notifies sentry" do
56
- expect(sentry).to receive(:capture_message).with(message, backtrace: backtrace, tags: { foo: "bar" })
57
-
58
- expect(notify).to eq(message)
59
- end
60
- end
61
- end
62
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Stoplight::Sentry do
4
- it "has a version number" do
5
- expect(Stoplight::Sentry::VERSION).not_to be_nil
6
- end
7
- end