nautilfer 0.3.0 → 0.3.1
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 +4 -4
- data/README.md +44 -0
- data/lib/nautilfer/version.rb +1 -1
- data/lib/nautilfer.rb +57 -6
- metadata +2 -3
- data/Gemfile.lock +0 -74
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f026890d209390f607032ea3ac7f6c30375600b711f2377c3df67b68bbd050e7
|
|
4
|
+
data.tar.gz: 943ed91b71baaa172ba03f7e861ccf41f65ecdd18ecdeec511cf4d26f0592ad2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 580405d5b98669d458560cc4a84abb99501eaed169eebfad4a0a27ff2496055125534379dbc5c144ddd76a30f96d3d17a73605493ccea3a8404d77a36ebcd37e
|
|
7
|
+
data.tar.gz: 46500be06ccc88b586feddc3cad131bbe5ea9701be8df3a4ff67f9ad73d7b12dab6c1b8eeea9ee1bc51a654586f1dddd17aca9378aa8d7ab7e5de781889ff744
|
data/README.md
CHANGED
|
@@ -74,6 +74,50 @@ slack_notifier = Nautilfer.new(endpoint: "#{slack_webhook_url}", adapter: :slack
|
|
|
74
74
|
slack_notifier.notify("Deployment completed")
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
### Control notifications by environment
|
|
78
|
+
|
|
79
|
+
Use the environment controls to avoid sending notifications in non-production environments. The notifier checks the `environment` you pass in (defaulting to `ENV['NAUTILFER_ENV']`, `ENV['RAILS_ENV']`, or `ENV['RACK_ENV']`) and will only send messages when the environment is allowed.
|
|
80
|
+
|
|
81
|
+
Enable notifications only in specific environments:
|
|
82
|
+
|
|
83
|
+
```ruby
|
|
84
|
+
Nautilfer.to_teams(
|
|
85
|
+
message: "Release deployed",
|
|
86
|
+
endpoint: "#{workflow_endpoint}",
|
|
87
|
+
environment: 'production',
|
|
88
|
+
enabled_environments: ['production']
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Or disable notifications for certain environments:
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
Nautilfer.to_slack(
|
|
96
|
+
message: "Smoke tests running",
|
|
97
|
+
endpoint: "#{slack_webhook_url}",
|
|
98
|
+
environment: 'test',
|
|
99
|
+
disabled_environments: ['test', 'development']
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Configure defaults once
|
|
104
|
+
|
|
105
|
+
Persist your environment preferences by configuring defaults up front. New instances and helper calls will reuse these values unless you override them per call.
|
|
106
|
+
|
|
107
|
+
```ruby
|
|
108
|
+
Nautilfer.configure do |config|
|
|
109
|
+
config.environment = ENV['NAUTILFER_ENV']
|
|
110
|
+
config.enabled_environments = ['production']
|
|
111
|
+
config.disabled_environments = ['test']
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
notifier = Nautilfer.new(endpoint: "#{workflow_endpoint}", adapter: :teams)
|
|
115
|
+
notifier.notify("Deployment finished")
|
|
116
|
+
|
|
117
|
+
# Helpers will also reuse the configured defaults
|
|
118
|
+
Nautilfer.to_slack(message: "Deployment finished", endpoint: "#{slack_webhook_url}")
|
|
119
|
+
```
|
|
120
|
+
|
|
77
121
|
## Chatwork Notification Integration
|
|
78
122
|
|
|
79
123
|
To enable Chatwork notifications, configure the API token and room ID:
|
data/lib/nautilfer/version.rb
CHANGED
data/lib/nautilfer.rb
CHANGED
|
@@ -8,27 +8,78 @@ require "uri"
|
|
|
8
8
|
class Nautilfer
|
|
9
9
|
class Error < StandardError; end
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
class Configuration
|
|
12
|
+
attr_accessor :environment, :enabled_environments, :disabled_environments
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@enabled_environments = []
|
|
16
|
+
@disabled_environments = []
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.configuration
|
|
21
|
+
@configuration ||= Configuration.new
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.configure
|
|
25
|
+
yield(configuration)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.reset_configuration!
|
|
29
|
+
@configuration = Configuration.new
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def initialize(endpoint:, adapter: :teams, environment: nil, enabled_environments: nil, disabled_environments: nil)
|
|
33
|
+
config = self.class.configuration
|
|
34
|
+
|
|
12
35
|
@endpoint = URI.parse(endpoint)
|
|
13
36
|
@adapter = adapter
|
|
37
|
+
@environment = environment || config.environment || ENV['NAUTILFER_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV']
|
|
38
|
+
@enabled_environments = normalize_env_list(enabled_environments, config.enabled_environments)
|
|
39
|
+
@disabled_environments = normalize_env_list(disabled_environments, config.disabled_environments)
|
|
14
40
|
end
|
|
15
41
|
|
|
16
42
|
def notify(message)
|
|
43
|
+
return if notifications_disabled?
|
|
44
|
+
|
|
17
45
|
payload, headers = build_payload(message)
|
|
18
46
|
perform_request(payload, headers)
|
|
19
47
|
end
|
|
20
48
|
|
|
21
|
-
def self.to_teams(message:, endpoint:)
|
|
22
|
-
new(
|
|
49
|
+
def self.to_teams(message:, endpoint:, environment: nil, enabled_environments: nil, disabled_environments: nil)
|
|
50
|
+
new(
|
|
51
|
+
endpoint: endpoint,
|
|
52
|
+
adapter: :teams,
|
|
53
|
+
environment: environment,
|
|
54
|
+
enabled_environments: enabled_environments,
|
|
55
|
+
disabled_environments: disabled_environments
|
|
56
|
+
).notify(message)
|
|
23
57
|
end
|
|
24
58
|
|
|
25
|
-
def self.to_slack(message:, endpoint:)
|
|
26
|
-
new(
|
|
59
|
+
def self.to_slack(message:, endpoint:, environment: nil, enabled_environments: nil, disabled_environments: nil)
|
|
60
|
+
new(
|
|
61
|
+
endpoint: endpoint,
|
|
62
|
+
adapter: :slack,
|
|
63
|
+
environment: environment,
|
|
64
|
+
enabled_environments: enabled_environments,
|
|
65
|
+
disabled_environments: disabled_environments
|
|
66
|
+
).notify(message)
|
|
27
67
|
end
|
|
28
68
|
|
|
29
69
|
private
|
|
30
70
|
|
|
31
|
-
attr_reader :endpoint, :adapter
|
|
71
|
+
attr_reader :endpoint, :adapter, :environment, :enabled_environments, :disabled_environments
|
|
72
|
+
|
|
73
|
+
def normalize_env_list(custom_value, configured_value)
|
|
74
|
+
Array(custom_value.nil? ? configured_value : custom_value).compact
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def notifications_disabled?
|
|
78
|
+
return true if disabled_environments.include?(environment)
|
|
79
|
+
return false if enabled_environments.empty?
|
|
80
|
+
|
|
81
|
+
!enabled_environments.include?(environment)
|
|
82
|
+
end
|
|
32
83
|
|
|
33
84
|
def build_payload(message)
|
|
34
85
|
case adapter
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nautilfer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yusuke Abe
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-11-
|
|
10
|
+
date: 2025-11-16 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: Nautilfer provides a robust and flexible way to send notifications to
|
|
13
13
|
Microsoft Teams using workflow integrations.
|
|
@@ -23,7 +23,6 @@ files:
|
|
|
23
23
|
- CODE_OF_CONDUCT.md
|
|
24
24
|
- Dockerfile
|
|
25
25
|
- Gemfile
|
|
26
|
-
- Gemfile.lock
|
|
27
26
|
- LICENSE.txt
|
|
28
27
|
- README.md
|
|
29
28
|
- Rakefile
|
data/Gemfile.lock
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
nautilfer (0.3.0)
|
|
5
|
-
|
|
6
|
-
GEM
|
|
7
|
-
remote: https://rubygems.org/
|
|
8
|
-
specs:
|
|
9
|
-
addressable (2.8.7)
|
|
10
|
-
public_suffix (>= 2.0.2, < 7.0)
|
|
11
|
-
ast (2.4.2)
|
|
12
|
-
bigdecimal (3.1.8)
|
|
13
|
-
crack (1.0.0)
|
|
14
|
-
bigdecimal
|
|
15
|
-
rexml
|
|
16
|
-
diff-lcs (1.5.1)
|
|
17
|
-
hashdiff (1.1.1)
|
|
18
|
-
json (2.7.2)
|
|
19
|
-
language_server-protocol (3.17.0.3)
|
|
20
|
-
parallel (1.26.3)
|
|
21
|
-
parser (3.3.4.2)
|
|
22
|
-
ast (~> 2.4.1)
|
|
23
|
-
racc
|
|
24
|
-
public_suffix (6.0.1)
|
|
25
|
-
racc (1.8.1)
|
|
26
|
-
rainbow (3.1.1)
|
|
27
|
-
rake (13.2.1)
|
|
28
|
-
regexp_parser (2.9.2)
|
|
29
|
-
rexml (3.4.2)
|
|
30
|
-
rspec (3.13.0)
|
|
31
|
-
rspec-core (~> 3.13.0)
|
|
32
|
-
rspec-expectations (~> 3.13.0)
|
|
33
|
-
rspec-mocks (~> 3.13.0)
|
|
34
|
-
rspec-core (3.13.0)
|
|
35
|
-
rspec-support (~> 3.13.0)
|
|
36
|
-
rspec-expectations (3.13.2)
|
|
37
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
|
-
rspec-support (~> 3.13.0)
|
|
39
|
-
rspec-mocks (3.13.1)
|
|
40
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
41
|
-
rspec-support (~> 3.13.0)
|
|
42
|
-
rspec-support (3.13.1)
|
|
43
|
-
rubocop (1.66.0)
|
|
44
|
-
json (~> 2.3)
|
|
45
|
-
language_server-protocol (>= 3.17.0)
|
|
46
|
-
parallel (~> 1.10)
|
|
47
|
-
parser (>= 3.3.0.2)
|
|
48
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
49
|
-
regexp_parser (>= 2.4, < 3.0)
|
|
50
|
-
rubocop-ast (>= 1.32.1, < 2.0)
|
|
51
|
-
ruby-progressbar (~> 1.7)
|
|
52
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
|
53
|
-
rubocop-ast (1.32.1)
|
|
54
|
-
parser (>= 3.3.1.0)
|
|
55
|
-
ruby-progressbar (1.13.0)
|
|
56
|
-
unicode-display_width (2.5.0)
|
|
57
|
-
webmock (3.23.1)
|
|
58
|
-
addressable (>= 2.8.0)
|
|
59
|
-
crack (>= 0.3.2)
|
|
60
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
|
61
|
-
|
|
62
|
-
PLATFORMS
|
|
63
|
-
ruby
|
|
64
|
-
x86_64-linux
|
|
65
|
-
|
|
66
|
-
DEPENDENCIES
|
|
67
|
-
nautilfer!
|
|
68
|
-
rake (~> 13.0)
|
|
69
|
-
rspec (~> 3.0)
|
|
70
|
-
rubocop (~> 1.21)
|
|
71
|
-
webmock (~> 3.23)
|
|
72
|
-
|
|
73
|
-
BUNDLED WITH
|
|
74
|
-
2.7.1
|