luggage 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/CHANGES.md +9 -0
- data/README.md +38 -26
- data/lib/luggage/factory.rb +24 -14
- data/lib/luggage/version.rb +1 -1
- metadata +3 -3
- data/ChangeLog.rdoc +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5b8e6299a00d76b3bc1eb4ed219c2baea76d4c6
|
4
|
+
data.tar.gz: 836c4a9c74f7588a6c561ac1264ce6c568859afc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6659b895e186f99a30049b9daeab543cb0f7b9f060b0ed22d8255bad2fb37234fddc89d4b8039a7d1d5c1a05459bf81154dba66290a69bbd0572ad2d7bd5d544
|
7
|
+
data.tar.gz: d87f9515631498aa341f1c378169e9590fd174fedcc07daadb648e08dd9450869a40ff0329e24d30340f4c026f161e065363c3e4b7b6e1b8b81e58d4b04044e0
|
data/CHANGES.md
ADDED
data/README.md
CHANGED
@@ -18,8 +18,8 @@ That was easy, right?
|
|
18
18
|
|
19
19
|
## Before we get started...
|
20
20
|
|
21
|
-
Many of the following examples use a DSL/block style syntax. Most of the object
|
22
|
-
initializers accept a block and do an `instance_eval` on the new object
|
21
|
+
Many of the following examples use a DSL/block style syntax. Most of the object
|
22
|
+
initializers accept a block and do an `instance_eval` on the new object
|
23
23
|
if a block is passed. These three examples are equivalent:
|
24
24
|
|
25
25
|
``` ruby
|
@@ -61,31 +61,43 @@ f = Luggage.new(:connection => connection)
|
|
61
61
|
|
62
62
|
Keep in mind that the connection needs to be authenticated
|
63
63
|
|
64
|
-
### Using
|
64
|
+
### Using XOauth
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
the contents of `:authenticate` will be passed to `Net::IMAP#authenticate`.
|
66
|
+
Google has implemented XOauth for their IMAP connections. To use this pass in
|
67
|
+
`:server` as before and a token as `:xoauth`
|
69
68
|
|
70
69
|
``` ruby
|
71
|
-
f = Luggage.new(:server => 'imap.
|
72
|
-
f = Luggage.new(:server => ['imap.aol.com' 993, true], :authenticate => 'LOGIN user password')
|
70
|
+
f = Luggage.new(:server => ['imap.gmail.com', 993, true], :xoauth => token)
|
73
71
|
```
|
74
72
|
|
75
|
-
|
76
|
-
syntax of the initializer is available. See [the Ruby docs](http://rubydoc.info/stdlib/net/Net/IMAP)
|
77
|
-
for more details on auth and intialization
|
73
|
+
See the documentation for you service provider for details on generating that token.
|
78
74
|
|
79
|
-
### Using
|
75
|
+
### Using LOGIN
|
80
76
|
|
81
|
-
|
82
|
-
|
77
|
+
Many IMAP servers support the `LOGIN` command, which `Net::IMAP` exposes with
|
78
|
+
its [`#login`
|
79
|
+
method](http://rubydoc.info/stdlib/net/Net/IMAP#login-instance_method). Whatever
|
80
|
+
you put in the `:login` key, Luggage will pass to `Net::IMAP#login`.
|
83
81
|
|
84
82
|
``` ruby
|
85
|
-
f = Luggage.new(:server =>
|
83
|
+
f = Luggage.new(:server => 'imap.aol.com', :login => %w(username password))
|
86
84
|
```
|
87
85
|
|
88
|
-
|
86
|
+
### Using an authentication string
|
87
|
+
|
88
|
+
If you want to do something different, you can pass in `:server` and
|
89
|
+
`:authenticate`. The contents of the `:authenticate` key will be passed to along
|
90
|
+
`Net::IMAP#authenticate`.
|
91
|
+
|
92
|
+
``` ruby
|
93
|
+
f = Luggage.new(:server => 'imap.aol.com', :authenticate => %w(COMMAND arg1 arg2))
|
94
|
+
f = Luggage.new(:server => ['imap.aol.com' 993, true], :authenticate => %w(COMMAND arg1 arg2))
|
95
|
+
```
|
96
|
+
|
97
|
+
Notice that the value of `:server` will be passed to `Net::IMAP#new`, so the
|
98
|
+
full syntax of the initializer is available. See [the Net::IMAP
|
99
|
+
docs](http://rubydoc.info/stdlib/net/Net/IMAP) for more details on
|
100
|
+
authentication and intialization.
|
89
101
|
|
90
102
|
|
91
103
|
## Working with mailboxes
|
@@ -134,12 +146,12 @@ Luggage.new(:connection => c) do
|
|
134
146
|
end
|
135
147
|
```
|
136
148
|
|
137
|
-
Querying works somewhat like ActiveRecord scopes, in that you can chain calls to `where`
|
149
|
+
Querying works somewhat like ActiveRecord scopes, in that you can chain calls to `where`
|
138
150
|
to build up a compound query, which is only executed once you attempt to inspect the results.
|
139
151
|
Keep in mind that compound queries are generated by appending each key/value pair into
|
140
152
|
big string and sending it to the IMAP server - this isn't SQL
|
141
153
|
|
142
|
-
Messages are retrieved somewhat lazily. The `Message-ID` and `uid` fields are always fetched,
|
154
|
+
Messages are retrieved somewhat lazily. The `Message-ID` and `uid` fields are always fetched,
|
143
155
|
but the full body isn't fetched until you try to access a field like `subject` or `body`.
|
144
156
|
You can inspect retrieved messages using the same syntax as the [Mail](https://github.com/mikel/mail)
|
145
157
|
gem, for instance:
|
@@ -172,27 +184,27 @@ See the next section for more details on that `Luggage#message` method...
|
|
172
184
|
|
173
185
|
## Working with messages
|
174
186
|
|
175
|
-
`Luggage#message` and `Mailbox#message` provide interfaces for creating messages.
|
187
|
+
`Luggage#message` and `Mailbox#message` provide interfaces for creating messages.
|
176
188
|
|
177
189
|
* If you pass in a `:template` argument, the message will be created using the contents
|
178
|
-
of the file at that path.
|
179
|
-
* If you pass an array as `:flags`, the passed flags will be set for the message when
|
190
|
+
of the file at that path.
|
191
|
+
* If you pass an array as `:flags`, the passed flags will be set for the message when
|
180
192
|
it's uploaded to the remote server.
|
181
193
|
* A date can be passed as `:date` and will be used as the recieved-at date when the message
|
182
|
-
is uploaded.
|
183
|
-
* Any other arguments will be interpreted as properties to be set on the new message.
|
194
|
+
is uploaded.
|
195
|
+
* Any other arguments will be interpreted as properties to be set on the new message.
|
184
196
|
These will be set after the template is read (if provided), allowing
|
185
|
-
you to tweak the templates if needed.
|
197
|
+
you to tweak the templates if needed.
|
186
198
|
|
187
199
|
If using the `Luggage` version, a mailbox must be specified as the first argument.
|
188
200
|
|
189
201
|
``` ruby
|
190
202
|
Luggage.new(:connection => c) do
|
191
203
|
message("INBOX", :template => 'path/to/email.eml').save!
|
192
|
-
|
204
|
+
|
193
205
|
mailboxes "INBOX" do
|
194
206
|
message(:template => 'path/to/email.eml').save!
|
195
|
-
|
207
|
+
|
196
208
|
message(:template => 'path/to/email.eml', :subject => "Custom subject").save!
|
197
209
|
message do
|
198
210
|
subject "Howdy"
|
data/lib/luggage/factory.rb
CHANGED
@@ -4,31 +4,41 @@ module Luggage
|
|
4
4
|
|
5
5
|
# Factory
|
6
6
|
#
|
7
|
-
# Factories require an instance of Net::IMAP.
|
7
|
+
# Factories require an instance of Net::IMAP. Serveral methods are supported:
|
8
8
|
#
|
9
9
|
# Factory.new(:connection => connection)
|
10
|
-
# In this case, `connection` should be an authorized Net::IMAP instance
|
10
|
+
# In this case, `connection` should be an authorized Net::IMAP instance.
|
11
11
|
#
|
12
|
-
# Factory.new(:server => "imap.
|
13
|
-
# In this case
|
14
|
-
#
|
15
|
-
# for xoauth
|
12
|
+
# Factory.new(:server => "imap.gmail.com", :xoauth => [token, string])
|
13
|
+
# In this case we'll build a Net::IMAP instance and attempt to send a raw
|
14
|
+
# XOAUTH authentication request using the supplied token.
|
16
15
|
#
|
17
|
-
# Factory.new(:server =>
|
18
|
-
# In this case we'll build a Net::IMAP instance and
|
19
|
-
#
|
16
|
+
# Factory.new(:server => 'imap.example.com', :login => [username, password])
|
17
|
+
# In this case, we'll build a Net::IMAP instance and use the `#login` method
|
18
|
+
# to authenticate. This isn't the same as using 'LOGIN' as the auth method
|
19
|
+
# in the next example.
|
20
20
|
#
|
21
|
+
# Factory.new(:server => "imap.example.com", :authentication => [some_auth_method, appropriate, arguments])
|
22
|
+
# In this case, we'll build a Net::IMAP instance and attempt to authenticate
|
23
|
+
# with the value of `:authentication` by calling `Net::IMAP#authenticate`.
|
21
24
|
def initialize(args = {}, &block)
|
22
25
|
if args.has_key?(:connection)
|
23
26
|
@connection = args[:connection]
|
24
|
-
|
25
|
-
@connection = Net::IMAP.new(*Array(args[:server]))
|
26
|
-
@connection.authenticate(*args[:authenticate])
|
27
|
+
|
27
28
|
elsif args.has_key?(:server) && args.has_key?(:xoauth)
|
28
29
|
@connection = Net::IMAP.new(*Array(args[:server]))
|
29
|
-
@connection.
|
30
|
+
@connection.authenticate('XOAUTH', *Array(args[:xoauth]))
|
31
|
+
|
32
|
+
elsif args.has_key?(:server) && args.has_key?(:login)
|
33
|
+
@connection = Net::IMAP.new(*Array(args[:server]))
|
34
|
+
@connection.login(*Array(args[:login]))
|
35
|
+
|
36
|
+
elsif args.has_key?(:server) && args.has_key?(:authenticate)
|
37
|
+
@connection = Net::IMAP.new(*Array(args[:server]))
|
38
|
+
@connection.authenticate(*Array(args[:authenticate]))
|
39
|
+
|
30
40
|
else
|
31
|
-
raise ArgumentError,
|
41
|
+
raise ArgumentError, 'Imap Connection required.'
|
32
42
|
end
|
33
43
|
|
34
44
|
instance_eval &block if block_given?
|
data/lib/luggage/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luggage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Michael
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
@@ -146,7 +146,7 @@ files:
|
|
146
146
|
- .document
|
147
147
|
- .gitignore
|
148
148
|
- .rspec
|
149
|
-
-
|
149
|
+
- CHANGES.md
|
150
150
|
- Gemfile
|
151
151
|
- LICENSE.txt
|
152
152
|
- README.md
|
data/ChangeLog.rdoc
DELETED