gmail_gm_raw 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 21107bb95bf7958fd00ca24dbf4c04ca1e1d3368
4
+ data.tar.gz: 599fbc0e88602f602429577701ed50cec92cdcb9
5
+ SHA512:
6
+ metadata.gz: 09d8b7c0eb10f1ed2fe72ef4d8a1bb8e314e56907872a7234656ff058b194808ae737a8b810dab47e3ae8f77402eac06b90997aa3ae52ddf62c2c3b5dd336242
7
+ data.tar.gz: 80d4eee48e64d20073db279cbcb0dae0231e6df77dc67689093b81cc535902d03a928182439a4e68c51d033ba66ef8c9d81906e671eba640b0dca63182d6a3e1
@@ -0,0 +1,28 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ Gemfile.lock
21
+
22
+ ## PROJECT::SPECIFIC
23
+ *.rdb
24
+
25
+ ## Test Account details
26
+ spec/account.yml
27
+
28
+ .idea/
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/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
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,275 @@
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
+ * [Alex Genco](http://github.com/alexgenco)
28
+ * [Justin Grevich](http://github.com/jgrevich)
29
+
30
+ ## Installation
31
+
32
+ You can install it easy using rubygems:
33
+
34
+ sudo gem install gmail
35
+
36
+ Or install it manually:
37
+
38
+ git clone git://github.com/nu7hatch/gmail.git
39
+ cd gmail
40
+ rake install
41
+
42
+ gmail gem has the following dependencies (with Bundler all will be installed automatically):
43
+
44
+ * mail (Ruby 1.8.7 users should lock mail gem version at 2.5.3)
45
+ * mime
46
+ * gmail_xoauth
47
+ * smpt_tls (Ruby < 1.8.7)
48
+
49
+ ## Features
50
+
51
+ * Search emails
52
+ * Read emails (handles attachments)
53
+ * Emails: label, archive, delete, mark as read/unread/spam, star
54
+ * Manage labels
55
+ * Create and send multipart email messages in plaintext and/or html, with inline
56
+ images and attachments
57
+ * Utilizes Gmail's IMAP & SMTP, MIME-type detection and parses and generates
58
+ MIME properly.
59
+
60
+ ## Basic usage
61
+
62
+ First of all require the `gmail` library.
63
+
64
+ require 'gmail'
65
+
66
+ ### Authenticating gmail sessions
67
+
68
+ This will you automatically log in to your account.
69
+
70
+ gmail = Gmail.connect(username, password)
71
+ # play with your gmail...
72
+ gmail.logout
73
+
74
+ If you pass a block, the session will be passed into the block, and the session
75
+ will be logged out after the block is executed.
76
+
77
+ Gmail.connect(username, password) do |gmail|
78
+ # play with your gmail...
79
+ end
80
+
81
+ Examples above are "quiet", it means that it will not raise any errors when
82
+ session couldn't be started (eg. because of connection error or invalid
83
+ authorization data). You can use connection which handles errors raising:
84
+
85
+ Gmail.connect!(username, password)
86
+ Gmail.connect!(username, password) {|gmail| ... play with gmail ... }
87
+
88
+ You can also check if you are logged in at any time:
89
+
90
+ Gmail.connect(username, password) do |gmail|
91
+ gmail.logged_in?
92
+ end
93
+
94
+ ### XOAuth authentication
95
+
96
+ From v0.4.0 it's possible to authenticate with your Gmail account using XOAuth
97
+ method. It's very simple:
98
+
99
+ gmail = Gmail.connect(:xoauth, "email@domain.com",
100
+ :token => 'TOKEN',
101
+ :secret => 'TOKEN_SECRET',
102
+ :consumer_key => 'CONSUMER_KEY',
103
+ :consumer_secret => 'CONSUMER_SECRET'
104
+ )
105
+
106
+ For more information check out the [gmail_xoauth](https://github.com/nfo/gmail_xoauth)
107
+ gem from Nicolas Fouché.
108
+
109
+ ### Counting and gathering emails
110
+
111
+ Get counts for messages in the inbox:
112
+
113
+ gmail.inbox.count
114
+ gmail.inbox.count(:unread)
115
+ gmail.inbox.count(:read)
116
+
117
+ Count with some criteria:
118
+
119
+ gmail.inbox.count(:after => Date.parse("2010-02-20"), :before => Date.parse("2010-03-20"))
120
+ gmail.inbox.count(:on => Date.parse("2010-04-15"))
121
+ gmail.inbox.count(:from => "myfriend@gmail.com")
122
+ gmail.inbox.count(:to => "directlytome@gmail.com")
123
+
124
+ Combine flags and options:
125
+
126
+ gmail.inbox.count(:unread, :from => "myboss@gmail.com")
127
+
128
+ Browsing labeled emails is similar to work with inbox.
129
+
130
+ gmail.mailbox('Urgent').count
131
+
132
+ Getting messages works the same way as counting: Remember that every message in a
133
+ conversation/thread will come as a separate message.
134
+
135
+ gmail.inbox.emails(:unread, :before => Date.parse("2010-04-20"), :from => "myboss@gmail.com")
136
+
137
+ The [gm option](https://developers.google.com/gmail/imap_extensions?csw=1#extension_of_the_search_command_x-gm-raw) enables use of the Gmail search syntax.
138
+
139
+ gmail.inbox.emails(gm: '"testing"')
140
+
141
+ You can use also one of aliases:
142
+
143
+ gmail.inbox.find(...)
144
+ gmail.inbox.search(...)
145
+ gmail.inbox.mails(...)
146
+
147
+ Also you can manipulate each message using block style:
148
+
149
+ gmail.inbox.find(:unread).each do |email|
150
+ email.read!
151
+ end
152
+
153
+ ### Working with emails!
154
+
155
+ Any news older than 4-20, mark as read and archive it:
156
+
157
+ gmail.inbox.find(:before => Date.parse("2010-04-20"), :from => "news@nbcnews.com").each do |email|
158
+ email.read! # can also unread!, spam! or star!
159
+ email.archive!
160
+ end
161
+
162
+ Delete emails from X:
163
+
164
+ gmail.inbox.find(:from => "x-fiance@gmail.com").each do |email|
165
+ email.delete!
166
+ end
167
+
168
+ Save all attachments in the "Faxes" label to a local folder:
169
+
170
+ folder = "/where/ever"
171
+ gmail.mailbox("Faxes").emails.each do |email|
172
+ if !email.message.attachments.empty?
173
+ email.message.save_attachments_to(folder)
174
+ end
175
+ end
176
+
177
+ You can use also `#label` method instead of `#mailbox`:
178
+
179
+ gmail.label("Faxes").emails {|email| ... }
180
+
181
+ Save just the first attachment from the newest unread email (assuming pdf):
182
+
183
+ email = gmail.inbox.find(:unread).first
184
+ email.attachments[0].save_to_file("/path/to/location")
185
+
186
+ Add a label to a message:
187
+
188
+ email.label("Faxes")
189
+
190
+ Example above will raise error when you don't have the `Faxes` label. You can
191
+ avoid this using:
192
+
193
+ email.label!("Faxes") # The `Faxes` label will be automatically created now
194
+
195
+ You can also move message to a label/mailbox:
196
+
197
+ email.move_to("Faxes")
198
+ email.move_to!("NewLabel")
199
+
200
+ There is also few shortcuts to mark messages quickly:
201
+
202
+ email.read!
203
+ email.unread!
204
+ email.spam!
205
+ email.star!
206
+ email.unstar!
207
+
208
+ ### Managing labels
209
+
210
+ With Gmail gem you can also manage your labels. You can get list of defined
211
+ labels:
212
+
213
+ gmail.labels.all
214
+
215
+ Create new label:
216
+
217
+ gmail.labels.new("Urgent")
218
+ gmail.labels.add("AnotherOne")
219
+
220
+ Remove labels:
221
+
222
+ gmail.labels.delete("Urgent")
223
+
224
+ Or check if given label exists:
225
+
226
+ gmail.labels.exists?("Urgent") # => false
227
+ gmail.labels.exists?("AnotherOne") # => true
228
+
229
+ ### Composing and sending emails
230
+
231
+ Creating emails now uses the amazing [Mail](http://rubygems.org/gems/mail) rubygem.
232
+ See its [documentation here](http://github.com/mikel/mail). The Ruby Gmail will
233
+ automatically configure your Mail emails to be sent via your Gmail account's SMTP,
234
+ so they will be in your Gmail's "Sent" folder. Also, no need to specify the "From"
235
+ email either, because ruby-gmail will set it for you.
236
+
237
+ gmail.deliver do
238
+ to "email@example.com"
239
+ subject "Having fun in Puerto Rico!"
240
+ text_part do
241
+ body "Text of plaintext message."
242
+ end
243
+ html_part do
244
+ content_type 'text/html; charset=UTF-8'
245
+ body "<p>Text of <em>html</em> message.</p>"
246
+ end
247
+ add_file "/path/to/some_image.jpg"
248
+ end
249
+
250
+ Or, compose the message first and send it later
251
+
252
+ email = gmail.compose do
253
+ to "email@example.com"
254
+ subject "Having fun in Puerto Rico!"
255
+ body "Spent the day on the road..."
256
+ end
257
+ email.deliver! # or: gmail.deliver(email)
258
+
259
+ ## Note on Patches/Pull Requests
260
+
261
+ * Fork the project.
262
+ * Make your feature addition or bug fix.
263
+ * Add tests for it. This is important so I don't break it in a
264
+ future version unintentionally.
265
+ * Commit, do not mess with rakefile, version, or history.
266
+ (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)
267
+ * Send me a pull request. Bonus points for topic branches.
268
+
269
+ ## Copyright
270
+
271
+ * Copyrignt (c) 2010 Kriss 'nu7hatch' Kowalik
272
+ * Copyright (c) 2009-2010 BehindLogic
273
+
274
+ See LICENSE for details.
275
+
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env rake
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ begin
10
+ require 'rdoc/task'
11
+ rescue LoadError
12
+ require 'rdoc/rdoc'
13
+ require 'rake/rdoctask'
14
+ RDoc::Task = Rake::RDocTask
15
+ end
16
+
17
+ RDoc::Task.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = "Gmail for Ruby #{Gmail::VERSION}"
20
+ rdoc.rdoc_files.include('README*')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ Bundler::GemHelper.install_tasks
25
+
26
+ begin
27
+ require 'rspec/core/rake_task'
28
+ RSpec::Core::RakeTask.new(:spec)
29
+ rescue LoadError
30
+ task :spec do
31
+ abort 'Run `gem install rspec` to install RSpec'
32
+ end
33
+ end
34
+
35
+ task :default => :spec