paperback 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/tests.yml +46 -0
- data/.rubocop-disables.yml +26 -9
- data/CHANGELOG.md +7 -0
- data/README.md +4 -1
- data/lib/paperback/cli.rb +17 -0
- data/lib/paperback/document.rb +74 -11
- data/lib/paperback/preparer.rb +76 -21
- data/lib/paperback/version.rb +2 -1
- data/lib/paperback.rb +12 -0
- data/paperback.gemspec +10 -7
- data/sorbet/config +3 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
- data/sorbet/rbi/gems/chunky_png@1.4.0.rbi +4498 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +3426 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1083 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +272 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
- data/sorbet/rbi/gems/parallel@1.22.1.rbi +277 -0
- data/sorbet/rbi/gems/parser@3.2.0.0.rbi +6963 -0
- data/sorbet/rbi/gems/pdf-core@0.4.0.rbi +1682 -0
- data/sorbet/rbi/gems/prawn@1.3.0.rbi +5567 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +9990 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +408 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +3023 -0
- data/sorbet/rbi/gems/rbi@0.0.16.rbi +3008 -0
- data/sorbet/rbi/gems/regexp_parser@2.6.1.rbi +3481 -0
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +4717 -0
- data/sorbet/rbi/gems/rqrcode@0.10.1.rbi +617 -0
- data/sorbet/rbi/gems/rspec-core@3.12.0.rbi +10791 -0
- data/sorbet/rbi/gems/rspec-expectations@3.12.1.rbi +8106 -0
- data/sorbet/rbi/gems/rspec-mocks@3.12.1.rbi +5305 -0
- data/sorbet/rbi/gems/rspec-support@3.12.0.rbi +1617 -0
- data/sorbet/rbi/gems/rspec@3.12.0.rbi +88 -0
- data/sorbet/rbi/gems/rubocop-ast@1.24.1.rbi +6617 -0
- data/sorbet/rbi/gems/rubocop@0.93.1.rbi +40848 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +1234 -0
- data/sorbet/rbi/gems/sixword@0.4.0.rbi +536 -0
- data/sorbet/rbi/gems/spoom@1.1.15.rbi +2383 -0
- data/sorbet/rbi/gems/subprocess@1.5.6.rbi +391 -0
- data/sorbet/rbi/gems/tapioca@0.10.5.rbi +3207 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +3956 -0
- data/sorbet/rbi/gems/ttfunk@1.4.0.rbi +1951 -0
- data/sorbet/rbi/gems/unicode-display_width@1.8.0.rbi +40 -0
- data/sorbet/rbi/gems/unparser@0.6.7.rbi +4524 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +2555 -0
- data/sorbet/rbi/gems/yard-sorbet@0.8.0.rbi +441 -0
- data/sorbet/rbi/gems/yard@0.9.28.rbi +17816 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- data/spec/functional/paperback/cli_spec.rb +54 -25
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/paperback_spec.rb +1 -0
- metadata +89 -13
- data/sample/aes.key +0 -1
- data/sample/aes.pdf +0 -14413
- data/sample/aes.pdf.passphrase.txt +0 -1
- data/sample/rsa2048.pdf +0 -106803
- data/sample/rsa2048.pdf.passphrase.txt +0 -1
- data/sample/rsa2048.pem +0 -27
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: false
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'digest/sha2'
|
@@ -9,10 +10,40 @@ require 'subprocess'
|
|
9
10
|
RSpec.describe Paperback::CLI do
|
10
11
|
Executable = File.dirname(__FILE__) + '/../../bin/paperback'
|
11
12
|
|
13
|
+
SupportedPopplerVersions = [
|
14
|
+
/\A0\.86\..*\z/,
|
15
|
+
/\A22\.02\..*\z/,
|
16
|
+
]
|
17
|
+
|
18
|
+
def get_pdftotext_version
|
19
|
+
output = Subprocess.check_output(
|
20
|
+
['pdftotext', '-v'], stderr: Subprocess::STDOUT
|
21
|
+
)
|
22
|
+
first_line = output.lines(chomp: true)[0]
|
23
|
+
if first_line.nil?
|
24
|
+
raise Exception('Unexpected version line from pdftotext: ' + output.inspect)
|
25
|
+
end
|
26
|
+
|
27
|
+
parts = first_line.split(' ')
|
28
|
+
if parts[0] != 'pdftotext' || parts[1] != 'version'
|
29
|
+
raise Exception('Bad version line from pdftotext: ' + first_line.inspect)
|
30
|
+
end
|
31
|
+
|
32
|
+
return parts[2..].join(' ')
|
33
|
+
end
|
34
|
+
|
12
35
|
# pdftotext from poppler is a test dependency
|
13
36
|
it 'finds system pdftotext installed (test dependency)' do
|
14
37
|
expect(Subprocess.check_output(%w[which pdftotext])
|
15
38
|
).to match(/pdftotext/)
|
39
|
+
|
40
|
+
version = get_pdftotext_version
|
41
|
+
|
42
|
+
expect(version).to match(/\A\d+\..*/)
|
43
|
+
|
44
|
+
unless SupportedPopplerVersions.any? {|regex| regex.match(version) }
|
45
|
+
Paperback.log.warn("#{File.basename(__FILE__)}: Unsupported poppler-utils pdftotext version #{version}, tests may fail!")
|
46
|
+
end
|
16
47
|
end
|
17
48
|
|
18
49
|
describe 'end-to-end test:' do
|
@@ -40,25 +71,19 @@ RSpec.describe Paperback::CLI do
|
|
40
71
|
|
41
72
|
expected = <<-EOM
|
42
73
|
This is a paper backup produced by `paperback`. https://github.com/ab/paperback
|
43
|
-
Filename:
|
44
|
-
Backed up:
|
45
|
-
Mtime:
|
46
|
-
Bytes:
|
47
|
-
Comment:
|
48
|
-
SHA256:
|
49
|
-
Encrypted:
|
50
|
-
|
51
|
-
fox.txt
|
52
|
-
#{timestamp}
|
53
|
-
#{timestamp}
|
54
|
-
45
|
55
|
-
Some comment
|
56
|
-
b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380
|
57
|
-
no
|
58
|
-
|
59
|
-
1 of 2
|
60
74
|
|
75
|
+
Filename: fox.txt
|
76
|
+
Backed up: #{timestamp}
|
77
|
+
Mtime: #{timestamp}
|
78
|
+
Bytes: 45
|
79
|
+
Comment: Some comment
|
80
|
+
SHA256: b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380
|
81
|
+
Encrypted: no
|
82
|
+
|
83
|
+
|
84
|
+
1 of 2
|
61
85
|
\fThis sixword text encodes 45 bytes in 6 six-word sentences. Decode with `sixword -d`.
|
86
|
+
|
62
87
|
1: beak us ache sour bern lola
|
63
88
|
2: core arc hulk slid drew due
|
64
89
|
3: chub ends bog russ bess mast
|
@@ -66,16 +91,18 @@ no
|
|
66
91
|
5: coat mod hit need knew grim
|
67
92
|
6: cave ella raft fir a act3
|
68
93
|
|
94
|
+
|
69
95
|
This base64 text encodes 45 bytes in 61 characters. Decode with `base64 --decode`.
|
96
|
+
|
70
97
|
VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4K
|
71
98
|
|
72
|
-
2 of 2
|
73
99
|
|
100
|
+
2 of 2
|
74
101
|
\f
|
75
102
|
EOM
|
76
103
|
|
77
|
-
# strip trailing newline
|
78
|
-
expected = expected[0...-1]
|
104
|
+
# strip trailing newline and extra runs of spaces or newlines
|
105
|
+
expected = expected[0...-1].gsub(/ +/, ' ').gsub(/\n\n+/, "\n")
|
79
106
|
|
80
107
|
# create the backup file!
|
81
108
|
Paperback::CLI.create_backup(
|
@@ -88,14 +115,16 @@ VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4K
|
|
88
115
|
expect(File.read('fox.pdf', 20)).to start_with("%PDF-1.3\n")
|
89
116
|
|
90
117
|
# convert to text to see what's in it
|
91
|
-
Subprocess.check_call(%w[pdftotext fox.pdf fox.pdftotext.txt])
|
118
|
+
Subprocess.check_call(%w[pdftotext -layout fox.pdf fox.pdftotext.txt])
|
92
119
|
|
93
120
|
expect(File.size('fox.pdftotext.txt')).to be > 100
|
94
121
|
|
95
|
-
# This test is likely to break given even minor changes to paperback
|
96
|
-
# may not be particularly useful. However, it's nice to
|
97
|
-
# kind of end-to-end test.
|
98
|
-
|
122
|
+
# This test is likely to break given even minor changes to paperback or
|
123
|
+
# pdftotext, so it may not be particularly useful. However, it's nice to
|
124
|
+
# at least have some kind of end-to-end test.
|
125
|
+
converted_text = File.read('fox.pdftotext.txt')
|
126
|
+
converted_text_stripped = converted_text.gsub(/ +/, ' ').gsub(/\n\n+/, "\n")
|
127
|
+
expect(converted_text_stripped).to eq(expected)
|
99
128
|
end
|
100
129
|
|
101
130
|
it 'backs up encrypted content correctly' do
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/paperback_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Brody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
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: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.50'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sorbet
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.5'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: tapioca
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.10'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.10'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: yard
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +164,20 @@ dependencies:
|
|
136
164
|
- - "~>"
|
137
165
|
- !ruby/object:Gem::Version
|
138
166
|
version: '0.3'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sorbet-runtime
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.5'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.5'
|
139
181
|
- !ruby/object:Gem::Dependency
|
140
182
|
name: subprocess
|
141
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +202,7 @@ executables:
|
|
160
202
|
extensions: []
|
161
203
|
extra_rdoc_files: []
|
162
204
|
files:
|
205
|
+
- ".github/workflows/tests.yml"
|
163
206
|
- ".gitignore"
|
164
207
|
- ".rspec"
|
165
208
|
- ".rubocop-disables.yml"
|
@@ -177,12 +220,46 @@ files:
|
|
177
220
|
- lib/paperback/preparer.rb
|
178
221
|
- lib/paperback/version.rb
|
179
222
|
- paperback.gemspec
|
180
|
-
-
|
181
|
-
-
|
182
|
-
-
|
183
|
-
-
|
184
|
-
-
|
185
|
-
-
|
223
|
+
- sorbet/config
|
224
|
+
- sorbet/rbi/annotations/rainbow.rbi
|
225
|
+
- sorbet/rbi/gems/ast@2.4.2.rbi
|
226
|
+
- sorbet/rbi/gems/chunky_png@1.4.0.rbi
|
227
|
+
- sorbet/rbi/gems/coderay@1.1.3.rbi
|
228
|
+
- sorbet/rbi/gems/diff-lcs@1.5.0.rbi
|
229
|
+
- sorbet/rbi/gems/method_source@1.0.0.rbi
|
230
|
+
- sorbet/rbi/gems/netrc@0.11.0.rbi
|
231
|
+
- sorbet/rbi/gems/parallel@1.22.1.rbi
|
232
|
+
- sorbet/rbi/gems/parser@3.2.0.0.rbi
|
233
|
+
- sorbet/rbi/gems/pdf-core@0.4.0.rbi
|
234
|
+
- sorbet/rbi/gems/prawn@1.3.0.rbi
|
235
|
+
- sorbet/rbi/gems/pry@0.14.1.rbi
|
236
|
+
- sorbet/rbi/gems/rainbow@3.1.1.rbi
|
237
|
+
- sorbet/rbi/gems/rake@13.0.6.rbi
|
238
|
+
- sorbet/rbi/gems/rbi@0.0.16.rbi
|
239
|
+
- sorbet/rbi/gems/regexp_parser@2.6.1.rbi
|
240
|
+
- sorbet/rbi/gems/rexml@3.2.5.rbi
|
241
|
+
- sorbet/rbi/gems/rqrcode@0.10.1.rbi
|
242
|
+
- sorbet/rbi/gems/rspec-core@3.12.0.rbi
|
243
|
+
- sorbet/rbi/gems/rspec-expectations@3.12.1.rbi
|
244
|
+
- sorbet/rbi/gems/rspec-mocks@3.12.1.rbi
|
245
|
+
- sorbet/rbi/gems/rspec-support@3.12.0.rbi
|
246
|
+
- sorbet/rbi/gems/rspec@3.12.0.rbi
|
247
|
+
- sorbet/rbi/gems/rubocop-ast@1.24.1.rbi
|
248
|
+
- sorbet/rbi/gems/rubocop@0.93.1.rbi
|
249
|
+
- sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi
|
250
|
+
- sorbet/rbi/gems/sixword@0.4.0.rbi
|
251
|
+
- sorbet/rbi/gems/spoom@1.1.15.rbi
|
252
|
+
- sorbet/rbi/gems/subprocess@1.5.6.rbi
|
253
|
+
- sorbet/rbi/gems/tapioca@0.10.5.rbi
|
254
|
+
- sorbet/rbi/gems/thor@1.2.1.rbi
|
255
|
+
- sorbet/rbi/gems/ttfunk@1.4.0.rbi
|
256
|
+
- sorbet/rbi/gems/unicode-display_width@1.8.0.rbi
|
257
|
+
- sorbet/rbi/gems/unparser@0.6.7.rbi
|
258
|
+
- sorbet/rbi/gems/webrick@1.7.0.rbi
|
259
|
+
- sorbet/rbi/gems/yard-sorbet@0.8.0.rbi
|
260
|
+
- sorbet/rbi/gems/yard@0.9.28.rbi
|
261
|
+
- sorbet/tapioca/config.yml
|
262
|
+
- sorbet/tapioca/require.rb
|
186
263
|
- spec/functional/paperback/cli_spec.rb
|
187
264
|
- spec/spec_helper.rb
|
188
265
|
- spec/unit/paperback_spec.rb
|
@@ -198,15 +275,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
275
|
requirements:
|
199
276
|
- - ">="
|
200
277
|
- !ruby/object:Gem::Version
|
201
|
-
version: '2.
|
278
|
+
version: '2.7'
|
202
279
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
280
|
requirements:
|
204
281
|
- - ">="
|
205
282
|
- !ruby/object:Gem::Version
|
206
283
|
version: '0'
|
207
284
|
requirements: []
|
208
|
-
|
209
|
-
rubygems_version: 2.5.2.3
|
285
|
+
rubygems_version: 3.3.26
|
210
286
|
signing_key:
|
211
287
|
specification_version: 4
|
212
288
|
summary: Create paper backups of sensitive data
|
data/sample/aes.key
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
d˥�������z�D2�&L�:��B� �y�d�
|