mail_jack 0.2.4 → 0.2.5
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.
- data/lib/mail_jack.rb +8 -1
- data/lib/mail_jack/config.rb +4 -1
- data/lib/mail_jack/params_decoder.rb +6 -4
- data/lib/mail_jack/version.rb +1 -1
- metadata +27 -18
data/lib/mail_jack.rb
CHANGED
@@ -56,6 +56,8 @@ module MailJack
|
|
56
56
|
|
57
57
|
# return configuration if already configured
|
58
58
|
return @@config if defined?(@@config) and @@config.kind_of?(Config)
|
59
|
+
|
60
|
+
raise ArgumentError, "you must configure MailJack to use it. call MailJack.config{|config| ...} from an initializer" unless block_given?
|
59
61
|
|
60
62
|
# yield configuration
|
61
63
|
@@config = Config.new
|
@@ -64,7 +66,7 @@ module MailJack
|
|
64
66
|
# dynamically define the accessors onto Mail::Message
|
65
67
|
# so we can assign them later in the Interceptor
|
66
68
|
Mail::Message.class_eval do
|
67
|
-
attr_accessor *@@config.trackables.keys
|
69
|
+
attr_accessor *@@config.trackables.keys if @@config.trackables
|
68
70
|
end
|
69
71
|
|
70
72
|
# include the module that decorates(ie monkey patches)
|
@@ -76,8 +78,13 @@ module MailJack
|
|
76
78
|
# register the interceptor
|
77
79
|
Mail.register_interceptor(MailJack::Interceptor)
|
78
80
|
|
81
|
+
@@config.configured = true
|
79
82
|
end
|
80
83
|
|
84
|
+
def self.configured?
|
85
|
+
defined?(@@config) and @@config.configured?
|
86
|
+
end
|
87
|
+
|
81
88
|
# Fetch attributes gets the dynamically defined attributes
|
82
89
|
# off the object passed in, the object is ActionMailer::Base instance
|
83
90
|
def self.fetch_attributes(mailer)
|
data/lib/mail_jack/config.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module MailJack
|
2
2
|
class Config
|
3
|
-
attr_accessor :mailers, :href_filter, :trackables, :encode_to
|
3
|
+
attr_accessor :mailers, :href_filter, :trackables, :encode_to, :configured
|
4
4
|
def trackable
|
5
5
|
|
6
6
|
# use OpenStruct for sugary assignment
|
@@ -15,5 +15,8 @@ module MailJack
|
|
15
15
|
self.encode_to.present?
|
16
16
|
end
|
17
17
|
|
18
|
+
def configured?
|
19
|
+
@configured
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
@@ -5,6 +5,7 @@ module MailJack
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def call(env)
|
8
|
+
return @app.call(env) unless MailJack.configured?
|
8
9
|
decode_params(env) if MailJack.config.enable_encoding?
|
9
10
|
@status, @headers, @response = @app.call(env)
|
10
11
|
[@status, @headers, @response]
|
@@ -17,13 +18,14 @@ module MailJack
|
|
17
18
|
params = {'QUERY_STRING' => env["QUERY_STRING"], 'REQUEST_URI' => env["REQUEST_URI"].split("?")[1]}
|
18
19
|
|
19
20
|
params.each do |key, value|
|
20
|
-
next unless value.present?
|
21
|
-
|
21
|
+
next unless value.present?
|
22
22
|
hash = Rack::Utils.parse_query(value)
|
23
|
+
# next unless hash.has_key?(param_name.to_s)
|
24
|
+
|
23
25
|
encoded = hash.delete(param_name.to_s)
|
24
|
-
decoded = Base64.decode64(encoded)
|
26
|
+
decoded = Base64.decode64(encoded) if encoded
|
25
27
|
|
26
|
-
env[key].gsub!("#{param_name}=#{encoded}", decoded)
|
28
|
+
env[key].gsub!("#{param_name}=#{encoded}", decoded) if decoded
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
data/lib/mail_jack/version.rb
CHANGED
metadata
CHANGED
@@ -1,23 +1,28 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_jack
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.4
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.2.5
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Peter Philips
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
12
|
+
|
13
|
+
date: 2013-06-26 00:00:00 Z
|
13
14
|
dependencies: []
|
15
|
+
|
14
16
|
description: Autogenerate query parameters to links in emails to track click throughs
|
15
|
-
email:
|
17
|
+
email:
|
16
18
|
- pete@p373.net
|
17
19
|
executables: []
|
20
|
+
|
18
21
|
extensions: []
|
22
|
+
|
19
23
|
extra_rdoc_files: []
|
20
|
-
|
24
|
+
|
25
|
+
files:
|
21
26
|
- .document
|
22
27
|
- .gitignore
|
23
28
|
- Gemfile
|
@@ -34,26 +39,30 @@ files:
|
|
34
39
|
- mail_jack.gemspec
|
35
40
|
homepage: https://github.com/synth/mail_jack
|
36
41
|
licenses: []
|
42
|
+
|
37
43
|
post_install_message:
|
38
44
|
rdoc_options: []
|
39
|
-
|
45
|
+
|
46
|
+
require_paths:
|
40
47
|
- lib
|
41
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
49
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
55
|
none: false
|
49
|
-
requirements:
|
50
|
-
- -
|
51
|
-
- !ruby/object:Gem::Version
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
52
59
|
version: 1.3.6
|
53
60
|
requirements: []
|
61
|
+
|
54
62
|
rubyforge_project:
|
55
|
-
rubygems_version: 1.8.
|
63
|
+
rubygems_version: 1.8.19
|
56
64
|
signing_key:
|
57
65
|
specification_version: 3
|
58
66
|
summary: Autogenerate query parameters to links in emails to track click throughs
|
59
67
|
test_files: []
|
68
|
+
|