ficonabses 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -13,10 +13,18 @@ A simple way to send emails from your application using amazon ses. Register at
13
13
  == SYNOPSIS HTML EMAIL:
14
14
 
15
15
  * res =FiconabSES::Base.send_htmlemail('acccount','password','scott.sproule@estormtech.com','This is the subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
16
+ * for multiple sends use set_credentials(account,password), then send_html
17
+ * eg: f=FiconabSES::Base.new
18
+ * f.set_credentials(account,passwd)
19
+ * f.send_htmlemail('scott.sproule@estormtech.com','This is the subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
16
20
 
17
21
  == SYNOPSIS TEXT EMAIL:
18
22
 
19
- * res =FiconabSES::Base.send_textemail('acccount','password','scott.sproule@estormtech.com','This is the subject','contents of the email')
23
+ * res =FiconabSES::Base.send_textemail_direct('acccount','password','scott.sproule@estormtech.com','This is the subject','contents of the email')
24
+ or similarly
25
+ * eg: f=FiconabSES::Base.new
26
+ * f.set_credentials(account,passwd)
27
+ * f.send_textemail('scott.sproule@estormtech.com','This is the subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
20
28
 
21
29
  == REQUIREMENTS:
22
30
 
@@ -17,22 +17,29 @@ module FiconabSES
17
17
  @@host
18
18
  end
19
19
  # @@host= 'localhost:8083'
20
- def self.send_textemail(account,password,destination,subject,contents)
20
+ def set_credentials(account,passwd)
21
+ @account=account
22
+ @password=passwd
23
+ end
24
+ def self.send_textemail_direct(account,password,destination,subject,contents)
21
25
  f=FiconabSES::Base.new
22
- f.send_textemail(account,password,destination,subject,contents)
26
+ f.set_credentials(account,password)
27
+ f.send_textemail(destination,subject,contents)
23
28
  end
24
- def self.send_htmlemail(account,password,destination,subject,htmlcontents,textcontents=nil)
29
+ def self.send_htmlemail_direct(account,password,destination,subject,htmlcontents,textcontents=nil)
25
30
  f=FiconabSES::Base.new
26
- f.send_htmlemail(account,password,destination,subject,htmlcontents,textcontents)
31
+ f.set_credentials(account,password)
32
+ f.send_htmlemail(destination,subject,htmlcontents,textcontents)
27
33
  end
28
- def perform(account,password,url)
34
+ def perform(url)
29
35
  @uri=URI.parse(url)
36
+ raise 'credentials not set' if @account==nil
30
37
  res=''
31
38
  begin
32
- # Don't take longer than 60 seconds -- incase there is a problem with the server continue
39
+ # Don't take longer than 60 seconds -- incase there is a problem with our server continue
33
40
  Timeout::timeout(60) do
34
41
  @clnt=HTTPClient.new
35
- @clnt.set_auth(nil, account, password)
42
+ @clnt.set_auth(nil, @account, @password)
36
43
  @extheader = { 'Content-Type' => 'application/xml' }
37
44
  res=self.clnt.get_content(self.uri,self.extheader)
38
45
  end
@@ -52,16 +59,18 @@ module FiconabSES
52
59
  contents='' if contents==nil
53
60
  url="#{self.text_url(destination,subject,contents)}&html=#{URI.encode(html)}"
54
61
  end
55
- def send_textemail(account,password,destination,subject,contents)
62
+ def send_textemail(destination,subject,contents)
56
63
  url=self.text_url(destination,subject,contents)
57
64
  puts "url is: #{url}"
58
- perform(account,password,url)
65
+
66
+ perform(url)
59
67
  # res
60
68
  end
61
- def send_htmlemail(account,password,destination,subject,htmlcontents,textcontents=nil)
69
+ def send_htmlemail(destination,subject,htmlcontents,textcontents=nil)
62
70
  url=self.html_url(destination,subject,textcontents,htmlcontents)
63
71
  puts "url is: #{url}"
64
- perform(account,password,url)
72
+
73
+ perform(url)
65
74
  # res
66
75
  end
67
76
 
@@ -1,23 +1,43 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require File.dirname(__FILE__) + '/test_secret.rb' #FILL IN ACCOUNT/PASSWD AS GLOBALS IN THIS
2
3
 
3
4
  class TestFiconabses < Test::Unit::TestCase
4
5
 
5
6
  def setup
7
+ @account=ACCOUNT #in test_secret.rb put ACCOUNT='youraccount'
8
+ @passwd=PASSWD #in test_secret.rb put PASSWD='yourpasswd'
9
+ puts "CREDENTIALS ARE: account: #{@account} passwd: #{@passwd}"
6
10
  end
7
11
 
8
- def test_send_text
9
- res =FiconabSES::Base.send_textemail('scott','scott123','scott.sproule@gmail.com','This is the subject','contents of the email')
12
+ def test_send_text_direct
13
+ res =FiconabSES::Base.send_textemail_direct(@account,@passwd,'scott.sproule@gmail.com','This is the subject','contents of the email')
10
14
  puts "RES is: #{res}"
11
15
  assert res.include? '200'
12
16
  end
13
- def test_send_html
14
- res =FiconabSES::Base.send_htmlemail('scott','scott123','scott.sproule@gmail.com','This is the HTML subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
17
+ def test_send_html_direct
18
+ res =FiconabSES::Base.send_htmlemail_direct(@account,@passwd,'scott.sproule@gmail.com','This is the HTML subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
15
19
  puts "RES is: #{res}"
16
20
  assert res.include? '200'
17
21
  end
18
22
  def test_send_html_nil_text
19
- res =FiconabSES::Base.send_htmlemail('scott','scott123','scott.sproule@gmail.com','This is HTML Subject nil text','<h1>HTML Contents</h1><p>hi from paragraph</p>') #no text portion
23
+ res =FiconabSES::Base.send_htmlemail_direct(@account,@passwd,'scott.sproule@gmail.com','This is HTML Subject nil text','<h1>HTML Contents</h1><p>hi from paragraph</p>') #no text portion
20
24
  puts "RES is: #{res}"
21
25
  assert res.include? '200'
22
26
  end
27
+ def test_send_emails
28
+ f=FiconabSES::Base.new
29
+ f.set_credentials(@account,@passwd)
30
+ res =f.send_htmlemail('scott.sproule@gmail.com','This is HTML Subject nil text','<h1>HTML Contents</h1><p>hi from paragraph</p>') #no text portion
31
+ puts "RES is: #{res}"
32
+ assert res.include? '200'
33
+ res =f.send_textemail('scott.sproule@gmail.com','This is TEXT Subject nil text','contents') #no text portion
34
+ puts "RES is: #{res}"
35
+ assert res.include? '200'
36
+ end
37
+ def test_no_credentials
38
+ f=FiconabSES::Base.new
39
+ assert_raise RuntimeError do #should raise runtime error
40
+ res =f.send_htmlemail('scott.sproule@gmail.com','This is HTML Subject nil text','<h1>HTML Contents</h1><p>hi from paragraph</p>') #no text portion
41
+ end
42
+ end
23
43
  end
@@ -4,17 +4,18 @@ class TestFiconabses < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
6
  @f=FiconabSES::Base.new
7
+ @f.set_credentials('scott','scott123')
7
8
  @f.set_debug
8
9
  end
9
10
 
10
11
  def test_local_send_text
11
- res= @f.send_textemail('scott','scott123','scott.sproule@gmail.com',"'LOCALHOST': #{@f.host}",'contents of the email')
12
+ res= @f.send_textemail('scott.sproule@gmail.com',"'LOCALHOST': #{@f.host}",'contents of the email')
12
13
  puts "RES is: #{res}"
13
14
  assert res.include? '200'
14
15
  end
15
16
 
16
17
  def test_local_send_html
17
- res =@f.send_htmlemail('scott','scott123','scott.sproule@gmail.com',"'HTML:LOCALHOST': #{@f.host}",'<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
18
+ res =@f.send_htmlemail('scott.sproule@gmail.com',"'HTML:LOCALHOST': #{@f.host}",'<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
18
19
  puts "RES is: #{res}"
19
20
  assert res.include? '200'
20
21
  end
@@ -0,0 +1,2 @@
1
+ ACCOUNT='scott'
2
+ PASSWD='scott123'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Sproule
@@ -32,6 +32,7 @@ files:
32
32
  - test/test_ficonabses.rb
33
33
  - test/test_helper.rb
34
34
  - test/test_localhost.rb
35
+ - test/test_secret.rb
35
36
  - History.txt
36
37
  - Manifest.txt
37
38
  - PostInstall.txt