mailkick 0.3.1 → 0.4.0
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/CHANGELOG.md +7 -1
- data/LICENSE.txt +1 -1
- data/README.md +6 -0
- data/app/controllers/mailkick/subscriptions_controller.rb +1 -5
- data/app/models/mailkick/opt_out.rb +1 -1
- data/lib/generators/mailkick/install_generator.rb +3 -20
- data/lib/generators/mailkick/templates/{install.rb → install.rb.tt} +0 -0
- data/lib/mailkick.rb +5 -1
- data/lib/mailkick/model.rb +10 -9
- data/lib/mailkick/version.rb +1 -1
- metadata +9 -38
- data/.gitignore +0 -25
- data/.travis.yml +0 -16
- data/Gemfile +0 -6
- data/Rakefile +0 -9
- data/mailkick.gemspec +0 -32
- data/test/gemfiles/actionmailer42.gemfile +0 -6
- data/test/gemfiles/actionmailer50.gemfile +0 -6
- data/test/gemfiles/actionmailer51.gemfile +0 -6
- data/test/internal/app/mailers/user_mailer.rb +0 -7
- data/test/internal/app/models/user.rb +0 -3
- data/test/internal/app/views/user_mailer/welcome.html.erb +0 -1
- data/test/internal/app/views/user_mailer/welcome.text.erb +0 -1
- data/test/internal/config/database.yml +0 -3
- data/test/internal/db/schema.rb +0 -16
- data/test/mailkick_test.rb +0 -29
- data/test/test_helper.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8256980737a3ffda9fce00c4117b05566bf89728f39869e3c5f8afd8a0419728
|
4
|
+
data.tar.gz: dc8887bf9b238bdc3031e7f1b0aa3ba42a36f371494f62583b319b84dab70162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 670b60804614ab81daba07cbc20fdde047386b6ea704f66ce4934737b9211b16e34683ad469f318683195aa7036d19615ba4a0363352c0979ec6a40b2467f009
|
7
|
+
data.tar.gz: b5acb8496859d172360fb59ff06a7406831b79837264758eb9f6ba88c47ff3b731404b7a75bf08c59539553ff8ab44901785485e996c69063bdb086973a70977
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.4.0
|
2
|
+
|
3
|
+
- Fixed error with model methods and `email_key` option
|
4
|
+
- Fixed bug with `opted_out` scope
|
5
|
+
- Dropped support for Action Mailer 4.2
|
6
|
+
|
1
7
|
## 0.3.1
|
2
8
|
|
3
9
|
- Fixed `Secret should not be nil` error in Rails 5.2
|
@@ -10,7 +16,7 @@
|
|
10
16
|
- Fixed `Subscription not found` for Rails 5.2
|
11
17
|
- Use `references` in migration
|
12
18
|
- Use `smtp_settings[:domain]` for Mailgun
|
13
|
-
- Dropped support for
|
19
|
+
- Dropped support for Action Mailer < 4.2
|
14
20
|
|
15
21
|
## 0.2.1
|
16
22
|
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -31,11 +31,7 @@ module Mailkick
|
|
31
31
|
list: @list
|
32
32
|
}
|
33
33
|
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
34
|
-
|
35
|
-
render plain: "Subscription not found", status: :bad_request
|
36
|
-
else
|
37
|
-
render text: "Subscription not found", status: :bad_request
|
38
|
-
end
|
34
|
+
render plain: "Subscription not found", status: :bad_request
|
39
35
|
end
|
40
36
|
|
41
37
|
def opted_out?
|
@@ -2,6 +2,6 @@ module Mailkick
|
|
2
2
|
class OptOut < ActiveRecord::Base
|
3
3
|
self.table_name = "mailkick_opt_outs"
|
4
4
|
|
5
|
-
belongs_to :user,
|
5
|
+
belongs_to :user, polymorphic: true, optional: true
|
6
6
|
end
|
7
7
|
end
|
@@ -1,34 +1,17 @@
|
|
1
|
-
# taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
|
2
|
-
require "rails/generators"
|
3
|
-
require "rails/generators/migration"
|
4
|
-
require "active_record"
|
5
1
|
require "rails/generators/active_record"
|
6
2
|
|
7
3
|
module Mailkick
|
8
4
|
module Generators
|
9
5
|
class InstallGenerator < Rails::Generators::Base
|
10
|
-
include
|
11
|
-
|
12
|
-
source_root File.expand_path("../templates", __FILE__)
|
13
|
-
|
14
|
-
# Implement the required interface for Rails::Generators::Migration.
|
15
|
-
def self.next_migration_number(dirname) #:nodoc:
|
16
|
-
next_migration_number = current_migration_number(dirname) + 1
|
17
|
-
if ActiveRecord::Base.timestamped_migrations
|
18
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
19
|
-
else
|
20
|
-
"%.3d" % next_migration_number
|
21
|
-
end
|
22
|
-
end
|
6
|
+
include ActiveRecord::Generators::Migration
|
7
|
+
source_root File.join(__dir__, "templates")
|
23
8
|
|
24
9
|
def copy_migration
|
25
10
|
migration_template "install.rb", "db/migrate/install_mailkick.rb", migration_version: migration_version
|
26
11
|
end
|
27
12
|
|
28
13
|
def migration_version
|
29
|
-
|
30
|
-
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
31
|
-
end
|
14
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
32
15
|
end
|
33
16
|
end
|
34
17
|
end
|
File without changes
|
data/lib/mailkick.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# dependencies
|
1
2
|
require "set"
|
2
3
|
require "active_support"
|
3
4
|
|
4
|
-
|
5
|
+
# modules
|
5
6
|
require "mailkick/model"
|
6
7
|
require "mailkick/service"
|
7
8
|
require "mailkick/service/mailchimp"
|
@@ -10,6 +11,9 @@ require "mailkick/service/mandrill"
|
|
10
11
|
require "mailkick/service/sendgrid"
|
11
12
|
require "mailkick/version"
|
12
13
|
|
14
|
+
# integrations
|
15
|
+
require "mailkick/engine" if defined?(Rails)
|
16
|
+
|
13
17
|
module Mailkick
|
14
18
|
mattr_accessor :services, :user_method, :secret_token, :mount
|
15
19
|
self.services = []
|
data/lib/mailkick/model.rb
CHANGED
@@ -3,8 +3,8 @@ module Mailkick
|
|
3
3
|
def mailkick_user(opts = {})
|
4
4
|
email_key = opts[:email_key] || :email
|
5
5
|
class_eval do
|
6
|
-
scope :opted_out,
|
7
|
-
binds = [
|
6
|
+
scope :opted_out, lambda { |options = {}|
|
7
|
+
binds = [name, true]
|
8
8
|
if options[:list]
|
9
9
|
query = "(mailkick_opt_outs.list IS NULL OR mailkick_opt_outs.list = ?)"
|
10
10
|
binds << options[:list]
|
@@ -13,20 +13,21 @@ module Mailkick
|
|
13
13
|
end
|
14
14
|
where("#{options[:not] ? 'NOT ' : ''}EXISTS(SELECT * FROM mailkick_opt_outs WHERE (#{table_name}.#{email_key} = mailkick_opt_outs.email OR (#{table_name}.#{primary_key} = mailkick_opt_outs.user_id AND mailkick_opt_outs.user_type = ?)) AND mailkick_opt_outs.active = ? AND #{query})", *binds)
|
15
15
|
}
|
16
|
-
|
16
|
+
|
17
|
+
scope :not_opted_out, lambda { |options = {}|
|
17
18
|
opted_out(options.merge(not: true))
|
18
19
|
}
|
19
20
|
|
20
|
-
|
21
|
-
Mailkick.opted_out?({email:
|
21
|
+
define_method :opted_out? do |options = {}|
|
22
|
+
Mailkick.opted_out?({email: send(email_key), user: self}.merge(options))
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
Mailkick.opt_out({email:
|
25
|
+
define_method :opt_out do |options = {}|
|
26
|
+
Mailkick.opt_out({email: send(email_key), user: self}.merge(options))
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
Mailkick.opt_in({email:
|
29
|
+
define_method :opt_in do |options = {}|
|
30
|
+
Mailkick.opt_in({email: send(email_key), user: self}.merge(options))
|
30
31
|
end
|
31
32
|
end
|
32
33
|
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.
|
4
|
+
version: 0.4.0
|
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: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5'
|
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
|
-
version: '
|
26
|
+
version: '5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,26 +165,21 @@ dependencies:
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
description:
|
168
|
-
email:
|
169
|
-
- andrew@chartkick.com
|
168
|
+
email: andrew@chartkick.com
|
170
169
|
executables: []
|
171
170
|
extensions: []
|
172
171
|
extra_rdoc_files: []
|
173
172
|
files:
|
174
|
-
- ".gitignore"
|
175
|
-
- ".travis.yml"
|
176
173
|
- CHANGELOG.md
|
177
|
-
- Gemfile
|
178
174
|
- LICENSE.txt
|
179
175
|
- README.md
|
180
|
-
- Rakefile
|
181
176
|
- app/controllers/mailkick/subscriptions_controller.rb
|
182
177
|
- app/helpers/mailkick/url_helper.rb
|
183
178
|
- app/models/mailkick/opt_out.rb
|
184
179
|
- app/views/mailkick/subscriptions/show.html.erb
|
185
180
|
- config/routes.rb
|
186
181
|
- lib/generators/mailkick/install_generator.rb
|
187
|
-
- lib/generators/mailkick/templates/install.rb
|
182
|
+
- lib/generators/mailkick/templates/install.rb.tt
|
188
183
|
- lib/generators/mailkick/views_generator.rb
|
189
184
|
- lib/mailkick.rb
|
190
185
|
- lib/mailkick/engine.rb
|
@@ -195,18 +190,6 @@ files:
|
|
195
190
|
- lib/mailkick/service/mandrill.rb
|
196
191
|
- lib/mailkick/service/sendgrid.rb
|
197
192
|
- lib/mailkick/version.rb
|
198
|
-
- mailkick.gemspec
|
199
|
-
- test/gemfiles/actionmailer42.gemfile
|
200
|
-
- test/gemfiles/actionmailer50.gemfile
|
201
|
-
- test/gemfiles/actionmailer51.gemfile
|
202
|
-
- test/internal/app/mailers/user_mailer.rb
|
203
|
-
- test/internal/app/models/user.rb
|
204
|
-
- test/internal/app/views/user_mailer/welcome.html.erb
|
205
|
-
- test/internal/app/views/user_mailer/welcome.text.erb
|
206
|
-
- test/internal/config/database.yml
|
207
|
-
- test/internal/db/schema.rb
|
208
|
-
- test/mailkick_test.rb
|
209
|
-
- test/test_helper.rb
|
210
193
|
homepage: https://github.com/ankane/mailkick
|
211
194
|
licenses:
|
212
195
|
- MIT
|
@@ -219,27 +202,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
202
|
requirements:
|
220
203
|
- - ">="
|
221
204
|
- !ruby/object:Gem::Version
|
222
|
-
version: '
|
205
|
+
version: '2.4'
|
223
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
207
|
requirements:
|
225
208
|
- - ">="
|
226
209
|
- !ruby/object:Gem::Version
|
227
210
|
version: '0'
|
228
211
|
requirements: []
|
229
|
-
|
230
|
-
rubygems_version: 2.7.6
|
212
|
+
rubygems_version: 3.0.4
|
231
213
|
signing_key:
|
232
214
|
specification_version: 4
|
233
215
|
summary: Email subscriptions made easy
|
234
|
-
test_files:
|
235
|
-
- test/gemfiles/actionmailer42.gemfile
|
236
|
-
- test/gemfiles/actionmailer50.gemfile
|
237
|
-
- test/gemfiles/actionmailer51.gemfile
|
238
|
-
- test/internal/app/mailers/user_mailer.rb
|
239
|
-
- test/internal/app/models/user.rb
|
240
|
-
- test/internal/app/views/user_mailer/welcome.html.erb
|
241
|
-
- test/internal/app/views/user_mailer/welcome.text.erb
|
242
|
-
- test/internal/config/database.yml
|
243
|
-
- test/internal/db/schema.rb
|
244
|
-
- test/mailkick_test.rb
|
245
|
-
- test/test_helper.rb
|
216
|
+
test_files: []
|
data/.gitignore
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
23
|
-
*.log
|
24
|
-
*.sqlite
|
25
|
-
*.lock
|
data/.travis.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.4.2
|
4
|
-
sudo: false
|
5
|
-
script: bundle exec rake test
|
6
|
-
before_script:
|
7
|
-
- gem install bundler
|
8
|
-
notifications:
|
9
|
-
email:
|
10
|
-
on_success: never
|
11
|
-
on_failure: change
|
12
|
-
gemfile:
|
13
|
-
- Gemfile
|
14
|
-
- test/gemfiles/actionmailer51.gemfile
|
15
|
-
- test/gemfiles/actionmailer50.gemfile
|
16
|
-
- test/gemfiles/actionmailer42.gemfile
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/mailkick.gemspec
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "mailkick/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "mailkick"
|
8
|
-
spec.version = Mailkick::VERSION
|
9
|
-
spec.authors = ["Andrew Kane"]
|
10
|
-
spec.email = ["andrew@chartkick.com"]
|
11
|
-
spec.summary = "Email subscriptions made easy"
|
12
|
-
spec.homepage = "https://github.com/ankane/mailkick"
|
13
|
-
spec.license = "MIT"
|
14
|
-
|
15
|
-
spec.files = `git ls-files -z`.split("\x0")
|
16
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_dependency "activesupport", ">= 4.2"
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "gibbon", ">= 2"
|
24
|
-
spec.add_development_dependency "mailgun-ruby"
|
25
|
-
spec.add_development_dependency "mandrill-api"
|
26
|
-
spec.add_development_dependency "minitest"
|
27
|
-
spec.add_development_dependency "rake"
|
28
|
-
spec.add_development_dependency "sendgrid_toolkit"
|
29
|
-
spec.add_development_dependency "combustion"
|
30
|
-
spec.add_development_dependency "rails"
|
31
|
-
spec.add_development_dependency "sqlite3"
|
32
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<p><%= mailkick_unsubscribe_url %></p>
|
@@ -1 +0,0 @@
|
|
1
|
-
Unsubscribe: <%= mailkick_unsubscribe_url %>
|
data/test/internal/db/schema.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
ActiveRecord::Schema.define do
|
2
|
-
create_table :mailkick_opt_outs do |t|
|
3
|
-
t.string :email
|
4
|
-
t.references :user, polymorphic: true
|
5
|
-
t.boolean :active, null: false, default: true
|
6
|
-
t.string :reason
|
7
|
-
t.string :list
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
|
11
|
-
add_index :mailkick_opt_outs, :email
|
12
|
-
|
13
|
-
create_table :users do |t|
|
14
|
-
t.string :email
|
15
|
-
end
|
16
|
-
end
|
data/test/mailkick_test.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative "test_helper"
|
2
|
-
|
3
|
-
class MailkickTest < Minitest::Test
|
4
|
-
def test_unsubscribe_url
|
5
|
-
message = UserMailer.welcome.deliver_now
|
6
|
-
html_body = message.html_part.body.to_s
|
7
|
-
assert_includes html_body, "unsubscribe"
|
8
|
-
text_body = message.text_part.body.to_s
|
9
|
-
assert_includes text_body, "unsubscribe"
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_opt_out
|
13
|
-
email = "test2@example.org"
|
14
|
-
user = User.create!(email: email)
|
15
|
-
|
16
|
-
Mailkick.opt_out(email: email, user: user)
|
17
|
-
|
18
|
-
opt_outs = Mailkick::OptOut.all.to_a
|
19
|
-
assert_equal 1, opt_outs.size
|
20
|
-
|
21
|
-
opt_out = opt_outs.first
|
22
|
-
assert_equal email, opt_out.email
|
23
|
-
assert_equal user, opt_out.user
|
24
|
-
|
25
|
-
assert user.opted_out?
|
26
|
-
assert_equal 1, User.opted_out.count
|
27
|
-
assert_equal 0, User.not_opted_out.count
|
28
|
-
end
|
29
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
require "combustion"
|
3
|
-
Bundler.require(:default)
|
4
|
-
require "minitest/autorun"
|
5
|
-
require "minitest/pride"
|
6
|
-
require "logger"
|
7
|
-
|
8
|
-
Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test)
|
9
|
-
|
10
|
-
Combustion.path = "test/internal"
|
11
|
-
Combustion.initialize! :all do
|
12
|
-
if config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer)
|
13
|
-
config.active_record.sqlite3.represent_boolean_as_integer = false
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT) if ENV["VERBOSE"]
|
18
|
-
ActionMailer::Base.delivery_method = :test
|