luggage 1.1.1 → 1.1.2
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 +4 -0
- data/lib/luggage/mailbox.rb +3 -1
- data/lib/luggage/message.rb +8 -9
- data/lib/luggage/version.rb +1 -1
- data/spec/luggage/factory_spec.rb +3 -3
- data/spec/luggage/message_spec.rb +4 -4
- data/spec/spec_helper.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dcaf5c5940857410afb20c4e5bca8e13dcd7104
|
4
|
+
data.tar.gz: 019ce4b62e899a33b2119bb24b1d0f327ea3c634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99b5fea709397491179ab1f6c19c6e2b04ea6b933f2eae238f39e2d670120c02520618e01763315d31a2a1aa44a40f3ec55901af07a0635c441d1c7ddeb01408
|
7
|
+
data.tar.gz: da1204cc9373fa4703403ace74d4058b8458011fce034df33baa80903091ec22e069d8282f0dee25de7aedebbdbe52eb547e04102d7bf553cbb43b9da9bbcbb3
|
data/CHANGES.md
CHANGED
data/lib/luggage/mailbox.rb
CHANGED
@@ -28,7 +28,9 @@ module Luggage
|
|
28
28
|
# Returns true if this mailbox exists on the remote server, false otherwise
|
29
29
|
#
|
30
30
|
def exists?
|
31
|
-
@exists
|
31
|
+
return @exists if instance_variable_defined?(:@exists)
|
32
|
+
|
33
|
+
@exists = !connection.list("", name).empty?
|
32
34
|
end
|
33
35
|
|
34
36
|
# Deletes this mailbox on the remote server
|
data/lib/luggage/message.rb
CHANGED
@@ -36,7 +36,7 @@ module Luggage
|
|
36
36
|
# `connection` should be an authenticated Imap connection
|
37
37
|
# `mailbox` should be either a Mailbox or a string describing a remote mailbox
|
38
38
|
# `args[:date]` when this message is appended to the remote server, this is the date which will be used
|
39
|
-
# `args[:template]` use this file as the initial raw email content.
|
39
|
+
# `args[:template]` use this file as the initial raw email content.
|
40
40
|
# `args[:message_id]` use this as for the Message-ID header. This header is used to identify messages across requests
|
41
41
|
#
|
42
42
|
def initialize(connection, mailbox, args = {}, &block)
|
@@ -87,10 +87,10 @@ module Luggage
|
|
87
87
|
#
|
88
88
|
def exists?
|
89
89
|
mailbox.select!
|
90
|
-
connection.uid_search("HEADER Message-ID #{message_id}")
|
90
|
+
connection.uid_search("HEADER Message-ID #{message_id}")
|
91
91
|
end
|
92
92
|
|
93
|
-
# Proxy all other methods to this instance's Mail::Message
|
93
|
+
# Proxy all other methods to this instance's Mail::Message
|
94
94
|
#
|
95
95
|
def method_missing(meth, *args, &block)
|
96
96
|
if mail.respond_to?(meth)
|
@@ -117,16 +117,15 @@ module Luggage
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def mail
|
120
|
-
reload
|
120
|
+
reload if @mail.nil?
|
121
121
|
@mail
|
122
122
|
end
|
123
123
|
|
124
124
|
def uid
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
@uid
|
125
|
+
return @uid if instance_variable_defined?(:@uid)
|
126
|
+
|
127
|
+
mailbox.select!
|
128
|
+
@uid = fetch_uid
|
130
129
|
end
|
131
130
|
|
132
131
|
def fetch_uid
|
data/lib/luggage/version.rb
CHANGED
@@ -42,9 +42,9 @@ describe Luggage::Factory do
|
|
42
42
|
describe "#mailboxes" do
|
43
43
|
before(:each) do
|
44
44
|
connection.stub(:list).
|
45
|
-
and_return([
|
46
|
-
OpenStruct.new(:name => "Mailbox_1"),
|
47
|
-
OpenStruct.new(:name => "Mailbox_2"),
|
45
|
+
and_return([
|
46
|
+
OpenStruct.new(:name => "Mailbox_1"),
|
47
|
+
OpenStruct.new(:name => "Mailbox_2"),
|
48
48
|
OpenStruct.new(:name => "Mailbox_3"),
|
49
49
|
OpenStruct.new(:name => "Mailbox_4") ])
|
50
50
|
end
|
@@ -62,7 +62,7 @@ describe Luggage::Message do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "sets date if passed" do
|
65
|
-
date = 2
|
65
|
+
date = Date.today - 2
|
66
66
|
expect(Luggage::Message.new(connection, :mailbox, :date => date).date).to eq(date)
|
67
67
|
end
|
68
68
|
|
@@ -90,7 +90,7 @@ describe Luggage::Message do
|
|
90
90
|
it "fetches raw email" do
|
91
91
|
connection.should_receive(:uid_fetch).
|
92
92
|
with([1], ["FLAGS", "INTERNALDATE", "BODY.PEEK[]"]).
|
93
|
-
and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" =>
|
93
|
+
and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" => (Time.now - 60 * 60 * 24).to_s}}] )
|
94
94
|
|
95
95
|
message.reload
|
96
96
|
end
|
@@ -98,7 +98,7 @@ describe Luggage::Message do
|
|
98
98
|
it "fetches flags" do
|
99
99
|
connection.should_receive(:uid_fetch).
|
100
100
|
with([1], ["FLAGS", "INTERNALDATE", "BODY.PEEK[]"]).
|
101
|
-
and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" =>
|
101
|
+
and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" => (Time.now - 60 * 60 * 24).to_s}}] )
|
102
102
|
|
103
103
|
message.reload
|
104
104
|
end
|
@@ -120,7 +120,7 @@ describe Luggage::Message do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it "appends message to mailbox" do
|
123
|
-
message_date = 2
|
123
|
+
message_date = Date.today - 2
|
124
124
|
message.stub(:raw_message).and_return("Random Content")
|
125
125
|
message.stub(:flags).and_return([:Seen])
|
126
126
|
message.stub(:date).and_return(message_date)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'rspec/mocks'
|
3
3
|
require 'rspec/expectations'
|
4
|
-
require 'active_support/time'
|
5
4
|
require 'pry'
|
6
5
|
|
7
6
|
require 'luggage'
|
@@ -24,7 +23,13 @@ shared_context "factories" do
|
|
24
23
|
c.stub(:select)
|
25
24
|
c.stub(:send_command)
|
26
25
|
c.stub(:uid_store)
|
27
|
-
c.stub(:uid_fetch).and_return(
|
26
|
+
c.stub(:uid_fetch).and_return([{
|
27
|
+
:attr => {
|
28
|
+
"BODY[]" => "raw_body",
|
29
|
+
"FLAGS" => [],
|
30
|
+
"INTERNALDATE" => (Time.now - 60 * 60 * 24).to_s
|
31
|
+
}
|
32
|
+
}])
|
28
33
|
c.stub(:uid_search).and_return([1])
|
29
34
|
c.stub(:list).and_return([])
|
30
35
|
c
|