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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7b02c1b68e24f2001a70a4e34dee2a5230139a6a10d14b0d368630a78b1886e
4
- data.tar.gz: 9c6895c0a4286c029ce834fab53ed033c2faab0fb2ad7a45f69cb6c768965cd4
3
+ metadata.gz: df4702af2c7a0fa3f3a6c4c12c574c41db890e1d722c56446fe544318642ab3a
4
+ data.tar.gz: 23dbf9d7ed7f1bfb76062578e85b3e87e583d1519092641752e2313107954ef4
5
5
  SHA512:
6
- metadata.gz: fb39ef37aa06e7898737ff6473765627bdab19079a91e2abb5aa6ebeebb445f41f9c70cd8c63b0afe46e9b699eaca1462eae7a5b9a2981f1827e934b31ab835d
7
- data.tar.gz: e32b7dddd40d4a592fb0c2016ac95e0bcd0fea757537ec50ecce35a229888d251283116f9937bd732ef68e4a571f8774983a5ebcbacdaf0d0ac518126a14b5bf
6
+ metadata.gz: 6ad4868d8396141174bf46e53879cfc997cca78f58e3fa6893ba082064e5d24d3cf2b0887225f10b51a9bef30fbef431d17a9287a72c8cc3ff56a93eead38894
7
+ data.tar.gz: b7db13c0cc438c0ec3855130df398e09801d766f1c0aeaaef687ca606307049c37203eaa69efc76c43a8347f0b3277b4e1fe261485d309999f15781e1efd5073
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .rvmrc
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack_mailer (0.1.0)
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.0.pre.3
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
- def self.config
15
- @configuration ||= Slack::Mailer::Configuration.new
16
- end
14
+ class << self
15
+ def config
16
+ @configuration ||= Slack::Mailer::Configuration.new
17
+ end
17
18
 
18
- def self.reset
19
- @configuration = Slack::Mailer::Configuration.new
20
- end
19
+ def reset
20
+ @configuration = Slack::Mailer::Configuration.new
21
+ end
21
22
 
22
- def self.configure
23
- yield(config)
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, :url, :retry_count
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(url, username: name, channel: channel, link_names: 1).ping(message)
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
@@ -1,5 +1,5 @@
1
1
  module Slack
2
2
  class Mailer
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
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
- url = Slack::Mailer::Configuration.config.slack_hook_urls.mrandom
21
- Slack::Notifier.new(url, username: name, channel: channel, link_names: 1).ping(message)
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.0
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-03-16 00:00:00.000000000 Z
11
+ date: 2018-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler