stoplight-honeybadger 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 07ee52ce63031df39696cb4cc923766a2b9c072cc61d5bc2fefdc3aff40a6b17
4
+ data.tar.gz: 98b975287fe7d88deb2ed553f106ed83e1bcde93ac2cd82f9df1c00da4457e6e
5
+ SHA512:
6
+ metadata.gz: fa9a5f936382c9f43fee95a35d7a5913679f3ff23c26bc1d767912e69e78618e40a66a0793f044403970d7bfdbffbe884e5c2f594e875f0c04399117210ab479
7
+ data.tar.gz: 91132d151c0c8a3d5af5a9c7e8ebc0e04e1d7eb10ae3a0c309c7c1e797c7e760ac3b9ef8797817a0d78ce6f4a248cd5aad3cc07e9dc3ca860e355ea478851955
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 QoQa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Stoplight::Honeybadger
2
+ Honeybadger notifier for Stoplight
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```
9
+ gem 'stoplight-honeybadger'
10
+ ```
11
+
12
+ And then execute:
13
+ ```
14
+ $ bundle install
15
+ ```
16
+
17
+ Or install it yourself as:
18
+ ```
19
+ $ gem install stoplight-honeybadger
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Make sure you have the [honeybadger gem](https://github.com/honeybadger-io/honeybadger-ruby) installed before configuring Stoplight.
25
+
26
+ ```ruby
27
+ require 'honeybadger'
28
+
29
+ notifier = Stoplight::Honeybadger::Notifier.new(Honeybadger)
30
+ # => #<Stoplight::Honeybadger::Notifier:...>
31
+ Stoplight::Light.default_notifiers += [notifier]
32
+ # => [#<Stoplight::Notifier::IO:...>, #<Stoplight::Honeybadger::Notifier:...>]
33
+ ```
34
+
35
+ You can configure notifier to add custom option to the notification:
36
+
37
+ ```
38
+ notifier = Stoplight::Honeybadger::Notifier.new(Honeybadger, tags: {foo: 'bar'})
39
+ # => #<Stoplight::Honeybadger::Notifier:...>
40
+ Stoplight::Light.default_notifiers += [notifier]
41
+ # => [#<Stoplight::Notifier::IO:...>, #<Stoplight::Honeybadger::Notifier:...>]
42
+ ```
43
+
44
+ ## Development
45
+
46
+ After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
47
+
48
+ 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 the created tag, and push the .gem file to rubygems.org.
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/qoqa/stoplight-honeybadger
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the MIT License.
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stoplight
4
+ module Honeybadger
5
+ # Usage:
6
+ #
7
+ # notifier = Stoplight::Honeybadger::Notifier.new('api key')
8
+ # Stoplight::Light.default_notifiers += [notifier]
9
+ #
10
+ class Notifier < ::Stoplight::Notifier::Base
11
+ DEFAULT_OPTIONS = {
12
+ parameters: {},
13
+ session: {},
14
+ context: {}
15
+ }.freeze
16
+
17
+ # @return [String]
18
+ attr_reader :api_key
19
+ # @return [Proc]
20
+ attr_reader :formatter
21
+ # @return [Hash{Symbol => Object}]
22
+ attr_reader :options
23
+
24
+ # rubocop:disable Lint/MissingSuper
25
+ # @param api_key [String]
26
+ # @param formatter [Proc, nil]
27
+ # @param options [Hash{Symbol => Object}]
28
+ # @option options [Hash] :parameters
29
+ # @option options [Hash] :session
30
+ # @option options [Hash] :context
31
+ def initialize(api_key, formatter = nil, options = {})
32
+ @api_key = api_key
33
+ @formatter = formatter || Stoplight::Default::FORMATTER
34
+ @options = DEFAULT_OPTIONS.merge(options)
35
+ end
36
+ # rubocop:enable Lint/MissingSuper
37
+
38
+ # @param light [Stoplight::Light]
39
+ # @param from_color [String]
40
+ # @param to_color [String]
41
+ # @param error [StandardError]
42
+ # @return [String]
43
+ def notify(light, from_color, to_color, error)
44
+ message = formatter.call(light, from_color, to_color, error)
45
+ ::Honeybadger.notify(options.merge(
46
+ api_key: api_key,
47
+ error_message: message,
48
+ backtrace: error&.backtrace
49
+ ))
50
+ message
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stoplight
4
+ module Honeybadger
5
+ VERSION = '1.0.0'
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'honeybadger'
4
+ require 'stoplight'
5
+ require_relative 'honeybadger/version'
6
+ require_relative 'honeybadger/notifier'
7
+
8
+ # Stoplight module
9
+ module Stoplight
10
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stoplight-honeybadger
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - QoQa
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2024-12-30 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Honeybadger notifier for Stoplight
13
+ email:
14
+ - dev@qoqa.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE.txt
20
+ - README.md
21
+ - lib/stoplight/honeybadger.rb
22
+ - lib/stoplight/honeybadger/notifier.rb
23
+ - lib/stoplight/honeybadger/version.rb
24
+ homepage: https://github.com/qoqa/stoplight-honeybadger
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://github.com/qoqa/stoplight-honeybadger
29
+ source_code_uri: https://github.com/qoqa/stoplight-honeybadger
30
+ changelog_uri: https://github.com/qoqa/stoplight-honeybadger/releases
31
+ rubygems_mfa_required: 'true'
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.3.3
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.6.2
47
+ specification_version: 4
48
+ summary: Honeybadger notifier for Stoplight
49
+ test_files: []