imap-backup 4.0.0.rc5 → 4.0.0.rc6

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
  SHA256:
3
- metadata.gz: f6b754ca94002e528fff72fa9bfbe6316281d3325796843d312303c4956cd03f
4
- data.tar.gz: dc7230bd742a4db2dfe24a358c6bac1508433578c1eb108130bbd5d89e41b60c
3
+ metadata.gz: c7b332f900f4a22c6683220d746d4ff1565a0f9f4a69e5de1e7a107a1a17960e
4
+ data.tar.gz: b8d883e30dd1aa8fe65e839b350610755c66edf08da646579ec1aed1d3db2def
5
5
  SHA512:
6
- metadata.gz: 3b8cbc016eb22fe70240bad350ad2d9e009800af15db493f798aa33367e7b67ae0725ce6f8d97666c0f0ad46101fe793f2447d241199ffdc983a17d60c47a852
7
- data.tar.gz: 0f3c5a5a4e8e257dca263c25ac004e7d697908dfaccc9a82e354b5dfa8164f61e8671feb20afc8a4afd55bc3e79337bf723c715f61ce758d3a6e7ba1f8448677
6
+ metadata.gz: 8ca8d8e00cbc067e365b71c6ebe356c13d2595f7718281dac2e03da366e0eddff9d34b17a42e6881274597a5211f17e3035d6b6e2d3d1e0ecf3ea9a64c48493d
7
+ data.tar.gz: 846f087342def5d962a6683a9ff7f082ddfa628ffe803258eb8e33b3cfc3d0dddb2cd4ab34e2a9e19dd39740499b5a87e7f362bd03ddbed4beacfce67475272d
data/docs/restore.md ADDED
@@ -0,0 +1,13 @@
1
+ # FAQ
2
+
3
+ # How does restore work?
4
+
5
+ # What are all these 'INBOX.12345' files?
6
+
7
+ # Will my email get overwritten?
8
+
9
+ ## How do I restore to a different service?
10
+
11
+ 1. Run setup and add the new server, (but don't run any backups),
12
+ 2. Rename of the existing backup directory to match the new email address,
13
+ 3. Run the restore.
data/docs/setup.md ADDED
@@ -0,0 +1,5 @@
1
+ # HOWTOs
2
+
3
+ ## Set the server for a Google Apps account
4
+
5
+ Use imap.gmail.com
data/imap-backup.gemspec CHANGED
@@ -1,5 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.expand_path("lib", __dir__))
2
2
  require "imap/backup/version"
3
+ require "rake/file_list"
3
4
 
4
5
  Gem::Specification.new do |gem|
5
6
  gem.name = "imap-backup"
@@ -8,8 +9,17 @@ Gem::Specification.new do |gem|
8
9
  gem.authors = ["Joe Yates"]
9
10
  gem.email = ["joe.g.yates@gmail.com"]
10
11
  gem.homepage = "https://github.com/joeyates/imap-backup"
12
+ gem.licenses = ["MIT"]
13
+
14
+ # Build list of files manually, see also
15
+ # https://github.com/rubygems/rubygems/blob/master/bundler/bundler.gemspec#L37
16
+ gem.files = %w[bin/imap-backup]
17
+ gem.files += Dir.glob("docs/*{.png,.md}")
18
+ gem.files += Dir.glob("lib/**/*.rb")
19
+ gem.files += Dir.glob("spec/**/*{.rb,.yml}")
20
+ gem.files += %w[imap-backup.gemspec]
21
+ gem.files += %w[LICENSE README.md]
11
22
 
12
- gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
13
23
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
14
24
  gem.test_files = gem.files.grep(%r{^spec/})
15
25
  gem.require_paths = ["lib"]
@@ -21,8 +21,8 @@ module Imap::Backup
21
21
  end
22
22
  end
23
23
 
