mailkick 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0750bea0ea92b3202ed0d741f50efb0c40ec7a1f
4
- data.tar.gz: 55d4087445153084af0810e7e5a729eb379d3bbb
3
+ metadata.gz: 0bf0541ba51746a50f8a286d7acd0bed58660b4b
4
+ data.tar.gz: 796d78becdc4f302b06dd1eb7bf44df154fd9e6f
5
5
  SHA512:
6
- metadata.gz: 3fce62385ba937b6ad173db9a27d93dcb26a95e453868bf5f81b278ee1d8b5ce3ae98661aa4bc53894e07793ad6be240fc29b2294123717e03b4f4cf6916aa22
7
- data.tar.gz: 57818f63ff5dba4a8c020e926a19bc5733e7b75c3b0278629ed2ca9ee010195d9791061f544cd5b8e06e8fa0b2173baa3c3459ecab3cd728e71095d75245a731
6
+ metadata.gz: da32468a31c92c6e674eb1b397827d155c01bd918ade637c9145702b92c35ebb39c916eee01c680efad85ac1b2d298ad2b4b9bb2033bd1d04dfab67baca8e58c
7
+ data.tar.gz: 11cbb1e1b2cce5d3763cb11517892d010240ad24e467ff3a2f9b9d8f1d69a1320ab8efd777093edaf328ba1241495bf2f50303d39e82b5333e35dd49b8b130bd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.4
2
+
3
+ - Use `Module#prepend` instead of `alias_method_chain`
4
+
1
5
  ## 0.1.3
2
6
 
3
7
  - Fixed issue with double escaping tokens
data/lib/mailkick.rb CHANGED
@@ -21,9 +21,7 @@ module Mailkick
21
21
 
22
22
  def self.discover_services
23
23
  Service.subclasses.each do |service|
24
- if service.discoverable?
25
- services << service.new
26
- end
24
+ services << service.new if service.discoverable?
27
25
  end
28
26
  end
29
27
 
@@ -67,9 +65,7 @@ module Mailkick
67
65
  parts << "user_id = ? and user_type = ?"
68
66
  binds.concat [user.id, user.class.name]
69
67
  end
70
- if parts.any?
71
- relation = relation.where(parts.join(" OR "), *binds)
72
- end
68
+ relation = relation.where(parts.join(" OR "), *binds) if parts.any?
73
69
 
74
70
  relation =
75
71
  if options[:list]
@@ -91,5 +87,5 @@ module Mailkick
91
87
  end
92
88
  end
93
89
 
94
- ActionMailer::Base.send :include, Mailkick::Mailer
90
+ ActionMailer::Base.send(:prepend, Mailkick::Mailer)
95
91
  ActiveRecord::Base.send(:extend, Mailkick::Model) if defined?(ActiveRecord)
@@ -1,13 +1,7 @@
1
1
  module Mailkick
2
2
  module Mailer
3
- def self.included(base)
4
- base.class_eval do
5
- alias_method_chain :mail, :mailkick
6
- end
7
- end
8
-
9
- def mail_with_mailkick(headers = {}, &block)
10
- message = mail_without_mailkick(headers, &block)
3
+ def mail(headers = {}, &block)
4
+ message = super
11
5
 
12
6
  Mailkick::Processor.new(message).process
13
7
 
@@ -3,8 +3,8 @@
3
3
  module Mailkick
4
4
  class Service
5
5
  class Mailgun < Mailkick::Service
6
- def initalize(options = {})
7
- require 'mailgun'
6
+ def initialize(options = {})
7
+ require "mailgun"
8
8
  mailgun_client = ::Mailgun::Client.new(options[:api_key] || ENV["MAILGUN_API_KEY"])
9
9
  domain = options[:domain] || ActionMailer::Base.default_url_options[:host]
10
10
  @mailgun_events = ::Mailgun::Events.new(mailgun_client, domain)
@@ -15,15 +15,15 @@ module Mailkick
15
15
  end
16
16
 
17
17
  def unsubscribes
18
- fetch(@mailgun_events.get({event: 'unsubscribed'}), 'unsubscribe')
18
+ fetch(@mailgun_events.get(event: "unsubscribed"), "unsubscribe")
19
19
  end
20
20
 
21
21
  def spam_reports
22
- fetch(@mailgun_events.get({event: 'complained'}), 'spam')
22
+ fetch(@mailgun_events.get(event: "complained"), "spam")
23
23
  end
24
24
 
25
25
  def bounces
26
- fetch(@mailgun_events.get({event: 'failed'}), 'bounce')
26
+ fetch(@mailgun_events.get(event: "failed"), "bounce")
27
27
  end
28
28
 
29
29
  def self.discoverable?
@@ -33,10 +33,10 @@ module Mailkick
33
33
  protected
34
34
 
35
35
  def fetch(response, reason)
36
- response.to_h['items'].map do |record|
36
+ response.to_h["items"].map do |record|
37
37
  {
38
- email: record['recipient'],
39
- time: ActiveSupport::TimeZone['UTC'].at(record['timestamp']),
38
+ email: record["recipient"],
39
+ time: ActiveSupport::TimeZone["UTC"].at(record["timestamp"]),
40
40
  reason: reason
41
41
  }
42
42
  end
@@ -1,3 +1,3 @@
1
1
  module Mailkick
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-30 00:00:00.000000000 Z
11
+ date: 2016-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.4.5
94
+ rubygems_version: 2.4.5.1
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Email subscriptions made easy