slack_mailer 0.1.0 → 0.1.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/.gitignore +1 -0
- data/Gemfile.lock +3 -3
- data/README.md +1 -1
- data/lib/slack_mailer/configuration.rb +16 -8
- data/lib/slack_mailer/delivery_worker.rb +3 -7
- data/lib/slack_mailer/version.rb +1 -1
- data/lib/slack_mailer.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df4702af2c7a0fa3f3a6c4c12c574c41db890e1d722c56446fe544318642ab3a
|
4
|
+
data.tar.gz: 23dbf9d7ed7f1bfb76062578e85b3e87e583d1519092641752e2313107954ef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ad4868d8396141174bf46e53879cfc997cca78f58e3fa6893ba082064e5d24d3cf2b0887225f10b51a9bef30fbef431d17a9287a72c8cc3ff56a93eead38894
|
7
|
+
data.tar.gz: b7db13c0cc438c0ec3855130df398e09801d766f1c0aeaaef687ca606307049c37203eaa69efc76c43a8347f0b3277b4e1fe261485d309999f15781e1efd5073
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slack_mailer (0.1.
|
4
|
+
slack_mailer (0.1.3)
|
5
|
+
slack-notifier (~> 2.3.2)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
@@ -30,8 +31,7 @@ DEPENDENCIES
|
|
30
31
|
bundler (~> 1.16.a)
|
31
32
|
rake (~> 10.0)
|
32
33
|
rspec (~> 3.0)
|
33
|
-
slack-notifier (~> 2.3.2)
|
34
34
|
slack_mailer!
|
35
35
|
|
36
36
|
BUNDLED WITH
|
37
|
-
1.16.
|
37
|
+
1.16.1
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ Add queue for sidekiq in to config/sidekiq.yml
|
|
30
30
|
Create configuration file config/initializers/slack_mailer.rb
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
Slack::Mailer.configure do |config|
|
33
|
+
Slack::Mailer::Configuration.configure do |config|
|
34
34
|
config.templates_path = "#{Rails.root}/app/views/slack_templates/"
|
35
35
|
config.templates_type = 'text'
|
36
36
|
config.erb_in_templates = true
|
@@ -11,17 +11,25 @@ module Slack
|
|
11
11
|
@slack_hook_urls = nil
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
class << self
|
15
|
+
def config
|
16
|
+
@configuration ||= Slack::Mailer::Configuration.new
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def reset
|
20
|
+
@configuration = Slack::Mailer::Configuration.new
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
def configure
|
24
|
+
yield(config)
|
25
|
+
end
|
26
|
+
|
27
|
+
def slack_hook_url
|
28
|
+
@slack_hook_urls_size ||= config.slack_hook_urls.size
|
29
|
+
config.slack_hook_urls[Time.now.to_i % @slack_hook_urls_size]
|
30
|
+
end
|
24
31
|
end
|
32
|
+
|
25
33
|
end
|
26
34
|
end
|
27
35
|
end
|
@@ -13,16 +13,12 @@ module Slack
|
|
13
13
|
Slack::Mailer::DeliveryWorker.perform_async(msg['args'][0])
|
14
14
|
end
|
15
15
|
|
16
|
-
attr_accessor :name, :channel, :message
|
17
|
-
|
18
|
-
def retry_count
|
19
|
-
@retry_count || 0
|
20
|
-
end
|
16
|
+
attr_accessor :name, :channel, :message
|
21
17
|
|
22
18
|
def perform(params)
|
23
|
-
params['url'] = Slack::Mailer::Configuration.config.slack_hook_urls[retry_count]
|
24
19
|
params.each{ |attribute, value| send("#{attribute}=", value) if respond_to?(attribute) }
|
25
|
-
Slack::Notifier.new(
|
20
|
+
Slack::Notifier.new(Slack::Mailer::Configuration.slack_hook_url, username: name, channel: channel, link_names: 1)
|
21
|
+
.ping(message)
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
data/lib/slack_mailer/version.rb
CHANGED
data/lib/slack_mailer.rb
CHANGED
@@ -4,8 +4,8 @@ require 'slack-notifier'
|
|
4
4
|
|
5
5
|
module Slack
|
6
6
|
class Mailer
|
7
|
-
class << self
|
8
7
|
|
8
|
+
class << self
|
9
9
|
def method_missing(method, *args)
|
10
10
|
self.new.send(method, *args)
|
11
11
|
end
|
@@ -17,10 +17,9 @@ module Slack
|
|
17
17
|
|
18
18
|
def send_direct_message(channel = '', name = '', message = '')
|
19
19
|
return if channel.empty? || name.empty? || message.empty?
|
20
|
-
|
21
|
-
|
20
|
+
Slack::Notifier.new(Slack::Mailer::Configuration.slack_hook_url, username: name, channel: channel, link_names: 1)
|
21
|
+
.ping(message)
|
22
22
|
end
|
23
|
-
|
24
23
|
end
|
25
24
|
|
26
25
|
def mail(to: nil, template: nil, use_sidekiq: true)
|
@@ -39,5 +38,6 @@ module Slack
|
|
39
38
|
ActionView::Base.new("#{Slack::Mailer::Configuration.config.templates_path}/#{self.class.name.underscore}",
|
40
39
|
{}, ActionController::Base.new).render(file: template, locals: instance_variables || {})
|
41
40
|
end
|
41
|
+
|
42
42
|
end
|
43
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Appodeal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|