digest-crc 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/integration.yml +1 -1
- data/.github/workflows/ruby.yml +3 -3
- data/ChangeLog.md +6 -0
- data/LICENSE.txt +1 -1
- data/README.md +5 -10
- data/benchmarks.rb +1 -0
- data/digest-crc.gemspec +8 -4
- data/ext/digest/crc64_nvme/crc64_nvme.c +102 -0
- data/ext/digest/crc64_nvme/crc64_nvme.h +8 -0
- data/ext/digest/crc64_nvme/crc64_nvme_ext.c +31 -0
- data/ext/digest/crc64_nvme/extconf.rb +7 -0
- data/gemspec.yml +1 -1
- data/lib/digest/crc.rb +85 -9
- data/lib/digest/crc1.rb +2 -0
- data/lib/digest/crc15.rb +2 -32
- data/lib/digest/crc16.rb +2 -32
- data/lib/digest/crc16_ccitt.rb +2 -14
- data/lib/digest/crc16_dnp.rb +2 -14
- data/lib/digest/crc16_genibus.rb +2 -14
- data/lib/digest/crc16_kermit.rb +2 -14
- data/lib/digest/crc16_x_25.rb +3 -1
- data/lib/digest/crc16_xmodem.rb +2 -14
- data/lib/digest/crc16_zmodem.rb +2 -14
- data/lib/digest/crc24.rb +2 -33
- data/lib/digest/crc32.rb +2 -34
- data/lib/digest/crc32_bzip2.rb +2 -14
- data/lib/digest/crc32_mpeg.rb +2 -14
- data/lib/digest/crc32_posix.rb +2 -14
- data/lib/digest/crc32_xfer.rb +2 -14
- data/lib/digest/crc5.rb +2 -27
- data/lib/digest/crc64.rb +2 -38
- data/lib/digest/crc64_nvme.rb +90 -0
- data/lib/digest/crc8.rb +2 -27
- metadata +8 -36
- data/spec/crc15_spec.rb +0 -10
- data/spec/crc16_ccitt_spec.rb +0 -10
- data/spec/crc16_genibus_spec.rb +0 -10
- data/spec/crc16_kermit_spec.rb +0 -10
- data/spec/crc16_modbus_spec.rb +0 -10
- data/spec/crc16_qt_spec.rb +0 -10
- data/spec/crc16_spec.rb +0 -10
- data/spec/crc16_usb_spec.rb +0 -10
- data/spec/crc16_x_25_spec.rb +0 -10
- data/spec/crc16_xmodem_spec.rb +0 -10
- data/spec/crc16_zmodem_spec.rb +0 -10
- data/spec/crc1_spec.rb +0 -10
- data/spec/crc24_spec.rb +0 -10
- data/spec/crc32_bzip2_spec.rb +0 -10
- data/spec/crc32_jam_spec.rb +0 -10
- data/spec/crc32_mpeg_spec.rb +0 -16
- data/spec/crc32_posix_spec.rb +0 -10
- data/spec/crc32_spec.rb +0 -10
- data/spec/crc32_xfer_spec.rb +0 -10
- data/spec/crc32c_spec.rb +0 -10
- data/spec/crc5_spec.rb +0 -10
- data/spec/crc64_jones_spec.rb +0 -10
- data/spec/crc64_spec.rb +0 -10
- data/spec/crc64_xz_spec.rb +0 -10
- data/spec/crc8_1wire_spec.rb +0 -16
- data/spec/crc8_spec.rb +0 -10
- data/spec/crc_examples.rb +0 -37
- data/spec/crc_spec.rb +0 -72
- data/spec/integration/docker/Dockerfile.base +0 -9
- data/spec/integration/docker/Dockerfile.with-gcc +0 -3
- data/spec/integration/docker/Dockerfile.with-gcc-and-make +0 -3
- data/spec/integration/install_spec.rb +0 -59
- data/spec/spec_helper.rb +0 -3
data/spec/crc16_x_25_spec.rb
DELETED
data/spec/crc16_xmodem_spec.rb
DELETED
data/spec/crc16_zmodem_spec.rb
DELETED
data/spec/crc1_spec.rb
DELETED
data/spec/crc24_spec.rb
DELETED
data/spec/crc32_bzip2_spec.rb
DELETED
data/spec/crc32_jam_spec.rb
DELETED
data/spec/crc32_mpeg_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'crc_examples'
|
3
|
-
require 'digest/crc32_mpeg'
|
4
|
-
|
5
|
-
describe Digest::CRC32MPEG do
|
6
|
-
let(:string) { '1234567890' }
|
7
|
-
let(:expected) { 'af97ac49' }
|
8
|
-
|
9
|
-
it_should_behave_like "CRC"
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "Digest::CRC32Mpeg" do
|
13
|
-
subject { Digest::CRC32Mpeg }
|
14
|
-
|
15
|
-
it { expect(subject).to eq(Digest::CRC32MPEG) }
|
16
|
-
end
|
data/spec/crc32_posix_spec.rb
DELETED
data/spec/crc32_spec.rb
DELETED
data/spec/crc32_xfer_spec.rb
DELETED
data/spec/crc32c_spec.rb
DELETED
data/spec/crc5_spec.rb
DELETED
data/spec/crc64_jones_spec.rb
DELETED
data/spec/crc64_spec.rb
DELETED
data/spec/crc64_xz_spec.rb
DELETED
data/spec/crc8_1wire_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'crc_examples'
|
3
|
-
require 'digest/crc8_1wire'
|
4
|
-
|
5
|
-
describe Digest::CRC8_1Wire do
|
6
|
-
let(:string) { '1234567890' }
|
7
|
-
let(:expected) { '4f' }
|
8
|
-
|
9
|
-
it_should_behave_like "CRC"
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "Digest::CRC81Wire" do
|
13
|
-
subject { Digest::CRC81Wire }
|
14
|
-
|
15
|
-
it { expect(subject).to eq(Digest::CRC8_1Wire) }
|
16
|
-
end
|
data/spec/crc8_spec.rb
DELETED
data/spec/crc_examples.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for "CRC" do
|
4
|
-
it "should calculate a checksum for text" do
|
5
|
-
expect(described_class.hexdigest(string)).to be == expected
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should calculate a checksum for multiple data" do
|
9
|
-
middle = (string.length / 2)
|
10
|
-
|
11
|
-
chunk1 = string[0...middle]
|
12
|
-
chunk2 = string[middle..-1]
|
13
|
-
|
14
|
-
crc = subject
|
15
|
-
crc << chunk1
|
16
|
-
crc << chunk2
|
17
|
-
|
18
|
-
expect(crc.hexdigest).to be == expected
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should provide direct access to the checksum value" do
|
22
|
-
crc = subject
|
23
|
-
crc << string
|
24
|
-
|
25
|
-
expect(crc.checksum).to be == expected.to_i(16)
|
26
|
-
end
|
27
|
-
|
28
|
-
if defined?(Ractor)
|
29
|
-
it "should calculate CRC inside ractor" do
|
30
|
-
digest = Ractor.new(described_class, string) do |klass, string|
|
31
|
-
klass.hexdigest(string)
|
32
|
-
end.take
|
33
|
-
|
34
|
-
expect(digest).to eq expected
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/spec/crc_spec.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'digest/crc'
|
3
|
-
|
4
|
-
describe Digest::CRC do
|
5
|
-
describe "#block_length" do
|
6
|
-
it { expect(subject.block_length).to be 1 }
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".pack" do
|
10
|
-
subject { described_class }
|
11
|
-
|
12
|
-
it do
|
13
|
-
expect { subject.pack(0) }.to raise_error(NotImplementedError)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#update" do
|
18
|
-
it do
|
19
|
-
expect { subject.update('') }.to raise_error(NotImplementedError)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "when inherited" do
|
24
|
-
subject do
|
25
|
-
Class.new(described_class).tap do |klass|
|
26
|
-
klass::WIDTH = 16
|
27
|
-
|
28
|
-
klass::INIT_CRC = 0x01
|
29
|
-
|
30
|
-
klass::XOR_MASK = 0x02
|
31
|
-
|
32
|
-
klass::TABLE = [0x01, 0x02, 0x03, 0x04].freeze
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should override WIDTH" do
|
37
|
-
expect(subject::WIDTH).not_to be described_class::WIDTH
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should override INIT_CRC" do
|
41
|
-
expect(subject::INIT_CRC).not_to be described_class::INIT_CRC
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should override XOR_MASK" do
|
45
|
-
expect(subject::XOR_MASK).not_to be described_class::XOR_MASK
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should override TABLE" do
|
49
|
-
expect(subject::TABLE).not_to be described_class::TABLE
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "#initialize" do
|
53
|
-
let(:instance) { subject.new }
|
54
|
-
|
55
|
-
it "should initialize @init_crc" do
|
56
|
-
expect(instance.instance_variable_get("@init_crc")).to be subject::INIT_CRC
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should initialize @xor_mask" do
|
60
|
-
expect(instance.instance_variable_get("@xor_mask")).to be subject::XOR_MASK
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should initialize @width" do
|
64
|
-
expect(instance.instance_variable_get("@width")).to be subject::WIDTH
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should initialize @table" do
|
68
|
-
expect(instance.instance_variable_get("@table")).to be subject::TABLE
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
|
3
|
-
describe "installing digest-crc" do
|
4
|
-
ROOT_DIR = File.expand_path('../../..',__FILE__)
|
5
|
-
DOCKER_DIR = File.expand_path('../docker', __FILE__)
|
6
|
-
|
7
|
-
IMAGES = %w[
|
8
|
-
test-digest-crc-base
|
9
|
-
test-digest-crc-with-gcc
|
10
|
-
test-digest-crc-with-gcc-and-make
|
11
|
-
]
|
12
|
-
|
13
|
-
before(:all) do
|
14
|
-
puts ">>> Building digest-crc gem ..."
|
15
|
-
Dir.chdir(ROOT_DIR) do
|
16
|
-
system 'gem', 'build',
|
17
|
-
'-o', File.join(DOCKER_DIR,'digest-crc.gem'),
|
18
|
-
'digest-crc.gemspec'
|
19
|
-
end
|
20
|
-
|
21
|
-
IMAGES.each do |image|
|
22
|
-
suffix = image.sub('test-digest-crc-','')
|
23
|
-
|
24
|
-
puts ">>> Building #{image} docker image ..."
|
25
|
-
Dir.chdir(DOCKER_DIR) do
|
26
|
-
system "docker build -t #{image} --file Dockerfile.#{suffix} ."
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when installing into a slim environment" do
|
32
|
-
let(:image) { 'test-digest-crc-base' }
|
33
|
-
|
34
|
-
it "should successfully install digest-crc" do
|
35
|
-
expect(system("docker run #{image}")).to be(true)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "when gcc is installed" do
|
40
|
-
let(:image) { 'test-digest-crc-with-gcc' }
|
41
|
-
|
42
|
-
it "should successfully install digest-crc" do
|
43
|
-
expect(system("docker run #{image}")).to be(true)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "when gcc and make are installed" do
|
48
|
-
let(:image) { 'test-digest-crc-with-gcc-and-make' }
|
49
|
-
|
50
|
-
it "should successfully install digest-crc" do
|
51
|
-
expect(system("docker run #{image}")).to be(true)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
after(:all) do
|
56
|
-
puts ">>> Removing test-digest-crc docker images ..."
|
57
|
-
system "docker image rm -f #{IMAGES.reverse.join(' ')}"
|
58
|
-
end
|
59
|
-
end
|
data/spec/spec_helper.rb
DELETED