ficonabses 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +31 -13
- data/lib/ficonabses/base.rb +25 -7
- data/test/test_ficonabses.rb +25 -12
- data/test/test_localhost.rb +22 -2
- data/test/test_secret.rb +3 -1
- data/test/test_templates.rb +28 -0
- metadata +4 -3
data/README.rdoc
CHANGED
@@ -2,29 +2,44 @@
|
|
2
2
|
|
3
3
|
* http://github.com/semdinsp/ficonabses
|
4
4
|
|
5
|
+
== WARNING NOT PRODUCTION READY:
|
5
6
|
== DESCRIPTION:
|
6
7
|
|
7
|
-
A simple way to send emails from your application using amazon ses. Register at admin.ses.sg.estormtech.com to create your account.
|
8
|
+
A simple way to send emails from your application using amazon ses. Register at admin.ses.sg.estormtech.com[http:admin.ses.sg.estormtech.com] to create your account. Templates can be emails or Apple Push Notifications. APNs require more configuration so please contact estormtech directly to implement this functionality but the same code will send either in your application.
|
8
9
|
|
9
10
|
== FEATURES/PROBLEMS:
|
10
11
|
|
11
|
-
* A simple way to send text and html emails from your application. Templates for the contents of the email can be configured at http
|
12
|
+
* A simple way to send text and html emails from your application. Templates for the contents of the email can be configured at admin.ses.sg.estormtech.com[http:admin.ses.sg.estormtech.com]
|
13
|
+
|
14
|
+
* You can send spontaneous emails directly in your code. Or more elegantly you can set up a template on the system and send it with contents inserted in the parameters of the call. That way you can change the template (eg have a different design for Halloween or Eid or Christmas) while not touching your production code.
|
12
15
|
|
13
16
|
== SYNOPSIS HTML EMAIL:
|
14
17
|
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
|
19
|
-
|
18
|
+
* res =FiconabSES::Base.send_htmlemail('acccount','password','destination@xxxxx.com','This is the subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
|
19
|
+
* for multiple sends use set_credentials(account,password), then send_html
|
20
|
+
* or similarly functionality eg:
|
21
|
+
f=FiconabSES::Base.new
|
22
|
+
f.set_credentials(account,passwd)
|
23
|
+
f.send_htmlemail(@destination,'This is the subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
|
20
24
|
|
21
25
|
== SYNOPSIS TEXT EMAIL:
|
22
26
|
|
23
|
-
*
|
24
|
-
or similarly
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
* res =FiconabSES::Base.send_textemail_direct('acccount','password',@destination,'This is the subject','contents of the email')
|
28
|
+
* or similarly functionality eg:
|
29
|
+
f=FiconabSES::Base.new
|
30
|
+
f.set_credentials(account,passwd)
|
31
|
+
f.send_textemail(@destination,'This is the subject','text contents of the email')
|
32
|
+
|
33
|
+
== SYNOPSIS USING A TEMPLATE:
|
34
|
+
* The subject and contents of the template are defined on the system. See admin.ses.sg.estormtech.com[http:admin.ses.sg.estormtech.com]. As well as a bcc variable is also possible to be defined to automatically copy an adress
|
35
|
+
|
36
|
+
* res =FiconabSES::Base.send_template_direct(@account,@passwd,@destination,templatename)
|
37
|
+
* or similarly using objects
|
38
|
+
f=FiconabSES::Base.new
|
39
|
+
f.set_credentials(@account,@passwd)
|
40
|
+
res =f.send_template(@destination,'testtemplate')
|
41
|
+
|
42
|
+
== SYNOPSIS USING A TEMPLATE PLUS PARAMETERS
|
28
43
|
|
29
44
|
== REQUIREMENTS:
|
30
45
|
|
@@ -35,7 +50,10 @@ or similarly
|
|
35
50
|
* sudo gem install ficonabses httpclient
|
36
51
|
|
37
52
|
== DEPENDENCY:
|
38
|
-
|
53
|
+
* dependency on httpclient.
|
54
|
+
|
55
|
+
== TESTS
|
56
|
+
* See the tests files attached to the gem or on this website
|
39
57
|
|
40
58
|
== LICENSE:
|
41
59
|
|
data/lib/ficonabses/base.rb
CHANGED
@@ -31,6 +31,11 @@ module FiconabSES
|
|
31
31
|
f.set_credentials(account,password)
|
32
32
|
f.send_htmlemail(destination,subject,htmlcontents,textcontents)
|
33
33
|
end
|
34
|
+
def self.send_template_direct(account,password,destination,templatename)
|
35
|
+
f=FiconabSES::Base.new
|
36
|
+
f.set_credentials(account,password)
|
37
|
+
f.send_template(destination,templatename)
|
38
|
+
end
|
34
39
|
def perform(url)
|
35
40
|
@uri=URI.parse(url)
|
36
41
|
raise 'credentials not set' if @account==nil
|
@@ -51,8 +56,16 @@ module FiconabSES
|
|
51
56
|
res
|
52
57
|
|
53
58
|
end
|
59
|
+
def action_url(action,destination)
|
60
|
+
url="http://#{@@host}/#{action}?destination=#{URI.encode(destination)}"
|
61
|
+
url
|
62
|
+
end
|
54
63
|
def text_url(destination,subject,contents)
|
55
|
-
url="
|
64
|
+
url="#{self.action_url('ficonabsendemail',destination)}&subject=#{URI.encode(subject)}&text=#{URI.encode(contents)}"
|
65
|
+
url
|
66
|
+
end
|
67
|
+
def template_url(destination,templatename)
|
68
|
+
url="#{self.action_url('ficonabsimpletemplate',destination)}&template=#{URI.encode(templatename)}"
|
56
69
|
url
|
57
70
|
end
|
58
71
|
def html_url(destination,subject,contents,html)
|
@@ -61,16 +74,21 @@ module FiconabSES
|
|
61
74
|
end
|
62
75
|
def send_textemail(destination,subject,contents)
|
63
76
|
url=self.text_url(destination,subject,contents)
|
64
|
-
puts "url is: #{url}"
|
65
|
-
|
66
|
-
perform(url)
|
77
|
+
#puts "url is: #{url}"
|
78
|
+
perform(url)
|
67
79
|
# res
|
68
80
|
end
|
81
|
+
def send_template(destination,templatename)
|
82
|
+
url=self.template_url(destination,templatename)
|
83
|
+
puts "url is: #{url}"
|
84
|
+
perform(url)
|
85
|
+
# res
|
86
|
+
end
|
69
87
|
def send_htmlemail(destination,subject,htmlcontents,textcontents=nil)
|
88
|
+
textcontents='-' if textcontents==nil
|
70
89
|
url=self.html_url(destination,subject,textcontents,htmlcontents)
|
71
|
-
puts "url is: #{url}"
|
72
|
-
|
73
|
-
perform(url)
|
90
|
+
#puts "url is: #{url}"
|
91
|
+
perform(url)
|
74
92
|
# res
|
75
93
|
end
|
76
94
|
|
data/test/test_ficonabses.rb
CHANGED
@@ -4,40 +4,53 @@ require File.dirname(__FILE__) + '/test_secret.rb' #FILL IN ACCOUNT/PASSWD AS G
|
|
4
4
|
class TestFiconabses < Test::Unit::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
|
-
@account=ACCOUNT #in test_secret.rb put ACCOUNT='youraccount'
|
7
|
+
@account=ACCOUNT #in test_secret.rb put ACCOUNT='youraccount' or insert your parameters direclty here eg @ACCOUNT='myaccount'
|
8
8
|
@passwd=PASSWD #in test_secret.rb put PASSWD='yourpasswd'
|
9
|
+
@destination=DESTINATION # eg your email address 'xxx@yyyy.com'
|
10
|
+
|
11
|
+
end
|
12
|
+
def test_creds
|
9
13
|
puts "CREDENTIALS ARE: account: #{@account} passwd: #{@passwd}"
|
14
|
+
# self assert true
|
10
15
|
end
|
11
|
-
|
12
16
|
def test_send_text_direct
|
13
|
-
|
14
|
-
|
17
|
+
puts 'SEND TEXT DIRECT'
|
18
|
+
res =FiconabSES::Base.send_textemail_direct(@account,@passwd,@destination,'This is the subject','contents of the email')
|
19
|
+
#puts "RES is: #{res}"
|
15
20
|
assert res.include? '200'
|
16
21
|
end
|
17
22
|
def test_send_html_direct
|
18
|
-
|
19
|
-
|
23
|
+
puts "SEND HTML DIRECT"
|
24
|
+
res =FiconabSES::Base.send_htmlemail_direct(@account,@passwd,@destination,'This is the HTML subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
|
25
|
+
#puts "RES is: #{res}"
|
20
26
|
assert res.include? '200'
|
27
|
+
assert false==(res.include? 'Error')
|
28
|
+
end
|
21
29
|
end
|
22
30
|
def test_send_html_nil_text
|
23
|
-
|
31
|
+
puts "SEND HTML with NIL text"
|
32
|
+
res =FiconabSES::Base.send_htmlemail_direct(@account,@passwd,@destination,'This is HTML Subject nil text','<h1>HTML Contents</h1><p>hi from paragraph</p>') #no text portion
|
24
33
|
puts "RES is: #{res}"
|
25
34
|
assert res.include? '200'
|
35
|
+
assert false==(res.include? 'Error')
|
36
|
+
end
|
26
37
|
end
|
27
38
|
def test_send_emails
|
28
39
|
f=FiconabSES::Base.new
|
29
40
|
f.set_credentials(@account,@passwd)
|
30
|
-
res =f.send_htmlemail(
|
31
|
-
puts "RES is: #{res}"
|
41
|
+
res =f.send_htmlemail(@destination,'This is HTML Subject nil text','<h1>HTML Contents</h1><p>hi from paragraph</p>') #no text portion
|
42
|
+
#puts "RES is: #{res}"
|
32
43
|
assert res.include? '200'
|
33
|
-
res =f.send_textemail(
|
34
|
-
|
44
|
+
res =f.send_textemail(@destination,'This is TEXT Subject nil text','contents') #no text portion
|
45
|
+
# puts "RES is: #{res}"
|
35
46
|
assert res.include? '200'
|
47
|
+
assert false==(res.include? 'Error')
|
48
|
+
end
|
36
49
|
end
|
37
50
|
def test_no_credentials
|
38
51
|
f=FiconabSES::Base.new
|
39
52
|
assert_raise RuntimeError do #should raise runtime error
|
40
|
-
res =f.send_htmlemail(
|
53
|
+
res =f.send_htmlemail(@destination,'This is HTML Subject nil text','<h1>HTML Contents</h1><p>hi from paragraph</p>') #no text portion
|
41
54
|
end
|
42
55
|
end
|
43
56
|
end
|
data/test/test_localhost.rb
CHANGED
@@ -6,18 +6,38 @@ class TestFiconabses < Test::Unit::TestCase
|
|
6
6
|
@f=FiconabSES::Base.new
|
7
7
|
@f.set_credentials('scott','scott123')
|
8
8
|
@f.set_debug
|
9
|
+
@destination='scott.sproule@gmail.com'
|
10
|
+
@tsipid ='7923044488'
|
9
11
|
end
|
10
12
|
|
11
13
|
def test_local_send_text
|
12
|
-
res= @f.send_textemail(
|
14
|
+
res= @f.send_textemail(@destination,"'LOCALHOST': #{@f.host}",'contents of the email')
|
13
15
|
puts "RES is: #{res}"
|
14
16
|
assert res.include? '200'
|
17
|
+
assert false==(res.include? 'Error')
|
15
18
|
end
|
16
19
|
|
17
20
|
def test_local_send_html
|
18
|
-
res =@f.send_htmlemail(
|
21
|
+
res =@f.send_htmlemail(@destination,"'HTML:LOCALHOST': #{@f.host}",'<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
|
19
22
|
puts "RES is: #{res}"
|
20
23
|
assert res.include? '200'
|
24
|
+
assert false==(res.include? 'Error')
|
21
25
|
end
|
26
|
+
def test_local_send_template
|
27
|
+
|
28
|
+
res =@f.send_template(@destination,'testtemplate') #no text portion
|
29
|
+
puts "RES is: #{res}"
|
30
|
+
assert res.include? '200'
|
31
|
+
assert false==(res.include? 'Error')
|
32
|
+
|
33
|
+
end
|
34
|
+
def test_local_apn_template
|
35
|
+
|
36
|
+
res =@f.send_template(@tsipid,'apn_template') #no text portion
|
37
|
+
puts "RES is: #{res}"
|
38
|
+
assert res.include? '200'
|
39
|
+
assert false==(res.include? 'Error')
|
40
|
+
|
41
|
+
end
|
22
42
|
|
23
43
|
end
|
data/test/test_secret.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/test_secret.rb' #FILL IN ACCOUNT/PASSWD AS GLOBALS IN THIS
|
3
|
+
|
4
|
+
class TestFiconabses < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@account=ACCOUNT #in test_secret.rb put ACCOUNT='youraccount' or insert your parameters direclty here eg @ACCOUNT='myaccount'
|
8
|
+
@passwd=PASSWD #in test_secret.rb put PASSWD='yourpasswd'
|
9
|
+
puts "CREDENTIALS ARE: account: #{@account} passwd: #{@passwd}"
|
10
|
+
@destination=DESTINATION
|
11
|
+
@tsipid=TSIPID
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_send_template_direct
|
15
|
+
res =FiconabSES::Base.send_template_direct(@account,@passwd,@destination,'testtemplate')
|
16
|
+
puts "RES is: #{res}"
|
17
|
+
assert res.include? '200'
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_send_template
|
21
|
+
f=FiconabSES::Base.new
|
22
|
+
f.set_credentials(@account,@passwd)
|
23
|
+
res =f.send_template(@destination,'testtemplate') #no text portion
|
24
|
+
puts "RES is: #{res}"
|
25
|
+
assert res.include? '200'
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 5
|
9
|
+
version: 0.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Scott Sproule
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-11-
|
17
|
+
date: 2011-11-18 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- test/test_helper.rb
|
34
34
|
- test/test_localhost.rb
|
35
35
|
- test/test_secret.rb
|
36
|
+
- test/test_templates.rb
|
36
37
|
- History.txt
|
37
38
|
- Manifest.txt
|
38
39
|
- PostInstall.txt
|