ficonabses 0.1.1 → 0.1.2

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 CHANGED
@@ -8,19 +8,26 @@ A simple way to send emails from your application using amazon ses. Register at
8
8
 
9
9
  == FEATURES/PROBLEMS:
10
10
 
11
- * FIX (list of features or problems)
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://admin.ses.sg.estormtech.com
12
12
 
13
- == SYNOPSIS:
13
+ == SYNOPSIS HTML EMAIL:
14
14
 
15
- FIX (code sample of usage)
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
+
17
+ == SYNOPSIS TEXT EMAIL:
18
+
19
+ * res =FiconabSES::Base.send_textemail('acccount','password','scott.sproule@estormtech.com','This is the subject','contents of the email')
16
20
 
17
21
  == REQUIREMENTS:
18
22
 
19
- * FIX (list of requirements)
23
+ * httpclient gem and ses.sg.estormtech.com is up and you have an account/password at admin.ses.sg.estormtech.com.
20
24
 
21
25
  == INSTALL:
22
26
 
23
- * FIX (sudo gem install, anything else)
27
+ * sudo gem install ficonabses httpclient
28
+
29
+ == DEPENDENCY:
30
+ dependency on httpclient.
24
31
 
25
32
  == LICENSE:
26
33
 
@@ -5,16 +5,20 @@ require 'httpclient'
5
5
  gem 'nokogiri'
6
6
  require 'nokogiri'
7
7
 
8
- module Ficonab
8
+ module FiconabSES
9
9
  class Base
10
10
  attr_accessor :host,:account,:password,:uri,:clnt,:extheader
11
11
 
12
12
  @@host= 'ses.sg.estormtech.com'
13
13
  # @@host= 'localhost:8083'
14
14
  def self.send_textemail(account,password,destination,subject,contents)
15
- f=Ficonab::Base.new
15
+ f=FiconabSES::Base.new
16
16
  f.send_textemail(account,password,destination,subject,contents)
17
17
  end
18
+ def self.send_htmlemail(account,password,destination,subject,htmlcontents,textcontents=nil)
19
+ f=FiconabSES::Base.new
20
+ f.send_htmlemail(account,password,destination,subject,htmlcontents,textcontents)
21
+ end
18
22
  def perform(account,password,url)
19
23
  @uri=URI.parse(url)
20
24
  res=''
@@ -34,14 +38,26 @@ module Ficonab
34
38
  res
35
39
 
36
40
  end
41
+ def text_url(destination,subject,contents)
42
+ url="http://#{@@host}/ficonabsendemail?destination=#{URI.encode(destination)}&text=#{URI.encode(contents)}&subject=#{URI.encode(subject)}"
43
+ url
44
+ end
45
+ def html_url(destination,subject,contents,html)
46
+ contents='' if contents==nil
47
+ url="#{self.text_url(destination,subject,contents)}&html=#{URI.encode(contents)}"
48
+ end
37
49
  def send_textemail(account,password,destination,subject,contents)
38
-
39
-
40
- url="http://#{@@host}/ficonabsendemail?destination=#{URI.encode(destination)}&text=#{URI.encode(contents)}&subject=#{URI.encode(subject)}"
50
+ url=self.text_url(destination,subject,contents)
41
51
  puts "url is: #{url}"
42
52
  perform(account,password,url)
43
53
  # res
44
- end
54
+ end
55
+ def send_htmlemail(account,password,destination,subject,htmlcontents,textcontents=nil)
56
+ url=self.html_url(destination,subject,textcontents,htmlcontents)
57
+ puts "url is: #{url}"
58
+ perform(account,password,url)
59
+ # res
60
+ end
45
61
 
46
62
  end # Class
47
63
  end #Module
data/lib/ficonabses.rb CHANGED
@@ -2,6 +2,6 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
  Dir[File.join(File.dirname(__FILE__), 'ficonabses/**/*.rb')].sort.each { |lib| require lib }
4
4
 
5
- module Ficonabses
5
+ module FiconabSES
6
6
  VERSION = '0.0.1'
7
7
  end
@@ -6,8 +6,18 @@ class TestFiconabses < Test::Unit::TestCase
6
6
  end
7
7
 
8
8
  def test_send_text
9
- res =Ficonab::Base.send_textemail('scott','scott123','scott.sproule@gmail.com','This is the subject','contents of the email')
9
+ res =FiconabSES::Base.send_textemail('scott','scott123','scott.sproule@gmail.com','This is the subject','contents of the email')
10
10
  puts "RES is: #{res}"
11
11
  assert res.include? '200'
12
12
  end
13
+ def test_send_html
14
+ res =FiconabSES::Base.send_htmlemail('scott','scott123','scott.sproule@gmail.com','This is the subject','<h1>HTML Contents</h1><p>hi from paragraph</p>','text contents of the email')
15
+ puts "RES is: #{res}"
16
+ assert res.include? '200'
17
+ end
18
+ def test_send_html_nil_text
19
+ res =FiconabSES::Base.send_htmlemail('scott','scott123','scott.sproule@gmail.com','This is the subject','<h1>HTML Contents</h1><p>hi from paragraph</p>') #no text portion
20
+ puts "RES is: #{res}"
21
+ assert res.include? '200'
22
+ end
13
23
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
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-13 00:00:00 +08:00
17
+ date: 2011-11-15 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies: []
20
20