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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/mailkick.rb +3 -7
- data/lib/mailkick/mailer.rb +2 -8
- data/lib/mailkick/service/mailgun.rb +8 -8
- data/lib/mailkick/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bf0541ba51746a50f8a286d7acd0bed58660b4b
|
4
|
+
data.tar.gz: 796d78becdc4f302b06dd1eb7bf44df154fd9e6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da32468a31c92c6e674eb1b397827d155c01bd918ade637c9145702b92c35ebb39c916eee01c680efad85ac1b2d298ad2b4b9bb2033bd1d04dfab67baca8e58c
|
7
|
+
data.tar.gz: 11cbb1e1b2cce5d3763cb11517892d010240ad24e467ff3a2f9b9d8f1d69a1320ab8efd777093edaf328ba1241495bf2f50303d39e82b5333e35dd49b8b130bd
|
data/CHANGELOG.md
CHANGED
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
|
90
|
+
ActionMailer::Base.send(:prepend, Mailkick::Mailer)
|
95
91
|
ActiveRecord::Base.send(:extend, Mailkick::Model) if defined?(ActiveRecord)
|
data/lib/mailkick/mailer.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
module Mailkick
|
2
2
|
module Mailer
|
3
|
-
def
|
4
|
-
|
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
|
7
|
-
require
|
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(
|
18
|
+
fetch(@mailgun_events.get(event: "unsubscribed"), "unsubscribe")
|
19
19
|
end
|
20
20
|
|
21
21
|
def spam_reports
|
22
|
-
fetch(@mailgun_events.get(
|
22
|
+
fetch(@mailgun_events.get(event: "complained"), "spam")
|
23
23
|
end
|
24
24
|
|
25
25
|
def bounces
|
26
|
-
fetch(@mailgun_events.get(
|
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[
|
36
|
+
response.to_h["items"].map do |record|
|
37
37
|
{
|
38
|
-
email: record[
|
39
|
-
time: ActiveSupport::TimeZone[
|
38
|
+
email: record["recipient"],
|
39
|
+
time: ActiveSupport::TimeZone["UTC"].at(record["timestamp"]),
|
40
40
|
reason: reason
|
41
41
|
}
|
42
42
|
end
|
data/lib/mailkick/version.rb
CHANGED
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.
|
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:
|
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
|