imap 0.4.6 → 0.4.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26d3a42b29eb3be8775fc3ec60f3559b0834e8ef106e2e3458cd2b93bdee7364
4
- data.tar.gz: 85aebe82c105a2d7db62c581ca61bd2c0630fcd7054dc777a02a86e84fd620ba
3
+ metadata.gz: 2de58b7edfcefd22cb470e09a7feb4e96ac4604d5ff0fae0d3c30d113870b956
4
+ data.tar.gz: aaa7cf9c1ca0ae8f8b988d34774f83af8744c59e47df43d4a68b4ddcf251eaec
5
5
  SHA512:
6
- metadata.gz: bb36b35b0cd5f9ddc6895aa0bfe9c0d644cd5386f13f4b26a66324d767560c3af41a8741be6a4fecf4f69fbbf6028dc823e1207e9aba50ab63a382b0a9750c50
7
- data.tar.gz: 79add07e74eb8acc3105b3791be56d020cc50c89e80d47d3e47f8b46cf997b6e9c7fdd44e536292435f5560f380bd1bdac2d966c4bfc53bd548a010e77b93432
6
+ metadata.gz: dee87ae3c7717846c25f0d4bcb16274163ac43b148dcc44f5512a1d19f3095d364c0990c187f90d383a6e4d3b11f632d2a10cac6f902f9296346be32a3c84372
7
+ data.tar.gz: 3aefa08e1f4a73e01cdd63d3dc3fcea30caf64dadca3b91ffa918dd535ecdaf43c6c795a7a84d6c532168c8f3dfa590defe5f6ea29e2b8680505148674e265b7
data/CHANGELOG CHANGED
@@ -1,46 +1,83 @@
1
- # CHANGELOG
2
-
3
- ## [0.4.6] - 2026-09-17, ~ Imap::Message#body: BODY.PEEK[TEXT]; ~ Imap::Search#to_imap_search_keys: raise upon a key which is neither
4
- - ~ Imap::Message#body: BODY.PEEK[TEXT] for BODY[TEXT]. Reading a body set \Seen, so anything which looked at one marked it read; PEEK is the whole of the difference and the response still answers to BODY[TEXT].
5
- - ~ Imap::Search#to_imap_search_keys: + UnknownSearchKey where the case matched neither operator. An unrecognised key was dropped and the search ran wider than it was asked for, saying nothing.
6
- - ~ Imap::Message#to: [] where the envelope carries no to, which raised NoMethodError upon nil.
7
- - ~ test/test_helper.rb: MockIMAP answers BODY.PEEK[TEXT] with BODY[TEXT] as a server does, records the attrs fetched, and gives message 99 an envelope with no to.
8
- - + a test apiece: that #body peeks, that #to is empty where there is no to, and that an unknown key raises.
9
- - ~ Imap::VERSION: /0.4.5/0.4.6/
10
-
11
- ## [0.4.5] - 2026-09-17, + Gemfile; ~ imap.gemspec: dependencies=, - spec.date, + metadata
12
- - + Gemfile: source and gemspec, as switches, eodhd and moby have it, so that the dependencies are declared once in the gemspec rather than restated here to drift. bitget and coinmarketcap restate theirs and are the minority. This was the only gem here with no Gemfile at all.
13
- - ~ imap.gemspec: + 'Gemfile' to spec.files, which every other gem here ships.
14
- - ~ imap.gemspec: dependencies= and development_dependencies= through the Gem::Specification extension, as switches, eodhd and moby have it and as bitget, coinmarketcap and this did not. The constraints survive: the splat takes a bare string or a [name, constraint] pair alike.
15
- - ~ imap.gemspec: - spec.date = '2025-12-20', nine months and two versions stale, and the last one left in the estate. RubyGems answers 1980-01-02 in its place, the reproducible-build epoch, which is what coinmarketcap has carried since dropping its own at 0.6.0.
16
- - ~ imap.gemspec: + metadata, the four uris switches and moby declare, so that the RubyGems page links to the issues, the changelog, the source and the README. master here where moby says main, each by the branch it is on.
17
- - ~ Imap::VERSION: /0.4.4/0.4.5/
18
-
19
- ## [0.4.4] - 2026-09-17, + Rakefile, - test/test_all.rb
20
- - + 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.
21
- - - test/test_all.rb: a second entry point which the Rakefile's FileList makes redundant, and which had drifted from the files on disk in two ways: it never loaded test/Imap/VERSION_test.rb, added in 0.4.2, so it ran 42 tests where there are 44; and it required './Imap_test' for a file named imap_test.rb, which resolved only because the filesystem is case insensitive and would not have on Linux. A glob cannot drift. 14 of the 16 gems here with a Rakefile carry no such file; switches keeps spec/all.rb because its Rakefile targets it, and bitget carries the same redundancy this removes.
22
- - ~ 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.
23
- - ~ imap.gemspec: + 'Rakefile' to spec.files, as eodhd, switches and moby have.
24
- - ~ Imap::VERSION: /0.4.3/0.4.4/
25
-
26
- ## [0.4.3] - 2026-09-17, ~ test/test_helper.rb: + require 'minitest/mock', which minitest 6 no longer brings
27
- - ~ test/test_helper.rb: + `require 'minitest/mock'`. 35 of the 42 tests call stub and not one of them could: the suite answered "42 runs, 7 assertions, 0 failures, 35 errors". minitest 5's autorun required minitest/mock and shipped it, so the suite ran until minitest 6 dropped both the require and the file; the same thing coinmarketcap 0.6.1 found.
28
- - ~ imap.gemspec: + minitest-mock as a development dependency, which minitest ~> 5.0 carried and minitest 6 does not.
29
- - ~ Imap::VERSION: /0.4.2/0.4.3/
30
-
31
- ## [0.4.2] - 2026-09-10, ~ lib/imap.rb: + require_relative './Imap/VERSION'; + test/Imap/VERSION_test.rb
32
- - ~ lib/imap.rb: + `require_relative './Imap/VERSION'`, last among the requires. The file had been present and unreached, so `require 'imap'` left Imap::VERSION undefined and the gemspec was the only thing loading it.
33
- - + test/Imap/VERSION_test.rb: that Imap::VERSION is a string and that it is three numbers separated by dots. Modelled on moby's, less the example comparing against the changelog, which was unreachable here while the file was misspelt.
34
- - The test loads the library rather than VERSION.rb, which is the whole of its value: run against v0.4.1 it fails with "uninitialized constant Imap::VERSION". Nine libraries were in that state and not one of them carried this test.
35
- - ~ Imap::VERSION: /0.4.1/0.4.2/
36
-
37
- ## [0.4.1] - 2026-08-22, + LICENSE; ~ imap.gemspec: + CHANGELOG
38
- - + LICENSE: the MIT text, copyright 2025-2026 thoran. The gemspec had declared MIT while the repository carried no licence text at all.
39
- - ~ imap.gemspec: + 'LICENSE' and 'CHANGELOG' to spec.files, neither of which the gem had been shipping.
40
- - ~ Imap::VERSION: /0.4.0/0.4.1/
41
-
42
- ## [0.4.0] - 2025-12-20, Cleanup for publishing.
43
- - /ImapClient/Imap/
44
- - + imap.gemspec
45
- - + tests
46
- - + Imap::Message#to.
1
+ # imap/CHANGELOG
2
+
3
+ ## 20260917
4
+
5
+ 0.4.8: Rewrite the CHANGELOG in the standard form.
6
+
7
+ 1. ~ CHANGELOG: ## before each date rather than ## [version] - date, the version and its summary beneath, a blank line between that and the first item, and the items numbered rather than dashed. No item is reworded, dropped or reordered.
8
+ 2. ~ CHANGELOG: the dates in basic form, 20260910 for 2026-09-10, as every other gem here writes them.
9
+ 3. ~ CHANGELOG: + the title, # imap/CHANGELOG, as coinmarketcap.rb and release-audit have it.
10
+ 4. ~ CHANGELOG: the five releases of 20260917 under one date heading, which is how the form carries more than one in a day.
11
+ 5. 9 of the 12 gems here were already in this form; imap and gate.rb were not, which leaves gate.rb.
12
+ 6. ~ Imap::VERSION: /0.4.7/0.4.8/
13
+
14
+ 0.4.7: ~ Imap::Search: the chaining interface, which the header has documented and which has never run
15
+
16
+ 1. ~ Imap::Search: the generated methods named in lower case, so that from() answers where FROM() did. All 32 were upper case, being defined straight off the key constants, and none was reachable as the header wrote it.
17
+ 2. ~ Imap::Search: the generated methods return self, having returned the criteria hash, so that they chain.
18
+ 3. + Imap::Search#not: applies to what follows immediately and to nothing after it. + Negated, which carries a general key's value through the hash; a boolean needs none, false already reading as NOT.
19
+ 4. ~ Imap::Search#general_to_imap_search_key: ['NOT', key, value] where the value is Negated.
20
+ 5. ~ Imap::Search: the Usage header takes an imap_client, without which all() has nothing to search.
21
+ 6. + tests: the lower case names, that they chain, both negations, and that not applies once only.
22
+ 7. ~ Imap::VERSION: /0.4.6/0.4.7/
23
+
24
+ 0.4.6: ~ Imap::Message#body: BODY.PEEK[TEXT]; ~ Imap::Search#to_imap_search_keys: raise upon a key which is neither
25
+
26
+ 1. ~ Imap::Message#body: BODY.PEEK[TEXT] for BODY[TEXT]. Reading a body set \Seen, so anything which looked at one marked it read; PEEK is the whole of the difference and the response still answers to BODY[TEXT].
27
+ 2. ~ Imap::Search#to_imap_search_keys: + UnknownSearchKey where the case matched neither operator. An unrecognised key was dropped and the search ran wider than it was asked for, saying nothing.
28
+ 3. ~ Imap::Message#to: [] where the envelope carries no to, which raised NoMethodError upon nil.
29
+ 4. ~ test/test_helper.rb: MockIMAP answers BODY.PEEK[TEXT] with BODY[TEXT] as a server does, records the attrs fetched, and gives message 99 an envelope with no to.
30
+ 5. + a test apiece: that #body peeks, that #to is empty where there is no to, and that an unknown key raises.
31
+ 6. ~ Imap::VERSION: /0.4.5/0.4.6/
32
+
33
+ 0.4.5: + Gemfile; ~ imap.gemspec: dependencies=, - spec.date, + metadata
34
+
35
+ 1. + Gemfile: source and gemspec, as switches, eodhd and moby have it, so that the dependencies are declared once in the gemspec rather than restated here to drift. bitget and coinmarketcap restate theirs and are the minority. This was the only gem here with no Gemfile at all.
36
+ 2. ~ imap.gemspec: + 'Gemfile' to spec.files, which every other gem here ships.
37
+ 3. ~ imap.gemspec: dependencies= and development_dependencies= through the Gem::Specification extension, as switches, eodhd and moby have it and as bitget, coinmarketcap and this did not. The constraints survive: the splat takes a bare string or a [name, constraint] pair alike.
38
+ 4. ~ imap.gemspec: - spec.date = '2025-12-20', nine months and two versions stale, and the last one left in the estate. RubyGems answers 1980-01-02 in its place, the reproducible-build epoch, which is what coinmarketcap has carried since dropping its own at 0.6.0.
39
+ 5. ~ imap.gemspec: + metadata, the four uris switches and moby declare, so that the RubyGems page links to the issues, the changelog, the source and the README. master here where moby says main, each by the branch it is on.
40
+ 6. ~ Imap::VERSION: /0.4.4/0.4.5/
41
+
42
+ 0.4.4: + Rakefile, - test/test_all.rb
43
+
44
+ 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.
45
+ 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 in two ways: it never loaded test/Imap/VERSION_test.rb, added in 0.4.2, so it ran 42 tests where there are 44; and it required './Imap_test' for a file named imap_test.rb, which resolved only because the filesystem is case insensitive and would not have on Linux. A glob cannot drift. 14 of the 16 gems here with a Rakefile carry no such file; switches keeps spec/all.rb because its Rakefile targets it, and bitget carries the same redundancy this removes.
46
+ 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.
47
+ 4. ~ imap.gemspec: + 'Rakefile' to spec.files, as eodhd, switches and moby have.
48
+ 5. ~ Imap::VERSION: /0.4.3/0.4.4/
49
+
50
+ 0.4.3: ~ test/test_helper.rb: + require 'minitest/mock', which minitest 6 no longer brings
51
+
52
+ 1. ~ test/test_helper.rb: + `require 'minitest/mock'`. 35 of the 42 tests call stub and not one of them could: the suite answered "42 runs, 7 assertions, 0 failures, 35 errors". minitest 5's autorun required minitest/mock and shipped it, so the suite ran until minitest 6 dropped both the require and the file; the same thing coinmarketcap 0.6.1 found.
53
+ 2. ~ imap.gemspec: + minitest-mock as a development dependency, which minitest ~> 5.0 carried and minitest 6 does not.
54
+ 3. ~ Imap::VERSION: /0.4.2/0.4.3/
55
+
56
+
57
+ ## 20260910
58
+
59
+ 0.4.2: ~ lib/imap.rb: + require_relative './Imap/VERSION'; + test/Imap/VERSION_test.rb
60
+
61
+ 1. ~ lib/imap.rb: + `require_relative './Imap/VERSION'`, last among the requires. The file had been present and unreached, so `require 'imap'` left Imap::VERSION undefined and the gemspec was the only thing loading it.
62
+ 2. + test/Imap/VERSION_test.rb: that Imap::VERSION is a string and that it is three numbers separated by dots. Modelled on moby's, less the example comparing against the changelog, which was unreachable here while the file was misspelt.
63
+ 3. The test loads the library rather than VERSION.rb, which is the whole of its value: run against v0.4.1 it fails with "uninitialized constant Imap::VERSION". Nine libraries were in that state and not one of them carried this test.
64
+ 4. ~ Imap::VERSION: /0.4.1/0.4.2/
65
+
66
+
67
+ ## 20260822
68
+
69
+ 0.4.1: + LICENSE; ~ imap.gemspec: + CHANGELOG
70
+
71
+ 1. + LICENSE: the MIT text, copyright 2025-2026 thoran. The gemspec had declared MIT while the repository carried no licence text at all.
72
+ 2. ~ imap.gemspec: + 'LICENSE' and 'CHANGELOG' to spec.files, neither of which the gem had been shipping.
73
+ 3. ~ Imap::VERSION: /0.4.0/0.4.1/
74
+
75
+
76
+ ## 20251220
77
+
78
+ 0.4.0: Cleanup for publishing.
79
+
80
+ 1. /ImapClient/Imap/
81
+ 2. + imap.gemspec
82
+ 3. + tests
83
+ 4. + Imap::Message#to.
data/lib/Imap/Search.rb CHANGED
@@ -2,8 +2,8 @@
2
2
  # Imap::Search
