gmail-afurmanov 0.1.0

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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --backtrace
@@ -0,0 +1,82 @@
1
+ # Gmail gem changelog
2
+
3
+ ## 0.4.0
4
+
5
+ * Added XOAUTH authentication method (Thanks Stefano Bernardi and Nicolas Fouché)
6
+ * Separated clients
7
+ * Fixed specs
8
+
9
+ ## 0.3.4
10
+
11
+ * Fixes in mailbox filters shortcuts (Thanks Benjamin Bock)
12
+
13
+ ## 0.3.3
14
+
15
+ * Added #expunge to Mailbox (Thanks Benjamin Bock)
16
+ * Added more mailbox filters (Thanks Benjamin Bock)
17
+ * Added shortcuts for mailbox filters
18
+ * Minor bugfixes
19
+
20
+ ## 0.3.2
21
+
22
+ * Added envelope fetching
23
+ * Minor bugfixes
24
+
25
+ ## 0.3.0
26
+
27
+ * Refactoring
28
+ * Fixed bugs
29
+ * API improvements
30
+ * Better documentation
31
+ * Code cleanup
32
+ * RSpec for everything
33
+
34
+ ## 0.1.1 / 2010-05-11
35
+
36
+ * Added explicit tmail dependency in gemspec
37
+ * Added better README tutorial content
38
+
39
+ ## 0.0.9 / 2010-04-17
40
+
41
+ * Fixed content-transfer-encoding when sending email
42
+
43
+ ## 0.0.8 / 2009-12-23
44
+
45
+ * Fixed attaching a file to an empty message
46
+
47
+ ## 0.0.7 / 2009-12-23
48
+
49
+ * Improved multipart message parsing reliability
50
+
51
+ ## 0.0.6 / 2009-12-21
52
+
53
+ * Fixed multipart parsing for when the boundary is marked in quotes.
54
+
55
+ ## 0.0.5 / 2009-12-16
56
+
57
+ * Fixed IMAP initializer to work with Ruby 1.9's net/imap
58
+ * Better logout depending on the IMAP connection itself
59
+ * Added MIME::Message#text and MIME::Message#html for easier access to an email body
60
+ * Improved the MIME-parsing API slightly
61
+ * Added some tests
62
+
63
+ ## 0.0.4 / 2009-11-30
64
+
65
+ * Added label creation (thanks to Justin Perkins / http://github.com/justinperkins)
66
+ * Made the gem login automatically when first needed
67
+ * Added an optional block on the Gmail.new object that will login and logout for you
68
+ * Added several search options (thanks to Mikkel Malmberg / http://github.com/mikker)
69
+
70
+ ## 0.0.3 / 2009-11-19
71
+
72
+ * Fixed MIME::Message#content= for messages without an encoding
73
+ * Added Gmail#new_message
74
+
75
+ ## 0.0.2 / 2009-11-18
76
+
77
+ * Made all of the examples in the README possible
78
+
79
+ ## 0.0.1 / 2009-11-18
80
+
81
+ * Birthday!
82
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyrignt (c) 2010 Kriss 'nu7hatch' Kowalik
2
+ Copyright (c) 2009-2010 BehindLogic
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,268 @@
1
+ # GMail for Ruby
2
+
3
+ A Rubyesque interface to Google's GMail, with all the tools you'll need. Search,
4
+ read and send multipart emails, archive, mark as read/unread, delete emails,
5
+ and manage labels.
6
+
7
+ It's based on Daniel Parker's ruby-gmail gem. This version has more friendy
8
+ API, is well tested, better documented and have many other improvements.
9
+
10
+ ## Author(s)
11
+
12
+ * Kriss 'nu7hatch' Kowalik
13
+ * [Daniel Parker of BehindLogic.com](http://github.com/dcparker)
14
+
15
+ Extra thanks for specific feature contributions from:
16
+
17
+ * [abhishiv](http://github.com/abhishiv)
18
+ * [Michael Young](http://github.com/myoung8)
19
+ * [Nicolas Fouché](http://github.com/nfo)
20
+ * [Stefano Bernardi](http://github.com/stefanobernardi)
21
+ * [Benjamin Bock](http://github.com/bb)
22
+ * [Arthur Chiu](http://github.com/achiu)
23
+ * [Justin Perkins](http://github.com/justinperkins)
24
+ * [Mikkel Malmberg](http://github.com/mikker)
25
+ * [Julien Blanchard](http://github.com/julienXX)
26
+ * [Federico Galassi](http://github.com/fgalassi)
27
+
28
+ ## Installation
29
+
30
+ You can install it easy using rubygems:
31
+
32
+ sudo gem install gmail
33
+
34
+ Or install it manualy:
35
+
36
+ git clone git://github.com/nu7hatch/gmail.git
37
+ cd gmail
38
+ rake install
39
+
40
+ To install gmail gem you have to met following requirements (with rubygems all
41
+ will be installed automatically):
42
+
43
+ * mail
44
+ * mime
45
+ * smpt_tls (Ruby < 1.8.7)
46
+
47
+ ## Features
48
+
49
+ * Search emails
50
+ * Read emails (handles attachments)
51
+ * Emails: label, archive, delete, mark as read/unread/spam, star
52
+ * Manage labels
53
+ * Create and send multipart email messages in plaintext and/or html, with inline
54
+ images and attachments
55
+ * Utilizes Gmail's IMAP & SMTP, MIME-type detection and parses and generates
56
+ MIME properly.
57
+
58
+ ## Basic usage
59
+
60
+ First of all require the `gmail` library.
61
+
62
+ require 'gmail'
63
+
64
+ ### Authenticating gmail sessions
65
+
66
+ This will you automatically log in to your account.
67
+
68
+ gmail = Gmail.connect(username, password)
69
+ # play with your gmail...
70
+ gmail.logout
71
+
72
+ If you pass a block, the session will be passed into the block, and the session
73
+ will be logged out after the block is executed.
74
+
75
+ Gmail.connect(username, password) do |gmail|
76
+ # play with your gmail...
77
+ end
78
+
79
+ Examples above are "quiet", it means that it will not raise any errors when
80
+ session couldn't be started (eg. because of connection error or invalid
81
+ authorization data). You can use connection which handles errors raising:
82
+
83
+ Gmail.connect!(username, password)
84
+ Gmail.connect!(username, password) {|gmail| ... play with gmail ... }
85
+
86
+ You can also check if you are logged in at any time:
87
+
88
+ Gmail.connect(username, password) do |gmail|
89
+ gmail.logged_in?
90
+ end
91
+
92
+ ### XOAuth authentication
93
+
94
+ From v0.4.0 it's possible to authenticate with your Gmail account using XOAuth
95
+ method. It's very simple:
96
+
97
+ gmail = Gmail.connect(:xoauth, "email@domain.com",
98
+ :token => 'TOKEN',
99
+ :secret => 'TOKEN_SECRET',
100
+ :consumer_key => 'CONSUMER_KEY',
101
+ :consumer_secret => 'CONSUMER_SECRET'
102
+ )
103
+
104
+ For more information check out the [gmail_xoauth](https://github.com/nfo/gmail_xoauth)
105
+ gem from Nicolas Fouché.
106
+
107
+ ### Counting and gathering emails
108
+
109
+ Get counts for messages in the inbox:
110
+
111
+ gmail.inbox.count
112
+ gmail.inbox.count(:unread)
113
+ gmail.inbox.count(:read)
114
+
115
+ Count with some criteria:
116
+
117
+ gmail.inbox.count(:after => Date.parse("2010-02-20"), :before => Date.parse("2010-03-20"))
118
+ gmail.inbox.count(:on => Date.parse("2010-04-15"))
119
+ gmail.inbox.count(:from => "myfriend@gmail.com")
120
+ gmail.inbox.count(:to => "directlytome@gmail.com")
121
+
122
+ Combine flags and options:
123
+
124
+ gmail.inbox.count(:unread, :from => "myboss@gmail.com")
125
+
126
+ Browsing labeled emails is similar to work with inbox.
127
+
128
+ gmail.mailbox('Urgent').count
129
+
130
+ Getting messages works the same way as counting: Remember that every message in a
131
+ conversation/thread will come as a separate message.
132
+
133
+ gmail.inbox.emails(:unread, :before => Date.parse("2010-04-20"), :from => "myboss@gmail.com")
134
+
135
+ You can use also one of aliases:
136
+
137
+ gmail.inbox.find(...)
138
+ gmail.inbox.search(...)
139
+ gmail.inbox.mails(...)
140
+
141
+ Also you can manipulate each message using block style:
142
+
143
+ gmail.inbox.find(:unread) do |email|
144
+ email.read!
145
+ end
146
+
147
+ ### Working with emails!
148
+
149
+ Any news older than 4-20, mark as read and archive it:
150
+
151
+ gmail.inbox.find(:before => Date.parse("2010-04-20"), :from => "news@nbcnews.com") do |email|
152
+ email.read! # can also unread!, spam! or star!
153
+ email.archive!
154
+ end
155
+
156
+ Delete emails from X:
157
+
158
+ gmail.inbox.find(:from => "x-fiance@gmail.com").each do |email|
159
+ email.delete!
160
+ end
161
+
162
+ Save all attachments in the "Faxes" label to a local folder:
163
+
164
+ folder = "/where/ever"
165
+ gmail.mailbox("Faxes").emails do |email|
166
+ if !email.message.attachments.empty?
167
+ email.message.save_attachments_to(folder)
168
+ end
169
+ end
170
+
171
+ You can use also `#label` method instead of `#mailbox`:
172
+
173
+ gmail.label("Faxes").emails {|email| ... }
174
+
175
+ Save just the first attachment from the newest unread email (assuming pdf):
176
+
177
+ email = gmail.inbox.find(:unread).first
178
+ email.attachments[0].save_to_file("/path/to/location")
179
+
180
+ Add a label to a message:
181
+
182
+ email.label("Faxes")
183
+
184
+ Example above will raise error when you don't have the `Faxes` label. You can
185
+ avoid this using:
186
+
187
+ email.label!("Faxes") # The `Faxes` label will be automatically created now
188
+
189
+ You can also move message to a label/mailbox:
190
+
191
+ email.move_to("Faxes")
192
+ email.move_to!("NewLabel")
193
+
194
+ There is also few shortcuts to mark messages quickly:
195
+
196
+ email.read!
197
+ email.unread!
198
+ email.spam!
199
+ email.star!
200
+ email.unstar!
201
+
202
+ ### Managing labels
203
+
204
+ With Gmail gem you can also manage your labels. You can get list of defined
205
+ labels:
206
+
207
+ gmail.labels.all
208
+
209
+ Create new label:
210
+
211
+ gmail.labels.new("Urgent")
212
+ gmail.labels.add("AnotherOne")
213
+
214
+ Remove labels:
215
+
216
+ gmail.labels.delete("Uregent")
217
+
218
+ Or check if given label exists:
219
+
220
+ gmail.labels.exists?("Uregent") # => false
221
+ gmail.labels.exists?("AnotherOne") # => true
222
+
223
+ ### Composing and sending emails
224
+
225
+ Creating emails now uses the amazing [Mail](http://rubygems.org/gems/mail) rubygem.
226
+ See its [documentation here](http://github.com/mikel/mail). The Ruby Gmail will
227
+ automatically configure your Mail emails to be sent via your Gmail account's SMTP,
228
+ so they will be in your Gmail's "Sent" folder. Also, no need to specify the "From"
229
+ email either, because ruby-gmail will set it for you.
230
+
231
+ gmail.deliver do
232
+ to "email@example.com"
233
+ subject "Having fun in Puerto Rico!"
234
+ text_part do
235
+ body "Text of plaintext message."
236
+ end
237
+ html_part do
238
+ body "<p>Text of <em>html</em> message.</p>"
239
+ end
240
+ add_file "/path/to/some_image.jpg"
241
+ end
242
+
243
+ Or, compose the message first and send it later
244
+
245
+ email = gmail.compose do
246
+ to "email@example.com"
247
+ subject "Having fun in Puerto Rico!"
248
+ body "Spent the day on the road..."
249
+ end
250
+ email.deliver! # or: gmail.deliver(email)
251
+
252
+ ## Note on Patches/Pull Requests
253
+
254
+ * Fork the project.
255
+ * Make your feature addition or bug fix.
256
+ * Add tests for it. This is important so I don't break it in a
257
+ future version unintentionally.
258
+ * Commit, do not mess with rakefile, version, or history.
259
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
260
+ * Send me a pull request. Bonus points for topic branches.
261
+
262
+ ## Copyright
263
+
264
+ * Copyrignt (c) 2010 Kriss 'nu7hatch' Kowalik
265
+ * Copyright (c) 2009-2010 BehindLogic
266
+
267
+ See LICENSE for details.
268
+
@@ -0,0 +1,39 @@
1
+ # -*- ruby -*-
2
+
3
+ $:.unshift(File.expand_path('../lib', __FILE__))
4
+ require 'gmail/version'
5
+
6
+ begin
7
+ require 'ore/tasks'
8
+ Ore::Tasks.new
9
+ rescue LoadError => e
10
+ STDERR.puts e.message
11
+ STDERR.puts "Run `gem install ore-tasks` to install 'ore/tasks'."
12
+ end
13
+
14
+ begin
15
+ require 'rspec/core/rake_task'
16
+ RSpec::Core::RakeTask.new(:spec)
17
+ rescue LoadError
18
+ task :spec do
19
+ abort 'Run `gem install rspec` to install RSpec'
20
+ end
21
+ end
22
+
23
+ task :test => :spec
24
+ task :default => :test
25
+
26
+ begin
27
+ require 'metric_fu'
28
+ rescue LoadError => e
29
+ STDERR.puts e.message
30
+ STDERR.puts "Run `gem install metric_fu` to install Metric-Fu"
31
+ end
32
+
33
+ require 'rake/rdoctask'
34
+ Rake::RDocTask.new do |rdoc|
35
+ rdoc.rdoc_dir = 'rdoc'
36
+ rdoc.title = "Gmail for Ruby #{Gmail.version}"
37
+ rdoc.rdoc_files.include('README*')
38
+ rdoc.rdoc_files.include('lib/**/*.rb')
39
+ end
data/TODO.md ADDED
@@ -0,0 +1,6 @@
1
+ # TODO
2
+
3
+ * Specs for xoauth
4
+ * Specs for message operations
5
+ * Specs for filters in mailbox
6
+ * Non-English accounts
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ "0.1.0"
@@ -0,0 +1,22 @@
1
+ name: gmail-afurmanov
2
+ summary:
3
+ A Rubyesque interface to Gmail, with all the tools you will need.
4
+ description:
5
+ A Rubyesque interface to Gmail, with all the tools you will need.
6
+ Search, read and send multipart emails; archive, mark as read/unread,
7
+ delete emails; and manage labels.
8
+
9
+ license: MIT
10
+ authors: Chris Kowalik
11
+ email: chris@nu7hat.ch
12
+ homepage: http://github.com/nu7hatch/gmail
13
+
14
+ dependencies:
15
+ mime: >= 0.1
16
+ mail: >= 2.2.1
17
+ gmail_xoauth: >= 0.3.0
18
+
19
+ development_dependencies:
20
+ ore-tasks: ~> 0.4
21
+ rspec: ~> 2.0
22
+ mocha: >= 0.9