imap 0.11.0 → 0.12.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/CHANGELOG +15 -1
- data/lib/Imap/Message.rb +13 -1
- data/lib/Imap/VERSION.rb +1 -1
- data/test/Imap/Message_test.rb +28 -0
- data/test/test_helper.rb +3 -0
- metadata +3 -3
- /data/test/{Imap_test.rb → imap_test.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf1e1e584ce9151c1729d359ab2ba2ac68b75c3d06a3fd15ef7512defa491c12
|
|
4
|
+
data.tar.gz: 0f07df5b9ae03d1421e5a243655fdfe56237ee2c1a9fc7597cacc3599f6db0a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 696700ed822fd7d2af94fa66d07dd81dced92892a8437d64c53ac4ed94e27df3a9846374cb148deee2225bcc8250745e394bb151ed2029839bfbbc68a250faf0
|
|
7
|
+
data.tar.gz: 5c3786b4fa23995246292616675a0d2aa394c0827cb2114caee990de8992d971506f44fee5acc533ca17960b7504b239f0fcf52657f5414ad4ec9d2de1b8bf6f
|
data/CHANGELOG
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# imap/CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20261014
|
|
4
|
+
|
|
5
|
+
0.12.0: ~ Imap::Message: + #mailbox, and a select before every fetch and store. A sequence number is valid only inside the SELECT which issued it, so a message whose body was read after another mailbox had been selected read that other mailbox instead, and said nothing about it.
|
|
6
|
+
|
|
7
|
+
1. + Imap::Message#mailbox, taken from the client at construction, so .search and .for hand back messages which know where they came from.
|
|
8
|
+
2. + Imap::Message#select_mailbox: selects back where the client has moved on since.
|
|
9
|
+
3. ~ Imap::Message#fetch_data, #mark_as_seen: select_mailbox first. #body, #source and a flag store all reached the server by sequence number and none of them checked.
|
|
10
|
+
4. ~ Imap::Message#initialize: + mailbox, defaulting to the client's current one, so a message built by hand is guarded too.
|
|
11
|
+
5. ~ test/Imap_test.rb --> test/imap_test.rb, the file it tests being lib/imap.rb. git mv declines a destination differing only in case, so it went by way of a third name.
|
|
12
|
+
6. ~ CHANGELOG: 0.4.4's second item said test_all.rb "required './Imap_test' for a file named imap_test.rb". It required './Imap_test' for test/Imap_test.rb, which matched, and the clause is struck. What remains of that item, that test_all.rb never loaded test/Imap/VERSION_test.rb, holds.
|
|
13
|
+
7. + 4 tests: that a message knows its mailbox, that a fetch selects back, that a flag store selects back, and that neither selects where the client is already there. The two which select back fail with the guard removed.
|
|
14
|
+
8. ~ Imap::VERSION: /0.11.0/0.12.0/
|
|
15
|
+
|
|
16
|
+
|
|
3
17
|
## 20260919
|
|
4
18
|
|
|
5
19
|
0.11.0: ~ README.md: rewritten for the surface as it now stands; ~ the gemspecs: /['minitest', '~> 5.0']/'minitest'/, /['rake', '~> 13.0']/'rake'/. The README documented 0.4, five minors back, and the minitest line permitted only versions the suite no longer runs on.
|
|
@@ -118,7 +132,7 @@
|
|
|
118
132
|
0.4.4: + Rakefile, - test/test_all.rb
|
|
119
133
|
|
|
120
134
|
1. + Rakefile: Rake::TestTask over FileList['test/**/*_test.rb'], with libs for lib and test, and warning = true. The minimal form nine of the gems here use rather than the fuller one five use: the :spec alias and the :version task belong to the minority, and a :version task reading VERSION.rb would not have caught 0.4.1, where require 'imap' left Imap::VERSION undefined while VERSION.rb sat there defining it. rake has been a development dependency since 0.4.0 with nothing here to run.
|
|
121
|
-
2. - test/test_all.rb: a second entry point which the Rakefile's FileList makes redundant, and which had drifted from the files on disk
|
|
135
|
+
2. - test/test_all.rb: a second entry point which the Rakefile's FileList makes redundant, and which had drifted from the files on disk: it never loaded test/Imap/VERSION_test.rb, added in 0.4.2, so it ran 42 tests where there are 44. A glob cannot drift.
|
|
122
136
|
3. ~ test/Imap/Message_test.rb: must_match(/Mock body/) for must_match /Mock body/, the ambiguous / which warning = true reports and which is the only warning the suite raises.
|
|
123
137
|
4. ~ imap.gemspec: + 'Rakefile' to spec.files.
|
|
124
138
|
5. ~ Imap::VERSION: /0.4.3/0.4.4/
|
data/lib/Imap/Message.rb
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# 10. Imap::Message.new(message_id, imap_client).received_at
|
|
15
15
|
# 11. Imap::Message.new(message_id, imap_client).attachment_filenames
|
|
16
16
|
# 12. Imap::Message.new(message_id, imap_client).source
|
|
17
|
+
# 13. Imap::Message.new(message_id, imap_client).mailbox
|
|
17
18
|
|
|
18
19
|
require 'time'
|
|
19
20
|
|
|
@@ -71,6 +72,7 @@ class Imap
|
|
|
71
72
|
|
|
72
73
|
attr_accessor :imap_client
|
|
73
74
|
attr_accessor :message_id
|
|
75
|
+
attr_reader :mailbox
|
|
74
76
|
|
|
75
77
|
def uid
|
|
76
78
|
data.uid
|
|
@@ -148,16 +150,25 @@ class Imap
|
|
|
148
150
|
end
|
|
149
151
|
|
|
150
152
|
def mark_as_seen
|
|
153
|
+
select_mailbox
|
|
151
154
|
imap_client.imap.store(@message_id, '+FLAGS', [:Seen])
|
|
152
155
|
end
|
|
153
156
|
alias_method :mark_as_read, :mark_as_seen
|
|
154
157
|
|
|
155
158
|
private
|
|
156
159
|
|
|
157
|
-
def initialize(message_id = nil, imap_client = nil, data = nil)
|
|
160
|
+
def initialize(message_id = nil, imap_client = nil, data = nil, mailbox = nil)
|
|
158
161
|
@message_id = message_id
|
|
159
162
|
@imap_client = imap_client
|
|
160
163
|
@data = data
|
|
164
|
+
@mailbox = mailbox || (imap_client && imap_client.mailbox)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# A sequence number means nothing outside the mailbox which issued it, so
|
|
168
|
+
# anything fetched after another mailbox was selected has to select back.
|
|
169
|
+
def select_mailbox
|
|
170
|
+
return unless mailbox && imap_client && imap_client.mailbox != mailbox
|
|
171
|
+
imap_client.mailbox = mailbox
|
|
161
172
|
end
|
|
162
173
|
|
|
163
174
|
# The Net::IMAP::FetchData itself rather than its attr hash, since it reads
|
|
@@ -218,6 +229,7 @@ class Imap
|
|
|
218
229
|
end
|
|
219
230
|
|
|
220
231
|
def fetch_data(*fetch_attributes)
|
|
232
|
+
select_mailbox
|
|
221
233
|
@fetch_data = imap_client.imap.fetch(message_id, [*fetch_attributes])
|
|
222
234
|
end
|
|
223
235
|
end
|
data/lib/Imap/VERSION.rb
CHANGED
data/test/Imap/Message_test.rb
CHANGED
|
@@ -237,6 +237,34 @@ describe Imap::Message do
|
|
|
237
237
|
end
|
|
238
238
|
end
|
|
239
239
|
|
|
240
|
+
describe '#mailbox' do
|
|
241
|
+
it 'knows the mailbox it was built in' do
|
|
242
|
+
_(Imap::Message.for(client, [1]).first.mailbox).must_equal 'INBOX'
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'selects back before fetching, where the client has moved on since' do
|
|
246
|
+
message = Imap::Message.for(client, [1]).first
|
|
247
|
+
client.mailbox = 'Archive/2026'
|
|
248
|
+
message.body
|
|
249
|
+
_(client.mailbox).must_equal 'INBOX'
|
|
250
|
+
_(client.imap.selects.last).must_equal 'INBOX'
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it 'selects back before storing a flag' do
|
|
254
|
+
message = Imap::Message.for(client, [1]).first
|
|
255
|
+
client.mailbox = 'Archive/2026'
|
|
256
|
+
message.mark_as_seen
|
|
257
|
+
_(client.imap.selects.last).must_equal 'INBOX'
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
it 'does not select where the client is already there' do
|
|
261
|
+
message = Imap::Message.for(client, [1]).first
|
|
262
|
+
before = (client.imap.selects || []).length
|
|
263
|
+
message.body
|
|
264
|
+
_((client.imap.selects || []).length).must_equal before
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
|
|
240
268
|
describe '#urls' do
|
|
241
269
|
it 'extracts http URLs from body' do
|
|
242
270
|
imap_message.stub(:body, 'Check out http://example.com and https://test.com') do
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: imap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -85,7 +85,7 @@ files:
|
|
|
85
85
|
- test/Imap/Message_test.rb
|
|
86
86
|
- test/Imap/Search_test.rb
|
|
87
87
|
- test/Imap/VERSION_test.rb
|
|
88
|
-
- test/
|
|
88
|
+
- test/imap_test.rb
|
|
89
89
|
- test/test_helper.rb
|
|
90
90
|
homepage: https://github.com/thoran/imap
|
|
91
91
|
licenses:
|
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
requirements: []
|
|
112
|
-
rubygems_version: 4.0.
|
|
112
|
+
rubygems_version: 4.0.22
|
|
113
113
|
specification_version: 4
|
|
114
114
|
summary: IMAP for Ruby made easy.
|
|
115
115
|
test_files: []
|
|
File without changes
|