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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfb249a3e91d820836863718c53f9e86c2a454de8619faefb25e1b9720cf7640
4
- data.tar.gz: c988cb1572833486317fde003f0cb9a8c54d36f9feb3bc6204408e5a3a416276
3
+ metadata.gz: '08cc3ad47e2c50f41a587eb875f2acee3a6a3a886074cb08aafccb18578d3544'
4
+ data.tar.gz: d6f3a8a4f587b695c7681207bf8d523cca2e3b3e3f22501915d36c8a8d636f6f
5
5
  SHA512:
6
- metadata.gz: 70f0fb885391cb86803aba55c243dbe51cd5a898ee943d068fdbcbcab8713bb1da6dd44d704521260cd98cb4c86e8198ca5a937a9c154d761d796f5948f43b8e
7
- data.tar.gz: '0859660f2eae0ef259a3509151acfd7e54673da2d2e2b71b970071b5c487e1f6ac94a6c781a7e6c0baecaadbfee4f9bc220ac2d57db9ea9e89958885177b8934'
6
+ metadata.gz: 33eb154df6609a1b3bcc9a1db098b0a57073e2c4bd80b6a903d0da0207dc300e2e209b2b875c8d2a13eaab1efdd30edb45285d409100e1a6e44105100493f1b1
7
+ data.tar.gz: 3b7453241e907f57d4b35551ebc381493725c04520d74fa62e68ddbde0adffa16ad52df06a69d27cf36f307ed0e47db6110267099e47c72c32fdfecfc8b9f62c
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # MS Teams Notifier
1
+ # MS Teams Notifications
2
+ [![Gem Version](https://badge.fury.io/rb/ms_teams_notification.svg)](https://rubygems.org/gems/ms_teams_notification)
3
+ [![Build](https://github.com/abarrak/ms_teams_notification/actions/workflows/main.yml/badge.svg)](https://github.com/abarrak/ms_teams_notification/actions/workflows/main.yml)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2
5
 
3
- A ruby library from simple notification capablities for Microsoft Teams.
4
6
 
5
- > Extracted from [volume sweeper](https://github.com/abarrak/volume_sweeper/blob/main/lib/volume_sweeper) tool.
7
+ A ruby library from simple notification capablities for Microsoft Teams.
6
8
 
7
9
  ## Installation
8
10
 
@@ -1,16 +1,16 @@
1
- require 'uri'
2
- require 'active_support/core_ext/object/blank'
3
- require_relative 'logger'
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 **kwargs
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['Content-Type'] = 'application/json'
24
- request.body = { title: message_subject, text: text }.to_json
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 StandardError => e
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
- @log.msg "#{self_name}: argument #{sym} is empty.", level: :warn if opts[sym].blank?
47
- instance_variable_set "@#{sym.to_s}", opts[sym]
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 'erb'
2
- require 'active_support/core_ext/object/blank'
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 'logger'
2
- require 'singleton'
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 STDOUT
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('').to_s if @logger.respond_to?(level)
14
+ @logger.send level.to_s, message.join("").to_s if @logger.respond_to?(level)
15
15
  end
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MsTeamsNotification
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  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.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: