slactionmailer 0.0.2 → 0.0.3
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/lib/slactionmailer/delivery_method.rb +6 -4
- data/lib/slactionmailer/message.rb +3 -4
- data/lib/slactionmailer/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b73fc4cb138a09f2af4ff78a986845c9b50cd322
|
4
|
+
data.tar.gz: cc75c51e5aef197fcc16f90e344da89f4e2d3aad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7c9a7687045ac7d8babbe58983c8671af0dc7ca8fcc22153ce78f6c7454f12aa7ca6a40f5a71ffd655ba70f18edc0b186419b69ce56a8ceafd54edf9b7b9658
|
7
|
+
data.tar.gz: 2f500cefad7559c52c3a3bb7142aa4c80e3e55e74ecdb84e917fc80da240ae3c6d3b667e53af1ad2bc0dabb7443cf259e57fc74feb1c8fea7c95473833d509f2
|
@@ -3,16 +3,18 @@ module SlactionMailer
|
|
3
3
|
class InvalidOption < StandardError; end
|
4
4
|
|
5
5
|
attr_accessor :settings
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(options = {})
|
8
|
-
raise InvalidOption, 'ENV["SLACK_WEBHOOK_URL"]is required to send messages' if options[:webhook].nil?
|
9
|
-
raise InvalidOption, 'ENV["SLACK_CHANNEL"]is required to send messages' if options[:channel].nil?
|
10
8
|
raise InvalidOption, 'ENV["SLACK_USERNAME"]is required to send messages' if options[:username].nil?
|
11
9
|
self.settings = options
|
12
10
|
end
|
13
11
|
|
14
12
|
def deliver!(mail)
|
15
|
-
|
13
|
+
raise InvalidOption, 'channel is required to send messages' if mail[:channel].nil? && ENV["SLACK_CHANNEL"].nil?
|
14
|
+
raise InvalidOption, 'webhook is required to send messages' if mail[:webhook].nil? && ENV["SLACK_USERNAME"].nil?
|
15
|
+
channel = mail[:channel].nil? ? ENV["SLACK_CHANNEL"] : mail[:channel].value
|
16
|
+
webhook = mail[:webhook].nil? ? ENV["SLACK_WEBHOOK_URL"] : mail[:webhook].value
|
17
|
+
notifier = Slack::Notifier.new webhook, channel: channel, username: settings[:username]
|
16
18
|
if settings.key?(:template)
|
17
19
|
message = Message.new(mail, :template => settings[:template])
|
18
20
|
else
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'erb'
|
2
2
|
|
3
|
-
|
4
3
|
module SlactionMailer
|
5
4
|
class Message < ERB
|
6
|
-
|
5
|
+
|
7
6
|
def initialize(mail, options = {})
|
8
7
|
@mail = mail
|
9
8
|
@template = options.fetch(:template, self.class.template)
|
@@ -12,7 +11,7 @@ module SlactionMailer
|
|
12
11
|
|
13
12
|
def body
|
14
13
|
@mail.text_part.body.decoded
|
15
|
-
end
|
14
|
+
end
|
16
15
|
|
17
16
|
def from
|
18
17
|
@from ||= Array(@mail['from']).join(", ")
|
@@ -26,7 +25,7 @@ module SlactionMailer
|
|
26
25
|
"Subject: <%= @mail.subject %>
|
27
26
|
From: <%= from %>
|
28
27
|
To: <%= to %>
|
29
|
-
|
28
|
+
|
30
29
|
<%= body %>"
|
31
30
|
end
|
32
31
|
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slactionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Gillentine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 4.2.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.2.2
|
27
27
|
- !ruby/object:Gem::Dependency
|