luggage 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbf6c643e587287b8d3df07c913163c0c9b56c89
4
- data.tar.gz: d7bd6e2bf725860cf8392469f2ca1195358f9863
3
+ metadata.gz: e5b8e6299a00d76b3bc1eb4ed219c2baea76d4c6
4
+ data.tar.gz: 836c4a9c74f7588a6c561ac1264ce6c568859afc
5
5
  SHA512:
6
- metadata.gz: c6e39c9d15b0980de7e56c3df266bde5180388b114d145b01b26d66de2b129cde2e019e88dd0bbf3e0557a6b4fb8dce83ddd7fc0759ba88d2733785f68978264
7
- data.tar.gz: c070bbb000e6ed0654240cc40c41e015317d6625a07e1c89515ed932770b46b3f74f94c0f29e007087385f940a1d204ceeb5e816a3a2d792c12a726fbf385397
6
+ metadata.gz: 6659b895e186f99a30049b9daeab543cb0f7b9f060b0ed22d8255bad2fb37234fddc89d4b8039a7d1d5c1a05459bf81154dba66290a69bbd0572ad2d7bd5d544
7
+ data.tar.gz: d87f9515631498aa341f1c378169e9590fd174fedcc07daadb648e08dd9450869a40ff0329e24d30340f4c026f161e065363c3e4b7b6e1b8b81e58d4b04044e0
data/CHANGES.md ADDED
@@ -0,0 +1,9 @@
1
+ #Changes
2
+
3
+ ## 1.1.0
4
+
5
+ * Added `:login` authentication method to `Luggage.new`. - Ben Hamill
6
+
7
+ ## 1.0.0
8
+
9
+ * Initial release. - Ryan Michael & Eric Pinzur
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 an authentication string
64
+ ### Using XOauth
65
65
 
66
- `Net::IMAP` natively supports `LOGIN` and `CRAM-MD5` authentication schemes,
67
- if you want to use either of these you can pass in `:server` and `:authenticate`,
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.aol.com', :authenticate => 'LOGIN user password')
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
- Notice that the value of `:server` will be passed to `Net::IMAP#new`, so the full
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 XOauth
75
+ ### Using LOGIN
80
76
 
81
- Google has implemented XOauth for their IMAP connections. To use this pass in
82
- `:server` as before and a token as `:xoauth`
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 => ['imap.gmail.com', 993, true], :xoauth => token)
83
+ f = Luggage.new(:server => 'imap.aol.com', :login => %w(username password))
86
84
  ```
87
85
 
88
- See the documentation for you service provider for details on generating that token.
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"
@@ -4,31 +4,41 @@ module Luggage
4
4
 
5
5
  # Factory
6
6
  #
7
- # Factories require an instance of Net::IMAP. Serveral methods are supported:
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.example.com", :authentication => "LOGIN username password")
13
- # In this case, we'll build a Net::IMAP instance and attempt to authenticate with the
14
- # value of `authentication`. Net::IMAP supports LOGIN and CRAM-MD5 natively - see below
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 => "imap.gmail.com", :xoauth => "xoauth token string")
18
- # In this case we'll build a Net::IMAP instance and attempt to send a raw XOAUTH authentication
19
- # request using the supplied token.
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
- elsif args.has_key?(:server) && args.has_key?(:authenticate)
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.send(:send_command, "AUTHENTICATE XOAUTH #{args[:xoauth]}")
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, "Imap Connection required."
41
+ raise ArgumentError, 'Imap Connection required.'
32
42
  end
33
43
 
34
44
  instance_eval &block if block_given?
@@ -1,3 +1,3 @@
1
1
  module Luggage
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
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.0.0
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-13 00:00:00.000000000 Z
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
- - ChangeLog.rdoc
149
+ - CHANGES.md
150
150
  - Gemfile
151
151
  - LICENSE.txt
152
152
  - README.md
data/ChangeLog.rdoc DELETED
@@ -1,4 +0,0 @@
1
- === 0.1.0 / 2012-12-03
2
-
3
- * Initial release:
4
-