chat_notifier 0.2.3 → 0.2.5

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: bb939785ca31e416e1256cd820a7609e116a9d681497a1a559f91e1e074ee158
4
- data.tar.gz: 721d078e8cc48fa014ab9d7e3672e01a2c9917eb143d0657505cc948a505d332
3
+ metadata.gz: a442afb94e03ba8a40be94d62cb0043abe9a4a88430028bb79a5655ebe2d1f7e
4
+ data.tar.gz: 2070d04462fc7d9fec4daf08b25e900f03d5d7ce735aa5ac51eace3acc6429c6
5
5
  SHA512:
6
- metadata.gz: 59f2cf12159dc31f6ce11a66ac9dee633a072bc97b89c58c954b2ca169de6cec3959042ec77dd1b57a3991d1caf275f8f69b3917b6957bb9afda2720cf92ff48
7
- data.tar.gz: b7190b1bf16eacaaa70dbb0c1d694335e12756097e447d06599bb87f65a37a7b25174c9ddf7363be73a44030c2db9239706caecb285ff5125dadf3ef0ab7fb8e
6
+ metadata.gz: e892f14d366c45b01b3665523ee7b47eba8ad9b15021351b3f626763a08bacce3b72bdd5a6425338e5e1a5b3d94c3ae2294c3c92809060607b9bfa9b8aeaa273
7
+ data.tar.gz: 4a7cdd3397d62a9c7a9e25ea9b1bbf669a9e1c92eac97b95900764df0bc62b878cbd7e7942612852199a8ecd6efff13b0c6ed3604a7160b3d40b8da709e86c3d
data/CHANGELOG.md CHANGED
@@ -5,18 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [0.2.3] - 2024-09-21
8
+ ## [0.2.5] - 2026-02-02
9
9
 
10
- ### Fixed
10
+ ### Added
11
11
 
12
- - Incorrect configuration of the logger
12
+ - Dependabot configuration with weekly updates
13
13
 
14
- ## [0.2.2] - 2024-09-05
14
+ ### Changed
15
15
 
16
- ### Added
16
+ - Moved ENV variable setting `NOTIFY_APP_NAME` into the test helper
17
+ - Refactored method signatures for easier testing
18
+
19
+ ### Removed
20
+
21
+ - OpenStruct dependency
17
22
 
18
- - Test on ruby 3.3
23
+ ## [0.2.4] - 2025-01-16
19
24
 
20
- ### Fixed
25
+ ### Changed
21
26
 
22
- - Load "chat_notifier" from the minitest plugin
27
+ - Add support for Ruby 3.4
28
+ - Check for Rails application before using Rails.application
data/README.md CHANGED
@@ -79,12 +79,4 @@ end
79
79
 
80
80
  ## Contributing
81
81
 
