lzwrb 0.2.1 → 0.2.2
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 +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +2 -1
- data/lib/lzwrb.rb +5 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1227a41fbcf1834033772b23027c96f36a8ec6a8b4c3840aa67d0e21c407326e
|
4
|
+
data.tar.gz: 391e9884fa03d762764d9e118c2b7b977eb9b90c3eeea2460d60e42245b45616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02b472ee9e3ca47e1da3ef1c9aa3c33606dd84759121534c4e443299e8281b01b5a162aff9c00c5f4e129e360dbce693d90b66ced81452eaa22ebbcba167431b
|
7
|
+
data.tar.gz: 67dcb5a8d45113ca2c356b4502efcc9e493a0a67d5dafc03557c2020fa771cb92bfde7fb5cc8de3db79da7a6cae2adfcbf88a191307f82af58d0da4fb0914d57
|
data/.yardopts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
lib/**/*.rb - CHANGELOG.md
|
1
|
+
lib/**/*.rb -m markdown --no-private - CHANGELOG.md docs/**/*
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -11,7 +11,7 @@ lzwrb is a Ruby gem for LZW encoding and decoding. Main features:
|
|
11
11
|
* Compatible with many LZW specifications, including GIF (see [Presets](#presets)).
|
12
12
|
* Reasonably fast for pure Ruby (see [Benchmarks](#benchmarks)).
|
13
13
|
|
14
|
-
See also: [Documentation](https://www.rubydoc.info/gems/lzwrb/), [Changelog](https://
|
14
|
+
See also: [Documentation](https://www.rubydoc.info/gems/lzwrb/), [Changelog](https://github.com/edelkas/lzwrb/blob/master/CHANGELOG.md).
|
15
15
|
|
16
16
|
## Table of contents
|
17
17
|
|
@@ -225,6 +225,7 @@ Output:
|
|
225
225
|
[09:48:25.899] LZW <- Decoding 4.330KiB with 5-16 bit codes, LSB packing, STOP codes, textual mode.
|
226
226
|
[09:48:25.909] LZW -> Decoding finished in 0.010s (avg. 3.272 mbit/s).
|
227
227
|
[09:48:25.909] LZW -> Decoded data: 234.375KiB (98.15% compression).
|
228
|
+
true
|
228
229
|
```
|
229
230
|
|
230
231
|
Note how the encoder automatically selected a minimum code size of 5 bits, which suffices to hold the specified alphabet. Specifying fewer minimum bits doesn't make sense, and will be silently corrected by the encoder as well.
|
data/lib/lzwrb.rb
CHANGED
@@ -90,6 +90,9 @@ class LZWrb
|
|
90
90
|
# Enable the use of deferred Clear codes (the decoder won't rebuild the table, even when full, unless an explicit Clear code is received)
|
91
91
|
DEFAULT_DEFERRED = false
|
92
92
|
|
93
|
+
# Dictionary of binary chars for fast access
|
94
|
+
CHARS = 256.times.map(&:chr)
|
95
|
+
|
93
96
|
# Creates a new encoder/decoder object with the given settings.
|
94
97
|
# @param alphabet [Array<String>] Set of characters that compose the messages to encode.
|
95
98
|
# @param binary [Boolean] Use binary encoding or textual encoding.
|
@@ -221,10 +224,10 @@ class LZWrb
|
|
221
224
|
verify_data(data) if @safe
|
222
225
|
|
223
226
|
# LZW-encode data
|
224
|
-
buf = ''
|
227
|
+
buf = ''.b
|
225
228
|
put_code(@clear) if !@clear.nil?
|
226
229
|
proc = -> (c) {
|
227
|
-
c = c
|
230
|
+
c = CHARS[c] if @binary
|
228
231
|
@count += 1
|
229
232
|
next_buf = buf + c
|
230
233
|
if table_has(next_buf)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lzwrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- edelkas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
This library provides LZW encoding and decoding capabilities with no
|
@@ -22,7 +22,9 @@ description: |2
|
|
22
22
|
email:
|
23
23
|
executables: []
|
24
24
|
extensions: []
|
25
|
-
extra_rdoc_files:
|
25
|
+
extra_rdoc_files:
|
26
|
+
- README.md
|
27
|
+
- CHANGELOG.md
|
26
28
|
files:
|
27
29
|
- ".yardopts"
|
28
30
|
- CHANGELOG.md
|
@@ -34,7 +36,7 @@ metadata:
|
|
34
36
|
homepage_uri: https://github.com/edelkas/lzwrb
|
35
37
|
source_code_uri: https://github.com/edelkas/lzwrb
|
36
38
|
documentation_uri: https://www.rubydoc.info/gems/lzwrb
|
37
|
-
changelog_uri: https://
|
39
|
+
changelog_uri: https://github.com/edelkas/lzwrb/blob/master/CHANGELOG.md
|
38
40
|
post_install_message:
|
39
41
|
rdoc_options: []
|
40
42
|
require_paths:
|