gmail-mailer 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md ADDED
@@ -0,0 +1,10 @@
1
+ = gmail-mailer Changelog
2
+
3
+ === 0.3.0
4
+ * Removed the `from` field from `GmailMailer::Message`
5
+ * Added accessors for `to`, `subject`, `body` fields
6
+ * put validation on `to` field.
7
+ === 0.2.0
8
+ * Removed attachments from the constructor and added `add_attachment` method
9
+ === 0.1.0
10
+ * Initial version
@@ -1,22 +1,20 @@
1
- = gmail-mailer
1
+ Programatically send emails using a given gmail account. No username/passwords needed, just use your OAUTH credentials
2
2
 
3
- simple gem to allow you to send emails using your gmail account (without having to fiddle around with passwords)
3
+ ## Usage
4
+ ### Creating a message
5
+ message = GmailMailer::Message.new("to", "Hello Subject", "Hello Body")
4
6
 
5
- = Usage
6
- == Creating a message
7
- message = GmailMailer::Message.new("to", "from", "Hello Subject", "Hello Body")
7
+ ### Adding attachments
8
+ **NOTE:** Only single attachments work at the current moment in time
9
+ message.add_attachment("<path-to-file>")
8
10
 
9
- == Adding attachments
10
- ((*NOTE:*))Only single attachments work at the current moment in time
11
- message.add_attachment(Filepath)
12
-
13
- == Setting up gmail-mailer
11
+ ### Setting up gmail-mailer
14
12
  You will need to provide mailer with a hashmap containing the ouath details for your account.
15
13
 
16
- == Sending a message
14
+ ### Sending a message
17
15
  mailer.send(message)
18
16
 
19
- == Example application
17
+ ### Example application
20
18
  require 'gmail-mailer'
21
19
  email_credentials =
22
20
  {
@@ -30,13 +28,19 @@ You will need to provide mailer with a hashmap containing the ouath details for
30
28
  :email=>"<your gmail address>"
31
29
  }
32
30
 
33
- message = GmailMailer::Message.new("to","from", "Hello Subject", "Hello Body")
31
+ # construct message
32
+ message = GmailMailer::Message.new("to", "Hello Subject", "Hello Body")
33
+
34
+ # add an attachment to the message
34
35
  message.add_attachment(File.expand_path('~/image.png'))
35
36
 
37
+ # construct mailer using the email_credentials defined above
36
38
  mailer = GmailMailer::Mailer.new(email_credentials)
39
+
40
+ # send email
37
41
  mailer.send(message)
38
42
 
39
- == Contributing to gmail-mailer
43
+ ### Contributing to gmail-mailer
40
44
 
41
45
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
42
46
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
@@ -46,7 +50,7 @@ You will need to provide mailer with a hashmap containing the ouath details for
46
50
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
47
51
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
48
52
 
49
- == Copyright
53
+ ### Copyright
50
54
 
51
55
  Copyright (c) 2011 Daniel Harper. See LICENSE.txt for
52
56
  further details.
data/TODO.txt CHANGED
@@ -1,3 +1,4 @@
1
1
  changes needed for next version: -
2
- - Add more validation for email configuration
2
+ - Better validation for email configuration
3
3
  - Add better handling for SMTP errors
4
+ - unit testing
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
data/gmail-mailer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gmail-mailer}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Harper"]
@@ -14,14 +14,15 @@ Gem::Specification.new do |s|
14
14
  s.email = %q{djharperuk@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.rdoc"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ "Changelog.md",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
24
- "README.rdoc",
25
+ "README.md",
25
26
  "Rakefile",
26
27
  "TODO.txt",
27
28
  "VERSION",
data/lib/gmail-mailer.rb CHANGED
@@ -9,7 +9,6 @@ module GmailMailer
9
9
 
10
10
  def send(message)
11
11
  mail = Mail.new do
12
- from message.from
13
12
  to message.to
14
13
  subject message.subject
15
14
  body message.body
@@ -52,10 +51,11 @@ module GmailMailer
52
51
  end
53
52
 
54
53
  class Message
55
- attr_reader :to, :from, :subject, :body, :attachments
56
- def initialize(to, from, subject="", body="")
57
- @to = to
58
- @from = from
54
+ attr_accessor :to, :subject, :body
55
+ attr_reader :attachments
56
+ def initialize(to, subject="", body="")
57
+ raise ArgumentError, "You must specify an email address to send the message to!" if(to.nil? or to.empty?)
58
+ @to = to
59
59
  @subject = subject
60
60
  @body = body
61
61
  @attachments = []
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Harper
@@ -115,13 +115,14 @@ extensions: []
115
115
 
116
116
  extra_rdoc_files:
117
117
  - LICENSE.txt
118
- - README.rdoc
118
+ - README.md
119
119
  files:
120
120
  - .document
121
+ - Changelog.md
121
122
  - Gemfile
122
123
  - Gemfile.lock
123
124
  - LICENSE.txt
124
- - README.rdoc
125
+ - README.md
125
126
  - Rakefile
126
127
  - TODO.txt
127
128
  - VERSION
@@ -141,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
142
  requirements:
142
143
  - - ">="
143
144
  - !ruby/object:Gem::Version
144
- hash: -2151435929044116729
145
+ hash: -3791998660236781509
145
146
  segments:
146
147
  - 0
147
148
  version: "0"