3
3
 
4
4
  # Usage:
5
- # 1. Imap::Search.new.not.subject('Payday Loans').answered.from('noreply@example.com').all
6
- # 2. Imap::Search.new({from: 'noreply@example.com', answered: true})
5
+ # 1. Imap::Search.new(imap_client).not.subject('Payday Loans').answered.from('noreply@example.com').all
6
+ # 2. Imap::Search.new(imap_client, {from: 'noreply@example.com', answered: true})
7
7
 
8
8
  # Notes:
9
9
  # 1. List of search keys taken from RFC-3501 (INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1), http://tools.ietf.org/html/rfc3501.
@@ -13,6 +13,11 @@ class Imap
13
13
 
14
14
  class UnknownSearchKey < ArgumentError; end
15
15
 
16
+ # A general key carries its value; negating one has to carry both, the hash
17
+ # having nowhere else to put it. A boolean key needs none of this: false
18
+ # already reads as NOT.
19
+ Negated = Struct.new(:value)
20
+
16
21
  ALL_SEARCH_KEYS = %w{
17
22
  ALL
18
23
  ANSWERED
@@ -84,17 +89,25 @@ class Imap
84
89
  }
85
90
 
86
91
  BOOLEAN_SEARCH_KEYS.each do |boolean_search_key|
