mad_mimi_two 0.2.0 → 0.04
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/README.rdoc +10 -25
- data/Rakefile +1 -1
- data/lib/mad_mimi_two/mad_mimi_mailer.rb +2 -24
- data/lib/mad_mimi_two.rb +1 -1
- data/test/test_mad_mimi_two.rb +4 -34
- metadata +29 -72
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
data/README.rdoc
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
courtesy scott sproule
|
6
6
|
www.estormtech.com
|
7
7
|
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
== DESCRIPTION:
|
11
11
|
|
12
|
-
Using Mad Mimi on rails 3. All of the elegant portions of the code are based on the original http://github.com/redsquirrel/mad_mimi_mailer by ethangunderson.
|
12
|
+
Using Mad Mimi on rails 3. All of the elegant portions of the code are based on the original http://github.com/redsquirrel/mad_mimi_mailer by ethangunderson.
|
13
13
|
|
14
14
|
All of the terrible stuff is by me. Apologies for taking an elegant solution and just crafting something that works.
|
15
15
|
|
@@ -18,11 +18,13 @@ All of the terrible stuff is by me. Apologies for taking an elegant solution an
|
|
18
18
|
* FIX (list of features or problems)
|
19
19
|
This has only been tested on Ruby 1.8.7.
|
20
20
|
Testing on Ruby 1.9 required.
|
21
|
-
Currently
|
21
|
+
Currently against rails 3 beta
|
22
22
|
|
23
|
+
If someone could suggest how to get rid of this I would be grateful:
|
24
|
+
./lib/mad_mimi_two/mad_mimi_mailer.rb:71: warning: default `to_a' will be obsolete
|
23
25
|
|
24
26
|
== SYNOPSIS:
|
25
|
-
== API CONFIG
|
27
|
+
== API CONFIG
|
26
28
|
Setup your api key in application.rb (at the end of the file, after the end for the config)
|
27
29
|
MadMimiTwo::MadMimiMessage.api_settings = {
|
28
30
|
:username => 'your_username@xys.com',
|
@@ -33,7 +35,7 @@ Setup your api key in application.rb (at the end of the file, after the end for
|
|
33
35
|
gem 'mad_mimi_two'
|
34
36
|
|
35
37
|
== MIMI MODEL
|
36
|
-
set up model
|
38
|
+
set up model (something like this)
|
37
39
|
class MadMimi < MadMimiTwo::MadMimiMessage
|
38
40
|
def self.mimi_promotion(tpromotion,tuser,thashvalues,cclist, tsubj)
|
39
41
|
msg=MadMimiTwo::MadMimiMessage.new do
|
@@ -42,7 +44,7 @@ class MadMimi < MadMimiTwo::MadMimiMessage
|
|
42
44
|
cc cclist
|
43
45
|
promotion tpromotion #[MAD MIMI PROMOTION NAME]
|
44
46
|
from 'support@estormtech.com'
|
45
|
-
bcc ["
|
47
|
+
bcc ["scott.sproule@estormtech.com", "eka.mardiarti@estormtech.com"]
|
46
48
|
email_placeholders thashvalues # [VALUES THAT NEED TO BE INSERTED AT MAD MIMI EMAIL these are the values in {} in the mad mimi email that you want replaced eg {:url='www.estormtech.com'}]
|
47
49
|
content_type "text/html"
|
48
50
|
end
|
@@ -56,20 +58,6 @@ this will return a ID from mad mimi like 1151260526
|
|
56
58
|
|
57
59
|
IGNORE: warning: peer certificate won't be verified in this SSL session
|
58
60
|
|
59
|
-
== Mail::Message
|
60
|
-
As this is subclassed from Mail::Message I believe that other ways to create the message will also work (such as passing in hash, etc (see the documentation))
|
61
|
-
|
62
|
-
== Check Status of sent message
|
63
|
-
t=MadMimiTwo::MadMimiMessage.new
|
64
|
-
r=t.check_status('1159748168') # this is value from ID
|
65
|
-
r is 'Sent'
|
66
|
-
|
67
|
-
== RAILS 2:
|
68
|
-
NOTE, The same code works in Rails 2 as well.
|
69
|
-
except that you need to change environment.rb
|
70
|
-
config.gem 'mad_mimi_two'
|
71
|
-
and at the end of the environment.rb file:
|
72
|
-
insert the api settings.
|
73
61
|
|
74
62
|
== REQUIREMENTS:
|
75
63
|
|
@@ -79,11 +67,8 @@ gem mail
|
|
79
67
|
|
80
68
|
== INSTALL:
|
81
69
|
|
82
|
-
gem
|
83
|
-
|
84
|
-
== RAILS TESTING:
|
85
|
-
|
86
|
-
Apologies but this needs work. I have simple tests in my application but nothing spectacular.
|
70
|
+
loading on gem server is a todo...
|
71
|
+
download from github to start with :) sorry.
|
87
72
|
|
88
73
|
== LICENSE:
|
89
74
|
|
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ $hoe = Hoe.spec 'mad_mimi_two' do
|
|
16
16
|
self.post_install_message = 'For more information on mad_mimi_two, see
|
17
17
|
http://github.com/semdinsp/mad_mimi_two' # TODO remove if post-install message not required
|
18
18
|
self.rubyforge_name = self.name # TODO this is default value
|
19
|
-
#self.
|
19
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
20
20
|
|
21
21
|
end
|
22
22
|
|
@@ -1,14 +1,3 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require 'rubygems'
|
3
|
-
gem 'httpclient'
|
4
|
-
require 'httpclient'
|
5
|
-
class Hash
|
6
|
-
def madmimiurlencode
|
7
|
-
to_a.map do |name_value|
|
8
|
-
name_value.map { |e| CGI.escape e.to_s }.join '='
|
9
|
-
end.join '&'
|
10
|
-
end
|
11
|
-
end
|
12
1
|
module MadMimiTwo
|
13
2
|
module MadMimiMailer
|
14
3
|
SINGLE_SEND_URL = 'https://api.madmimi.com/mailer'
|
@@ -16,17 +5,6 @@ module MadMimiTwo
|
|
16
5
|
def self.included(base)
|
17
6
|
base.extend(ClassMethods)
|
18
7
|
end
|
19
|
-
# check the status of a sent email
|
20
|
-
def check_status(msg_id)
|
21
|
-
url = "#{SINGLE_SEND_URL}s/status/#{msg_id}?#{MadMimiTwo::MadMimiMessage.api_settings.madmimiurlencode}"
|
22
|
-
begin
|
23
|
-
client= HTTPClient.new
|
24
|
-
res=client.get_content(url)
|
25
|
-
rescue HTTPClient::BadResponseError
|
26
|
-
res="problem retrieving status"
|
27
|
-
end
|
28
|
-
res
|
29
|
-
end
|
30
8
|
|
31
9
|
# Custom Mailer attributes
|
32
10
|
|
@@ -90,9 +68,9 @@ module MadMimiTwo
|
|
90
68
|
'username' => MadMimiTwo::MadMimiMessage.api_settings[:username],
|
91
69
|
'api_key' => MadMimiTwo::MadMimiMessage.api_settings[:api_key],
|
92
70
|
'promotion_name' => self.promotion, # scott || method.to_s.sub(/^#{method_prefix}_/, ''),
|
93
|
-
'recipients' => serialize(self[:to].
|
71
|
+
'recipients' => serialize(self[:to].to_a),
|
94
72
|
'subject' => self[:subject].to_s,
|
95
|
-
'bcc' => serialize(self[:bcc].
|
73
|
+
'bcc' => serialize(self[:bcc].to_a || MadMimiMailer.default_parameters[:bcc]),
|
96
74
|
'from' => (self[:from].to_s || MadMimiMailer.default_parameters[:from]),
|
97
75
|
'hidden' => serialize(self.hidden)
|
98
76
|
}
|
data/lib/mad_mimi_two.rb
CHANGED
data/test/test_mad_mimi_two.rb
CHANGED
@@ -14,9 +14,7 @@ class TestMadMimiTwo < Test::Unit::TestCase
|
|
14
14
|
puts t.inspect
|
15
15
|
assert t.headers.size==0, "headers not empty"
|
16
16
|
end
|
17
|
-
def
|
18
|
-
test="hello there"
|
19
|
-
hashv={ :body => test, :user => 'string'}
|
17
|
+
def test_header_setup
|
20
18
|
t=MadMimiTwo::MadMimiMessage.new do
|
21
19
|
subject 'tsubj test subject'
|
22
20
|
to 'scott.sproule@ficonab.com'
|
@@ -25,33 +23,13 @@ class TestMadMimiTwo < Test::Unit::TestCase
|
|
25
23
|
from 'support@estormtech.com'
|
26
24
|
bcc ["scott.sproule@estormtech.com", "eka.mardiarti@estormtech.com"]
|
27
25
|
# sent_on Time.now
|
28
|
-
|
26
|
+
body "body thashvalues" # :user => tuser, :url => turl
|
29
27
|
content_type "text/html"
|
30
28
|
end
|
31
29
|
puts t.inspect
|
32
30
|
assert t.headers.size==0, "headers not empty"
|
33
31
|
assert t[:to].to_s=='scott.sproule@ficonab.com', "to person not correct #{t[:to]}"
|
34
32
|
assert t.promotion.to_s=='new_crm', 'promotion first wrong'
|
35
|
-
assert t.email_placeholders.has_key?(:body), "placeholders seem wrong #{t.email_placeholders}"
|
36
|
-
assert t.email_placeholders.value?("hello there"), "placeholders seem wrong #{t.email_placeholders}"
|
37
|
-
#assert t[:promotion].to_s=='new_crm', 'promotion wrong'
|
38
|
-
end
|
39
|
-
def test_header_setup2
|
40
|
-
test="hello there"
|
41
|
-
t=MadMimiTwo::MadMimiMessage.new do
|
42
|
-
subject 'tsubj test subject'
|
43
|
-
to 'scott.sproule@ficonab.com'
|
44
|
-
# cc admin
|
45
|
-
promotion 'new_crm'
|
46
|
-
from 'support@estormtech.com'
|
47
|
-
bcc ["scott.sproule@estormtech.com", "eka.mardiarti@estormtech.com"]
|
48
|
-
# sent_on Time.now
|
49
|
-
email_placeholders :body => test, :user => 'string'
|
50
|
-
content_type "text/html"
|
51
|
-
end
|
52
|
-
puts t.inspect
|
53
|
-
assert t.email_placeholders.has_key?(:body), "placeholders seem wrong #{t.email_placeholders}"
|
54
|
-
assert t.email_placeholders.value?("hello there"), "placeholders seem wrong #{t.email_placeholders}"
|
55
33
|
#assert t[:promotion].to_s=='new_crm', 'promotion wrong'
|
56
34
|
end
|
57
35
|
def test_sending_mesage
|
@@ -69,19 +47,11 @@ class TestMadMimiTwo < Test::Unit::TestCase
|
|
69
47
|
end
|
70
48
|
# t.email_placeholders(thash)
|
71
49
|
r=t.deliver_mimi_message
|
72
|
-
puts "result: #{r} message:
|
50
|
+
puts "result: #{r} message: t.inspect"
|
51
|
+
assert t.headers.size==0, "headers not empty"
|
73
52
|
assert t.headers.size==0, "headers not empty"
|
74
53
|
assert t[:to].to_s=='scott.sproule@ficonab.com', "to person not correct #{t[:to]}"
|
75
54
|
assert t.promotion.to_s=='new_crm', 'promotion first wrong'
|
76
55
|
#assert t[:promotion].to_s=='new_crm', 'promotion wrong'
|
77
56
|
end
|
78
|
-
def test_check_status
|
79
|
-
# puts "message id: 1159748168" (old message id)
|
80
|
-
t=MadMimiTwo::MadMimiMessage.new
|
81
|
-
r=t.check_status('1159748168')
|
82
|
-
puts "'r is ' #{r}"
|
83
|
-
assert r.class==String, "response is not string r is: #{r} #{r.class}"
|
84
|
-
assert r=='sent', "message response not correct: #{r}"
|
85
|
-
|
86
|
-
end
|
87
57
|
end
|
metadata
CHANGED
@@ -1,93 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mad_mimi_two
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.2.0
|
8
|
+
- 4
|
9
|
+
version: "0.04"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
|
-
-
|
12
|
+
- Scott Sproule
|
14
13
|
autorequire:
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-23 00:00:00 +08:00
|
19
18
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 9
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 3
|
34
|
-
version: 2.0.3
|
35
|
-
type: :development
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: hoe
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 23
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 6
|
49
|
-
- 0
|
50
|
-
version: 2.6.0
|
51
|
-
type: :development
|
52
|
-
version_requirements: *id002
|
53
|
-
description: |-
|
54
|
-
Using Mad Mimi on rails 3. All of the elegant portions of the code are based on the original http://github.com/redsquirrel/mad_mimi_mailer by ethangunderson. (MadMimiTwo also runs in Rails 2)
|
55
|
-
|
56
|
-
All of the terrible stuff is by me. Apologies for taking an elegant solution and just crafting something that works.
|
57
|
-
email:
|
58
|
-
- scott.sproule@ficonab.com
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Update to the original madmimimailer gem to support the new actionmailer of rails3
|
22
|
+
email: scott.sproule@estormtech.com
|
59
23
|
executables: []
|
60
24
|
|
61
25
|
extensions: []
|
62
26
|
|
63
|
-
extra_rdoc_files:
|
64
|
-
|
65
|
-
- Manifest.txt
|
66
|
-
- PostInstall.txt
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
67
29
|
files:
|
68
|
-
- History.txt
|
69
|
-
- Manifest.txt
|
70
|
-
- PostInstall.txt
|
71
|
-
- README.rdoc
|
72
|
-
- Rakefile
|
73
|
-
- lib/mad_mimi_two.rb
|
74
30
|
- lib/mad_mimi_two/mad_mimi_mailer.rb
|
75
31
|
- lib/mad_mimi_two/mad_mimi_message.rb
|
76
|
-
-
|
77
|
-
- script/destroy
|
78
|
-
- script/generate
|
32
|
+
- lib/mad_mimi_two.rb
|
79
33
|
- test/test_helper.rb
|
80
34
|
- test/test_mad_mimi_two.rb
|
35
|
+
- History.txt
|
36
|
+
- Manifest.txt
|
37
|
+
- PostInstall.txt
|
38
|
+
- Rakefile
|
39
|
+
- README.rdoc
|
81
40
|
has_rdoc: true
|
82
|
-
homepage: http://github.com/semdinsp/
|
41
|
+
homepage: http://github.com/semdinsp/mad-mimi-on-rails-3
|
83
42
|
licenses: []
|
84
43
|
|
85
|
-
post_install_message:
|
86
|
-
|
87
|
-
|
88
|
-
rdoc_options:
|
89
|
-
- --main
|
90
|
-
- README.rdoc
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
91
47
|
require_paths:
|
92
48
|
- lib
|
93
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -104,17 +60,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
60
|
requirements:
|
105
61
|
- - ">="
|
106
62
|
- !ruby/object:Gem::Version
|
107
|
-
hash:
|
63
|
+
hash: 19
|
108
64
|
segments:
|
109
|
-
-
|
110
|
-
|
65
|
+
- 1
|
66
|
+
- 3
|
67
|
+
- 4
|
68
|
+
version: 1.3.4
|
111
69
|
requirements: []
|
112
70
|
|
113
71
|
rubyforge_project: mad_mimi_two
|
114
72
|
rubygems_version: 1.3.7
|
115
73
|
signing_key:
|
116
74
|
specification_version: 3
|
117
|
-
summary:
|
118
|
-
test_files:
|
119
|
-
|
120
|
-
- test/test_mad_mimi_two.rb
|
75
|
+
summary: Use MadMimi with Rails 3
|
76
|
+
test_files: []
|
77
|
+
|
data/script/console
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: script/console
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/mad_mimi_two.rb'}"
|
9
|
-
puts "Loading mad_mimi_two gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|