24
- desc "emails EMAIL FOLDER", "List emails in a folder"
25
- def emails(email, folder_name)
24
+ desc "list EMAIL FOLDER", "List emails in a folder"
25
+ def list(email, folder_name)
26
26
  connections = Imap::Backup::Configuration::List.new
27
27
  account = connections.accounts.find { |a| a[:username] == email }
28
28
  raise "#{email} is not a configured account" if !account
@@ -53,8 +53,13 @@ module Imap::Backup
53
53
  end
54
54
  end
55
55
 
56
- desc "email EMAIL FOLDER UID", "Show an email"
57
- def email(email, folder_name, uid)
56
+ desc "show EMAIL FOLDER UID[,UID]", "Show one or more emails"
57
+ long_desc <<~DESC
58
+ Prints out the requested emails.
59
+ If more than one UID is given, they are separated by a header indicating
60
+ the UID.
61
+ DESC
62
+ def show(email, folder_name, uids)
58
63
  connections = Imap::Backup::Configuration::List.new
59
64
  account = connections.accounts.find { |a| a[:username] == email }
60
65
  raise "#{email} is not a configured account" if !account
@@ -65,10 +70,17 @@ module Imap::Backup
65
70
  end
66
71
  raise "Folder '#{folder_name}' not found" if !folder_serializer
67
72
 
68
- loaded_message = folder_serializer.load(uid)
69
- raise "Message #{uid} not found in folder '#{folder_name}'" if !loaded_message
70
-
71
- puts loaded_message.supplied_body
73
+ uid_list = uids.split(",")
74
+ folder_serializer.each_message(uid_list).each do |uid, message|
75
+ if uid_list.count > 1
76
+ puts <<~HEADER
77
+ #{"-" * 80}
78
+ #{format("| UID: %-71s |", uid)}
79
+ #{"-" * 80}
80
+ HEADER
81
+ end
82
+ puts message.supplied_body
83
+ end
72
84
  end
73
85
  end
74
86
  end
@@ -22,7 +22,8 @@ module Imap::Backup
22
22
  Imap::Backup.logger.debug(
23
23
  "#{log_prefix} #{message['RFC822'].size} bytes"
24
24
  )
25
- serializer.save(uid, message)
25
+ body = message["RFC822"]
26
+ serializer.save(uid, body)
26
27
  end
27
28
  end
28
29
  end
@@ -40,7 +40,7 @@ module Imap::Backup
40
40
  @uids || []
41
41
  end
42
42
 
43
- def add(uid, message)
43
+ def add(uid, body)
44
44
  do_load if !loaded
45
45
  raise "Can't add messages without uid_validity" if !uid_validity
46
46
 
@@ -52,7 +52,6 @@ module Imap::Backup
52
52
  return
53
53
  end
54
54
 
55
- body = message["RFC822"]
56
55
  mboxrd_message = Email::Mboxrd::Message.new(body)
57
56
  mbox = nil
58
57
  begin
@@ -84,7 +83,8 @@ module Imap::Backup
84
83
  def each_message(required_uids)
85
84
  return enum_for(:each_message, required_uids) if !block_given?
86
85
 
87
- indexes = required_uids.each.with_object({}) do |uid, acc|
86
+ indexes = required_uids.each.with_object({}) do |uid_maybe_string, acc|
87
+ uid = uid_maybe_string.to_i
88
88
  index = uids.find_index(uid)
89
89
  acc[index] = uid if index
90
90
  end
@@ -4,6 +4,6 @@ module Imap::Backup
4
4
  MAJOR = 4
5
5
  MINOR = 0
6
6
  REVISION = 0
7
- PRE = "rc5"
7
+ PRE = "rc6"
8
8
  VERSION = [MAJOR, MINOR, REVISION, PRE].compact.map(&:to_s).join(".")
9
9
  end
@@ -2,7 +2,8 @@ describe Imap::Backup::Downloader do
2
2
  describe "#run" do
