thunderbird 0.1.1
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +181 -0
- data/.rubocop_todo.yml +17 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +23 -0
- data/Rakefile +12 -0
- data/lib/thunderbird/install.rb +21 -0
- data/lib/thunderbird/local_folder.rb +69 -0
- data/lib/thunderbird/profile.rb +35 -0
- data/lib/thunderbird/profiles.rb +75 -0
- data/lib/thunderbird/subdirectory.rb +98 -0
- data/lib/thunderbird/subdirectory_placeholder.rb +25 -0
- data/lib/thunderbird/version.rb +11 -0
- data/lib/thunderbird.rb +20 -0
- data/thunderbird.gemspec +31 -0
- metadata +78 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 06e03c762e9bef79479708b14604743fe03e509a742ecb60abb5302a2fd16788
|
|
4
|
+
data.tar.gz: 76d815453006b03948af39ac113ad07db3783d16904a39f71ee00c53fff2d44d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a61253e0d2559831f38f39d83fe5fa091846930f8b6ca6a6fe5317bb1aeada74e2cb3a480c39a604c85e648801a95904fcb6aeb9c9b896049214c76db5771b74
|
|
7
|
+
data.tar.gz: 4a5b2825eef339f31e2b9d33ced437e38430711478286d2eb081415648dab451fe547ffa159b97bcdfbe32b16b198b281d9b0e9bff4767bdb32539da9267c566
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
AllCops:
|
|
4
|
+
TargetRubyVersion: 2.5
|
|
5
|
+
Exclude:
|
|
6
|
+
- "bin/stubs/*"
|
|
7
|
+
- "vendor/**/*"
|
|
8
|
+
|
|
9
|
+
Gemspec/DateAssignment:
|
|
10
|
+
Enabled: true
|
|
11
|
+
|
|
12
|
+
Gemspec/RequireMFA:
|
|
13
|
+
Enabled: true
|
|
14
|
+
|
|
15
|
+
Layout/LineEndStringConcatenationIndentation:
|
|
16
|
+
Enabled: true
|
|
17
|
+
|
|
18
|
+
Layout/SpaceBeforeBrackets:
|
|
19
|
+
Enabled: true
|
|
20
|
+
|
|
21
|
+
Lint/AmbiguousAssignment:
|
|
22
|
+
Enabled: true
|
|
23
|
+
|
|
24
|
+
Lint/AmbiguousOperatorPrecedence:
|
|
25
|
+
Enabled: true
|
|
26
|
+
|
|
27
|
+
Lint/AmbiguousRange:
|
|
28
|
+
Enabled: true
|
|
29
|
+
|
|
30
|
+
Lint/DeprecatedConstants:
|
|
31
|
+
Enabled: true
|
|
32
|
+
|
|
33
|
+
Lint/DuplicateBranch:
|
|
34
|
+
Enabled: true
|
|
35
|
+
|
|
36
|
+
Lint/DuplicateRegexpCharacterClassElement:
|
|
37
|
+
Enabled: true
|
|
38
|
+
|
|
39
|
+
Lint/EmptyBlock:
|
|
40
|
+
Enabled: true
|
|
41
|
+
|
|
42
|
+
Lint/EmptyClass:
|
|
43
|
+
Enabled: true
|
|
44
|
+
|
|
45
|
+
Lint/EmptyInPattern:
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
Lint/IncompatibleIoSelectWithFiberScheduler:
|
|
49
|
+
Enabled: true
|
|
50
|
+
|
|
51
|
+
Lint/LambdaWithoutLiteralBlock:
|
|
52
|
+
Enabled: true
|
|
53
|
+
|
|
54
|
+
Lint/NoReturnInBeginEndBlocks:
|
|
55
|
+
Enabled: true
|
|
56
|
+
|
|
57
|
+
Lint/NumberedParameterAssignment:
|
|
58
|
+
Enabled: true
|
|
59
|
+
|
|
60
|
+
Lint/OrAssignmentToConstant:
|
|
61
|
+
Enabled: true
|
|
62
|
+
|
|
63
|
+
Lint/RedundantDirGlobSort:
|
|
64
|
+
Enabled: true
|
|
65
|
+
|
|
66
|
+
Lint/RequireRelativeSelfPath:
|
|
67
|
+
Enabled: true
|
|
68
|
+
|
|
69
|
+
Lint/SymbolConversion:
|
|
70
|
+
Enabled: true
|
|
71
|
+
|
|
72
|
+
Lint/ToEnumArguments:
|
|
73
|
+
Enabled: true
|
|
74
|
+
|
|
75
|
+
Lint/TripleQuotes:
|
|
76
|
+
Enabled: true
|
|
77
|
+
|
|
78
|
+
Lint/UnexpectedBlockArity:
|
|
79
|
+
Enabled: true
|
|
80
|
+
|
|
81
|
+
Lint/UnmodifiedReduceAccumulator:
|
|
82
|
+
Enabled: true
|
|
83
|
+
|
|
84
|
+
Lint/UselessRuby2Keywords:
|
|
85
|
+
Enabled: true
|
|
86
|
+
|
|
87
|
+
Naming/BlockForwarding:
|
|
88
|
+
Enabled: true
|
|
89
|
+
|
|
90
|
+
Security/IoMethods:
|
|
91
|
+
Enabled: true
|
|
92
|
+
|
|
93
|
+
Style/AccessorGrouping:
|
|
94
|
+
Enabled: true
|
|
95
|
+
EnforcedStyle: separated
|
|
96
|
+
|
|
97
|
+
Style/ArgumentsForwarding:
|
|
98
|
+
Enabled: true
|
|
99
|
+
|
|
100
|
+
Style/CollectionCompact:
|
|
101
|
+
Enabled: true
|
|
102
|
+
|
|
103
|
+
Style/DocumentDynamicEvalDefinition:
|
|
104
|
+
Enabled: true
|
|
105
|
+
|
|
106
|
+
Style/EmptyCaseCondition:
|
|
107
|
+
Enabled: false
|
|
108
|
+
|
|
109
|
+
Style/EndlessMethod:
|
|
110
|
+
Enabled: true
|
|
111
|
+
|
|
112
|
+
Style/FileRead:
|
|
113
|
+
Enabled: true
|
|
114
|
+
|
|
115
|
+
Style/FileWrite:
|
|
116
|
+
Enabled: true
|
|
117
|
+
|
|
118
|
+
Style/HashConversion:
|
|
119
|
+
Enabled: true
|
|
120
|
+
|
|
121
|
+
Style/HashExcept:
|
|
122
|
+
Enabled: true
|
|
123
|
+
|
|
124
|
+
Style/IfWithBooleanLiteralBranches:
|
|
125
|
+
Enabled: true
|
|
126
|
+
|
|
127
|
+
Style/InPatternThen:
|
|
128
|
+
Enabled: true
|
|
129
|
+
|
|
130
|
+
Style/MapToHash:
|
|
131
|
+
Enabled: true
|
|
132
|
+
|
|
133
|
+
Style/MultilineInPatternThen:
|
|
134
|
+
Enabled: true
|
|
135
|
+
|
|
136
|
+
Style/NegatedIf:
|
|
137
|
+
Enabled: false
|
|
138
|
+
|
|
139
|
+
Style/NegatedIfElseCondition:
|
|
140
|
+
Enabled: true
|
|
141
|
+
|
|
142
|
+
Style/NilLambda:
|
|
143
|
+
Enabled: true
|
|
144
|
+
|
|
145
|
+
Style/NumberedParameters:
|
|
146
|
+
Enabled: true
|
|
147
|
+
|
|
148
|
+
Style/NumberedParametersLimit:
|
|
149
|
+
Enabled: true
|
|
150
|
+
|
|
151
|
+
Style/OpenStructUse:
|
|
152
|
+
Enabled: true
|
|
153
|
+
|
|
154
|
+
Style/QuotedSymbols:
|
|
155
|
+
Enabled: true
|
|
156
|
+
|
|
157
|
+
Style/RedundantArgument:
|
|
158
|
+
Enabled: true
|
|
159
|
+
|
|
160
|
+
Style/RedundantSelfAssignmentBranch:
|
|
161
|
+
Enabled: true
|
|
162
|
+
|
|
163
|
+
Style/SelectByRegexp:
|
|
164
|
+
Enabled: true
|
|
165
|
+
|
|
166
|
+
Style/StringChars:
|
|
167
|
+
Enabled: true
|
|
168
|
+
|
|
169
|
+
Style/StringLiterals:
|
|
170
|
+
Enabled: true
|
|
171
|
+
EnforcedStyle: double_quotes
|
|
172
|
+
|
|
173
|
+
Style/StringLiteralsInInterpolation:
|
|
174
|
+
Enabled: true
|
|
175
|
+
EnforcedStyle: double_quotes
|
|
176
|
+
|
|
177
|
+
Style/SwapValues:
|
|
178
|
+
Enabled: true
|
|
179
|
+
|
|
180
|
+
Layout/LineLength:
|
|
181
|
+
Max: 120
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2022-02-06 20:52:48 UTC using RuboCop version 1.25.1.
|
|
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: 2
|
|
10
|
+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
|
11
|
+
Metrics/AbcSize:
|
|
12
|
+
Max: 25
|
|
13
|
+
|
|
14
|
+
# Offense count: 2
|
|
15
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
|
16
|
+
Metrics/MethodLength:
|
|
17
|
+
Max: 25
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Joe Yates
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Thunderbird
|
|
2
|
+
|
|
3
|
+
Interact to the local installation of Mozilla Thunderbird.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'thunderbird'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
Run `rake spec` to run the tests.
|
|
16
|
+
|
|
17
|
+
## Contributing
|
|
18
|
+
|
|
19
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/joeyates/thunderbird.
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "thunderbird/profiles"
|
|
4
|
+
|
|
5
|
+
class Thunderbird
|
|
6
|
+
# Represents an installation of Thunderbird
|
|
7
|
+
class Install
|
|
8
|
+
attr_reader :title
|
|
9
|
+
attr_reader :entries
|
|
10
|
+
|
|
11
|
+
# entries are lines from profile.ini
|
|
12
|
+
def initialize(title, entries)
|
|
13
|
+
@title = title
|
|
14
|
+
@entries = entries
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def default
|
|
18
|
+
Thunderbird::Profiles.new.profile_for_path(entries[:Default])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "thunderbird/profile"
|
|
4
|
+
require "thunderbird/subdirectory"
|
|
5
|
+
|
|
6
|
+
class Thunderbird
|
|
7
|
+
# A local folder is a file containing emails
|
|
8
|
+
class LocalFolder
|
|
9
|
+
attr_reader :path
|
|
10
|
+
attr_reader :profile
|
|
11
|
+
|
|
12
|
+
def initialize(profile, path)
|
|
13
|
+
@profile = profile
|
|
14
|
+
@path = path
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def set_up
|
|
18
|
+
return if path_elements.empty?
|
|
19
|
+
|
|
20
|
+
return true if !in_subdirectory?
|
|
21
|
+
|
|
22
|
+
subdirectory.set_up
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def full_path
|
|
26
|
+
if in_subdirectory?
|
|
27
|
+
File.join(subdirectory.full_path, folder_name)
|
|
28
|
+
else
|
|
29
|
+
folder_name
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def exists?
|
|
34
|
+
File.exist?(full_path)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def msf_path
|
|
38
|
+
"#{path}.msf"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def msf_exists?
|
|
42
|
+
File.exist?(msf_path)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def in_subdirectory?
|
|
48
|
+
path_elements.count > 1
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def subdirectory
|
|
52
|
+
return nil if !in_subdirectory?
|
|
53
|
+
|
|
54
|
+
Thunderbird::Subdirectory.new(profile, subdirectory_path)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def path_elements
|
|
58
|
+
path.split(File::SEPARATOR)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def subdirectory_path
|
|
62
|
+
File.join(path_elements[0..-2])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def folder_name
|
|
66
|
+
path_elements[-1]
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "thunderbird"
|
|
4
|
+
|
|
5
|
+
class Thunderbird
|
|
6
|
+
# A configured user profile
|
|
7
|
+
class Profile
|
|
8
|
+
attr_reader :title
|
|
9
|
+
attr_reader :entries
|
|
10
|
+
|
|
11
|
+
# entries are lines from profile.ini
|
|
12
|
+
def initialize(title, entries)
|
|
13
|
+
@title = title
|
|
14
|
+
@entries = entries
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def root
|
|
18
|
+
if relative?
|
|
19
|
+
File.join(Thunderbird.new.data_path, entries[:Path])
|
|
20
|
+
else
|
|
21
|
+
entries[:Path]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def local_folders_path
|
|
26
|
+
File.join(root, "Mail", "Local Folders")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def relative?
|
|
32
|
+
entries[:IsRelative] == "1"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "thunderbird"
|
|
4
|
+
require "thunderbird/install"
|
|
5
|
+
require "thunderbird/profile"
|
|
6
|
+
|
|
7
|
+
class Thunderbird
|
|
8
|
+
# http://kb.mozillazine.org/Profiles.ini_file
|
|
9
|
+
class Profiles
|
|
10
|
+
def profile_for_path(path)
|
|
11
|
+
title, entries = blocks.find { |_name, entries| entries[:Path] == path }
|
|
12
|
+
|
|
13
|
+
Thunderbird::Profile.new(title, entries) if title
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def profile(name)
|
|
17
|
+
title, entries = blocks.find { |_name, entries| entries[:Name] == name }
|
|
18
|
+
|
|
19
|
+
Thunderbird::Profile.new(title, entries) if title
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def installs
|
|
23
|
+
@installs ||= begin
|
|
24
|
+
pairs = blocks.filter { |name, _entries| name.start_with?("Install") }
|
|
25
|
+
pairs.map { |title, entries| Thunderbird::Install.new(title, entries) }
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
# Parse profiles.ini.
|
|
32
|
+
# Blocks start with a title, e.g. '[Abc]'
|
|
33
|
+
# and are followed by a number of lines
|
|
34
|
+
def blocks
|
|
35
|
+
@blocks ||= begin
|
|
36
|
+
blocks = {}
|
|
37
|
+
File.open(profiles_ini_path, "rb") do |f|
|
|
38
|
+
title = nil
|
|
39
|
+
entries = nil
|
|
40
|
+
|
|
41
|
+
loop do
|
|
42
|
+
line = f.gets
|
|
43
|
+
if !line
|
|
44
|
+
blocks[title] = entries if title
|
|
45
|
+
break
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
line.chomp!
|
|
49
|
+
|
|
50
|
+
# Is this line the start of a new block
|
|
51
|
+
match = line.match(/\A\[([A-Za-z0-9]+)\]\z/)
|
|
52
|
+
if match
|
|
53
|
+
# Store what we got before this title as a new block
|
|
54
|
+
blocks[title] = entries if title
|
|
55
|
+
|
|
56
|
+
# Start a new block
|
|
57
|
+
title = match[1]
|
|
58
|
+
entries = {}
|
|
59
|
+
elsif line != ""
|
|
60
|
+
# Collect entries until we get to the next title
|
|
61
|
+
key, value = line.split("=")
|
|
62
|
+
entries[key.to_sym] = value
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
blocks
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def profiles_ini_path
|
|
72
|
+
File.join(Thunderbird.new.data_path, "profiles.ini")
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "thunderbird/subdirectory_placeholder"
|
|
4
|
+
|
|
5
|
+
class Thunderbird
|
|
6
|
+
# Represents a subdirectory containing folders
|
|
7
|
+
class Subdirectory
|
|
8
|
+
# `path` is the UI path, it doesn't have the '.sbd' extensions
|
|
9
|
+
# that are present in the real, file system path
|
|
10
|
+
attr_reader :path
|
|
11
|
+
attr_reader :profile
|
|
12
|
+
|
|
13
|
+
def initialize(profile, path)
|
|
14
|
+
@profile = profile
|
|
15
|
+
@path = path
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_up
|
|
19
|
+
raise "Cannot create a subdirectory without a path" if !sub_directory?
|
|
20
|
+
|
|
21
|
+
if sub_sub_directory?
|
|
22
|
+
parent_ok = parent.set_up
|
|
23
|
+
return false if !parent_ok
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
ok = check
|
|
27
|
+
return false if !ok
|
|
28
|
+
|
|
29
|
+
FileUtils.mkdir_p full_path
|
|
30
|
+
placeholder.touch
|
|
31
|
+
|
|
32
|
+
true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# subdirectory relative path is 'Foo.sbd/Bar.sbd/Baz.sbd'
|
|
36
|
+
def full_path
|
|
37
|
+
relative_path = File.join(subdirectories)
|
|
38
|
+
File.join(profile.local_folders_path, relative_path)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def sub_directory?
|
|
44
|
+
path_elements.any?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def sub_sub_directory?
|
|
48
|
+
path_elements.count > 1
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def parent
|
|
52
|
+
return nil if !sub_sub_directory?
|
|
53
|
+
|
|
54
|
+
self.class.new(profile, File.join(path_elements[0..-2]))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# placeholder relative path is 'Foo.sbd/Bar.sbd/Baz'
|
|
58
|
+
def placeholder
|
|
59
|
+
@placeholder = begin
|
|
60
|
+
relative_path = File.join(subdirectories[0..-2], path_elements[-1])
|
|
61
|
+
path = File.join(profile.local_folders_path, relative_path)
|
|
62
|
+
Thunderbird::SubdirectoryPlaceholder.new(path)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def path_elements
|
|
67
|
+
path.split(File::SEPARATOR)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def exists?
|
|
71
|
+
File.exist?(full_path)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def directory?
|
|
75
|
+
File.directory?(full_path)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def subdirectories
|
|
79
|
+
path_elements.map { |p| "#{p}.sbd" }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def check
|
|
83
|
+
case
|
|
84
|
+
when exists? && !placeholder.exists?
|
|
85
|
+
Kernel.puts "Can't set up folder '#{full_path}': '#{full_path}' exists, but '#{placeholder.path}' is missing"
|
|
86
|
+
false
|
|
87
|
+
when placeholder.exists? && !placeholder.regular?
|
|
88
|
+
Kernel.puts "Can't set up folder '#{full_path}': '#{placeholder.path}' exists, but it is not a regular file"
|
|
89
|
+
false
|
|
90
|
+
when exists? && !directory?
|
|
91
|
+
Kernel.puts "Can't set up folder '#{full_path}': '#{full_path}' exists, but it is not a directory"
|
|
92
|
+
false
|
|
93
|
+
else
|
|
94
|
+
true
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Thunderbird
|
|
4
|
+
# Each subdirectory is "accompanied" by a blank
|
|
5
|
+
# file of the same name (without the '.sbd' extension)
|
|
6
|
+
class SubdirectoryPlaceholder
|
|
7
|
+
attr_reader :path
|
|
8
|
+
|
|
9
|
+
def initialize(path)
|
|
10
|
+
@path = path
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def exists?
|
|
14
|
+
File.exist?(path)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def regular?
|
|
18
|
+
File.file?(path)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def touch
|
|
22
|
+
FileUtils.touch path
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/thunderbird.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "os"
|
|
4
|
+
require_relative "thunderbird/version"
|
|
5
|
+
|
|
6
|
+
# Root information
|
|
7
|
+
class Thunderbird
|
|
8
|
+
VERSION = Version::VERSION
|
|
9
|
+
|
|
10
|
+
def data_path
|
|
11
|
+
case
|
|
12
|
+
when OS.linux?
|
|
13
|
+
File.join(Dir.home, ".thunderbird")
|
|
14
|
+
when OS.mac?
|
|
15
|
+
File.join(Dir.home, "Library", "Thunderbird")
|
|
16
|
+
when OS.windows?
|
|
17
|
+
File.join(ENV["APPDATA"].gsub("\\", "/"), "Thunderbird")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/thunderbird.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/thunderbird/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "thunderbird"
|
|
7
|
+
spec.version = Thunderbird::Version::VERSION
|
|
8
|
+
spec.authors = ["Joe Yates"]
|
|
9
|
+
spec.email = ["joe.g.yates@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Conveniences for interacting with Mozilla Thunderbird"
|
|
12
|
+
spec.homepage = "https://github.com/joeyates/thunderbird"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
spec.required_ruby_version = ">= 2.5"
|
|
15
|
+
|
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/joeyates/thunderbird"
|
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/joeyates/thunderbird/blob/main/CHANGELOG.md"
|
|
19
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
20
|
+
|
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
22
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
23
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = []
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_runtime_dependency "os"
|
|
31
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: thunderbird
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Joe Yates
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-02-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: os
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description:
|
|
28
|
+
email:
|
|
29
|
+
- joe.g.yates@gmail.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- ".rspec"
|
|
35
|
+
- ".rubocop.yml"
|
|
36
|
+
- ".rubocop_todo.yml"
|
|
37
|
+
- CHANGELOG.md
|
|
38
|
+
- Gemfile
|
|
39
|
+
- LICENSE.txt
|
|
40
|
+
- README.md
|
|
41
|
+
- Rakefile
|
|
42
|
+
- lib/thunderbird.rb
|
|
43
|
+
- lib/thunderbird/install.rb
|
|
44
|
+
- lib/thunderbird/local_folder.rb
|
|
45
|
+
- lib/thunderbird/profile.rb
|
|
46
|
+
- lib/thunderbird/profiles.rb
|
|
47
|
+
- lib/thunderbird/subdirectory.rb
|
|
48
|
+
- lib/thunderbird/subdirectory_placeholder.rb
|
|
49
|
+
- lib/thunderbird/version.rb
|
|
50
|
+
- thunderbird.gemspec
|
|
51
|
+
homepage: https://github.com/joeyates/thunderbird
|
|
52
|
+
licenses:
|
|
53
|
+
- MIT
|
|
54
|
+
metadata:
|
|
55
|
+
homepage_uri: https://github.com/joeyates/thunderbird
|
|
56
|
+
source_code_uri: https://github.com/joeyates/thunderbird
|
|
57
|
+
changelog_uri: https://github.com/joeyates/thunderbird/blob/main/CHANGELOG.md
|
|
58
|
+
rubygems_mfa_required: 'true'
|
|
59
|
+
post_install_message:
|
|
60
|
+
rdoc_options: []
|
|
61
|
+
require_paths:
|
|
62
|
+
- lib
|
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '2.5'
|
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '0'
|
|
73
|
+
requirements: []
|
|
74
|
+
rubygems_version: 3.1.6
|
|
75
|
+
signing_key:
|
|
76
|
+
specification_version: 4
|
|
77
|
+
summary: Conveniences for interacting with Mozilla Thunderbird
|
|
78
|
+
test_files: []
|