87
- define_method boolean_search_key do |value = true|
88
- criteria.merge!(boolean_search_key.to_sym => value)
92
+ define_method boolean_search_key.downcase do |value = true|
93
+ criteria.merge!(boolean_search_key.to_sym => negating? ? !value : value)
94
+ self
89
95
  end
90
96
  end
91
97
 
92
98
  GENERAL_SEARCH_KEYS.each do |general_search_key|
93
- define_method general_search_key do |value|
94
- criteria.merge!(general_search_key.to_sym => value)
99
+ define_method general_search_key.downcase do |value|
100
+ criteria.merge!(general_search_key.to_sym => negating? ? Negated.new(value) : value)
101
+ self
95
102
  end
96
103
  end
97
104
 
105
+ # Applies to what follows immediately, and to nothing after that.
106
+ def not
107
+ @negate = true
108
+ self
109
+ end
110
+
98
111
  attr_accessor :criteria
99
112
  attr_accessor :imap_client
100
113
 
@@ -121,7 +134,7 @@ class Imap
121
134
  end
122
135
 
123
136
  def general_to_imap_search_key(key, value)
124
- [key, value]
137
+ value.is_a?(Negated) ? ['NOT', key, value.value] : [key, value]
125
138
  end
126
139
 
127
140
  def boolean_to_imap_search_key(key, value)