3
3
  subject { described_class.new(folder, serializer) }
4
4
 
5
- let(:message) { {"RFC822" => "blah"} }
5
+ let(:body) { "blah" }
6
+ let(:message) { {"RFC822" => body} }
6
7
  let(:folder) do
7
8
  instance_double(
8
9
  Imap::Backup::Account::Folder,
@@ -18,7 +19,7 @@ describe Imap::Backup::Downloader do
18
19
 
19
20
  context "with fetched messages" do
20
21
  specify "are saved" do
21
- expect(serializer).to receive(:save).with("111", message)
22
+ expect(serializer).to receive(:save).with("111", body)
22
23
 
23
24
  subject.run
24
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc5
4
+ version: 4.0.0.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-19 00:00:00.000000000 Z
11
+ date: 2021-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -158,21 +158,12 @@ executables:
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
- - ".circleci/config.yml"
162
- - ".gitignore"
163
- - ".rspec"
164
- - ".rspec-all"
165
- - ".rubocop.yml"
166
- - ".rubocop_todo.yml"
167
- - CHANGELOG.md
168
- - Gemfile
169
161
  - LICENSE
170
162
  - README.md
171
- - Rakefile
172
163
  - bin/imap-backup
173
- - docker-compose.yml
174
164
  - docs/docker-imap.md
175
- - imap-backup
165
+ - docs/restore.md
166
+ - docs/setup.md
176
167
  - imap-backup.gemspec
177
168
  - lib/email/mboxrd/message.rb
178
169
  - lib/email/provider.rb
@@ -235,9 +226,9 @@ files:
235
226
  - spec/unit/imap/backup/uploader_spec.rb
236
227
  - spec/unit/imap/backup/utils_spec.rb
237
228
  - spec/unit/imap/backup_spec.rb
238
- - tmp/.gitkeep
239
229
  homepage: https://github.com/joeyates/imap-backup
240
- licenses: []
230
+ licenses:
231
+ - MIT
241
232
  metadata: {}
242
233
  post_install_message:
243
234
  rdoc_options: []
data/.circleci/config.yml DELETED
@@ -1,51 +0,0 @@
1
- version: 2.1
2
-
3
- orbs:
4
- ruby: circleci/ruby@1.1.2
5
-
6
- references:
7
- restore: &restore
8
- restore_cache:
9
- keys:
10
- - 'imap.backup.<< parameters.ruby_version >>.{{checksum "imap-backup.gemspec"}}'
11
- bundle: &bundle
12
- run:
13
- name: Install Ruby dependencies
14
- command: |
15
- bundle install
16
- bundle clean
17
- save: &save
18
- save_cache:
19
- key: 'imap.backup.<< parameters.ruby_version >>.{{checksum "imap-backup.gemspec"}}'
20
- paths:
21
- - vendor/bundle
22
-
23
- jobs:
24
- test:
25
- parameters:
26
- ruby_version:
27
- type: string
28
- environment:
29
- BUNDLE_PATH: ./vendor/bundle
30
- DOCKER_IMAP_SERVER: 993
31
- docker:
32
- - image: "cimg/ruby:<< parameters.ruby_version >>"
33
- - image: antespi/docker-imap-devel:latest
34
- environment:
35
- MAIL_ADDRESS: address@example.org
36
- MAIL_PASS: pass
37
- MAILNAME: example.org
38
- steps:
39
- - checkout
40
- - <<: *restore
41
- - <<: *bundle
42
- - <<: *save
43
- - ruby/rspec-test
44
-
45
- workflows:
46
- all-tests:
47
- jobs:
48
- - test:
49
- matrix:
50
- parameters:
51
- ruby_version: ["2.5", "2.6", "2.7"]
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- coverage
5
- pkg
6
- .rbenv-version
7
- vendor
8
- /tmp
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
data/.rspec-all DELETED
@@ -1,4 +0,0 @@
1
- --color
2
- --format documentation
3
- --order random
4
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,21 +0,0 @@
1
- inherit_from:
2
- - https://raw.githubusercontent.com/leanpanda-com/rubocop/0.89.1/rubocop-rspec.yml
3
- - .rubocop_todo.yml
4
-
5
- AllCops:
6
- Exclude:
7
- - "bin/stubs/*"
8
- DisplayCopNames:
9
- Enabled: true
10
-
11
- RSpec/ContextWording:
12
- Exclude:
13
- - "spec/features/**/*"
14
- RSpec/LeakyConstantDeclaration:
15
- Enabled: false
16
- RSpec/MessageSpies:
17
- Enabled: false
18
- RSpec/ReturnFromStub:
19
- Enabled: false
20
- Style/EmptyCaseCondition:
21
- Enabled: false
data/.rubocop_todo.yml DELETED
@@ -1,129 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2021-09-21 15:30:34 UTC using RuboCop version 1.21.0.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- # Cop supports --auto-correct.
11
- Layout/ElseAlignment:
12
- Exclude:
13
- - 'lib/imap/backup/configuration/gmail_oauth2.rb'
14
-
15
- # Offense count: 2
16
- # Cop supports --auto-correct.
17
- # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
18
- Layout/EmptyLineBetweenDefs:
19
- Exclude:
20
- - 'lib/google/auth/stores/in_memory_token_store.rb'
21
-
22
- # Offense count: 1
23
- # Cop supports --auto-correct.
24
- # Configuration parameters: EnforcedStyleAlignWith, Severity.
25
- # SupportedStylesAlignWith: keyword, variable, start_of_line
26
- Layout/EndAlignment:
27
- Exclude:
28
- - 'lib/imap/backup/configuration/gmail_oauth2.rb'
29
-
30
- # Offense count: 1
31
- # Cop supports --auto-correct.
32
- # Configuration parameters: Width, IgnoredPatterns.
33
- Layout/IndentationWidth:
34
- Exclude:
35
- - 'lib/imap/backup/configuration/gmail_oauth2.rb'
36
-
37
- # Offense count: 34
38
- # Configuration parameters: AllowedMethods.
39
- # AllowedMethods: enums
40
- Lint/ConstantDefinitionInBlock:
41
- Exclude:
42
- - 'lib/imap/backup/configuration/asker.rb'
43
- - 'spec/unit/gmail/authenticator_spec.rb'
44
- - 'spec/unit/google/auth/stores/in_memory_token_store_spec.rb'
45
- - 'spec/unit/imap/backup/account/connection_spec.rb'
46
- - 'spec/unit/imap/backup/account/folder_spec.rb'
47
- - 'spec/unit/imap/backup/configuration/account_spec.rb'
48
- - 'spec/unit/imap/backup/configuration/gmail_oauth2_spec.rb'
49
-
50
- # Offense count: 2
51
- # Cop supports --auto-correct.
52
- # Configuration parameters: AllowComments.
53
- Lint/UselessMethodDefinition:
54
- Exclude:
55
- - 'lib/imap/backup/configuration/account.rb'
56
- - 'lib/imap/backup/configuration/asker.rb'
57
-
58
- # Offense count: 11
59
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
60
- Metrics/AbcSize:
61
- Max: 33
62
-
63
- # Offense count: 3
64
- # Configuration parameters: CountComments, CountAsOne.
65
- Metrics/ClassLength:
66
- Max: 172
67
-
68
- # Offense count: 19
69
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
70
- Metrics/MethodLength:
71
- Max: 26
72
-
73
- # Offense count: 2
74
- # Configuration parameters: CountComments, CountAsOne.
75
- Metrics/ModuleLength:
76
- Max: 145
77
-
78
- # Offense count: 2
79
- # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers.
80
- # SupportedStyles: snake_case, normalcase, non_integer
81
- # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
82
- Naming/VariableNumber:
83
- Exclude:
84
- - 'lib/email/provider.rb'
85
- - 'spec/unit/email/provider_spec.rb'
86
-
87
- # Offense count: 209
88
- # Configuration parameters: AllowSubject.
89
- RSpec/MultipleMemoizedHelpers:
90
- Max: 16
91
-
92
- # Offense count: 49
93
- RSpec/NestedGroups:
94
- Max: 6
95
-
96
- # Offense count: 8
97
- # Cop supports --auto-correct.
98
- # Configuration parameters: EnforcedStyle.
99
- # SupportedStyles: nested, compact
100
- Style/ClassAndModuleChildren:
101
- Exclude:
102
- - 'lib/email/mboxrd/message.rb'
103
- - 'lib/imap/backup/downloader.rb'
104
- - 'lib/imap/backup/serializer.rb'
105
- - 'lib/imap/backup/serializer/mbox.rb'
106
- - 'lib/imap/backup/serializer/mbox_enumerator.rb'
107
- - 'lib/imap/backup/serializer/mbox_store.rb'
108
- - 'lib/imap/backup/uploader.rb'
109
- - 'lib/imap/backup/utils.rb'
110
-
111
- # Offense count: 1
112
- # Cop supports --auto-correct.
113
- Style/RedundantBegin:
114
- Exclude:
115
- - 'lib/imap/backup/account/connection.rb'
116
-
117
- # Offense count: 1
118
- # Cop supports --auto-correct.
119
- # Configuration parameters: MinSize, WordRegex.
120
- # SupportedStyles: percent, brackets
121
- Style/WordArray:
122
- EnforcedStyle: percent
123
-
124
- # Offense count: 1
125
- # Cop supports --auto-correct.
126
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
127
- # URISchemes: http, https
128
- Layout/LineLength:
129
- Max: 133
data/CHANGELOG.md DELETED
@@ -1,19 +0,0 @@
1
- # Change Log
2
- All notable changes to this project will be documented in this file.
3
-
4
- The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
- and this project adheres to [Semantic Versioning](http://semver.org/).
6
-
7
- ## [4.0.0.rc2] - 2021-11-18
8
-
9
- ### Removed
10
-
11
- * GMail OAuth2 support. Tokens only last a few days, so this authentication
12
- method is not usable for automated backups.
13
-
14
- ## [4.0.0.rc1] - 2021-11-17
15
-
16
- ### Added
17
-
18
- * `local` commands to list accounts, folders and emails and to view single
19
- emails.
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,18 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "rubocop/rake_task"
4
-
5
- RSpec::Core::RakeTask.new do |t|
6
- t.pattern = "spec/**/*_spec.rb"
7
- end
8
-
9
- desc "Run RSpec examples, excluding ones relying on Docker IMAP"
10
- RSpec::Core::RakeTask.new("no-docker") do |t|
11
- t.pattern = "spec/**/*_spec.rb"
12
- t.rspec_opts = "--tag ~docker"
13
- end
14
-
15
- RuboCop::RakeTask.new
16
-
17
- task default: :spec
18
- task default: :rubocop
data/docker-compose.yml DELETED
@@ -1,15 +0,0 @@
1
- # This file adapted from github.com/antespi/docker-imap-devel
2
- version: "3"
3
-
4
- services:
5
- imap:
6
- image: antespi/docker-imap-devel:latest
7
- container_name: imap
8
- ports:
9
- - "8025:25"
10
- - "8143:143"
11
- - "8993:993"
12
- environment:
13
- - MAILNAME=example.org
14
- - MAIL_ADDRESS=address@example.org
15
- - MAIL_PASS=pass
data/imap-backup DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.expand_path("../lib/", __dir__))
4
- require "imap/backup/cli"
5
-
6
- Imap::Backup::CLI.start(ARGV)
7
-
8
- __END__
9
-
data/tmp/.gitkeep DELETED
File without changes