82
- This gem is managed with [Reissue](https://github.com/SOFware/reissue).
83
-
84
- Releasing a new version:
85
-
86
- ```sh
87
- rake build:checksum
88
- rake release
89
- git push
90
- ```
82
+ This gem is managed with [Reissue](https://github.com/SOFware/reissue). Releases are automated via the [shared release workflow](https://github.com/SOFware/reissue/blob/main/.github/workflows/SHARED_WORKFLOW_README.md). Trigger a release by running the "Release gem to RubyGems.org" workflow from the Actions tab.
@@ -13,7 +13,7 @@ module ChatNotifier
13
13
  @environment = environment
14
14
  end
15
15
 
16
- attr :settings, :repository, :environment
16
+ attr_reader :settings, :repository, :environment
17
17
 
18
18
  class << self
19
19
  def handlers
@@ -45,16 +45,16 @@ module ChatNotifier
45
45
  def body
46
46
  end
47
47
 
48
- def post(messenger)
48
+ def post(messenger, process: Net::HTTP.method(:post))
49
49
  uri = URI(webhook_url)
50
50
 
51
- Net::HTTP.post(uri, payload(messenger))
51
+ process.call(uri, payload(messenger))
52
52
  end
53
53
 
54
- def conditional_post(messenger)
54
+ def conditional_post(messenger, process: Net::HTTP.method(:post))
55
55
  return if messenger.success? && !verbose?
56
56
 
57
- post(messenger)
57
+ post(messenger, process:)
58
58
  end
59
59
 
60
60
  def verbose?
@@ -36,7 +36,7 @@ module ChatNotifier
36
36
  @environment = environment
37
37
  end
38
38
 
39
- attr :summary, :app, :repository, :environment
39
+ attr_reader :summary, :app, :repository, :environment
40
40
 
41
41
  def failures = summary.failed_examples
42
42
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChatNotifier
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
data/lib/chat_notifier.rb CHANGED
@@ -16,25 +16,32 @@ module ChatNotifier
16
16
  class << self
17
17
  attr_accessor :logger
18
18
 
19
- def app
20
- if defined?(::Rails)
19
+ def app(env: ENV, name: env.fetch("NOTIFY_APP_NAME"))
20
+ name ||= if defined?(::Rails) && Rails.respond_to?(:application)
21
21
  Rails.application.class.module_parent
22
22
  else
23
- ENV.fetch("NOTIFY_APP_NAME")
23
+ raise "No app name provided and Rails is not defined"
24
24
  end
25
25
  end
26
26
 
27
+ STANDARDS = {
28
+ repository: Repository,
29
+ environment: TestEnvironment,
30
+ chatter: Chatter,
31
+ messenger: Messenger
32
+ }
33
+
27
34
  # In order to test this locally see `rake chat_notifier:debug`
28
- def debug!(env, summary:, notifier: :Debug)
29
- repository = Repository.for(env)
30
- environment = TestEnvironment.for(env)
35
+ def debug!(env, summary:, notifier: :Debug, **kwargs)
36
+ repository = (kwargs[:repository] || STANDARDS[:repository]).for(env)
37
+ environment = (kwargs[:environment] || STANDARDS[:environment]).for(env)
31
38
 
32
- chatter = Chatter.const_get(notifier).new(
39
+ chatter = (kwargs[:chatter] || STANDARDS[:chatter]).const_get(notifier).new(
33
40
  settings: env,
34
41
  repository: repository,
35
42
  environment: environment
36
43
  )
37
- messenger = Messenger.for(
44
+ messenger = (kwargs[:messenger] || STANDARDS[:messenger]).for(
38
45
  summary,
39
46
  app:,
40
47
  repository:,
@@ -44,16 +51,16 @@ module ChatNotifier
44
51
  chatter.post(messenger)
45
52
  end
46
53
 
47
- def call(summary:)
48
- repository = Repository.for(ENV)
49
- environment = TestEnvironment.for(ENV)
50
- chatter = Chatter.handling(
54
+ def call(summary:, **kwargs)
55
+ repository = (kwargs[:repository] || STANDARDS[:repository]).for(ENV)
56
+ environment = (kwargs[:environment] || STANDARDS[:environment]).for(ENV)
57
+ chatter = (kwargs[:chatter] || STANDARDS[:chatter]).handling(
51
58
  ENV,
52
59
  repository:,
53
60
  environment:
54
61
  )
55
62
 
56
- messenger = Messenger.for(
63
+ messenger = (kwargs[:messenger] || STANDARDS[:messenger]).for(
57
64
  summary,
58
65
  app:,
59
66
  repository:,
@@ -61,11 +68,9 @@ module ChatNotifier
61
68
  )
62
69
 
63
70
  chatter.each do |box|
64
- begin
65
- box.conditional_post(messenger)
66
- rescue => exception
67
- logger.error("ChatNotifier: #{box.webhook_url} #{exception.class}: #{exception.message}")
68
- end
71
+ box.conditional_post(messenger)
72
+ rescue => exception
73
+ logger.error("ChatNotifier: #{box.webhook_url} #{exception.class}: #{exception.message}")
69
74
  end
70
75
  end
71
76
  end
@@ -8,8 +8,8 @@ module Minitest
8
8
  ExceptionLocation = Data.define(:location)
9
9
  Summary = Data.define(:failed_examples)
10
10
  def report
11
- summary = Summary[(results.map{ |result| ExceptionLocation[result.source_location] })]
11
+ summary = Summary[(results.map { |result| ExceptionLocation[result.source_location] })]
12
12
  ::ChatNotifier.call(summary:)
13
13
  end
14
14
  end
15
- end
15
+ end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chat_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
8
8
  - Savannah Albanez
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2024-09-21 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Send test results to chat
15
14
  email:
@@ -36,12 +35,10 @@ files:
36
35
  - lib/chat_notifier/test_environment/github.rb
37
36
  - lib/chat_notifier/version.rb
38
37
  - lib/minitest/chat_notifier_plugin.rb
39
- homepage:
40
38
  licenses: []
41
39
  metadata:
42
40
  source_code_uri: https://github.com/SOFware/chat_notifier.git
43
41
  changelog_uri: https://github.com/SOFWare/chat_notifier/blob/master/CHANGELOG.md
44
- post_install_message:
45
42
  rdoc_options: []
46
43
  require_paths:
47
44
  - lib
@@ -56,8 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
53
  - !ruby/object:Gem::Version
57
54
  version: '0'
58
55
  requirements: []
59
- rubygems_version: 3.5.9
60
- signing_key:
56
+ rubygems_version: 3.6.9
61
57
  specification_version: 4
62
58
  summary: Notify chat of test results
63
59
  test_files: []