@@ -132,6 +145,12 @@ class Imap
132
145
  end
133
146
  end
134
147
 
148
+ def negating?
149
+ negate = @negate
150
+ @negate = false
151
+ negate
152
+ end
153
+
135
154
  def message_ids
136
155
  imap_client.imap.search(to_imap_search_keys)
137
156
  end
data/lib/Imap/VERSION.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Imap
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.8'
3
3
  end
@@ -44,6 +44,30 @@ describe Imap::Search do
44
44
  end
45
45
  end
46
46
 
47
+ describe 'the chaining interface' do
48
+ it 'names the keys in lower case' do
49
+ _(Imap::Search.new(client).from('x@y.com').criteria).must_equal({FROM: 'x@y.com'})
50
+ end
51
+
52
+ it 'returns itself, so that it chains' do
53
+ search = Imap::Search.new(client)
54
+ _(search.from('x@y.com')).must_be_same_as search
55
+ end
56
+
57
+ it 'negates a general key' do
58
+ _(Imap::Search.new(client).not.subject('Payday Loans').to_imap_search_keys).must_equal ['NOT', 'SUBJECT', 'Payday Loans']
59
+ end
60
+
61
+ it 'negates a boolean key' do
62
+ _(Imap::Search.new(client).not.seen.to_imap_search_keys).must_equal ['NOT', 'SEEN']
63
+ end
64
+
65
+ it 'negates what follows immediately and nothing after it' do
66
+ keys = Imap::Search.new(client).not.subject('Payday Loans').answered.from('noreply@example.com').to_imap_search_keys
67
+ _(keys).must_equal ['NOT', 'SUBJECT', 'Payday Loans', 'ANSWERED', 'FROM', 'noreply@example.com']
68
+ end
69
+ end
70
+
47
71
  describe '#message_ids' do
48
72
  it 'returns an array of message IDs' do
49
73
  ids = search.message_ids
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.6
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran