imapget 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ChangeLog +14 -0
- data/README +3 -3
- data/Rakefile +3 -3
- data/example/config.yaml +12 -11
- data/lib/imapget/cli.rb +2 -2
- data/lib/imapget/version.rb +1 -1
- data/lib/imapget.rb +26 -27
- metadata +28 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fe656b65453bccee9c4e108fa5c88f00647beeaccaae7b579cf5892f9e8c4236
|
4
|
+
data.tar.gz: d3a01358001af8415f4aff124863f7f5cc59008408cf14a8c2f034298eb043c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 431bc3e4b193c523cc044fcba3c5c49ca8d18daeabd28387170e5eabede4cf674fdec6eb8b95a7fe59bee399b85ef23daa0dd32ee8d15319333f4038a1863a37
|
7
|
+
data.tar.gz: 5a06d9e2e9898dc41bc1ada7ef41c083683d94bb7c5e34ab92c2bc6f5e778d9dcb9d1531123f73d5b91e0a9a434fe89412b9ec8b69d670dc743f9dd2e0bae29b
|
data/ChangeLog
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
= Revision history for imapget
|
4
4
|
|
5
|
+
== 0.3.0 [2022-08-19]
|
6
|
+
|
7
|
+
* Introduced default config section.
|
8
|
+
* Switched config to strings.
|
9
|
+
|
10
|
+
== 0.2.1 [2016-03-25]
|
11
|
+
|
12
|
+
* Fixed regression introduced in 0.2.0.
|
13
|
+
|
14
|
+
== 0.2.0 [2016-02-13]
|
15
|
+
|
16
|
+
* Fixed batch fetching.
|
17
|
+
* Internal refactoring.
|
18
|
+
|
5
19
|
== 0.1.0 [2014-04-14]
|
6
20
|
|
7
21
|
* Added options <tt>--dupes</tt> and <tt>--uniq</tt>.
|
data/README
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== VERSION
|
4
4
|
|
5
|
-
This documentation refers to imapget version 0.
|
5
|
+
This documentation refers to imapget version 0.3.0
|
6
6
|
|
7
7
|
|
8
8
|
== DESCRIPTION
|
@@ -14,7 +14,7 @@ server! Thus, it's different from your typical *sync* tool.
|
|
14
14
|
|
15
15
|
== LINKS
|
16
16
|
|
17
|
-
Documentation:: https://blackwinter.github.io/imapget
|
17
|
+
Documentation:: https://blackwinter.github.io/imapget
|
18
18
|
Source code:: https://github.com/blackwinter/imapget
|
19
19
|
RubyGem:: https://rubygems.org/gems/imapget
|
20
20
|
|
@@ -26,7 +26,7 @@ RubyGem:: https://rubygems.org/gems/imapget
|
|
26
26
|
|
27
27
|
== LICENSE AND COPYRIGHT
|
28
28
|
|
29
|
-
Copyright (C) 2009-
|
29
|
+
Copyright (C) 2009-2022 Jens Wille
|
30
30
|
|
31
31
|
imapget is free software: you can redistribute it and/or modify it under
|
32
32
|
the terms of the GNU Affero General Public License as published by the Free
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'lib/imapget/version'
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'hen'
|
@@ -13,9 +13,9 @@ begin
|
|
13
13
|
email: %q{jens.wille@gmail.com},
|
14
14
|
license: %q{AGPL-3.0},
|
15
15
|
homepage: :blackwinter,
|
16
|
-
dependencies:
|
16
|
+
dependencies: { cyclops: '~> 0.3', nuggets: '~> 1.5' },
|
17
17
|
|
18
|
-
required_ruby_version: '>= 1
|
18
|
+
required_ruby_version: '>= 2.1'
|
19
19
|
}
|
20
20
|
}}
|
21
21
|
rescue LoadError => err
|
data/example/config.yaml
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
### Global settings
|
2
2
|
|
3
|
-
:
|
4
|
-
:
|
3
|
+
default_config:
|
4
|
+
base_dir: /var/backup/mail # Point to storage location or specify on command-line.
|
5
|
+
strategy: exclude # This is the default strategy.
|
5
6
|
|
6
7
|
|
7
8
|
### Profiles
|
8
9
|
|
9
10
|
# Get all mailboxes (via SSL), *except* Spam and Trash.
|
10
11
|
you-1:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
host: imap.example.com
|
13
|
+
port: 123
|
14
|
+
ssl: true
|
15
|
+
user: login
|
16
|
+
exclude:
|
16
17
|
- Spam
|
17
18
|
- Trash
|
18
19
|
|
19
20
|
# Get *only* mailboxes INBOX, Sent, and Drafts.
|
20
21
|
you-2:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
host: imap.example.com
|
23
|
+
user: login2
|
24
|
+
strategy: include
|
25
|
+
include:
|
25
26
|
- INBOX
|
26
27
|
- Sent
|
27
28
|
- Drafts
|
data/lib/imapget/cli.rb
CHANGED
@@ -50,7 +50,7 @@ class IMAPGet
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def run(arguments)
|
53
|
-
|
53
|
+
default_config, profiles = config.delete(:default_config), config.to_a
|
54
54
|
|
55
55
|
(arguments.empty? ? profiles.map(&:first) : arguments).each { |profile|
|
56
56
|
profile_config = profile_config(profile, profiles, default_config) or next
|
@@ -67,7 +67,7 @@ class IMAPGet
|
|
67
67
|
} }
|
68
68
|
else
|
69
69
|
imapget.get(options[:directory] ||
|
70
|
-
File.join(profile_config[:base_dir] || '.', profile))
|
70
|
+
File.join(profile_config[:base_dir] || '.', profile.to_s))
|
71
71
|
end
|
72
72
|
}
|
73
73
|
end
|
data/lib/imapget/version.rb
CHANGED
data/lib/imapget.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# #
|
4
4
|
# imapget -- Download IMAP mails #
|
5
5
|
# #
|
6
|
-
# Copyright (C) 2009-
|
6
|
+
# Copyright (C) 2009-2016 Jens Wille #
|
7
7
|
# #
|
8
8
|
# Authors: #
|
9
9
|
# Jens Wille <jens.wille@gmail.com> #
|
@@ -68,7 +68,7 @@ class IMAPGet
|
|
68
68
|
end)
|
69
69
|
}
|
70
70
|
|
71
|
-
@strategy = options.fetch(:strategy, DEFAULT_STRATEGY)
|
71
|
+
@strategy = options.fetch(:strategy, DEFAULT_STRATEGY).to_sym
|
72
72
|
end
|
73
73
|
|
74
74
|
def mailboxes
|
@@ -90,9 +90,12 @@ class IMAPGet
|
|
90
90
|
else raise TypeError, "MailboxList or String expected, got #{mailbox.class}"
|
91
91
|
end
|
92
92
|
|
93
|
+
_excl = excl && name =~ excl
|
94
|
+
_incl = incl && name =~ incl
|
95
|
+
|
93
96
|
case strategy
|
94
|
-
when :include then
|
95
|
-
when :exclude then
|
97
|
+
when :include then _excl || !_incl
|
98
|
+
when :exclude then _excl && !_incl
|
96
99
|
end
|
97
100
|
end
|
98
101
|
|
@@ -130,26 +133,23 @@ class IMAPGet
|
|
130
133
|
}
|
131
134
|
}
|
132
135
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
dupes
|
136
|
+
hash.flat_map { |_, uids| uids.drop(1) if uids.size > 1 }.tap { |dupes|
|
137
|
+
dupes.compact!; log "#{name}: #{dupes.size}" unless quiet
|
138
|
+
}
|
138
139
|
end
|
139
140
|
|
140
141
|
def delete!(name, uids)
|
141
|
-
|
142
|
-
log "#{name}: #{uids.size}"
|
142
|
+
return if uids.empty?
|
143
143
|
|
144
|
-
|
144
|
+
log "#{name}: #{uids.size}"
|
145
145
|
|
146
|
-
|
147
|
-
count = imap.store(uids, '+FLAGS', [Net::IMAP::DELETED]).size
|
146
|
+
yield if block_given?
|
148
147
|
|
149
|
-
|
148
|
+
imap.select(name)
|
150
149
|
|
151
|
-
|
152
|
-
|
150
|
+
imap.store(uids, '+FLAGS', [Net::IMAP::DELETED]).size.tap { |count|
|
151
|
+
log "#{count} DELETED!"
|
152
|
+
}
|
153
153
|
end
|
154
154
|
|
155
155
|
def uniq!(name, &block)
|
@@ -169,22 +169,21 @@ class IMAPGet
|
|
169
169
|
end
|
170
170
|
|
171
171
|
def fetch_batch(batch, fetch_attr = FETCH_ATTR, &block)
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
end
|
179
|
-
end
|
172
|
+
case set = batch.first
|
173
|
+
when Array
|
174
|
+
batch = set.first .. (set.first + set.last - 1)
|
175
|
+
when Range
|
176
|
+
batch = set.first .. (set.last - 1) if set.exclude_end?
|
177
|
+
end if batch.size == 1
|
180
178
|
|
181
|
-
imap.uid_fetch(batch, fetch_attr)
|
179
|
+
mails = imap.uid_fetch(batch, fetch_attr)
|
180
|
+
mails.each(&block) if mails
|
182
181
|
end
|
183
182
|
|
184
183
|
def fetch(mail, dir, name)
|
185
184
|
uid = mail.attr['UID'].to_s
|
186
185
|
file = File.join(dir, uid)
|
187
|
-
exists = File.
|
186
|
+
exists = File.exist?(file)
|
188
187
|
|
189
188
|
if deleted?(mail)
|
190
189
|
if exists
|
metadata
CHANGED
@@ -1,57 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imapget
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cyclops
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: nuggets
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '1.5'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '1.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hen
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
45
48
|
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
50
|
+
version: 0.9.1
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.9'
|
52
58
|
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: 0.9.1
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rake
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,19 +97,14 @@ licenses:
|
|
91
97
|
metadata: {}
|
92
98
|
post_install_message: |2+
|
93
99
|
|
94
|
-
imapget-0.
|
100
|
+
imapget-0.3.0 [2022-08-19]:
|
95
101
|
|
96
|
-
*
|
97
|
-
*
|
98
|
-
* Added LOGIN as fallback for AUTHENTICATE.
|
99
|
-
* Added +batch_size+ option.
|
100
|
-
* Dropped +use_ssl+ options; use +ssl+ instead.
|
101
|
-
* Dropped support for Ruby 1.8.
|
102
|
-
* Internal refactoring.
|
102
|
+
* Introduced default config section.
|
103
|
+
* Switched config to strings.
|
103
104
|
|
104
105
|
rdoc_options:
|
105
106
|
- "--title"
|
106
|
-
- imapget Application documentation (v0.
|
107
|
+
- imapget Application documentation (v0.3.0)
|
107
108
|
- "--charset"
|
108
109
|
- UTF-8
|
109
110
|
- "--line-numbers"
|
@@ -116,16 +117,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
117
|
requirements:
|
117
118
|
- - ">="
|
118
119
|
- !ruby/object:Gem::Version
|
119
|
-
version: 1
|
120
|
+
version: '2.1'
|
120
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
122
|
requirements:
|
122
123
|
- - ">="
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
|
-
|
127
|
-
|
128
|
-
signing_key:
|
127
|
+
rubygems_version: 3.3.5
|
128
|
+
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Get IMAP mails.
|
131
131
|
test_files: []
|
132
|
+
...
|