ms_teams_notification 1.0.0 → 1.0.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 +5 -3
- data/lib/ms_teams_notification/base.rb +10 -10
- data/lib/ms_teams_notification/formatter.rb +2 -4
- data/lib/ms_teams_notification/logger.rb +4 -4
- data/lib/ms_teams_notification/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08cc3ad47e2c50f41a587eb875f2acee3a6a3a886074cb08aafccb18578d3544'
|
4
|
+
data.tar.gz: d6f3a8a4f587b695c7681207bf8d523cca2e3b3e3f22501915d36c8a8d636f6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33eb154df6609a1b3bcc9a1db098b0a57073e2c4bd80b6a903d0da0207dc300e2e209b2b875c8d2a13eaab1efdd30edb45285d409100e1a6e44105100493f1b1
|
7
|
+
data.tar.gz: 3b7453241e907f57d4b35551ebc381493725c04520d74fa62e68ddbde0adffa16ad52df06a69d27cf36f307ed0e47db6110267099e47c72c32fdfecfc8b9f62c
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
# MS Teams
|
1
|
+
# MS Teams Notifications
|
2
|
+
[](https://rubygems.org/gems/ms_teams_notification)
|
3
|
+
[](https://github.com/abarrak/ms_teams_notification/actions/workflows/main.yml)
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
2
5
|
|
3
|
-
A ruby library from simple notification capablities for Microsoft Teams.
|
4
6
|
|
5
|
-
|
7
|
+
A ruby library from simple notification capablities for Microsoft Teams.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
1
|
+
require "uri"
|
2
|
+
require "net/http"
|
3
|
+
require "active_support/core_ext/object/blank"
|
4
|
+
require_relative "logger"
|
4
5
|
|
5
6
|
module MsTeamsNotification
|
6
7
|
class Base
|
7
|
-
|
8
8
|
attr_reader :default_subject
|
9
9
|
|
10
10
|
def initialize **kwargs
|
11
11
|
@log = MsTeamsNotification::Logger.instance
|
12
12
|
|
13
|
-
setup_configuration
|
13
|
+
setup_configuration(**kwargs)
|
14
14
|
configure_ms_teams
|
15
15
|
end
|
16
16
|
|
@@ -20,8 +20,8 @@ module MsTeamsNotification
|
|
20
20
|
@log.msg "#{self_name}: sending ms teams notification."
|
21
21
|
|
22
22
|
request = Net::HTTP::Post.new @webhook_url.request_uri
|
23
|
-
request[
|
24
|
-
request.body = {
|
23
|
+
request["Content-Type"] = "application/json"
|
24
|
+
request.body = {title: message_subject, text: text}.to_json
|
25
25
|
|
26
26
|
http = Net::HTTP.new @webhook_url.host, @webhook_url.port
|
27
27
|
http.use_ssl = true
|
@@ -30,7 +30,7 @@ module MsTeamsNotification
|
|
30
30
|
body = http.request(request)&.body
|
31
31
|
@log.msg "#{self_name}: ms teams notification is sent."
|
32
32
|
body
|
33
|
-
rescue
|
33
|
+
rescue => e
|
34
34
|
@log.msg "#{self_name}: ms teams notification failed.", level: :error
|
35
35
|
@log.msg "#{self_name}: #{e.message}.", level: :error
|
36
36
|
end
|
@@ -43,8 +43,8 @@ module MsTeamsNotification
|
|
43
43
|
|
44
44
|
def setup_configuration **opts
|
45
45
|
%i[notification_subject ms_teams_webhook].each do |sym|
|
46
|
-
|
47
|
-
|
46
|
+
@log.msg "#{self_name}: argument #{sym} is empty.", level: :warn if opts[sym].blank?
|
47
|
+
instance_variable_set "@#{sym}", opts[sym]
|
48
48
|
end
|
49
49
|
|
50
50
|
@default_subject = "Automated Notification."
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "erb"
|
2
|
+
require "active_support/core_ext/object/blank"
|
3
3
|
|
4
4
|
module MsTeamsNotification
|
5
5
|
class Formatter
|
6
|
-
|
7
6
|
def initialize fields
|
8
7
|
@fields = fields
|
9
8
|
end
|
@@ -22,6 +21,5 @@ module MsTeamsNotification
|
|
22
21
|
HTML
|
23
22
|
).result(binding)
|
24
23
|
end
|
25
|
-
|
26
24
|
end
|
27
25
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "logger"
|
2
|
+
require "singleton"
|
3
3
|
|
4
4
|
module MsTeamsNotification
|
5
5
|
class Logger
|
6
6
|
include Singleton
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
@logger = ::Logger.new
|
9
|
+
@logger = ::Logger.new $stdout
|
10
10
|
@logger.level = ::Logger::DEBUG
|
11
11
|
end
|
12
12
|
|
13
13
|
def msg *message, level: :info
|
14
|
-
@logger.send level.to_s, message.join(
|
14
|
+
@logger.send level.to_s, message.join("").to_s if @logger.respond_to?(level)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ms_teams_notification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdullah Barrak
|
@@ -107,6 +107,20 @@ dependencies:
|
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '1.0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: webmock
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '3'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '3'
|
110
124
|
description: A ruby library that offers simple notification capablities for Microsoft
|
111
125
|
Teams.
|
112
126
|
email:
|