paperback 0.0.3 → 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 -12
- data/CHANGELOG.md +21 -0
- data/README.md +27 -6
- data/bin/paperback +4 -0
- data/lib/paperback/cli.rb +38 -2
- data/lib/paperback/document.rb +134 -17
- data/lib/paperback/preparer.rb +107 -29
- 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 +195 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/paperback_spec.rb +1 -0
- metadata +91 -7
@@ -0,0 +1,536 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `sixword` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem sixword`.
|
6
|
+
|
7
|
+
# Sixword, a binary encoder using the 6-word scheme from S/key standardized by
|
8
|
+
# RFC 2289, RFC 1760, and RFC 1751.
|
9
|
+
#
|
10
|
+
# All of the public methods are static methods on the Sixword module, for
|
11
|
+
# example {Sixword.encode} and {Sixword.decode}.
|
12
|
+
#
|
13
|
+
# The <tt>sixword</tt> command line interface and corresponding {Sixword::CLI}
|
14
|
+
# class is also very convenient for more complex use. It supports a variety of
|
15
|
+
# different styles for translating binary data and hexadecimal fingerprints.
|
16
|
+
#
|
17
|
+
# These hexadecimal methods are implemented in the {Sixword::Hex} module.
|
18
|
+
#
|
19
|
+
# source://sixword//lib/sixword/cli.rb#1
|
20
|
+
module Sixword
|
21
|
+
class << self
|
22
|
+
# Decode a six-word encoded string or string array.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# >> Sixword.decode("ACRE ADEN INN SLID MAD PAP")
|
26
|
+
# => "Hi world"
|
27
|
+
# @example
|
28
|
+
# >> Sixword.decode("acre aden inn slid mad pap")
|
29
|
+
# => "Hi world"
|
30
|
+
# @example
|
31
|
+
# Sixword.decode(%w{ACRE ADEN INN SLID MAD PAP})
|
32
|
+
# => "Hi world"
|
33
|
+
# @example
|
34
|
+
# Sixword.decode([])
|
35
|
+
# => ""
|
36
|
+
# @example
|
37
|
+
# Sixword.decode("COAT ACHE A A A ACT6", padding_ok: true)
|
38
|
+
# => "hi"
|
39
|
+
# @option options
|
40
|
+
# @param string_or_words [String, Array<String>] Either a String containing
|
41
|
+
# whitespace separated words or an Array of String words
|
42
|
+
# @param options [Hash]
|
43
|
+
# @raise InputError if the input is malformed or invalid in various ways
|
44
|
+
# @return [String] A binary string of bytes
|
45
|
+
#
|
46
|
+
# source://sixword//lib/sixword.rb#238
|
47
|
+
def decode(string_or_words, options = T.unsafe(nil)); end
|
48
|
+
|
49
|
+
# Encode a string of bytes in six-word encoding. If you want to use the
|
50
|
+
# custom padding scheme for inputs that are not a multiple of 8 in length,
|
51
|
+
# use Sixword.pad_encode instead.
|
52
|
+
#
|
53
|
+
# @example
|
54
|
+
# >> Sixword.encode('Hi world')
|
55
|
+
# => ["ACRE", "ADEN", "INN", "SLID", "MAD", "PAP"]
|
56
|
+
# @param byte_string [String] Length must be a multiple of 8
|
57
|
+
# @raise Sixword::InputError
|
58
|
+
# @return [Array<String>] an array of string words
|
59
|
+
# @see Sixword.encode_iter
|
60
|
+
#
|
61
|
+
# source://sixword//lib/sixword.rb#48
|
62
|
+
def encode(byte_string); end
|
63
|
+
|
64
|
+
# Encode a string of bytes in six-word encoding (full API). This is the
|
65
|
+
# relatively low level method that supports all the major options. See the
|
66
|
+
# various other top-level methods for convenience helpers.
|
67
|
+
#
|
68
|
+
# @option options
|
69
|
+
# @option options
|
70
|
+
# @param byte_string [String] A byte string to encode
|
71
|
+
# @param options [Hash]
|
72
|
+
# @raise Sixword::InputError on incorrectly padded inputs
|
73
|
+
# @raise ArgumentError on bad argument types
|
74
|
+
# @return [Enumerator, nil] If no block is given, return an Enumerator
|
75
|
+
# @yield [String] A String word (or String of space separated words, if
|
76
|
+
# :words_per_slice is given)
|
77
|
+
#
|
78
|
+
# source://sixword//lib/sixword.rb#159
|
79
|
+
def encode_iter(byte_string, options = T.unsafe(nil)); end
|
80
|
+
|
81
|
+
# Encode a string of bytes in six-word encoding. If you want to use the
|
82
|
+
# custom padding scheme for inputs that are not a multiple of 8 in length,
|
83
|
+
# use Sixword.pad_encode instead.
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
# >> Sixword.encode('Hi world')
|
87
|
+
# => ["ACRE", "ADEN", "INN", "SLID", "MAD", "PAP"]
|
88
|
+
# @param byte_string [String] Length must be a multiple of 8
|
89
|
+
# @raise Sixword::InputError
|
90
|
+
# @return [Array<String>] an array of string words
|
91
|
+
# @see Sixword.encode_iter
|
92
|
+
#
|
93
|
+
# source://sixword//lib/sixword.rb#48
|
94
|
+
def encode_to_a(byte_string); end
|
95
|
+
|
96
|
+
# Like {Sixword.encode}, but return a single string.
|
97
|
+
#
|
98
|
+
# @example
|
99
|
+
# Sixword.encode_to_s('Hi world' * 2)
|
100
|
+
# => "ACRE ADEN INN SLID MAD PAP ACRE ADEN INN SLID MAD PAP"
|
101
|
+
# @param byte_string [String] Length must be a multiple of 8
|
102
|
+
# @raise Sixword::InputError
|
103
|
+
# @return [String] a string of words separated by spaces
|
104
|
+
# @see Sixword.encode
|
105
|
+
#
|
106
|
+
# source://sixword//lib/sixword.rb#106
|
107
|
+
def encode_to_s(byte_string); end
|
108
|
+
|
109
|
+
# Like {Sixword.encode}, but return six words at a time (a complete block).
|
110
|
+
#
|
111
|
+
# @example
|
112
|
+
# Sixword.encode_to_sentences('Hi world' * 2)
|
113
|
+
# => ["ACRE ADEN INN SLID MAD PAP",
|
114
|
+
# "ACRE ADEN INN SLID MAD PAP"]
|
115
|
+
# @param byte_string [String] Length must be a multiple of 8
|
116
|
+
# @raise Sixword::InputError
|
117
|
+
# @return [Array<String>] an array of 6-word string sentences
|
118
|
+
# @see Sixword.encode
|
119
|
+
#
|
120
|
+
# source://sixword//lib/sixword.rb#89
|
121
|
+
def encode_to_sentences(byte_string); end
|
122
|
+
|
123
|
+
# Like {Sixword.decode}, but allow input to contain custom padding scheme.
|
124
|
+
#
|
125
|
+
# @example
|
126
|
+
# Sixword.decode("COAT ACHE A A A ACT6", padding_ok: true)
|
127
|
+
# => "hi"
|
128
|
+
# @param string_or_words [String, Array<String>] Either a String containing
|
129
|
+
# whitespace separated words or an Array of String words
|
130
|
+
# @raise InputError if the input is malformed or invalid in various ways
|
131
|
+
# @return [String] A binary string of bytes
|
132
|
+
# @see Sixword.decode
|
133
|
+
#
|
134
|
+
# source://sixword//lib/sixword.rb#276
|
135
|
+
def pad_decode(string_or_words); end
|
136
|
+
|
137
|
+
# Encode a string of bytes in six-word encoding, using the custom padding
|
138
|
+
# scheme established by this library. The output will be identical to
|
139
|
+
# {Sixword.encode} for strings that are a multiple of 8 in length.
|
140
|
+
#
|
141
|
+
# @example
|
142
|
+
# >> Sixword.encode('Hi wor')
|
143
|
+
# => ["ACRE", "ADEN", "INN", "SLID", "MAD", "PAP"]
|
144
|
+
# @param byte_string [String] A string of any length
|
145
|
+
# @return [Array<String>] an array of string words
|
146
|
+
# @see Sixword.encode_iter
|
147
|
+
#
|
148
|
+
# source://sixword//lib/sixword.rb#65
|
149
|
+
def pad_encode(byte_string); end
|
150
|
+
|
151
|
+
# Encode a string of bytes in six-word encoding, using the custom padding
|
152
|
+
# scheme established by this library. The output will be identical to
|
153
|
+
# {Sixword.encode} for strings that are a multiple of 8 in length.
|
154
|
+
#
|
155
|
+
# @example
|
156
|
+
# >> Sixword.encode('Hi wor')
|
157
|
+
# => ["ACRE", "ADEN", "INN", "SLID", "MAD", "PAP"]
|
158
|
+
# @param byte_string [String] A string of any length
|
159
|
+
# @return [Array<String>] an array of string words
|
160
|
+
# @see Sixword.encode_iter
|
161
|
+
#
|
162
|
+
# source://sixword//lib/sixword.rb#65
|
163
|
+
def pad_encode_to_a(byte_string); end
|
164
|
+
|
165
|
+
# Like {Sixword.encode_to_s}, but allow variable length input.
|
166
|
+
#
|
167
|
+
# @example
|
168
|
+
# >> Sixword.pad_encode_to_s('Hi worl' * 2)
|
169
|
+
# => "ACRE ADEN INN SLID MAD LEW CODY AS SIGH SUIT MUDD ABE2"
|
170
|
+
# @param byte_string [String] A string of any length
|
171
|
+
# @return [String] a string of words separated by spaces
|
172
|
+
#
|
173
|
+
# source://sixword//lib/sixword.rb#132
|
174
|
+
def pad_encode_to_s(byte_string); end
|
175
|
+
|
176
|
+
# Like {Sixword.encode_to_sentences}, but allow variable length input.
|
177
|
+
#
|
178
|
+
# @example
|
179
|
+
# >> Sixword.pad_encode_to_sentences('Hi worl' * 2)
|
180
|
+
# => ["ACRE ADEN INN SLID MAD LEW", "CODY AS SIGH SUIT MUDD ABE2"]
|
181
|
+
# @param byte_string [String] A string of any length
|
182
|
+
# @return [Array<String>] an array of 6-word string sentences
|
183
|
+
#
|
184
|
+
# source://sixword//lib/sixword.rb#119
|
185
|
+
def pad_encode_to_sentences(byte_string); end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# The Sixword::CLI class implements all of the complex processing needed for
|
190
|
+
# the sixword Command Line Interface.
|
191
|
+
#
|
192
|
+
# source://sixword//lib/sixword/cli.rb#5
|
193
|
+
class Sixword::CLI
|
194
|
+
# Create a Sixword CLI to operate on filename with options
|
195
|
+
#
|
196
|
+
# @option options
|
197
|
+
# @option options
|
198
|
+
# @option options
|
199
|
+
# @option options
|
200
|
+
# @param filename [String] Input file name (or '-' for stdin)
|
201
|
+
# @param options [Hash]
|
202
|
+
# @return [CLI] a new instance of CLI
|
203
|
+
#
|
204
|
+
# source://sixword//lib/sixword/cli.rb#33
|
205
|
+
def initialize(filename, options); end
|
206
|
+
|
207
|
+
# Return true if we are in encoding mode, false otherwise (decoding).
|
208
|
+
#
|
209
|
+
# @return [Boolean]
|
210
|
+
#
|
211
|
+
# source://sixword//lib/sixword/cli.rb#61
|
212
|
+
def encoding?; end
|
213
|
+
|
214
|
+
# @return [String] Input filename
|
215
|
+
#
|
216
|
+
# source://sixword//lib/sixword/cli.rb#11
|
217
|
+
def filename; end
|
218
|
+
|
219
|
+
# Return the value of the :hex_style option.
|
220
|
+
#
|
221
|
+
# @return [String, nil]
|
222
|
+
#
|
223
|
+
# source://sixword//lib/sixword/cli.rb#67
|
224
|
+
def hex_style; end
|
225
|
+
|
226
|
+
# @return [:encode, :decode]
|
227
|
+
#
|
228
|
+
# source://sixword//lib/sixword/cli.rb#20
|
229
|
+
def mode; end
|
230
|
+
|
231
|
+
# @return [Hash] Options hash
|
232
|
+
#
|
233
|
+
# source://sixword//lib/sixword/cli.rb#14
|
234
|
+
def options; end
|
235
|
+
|
236
|
+
# Return the value of the :pad option.
|
237
|
+
#
|
238
|
+
# @return [Boolean]
|
239
|
+
#
|
240
|
+
# source://sixword//lib/sixword/cli.rb#55
|
241
|
+
def pad?; end
|
242
|
+
|
243
|
+
# Format data as hex in various styles.
|
244
|
+
#
|
245
|
+
# source://sixword//lib/sixword/cli.rb#72
|
246
|
+
def print_hex(data, chunk_index, cols = T.unsafe(nil)); end
|
247
|
+
|
248
|
+
# Run the encoding/decoding operation, printing the result to stdout.
|
249
|
+
#
|
250
|
+
# source://sixword//lib/sixword/cli.rb#96
|
251
|
+
def run!; end
|
252
|
+
|
253
|
+
# @return [File, IO] Stream opened from #filename
|
254
|
+
#
|
255
|
+
# source://sixword//lib/sixword/cli.rb#17
|
256
|
+
def stream; end
|
257
|
+
|
258
|
+
private
|
259
|
+
|
260
|
+
# source://sixword//lib/sixword/cli.rb#213
|
261
|
+
def accumulate_hex_input; end
|
262
|
+
|
263
|
+
# source://sixword//lib/sixword/cli.rb#119
|
264
|
+
def do_decode!; end
|
265
|
+
|
266
|
+
# source://sixword//lib/sixword/cli.rb#129
|
267
|
+
def do_encode!; end
|
268
|
+
|
269
|
+
# source://sixword//lib/sixword/cli.rb#155
|
270
|
+
def process_encode_input; end
|
271
|
+
|
272
|
+
# Yield data 6 words at a time until EOF
|
273
|
+
#
|
274
|
+
# source://sixword//lib/sixword/cli.rb#187
|
275
|
+
def read_input_by_6_words; end
|
276
|
+
end
|
277
|
+
|
278
|
+
# Exception for certain input validation errors
|
279
|
+
#
|
280
|
+
# source://sixword//lib/sixword/cli.rb#8
|
281
|
+
class Sixword::CLI::CLIError < ::StandardError; end
|
282
|
+
|
283
|
+
# Various hexadecimal string encoding and decoding functions
|
284
|
+
#
|
285
|
+
# source://sixword//lib/sixword/hex.rb#3
|
286
|
+
module Sixword::Hex
|
287
|
+
class << self
|
288
|
+
# Decode a hexadecimal string to a byte string.
|
289
|
+
#
|
290
|
+
# @param hex_string [String]
|
291
|
+
# @param strip_chars [Boolean] Whether to accept and strip whitespace and
|
292
|
+
# other delimiters (see {HexStrip})
|
293
|
+
# @raise ArgumentError on invalid hex input
|
294
|
+
# @return [String]
|
295
|
+
#
|
296
|
+
# source://sixword//lib/sixword/hex.rb#94
|
297
|
+
def decode(hex_string, strip_chars = T.unsafe(nil)); end
|
298
|
+
|
299
|
+
# Encode a byte string as hexadecimal.
|
300
|
+
#
|
301
|
+
# @param bytes [String]
|
302
|
+
# @return [String] hexadecimal string
|
303
|
+
#
|
304
|
+
# source://sixword//lib/sixword/hex.rb#34
|
305
|
+
def encode(bytes); end
|
306
|
+
|
307
|
+
# Encode a byte string in hex with colons: lowercase in slices of 2
|
308
|
+
# separated by colons.
|
309
|
+
#
|
310
|
+
# @example
|
311
|
+
# >> encode_colons("9T]B\xF0\x039\xFF")
|
312
|
+
# => "39:54:5d:42:f0:03:39:ff"
|
313
|
+
# @param bytes [String]
|
314
|
+
# @return [String]
|
315
|
+
#
|
316
|
+
# source://sixword//lib/sixword/hex.rb#81
|
317
|
+
def encode_colons(bytes); end
|
318
|
+
|
319
|
+
# Encode a byte string as a GPG style fingerprint: uppercase in slices of 4
|
320
|
+
# separated by spaces.
|
321
|
+
#
|
322
|
+
# @example
|
323
|
+
# >> encode_fingerprint("9T]B\xF0\x039\xFF")
|
324
|
+
# => "3954 5D42 F003 39FF"
|
325
|
+
# @param bytes [String]
|
326
|
+
# @return [String]
|
327
|
+
#
|
328
|
+
# source://sixword//lib/sixword/hex.rb#66
|
329
|
+
def encode_fingerprint(bytes); end
|
330
|
+
|
331
|
+
# Encode a byte string as hexadecimal, returning it in slices joined by a
|
332
|
+
# delimiter. This is useful for generating colon or space separated strings
|
333
|
+
# like those commonly used in fingerprints.
|
334
|
+
#
|
335
|
+
# @example
|
336
|
+
# >> encode_slice("9T]B\xF0\x039\xFF", 2, ':')
|
337
|
+
# => "39:54:5d:42:f0:03:39:ff"
|
338
|
+
# @param bytes [String]
|
339
|
+
# @param slice [Integer]
|
340
|
+
# @param delimiter [String]
|
341
|
+
# @return [String]
|
342
|
+
#
|
343
|
+
# source://sixword//lib/sixword/hex.rb#52
|
344
|
+
def encode_slice(bytes, slice, delimiter); end
|
345
|
+
|
346
|
+
# Return whether single character string is one of the fill characters that
|
347
|
+
# are OK to strip from a hexadecimal string.
|
348
|
+
#
|
349
|
+
# @param char [String] String of length == 1
|
350
|
+
# @return [Boolean]
|
351
|
+
# @see [HexStrip]
|
352
|
+
#
|
353
|
+
# source://sixword//lib/sixword/hex.rb#22
|
354
|
+
def strip_char?(char); end
|
355
|
+
|
356
|
+
# Return whether string is entirely hexadecimal.
|
357
|
+
#
|
358
|
+
# @param string [String]
|
359
|
+
# @return [Boolean]
|
360
|
+
# @see [HexValid]
|
361
|
+
#
|
362
|
+
# source://sixword//lib/sixword/hex.rb#12
|
363
|
+
def valid_hex?(string); end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
# source://sixword//lib/sixword/hex.rb#5
|
368
|
+
Sixword::Hex::HexStrip = T.let(T.unsafe(nil), Regexp)
|
369
|
+
|
370
|
+
# source://sixword//lib/sixword/hex.rb#4
|
371
|
+
Sixword::Hex::HexValid = T.let(T.unsafe(nil), Regexp)
|
372
|
+
|
373
|
+
# Parent class for inputs that could plausibly occur at runtime.
|
374
|
+
#
|
375
|
+
# source://sixword//lib/sixword.rb#22
|
376
|
+
class Sixword::InputError < ::ArgumentError; end
|
377
|
+
|
378
|
+
# Raised when the parity check fails
|
379
|
+
#
|
380
|
+
# source://sixword//lib/sixword.rb#25
|
381
|
+
class Sixword::InvalidParity < ::Sixword::InputError; end
|
382
|
+
|
383
|
+
# Raised in decoding when a word of invalid format is encountered
|
384
|
+
#
|
385
|
+
# source://sixword//lib/sixword.rb#31
|
386
|
+
class Sixword::InvalidWord < ::Sixword::InputError; end
|
387
|
+
|
388
|
+
# The Lib module contains various internal utility functions. They are not
|
389
|
+
# really part of the public API and will probably not be useful to external
|
390
|
+
# callers.
|
391
|
+
#
|
392
|
+
# source://sixword//lib/sixword/lib.rb#6
|
393
|
+
module Sixword::Lib
|
394
|
+
class << self
|
395
|
+
# Given an array of bytes, pack them into a single Integer.
|
396
|
+
#
|
397
|
+
# @example
|
398
|
+
#
|
399
|
+
# >> byte_array_to_int([1, 2])
|
400
|
+
# => 258
|
401
|
+
# @param byte_array [Array<Fixnum>]
|
402
|
+
# @return [Integer]
|
403
|
+
#
|
404
|
+
# source://sixword//lib/sixword/lib.rb#218
|
405
|
+
def byte_array_to_int(byte_array); end
|
406
|
+
|
407
|
+
# Decode an array of 6 words into a 64-bit integer (representing 8 bytes).
|
408
|
+
#
|
409
|
+
# length of the byte array that it represents (will always be 8 unless
|
410
|
+
# padding_ok)
|
411
|
+
#
|
412
|
+
# @example
|
413
|
+
# >> Sixword::Lib.decode_6_words(%w{COAT ACHE A A A ACT6}, true)
|
414
|
+
# => [26729, 2]
|
415
|
+
#
|
416
|
+
# >> Sixword::Lib.decode_6_words(%w{ACRE ADEN INN SLID MAD PAP}, false)
|
417
|
+
# => [5217737340628397156, 8]
|
418
|
+
# @param word_array [Array<String>] A 6 element array of String words
|
419
|
+
# @param padding_ok [Boolean]
|
420
|
+
# @return [Array(Integer, Integer)] a 64-bit integer (the data) and the
|
421
|
+
#
|
422
|
+
# source://sixword//lib/sixword/lib.rb#63
|
423
|
+
def decode_6_words(word_array, padding_ok); end
|
424
|
+
|
425
|
+
# Decode an array of 6 words into a String of bytes.
|
426
|
+
#
|
427
|
+
# @example
|
428
|
+
# >> Lib.decode_6_words_to_bstring(%w{COAT ACHE A A A ACT6}, true)
|
429
|
+
# => "hi"
|
430
|
+
#
|
431
|
+
# >> Lib.decode_6_words_to_bstring(%w{ACRE ADEN INN SLID MAD PAP}, false)
|
432
|
+
# => "Hi world"
|
433
|
+
# @param word_array [Array<String>] A 6 element array of String words
|
434
|
+
# @param padding_ok [Boolean]
|
435
|
+
# @return [String]
|
436
|
+
# @see Sixword.decode_6_words
|
437
|
+
# @see Sixword.int_to_byte_array
|
438
|
+
#
|
439
|
+
# source://sixword//lib/sixword/lib.rb#143
|
440
|
+
def decode_6_words_to_bstring(word_array, padding_ok); end
|
441
|
+
|
442
|
+
# Encode an array of 8 bytes as an array of 6 words.
|
443
|
+
#
|
444
|
+
# @example
|
445
|
+
# >> Sixword::Lib.encode_64_bits([0] * 8)
|
446
|
+
# => ["A", "A", "A", "A", "A", "A"]
|
447
|
+
# @example
|
448
|
+
# >> Sixword::Lib.encode_64_bits([0xff] * 8)
|
449
|
+
# => ["YOKE", "YOKE", "YOKE", "YOKE", "YOKE", "YEAR"]
|
450
|
+
# @param byte_array [Array<Fixnum>] An array of length 8 containing
|
451
|
+
# integers in 0..255
|
452
|
+
# @return [Array<String>] An array of length 6 containing String words from
|
453
|
+
# {Sixword::WORDS}
|
454
|
+
#
|
455
|
+
# source://sixword//lib/sixword/lib.rb#24
|
456
|
+
def encode_64_bits(byte_array); end
|
457
|
+
|
458
|
+
# Extract the numeric padding from a word.
|
459
|
+
#
|
460
|
+
# @example
|
461
|
+
# >> Sixword::Lib.extract_padding("WORD3")
|
462
|
+
# => ["WORD", 3]
|
463
|
+
# @param word [String]
|
464
|
+
# @return [Array(String, Integer)] The String word, the Integer padding
|
465
|
+
#
|
466
|
+
# source://sixword//lib/sixword/lib.rb#118
|
467
|
+
def extract_padding(word); end
|
468
|
+
|
469
|
+
# Given an Integer, unpack it into an array of bytes.
|
470
|
+
#
|
471
|
+
# @example
|
472
|
+
# >> int_to_byte_array(258)
|
473
|
+
# => [1, 2]
|
474
|
+
# @example
|
475
|
+
# >> int_to_byte_array(258, 3)
|
476
|
+
# => [0, 1, 2]
|
477
|
+
# @param int [Integer]
|
478
|
+
# @param length [Integer] Left zero padded size of byte array to return. If
|
479
|
+
# not provided, no leading zeroes will be added.
|
480
|
+
# @return [Array<Fixnum>]
|
481
|
+
#
|
482
|
+
# source://sixword//lib/sixword/lib.rb#243
|
483
|
+
def int_to_byte_array(int, length = T.unsafe(nil)); end
|
484
|
+
|
485
|
+
# Compute two-bit parity on a byte array by summing each pair of bits.
|
486
|
+
# TODO: figure out which is faster
|
487
|
+
#
|
488
|
+
# @param byte_array [Array<Fixnum>]
|
489
|
+
# @return [Fixnum] An integer 0..3
|
490
|
+
# @see parity_int
|
491
|
+
#
|
492
|
+
# source://sixword//lib/sixword/lib.rb#173
|
493
|
+
def parity_array(byte_array); end
|
494
|
+
|
495
|
+
# Compute two-bit parity on a 64-bit integer representing an 8-byte array
|
496
|
+
# by summing each pair of bits.
|
497
|
+
# TODO: figure out which is faster
|
498
|
+
#
|
499
|
+
# @param int [Integer] A 64-bit integer representing 8 bytes
|
500
|
+
# @return [Fixnum] An integer 0..3
|
501
|
+
# @see parity_array
|
502
|
+
#
|
503
|
+
# source://sixword//lib/sixword/lib.rb#197
|
504
|
+
def parity_int(int); end
|
505
|
+
|
506
|
+
# Given a word, return the 11 bits it represents as an integer (i.e. its
|
507
|
+
# index in the WORDS list).
|
508
|
+
#
|
509
|
+
# @param word [String]
|
510
|
+
# @return [Fixnum] An integer 0..2047
|
511
|
+
#
|
512
|
+
# source://sixword//lib/sixword/lib.rb#154
|
513
|
+
def word_to_bits(word); end
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
# Raised in decoding when an unrecognized word is encountered
|
518
|
+
#
|
519
|
+
# source://sixword//lib/sixword.rb#28
|
520
|
+
class Sixword::UnknownWord < ::Sixword::InputError; end
|
521
|
+
|
522
|
+
# version string
|
523
|
+
#
|
524
|
+
# source://sixword//lib/sixword/version.rb#3
|
525
|
+
Sixword::VERSION = T.let(T.unsafe(nil), String)
|
526
|
+
|
527
|
+
# Dictionary from RFC 2289 Appendix D
|
528
|
+
# http://tools.ietf.org/html/rfc2289#appendix-D
|
529
|
+
#
|
530
|
+
# source://sixword//lib/sixword/words.rb#5
|
531
|
+
Sixword::WORDS = T.let(T.unsafe(nil), Array)
|
532
|
+
|
533
|
+
# A mapping from Word => Integer index in the word list
|
534
|
+
#
|
535
|
+
# source://sixword//lib/sixword/words.rb#264
|
536
|
+
Sixword::WORDS_HASH = T.let(T.unsafe(nil), Hash)
|