digest-crc 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/integration.yml +1 -1
  3. data/.github/workflows/ruby.yml +6 -6
  4. data/ChangeLog.md +11 -0
  5. data/Gemfile +2 -1
  6. data/LICENSE.txt +1 -1
  7. data/README.md +5 -10
  8. data/benchmarks.rb +1 -0
  9. data/digest-crc.gemspec +8 -4
  10. data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +4 -0
  11. data/ext/digest/crc15/crc15_ext.c +4 -0
  12. data/ext/digest/crc16/crc16_ext.c +4 -0
  13. data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +4 -0
  14. data/ext/digest/crc16_dnp/crc16_dnp_ext.c +4 -0
  15. data/ext/digest/crc16_genibus/crc16_genibus_ext.c +4 -0
  16. data/ext/digest/crc16_kermit/crc16_kermit_ext.c +4 -0
  17. data/ext/digest/crc16_modbus/crc16_modbus_ext.c +4 -1
  18. data/ext/digest/crc16_usb/crc16_usb_ext.c +4 -1
  19. data/ext/digest/crc16_x_25/crc16_x_25_ext.c +4 -1
  20. data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +4 -0
  21. data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +4 -0
  22. data/ext/digest/crc24/crc24_ext.c +4 -0
  23. data/ext/digest/crc32/crc32_ext.c +4 -0
  24. data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +4 -0
  25. data/ext/digest/crc32_jam/crc32_jam_ext.c +4 -1
  26. data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +4 -0
  27. data/ext/digest/crc32_posix/crc32_posix_ext.c +4 -0
  28. data/ext/digest/crc32_xfer/crc32_xfer_ext.c +4 -0
  29. data/ext/digest/crc32c/crc32c_ext.c +4 -1
  30. data/ext/digest/crc5/crc5_ext.c +4 -0
  31. data/ext/digest/crc64/crc64_ext.c +4 -0
  32. data/ext/digest/crc64_jones/crc64_jones_ext.c +4 -1
  33. data/ext/digest/crc64_nvme/crc64_nvme.c +102 -0
  34. data/ext/digest/crc64_nvme/crc64_nvme.h +8 -0
  35. data/ext/digest/crc64_nvme/crc64_nvme_ext.c +31 -0
  36. data/ext/digest/crc64_nvme/extconf.rb +7 -0
  37. data/ext/digest/crc64_xz/crc64_xz_ext.c +4 -1
  38. data/ext/digest/crc8/crc8_ext.c +4 -0
  39. data/ext/digest/crc8_1wire/crc8_1wire_ext.c +4 -1
  40. data/gemspec.yml +1 -1
  41. data/lib/digest/crc.rb +85 -9
  42. data/lib/digest/crc1.rb +2 -0
  43. data/lib/digest/crc15.rb +2 -32
  44. data/lib/digest/crc16.rb +2 -32
  45. data/lib/digest/crc16_ccitt.rb +2 -14
  46. data/lib/digest/crc16_dnp.rb +2 -14
  47. data/lib/digest/crc16_genibus.rb +2 -14
  48. data/lib/digest/crc16_kermit.rb +2 -14
  49. data/lib/digest/crc16_x_25.rb +3 -1
  50. data/lib/digest/crc16_xmodem.rb +2 -14
  51. data/lib/digest/crc16_zmodem.rb +2 -14
  52. data/lib/digest/crc24.rb +2 -33
  53. data/lib/digest/crc32.rb +2 -34
  54. data/lib/digest/crc32_bzip2.rb +2 -14
  55. data/lib/digest/crc32_mpeg.rb +2 -14
  56. data/lib/digest/crc32_posix.rb +2 -14
  57. data/lib/digest/crc32_xfer.rb +2 -14
  58. data/lib/digest/crc5.rb +19 -44
  59. data/lib/digest/crc64.rb +2 -38
  60. data/lib/digest/crc64_nvme.rb +90 -0
  61. data/lib/digest/crc8.rb +2 -27
  62. metadata +8 -36
  63. data/spec/crc15_spec.rb +0 -10
  64. data/spec/crc16_ccitt_spec.rb +0 -10
  65. data/spec/crc16_genibus_spec.rb +0 -10
  66. data/spec/crc16_kermit_spec.rb +0 -10
  67. data/spec/crc16_modbus_spec.rb +0 -10
  68. data/spec/crc16_qt_spec.rb +0 -10
  69. data/spec/crc16_spec.rb +0 -10
  70. data/spec/crc16_usb_spec.rb +0 -10
  71. data/spec/crc16_x_25_spec.rb +0 -10
  72. data/spec/crc16_xmodem_spec.rb +0 -10
  73. data/spec/crc16_zmodem_spec.rb +0 -10
  74. data/spec/crc1_spec.rb +0 -10
  75. data/spec/crc24_spec.rb +0 -10
  76. data/spec/crc32_bzip2_spec.rb +0 -10
  77. data/spec/crc32_jam_spec.rb +0 -10
  78. data/spec/crc32_mpeg_spec.rb +0 -16
  79. data/spec/crc32_posix_spec.rb +0 -10
  80. data/spec/crc32_spec.rb +0 -10
  81. data/spec/crc32_xfer_spec.rb +0 -10
  82. data/spec/crc32c_spec.rb +0 -10
  83. data/spec/crc5_spec.rb +0 -12
  84. data/spec/crc64_jones_spec.rb +0 -10
  85. data/spec/crc64_spec.rb +0 -10
  86. data/spec/crc64_xz_spec.rb +0 -10
  87. data/spec/crc8_1wire_spec.rb +0 -16
  88. data/spec/crc8_spec.rb +0 -10
  89. data/spec/crc_examples.rb +0 -27
  90. data/spec/crc_spec.rb +0 -72
  91. data/spec/integration/docker/Dockerfile.base +0 -9
  92. data/spec/integration/docker/Dockerfile.with-gcc +0 -3
  93. data/spec/integration/docker/Dockerfile.with-gcc-and-make +0 -3
  94. data/spec/integration/install_spec.rb +0 -59
  95. data/spec/spec_helper.rb +0 -1
@@ -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
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- require 'crc_examples'
3
- require 'digest/crc8'
4
-
5
- describe Digest::CRC8 do
6
- let(:string) { '1234567890' }
7
- let(:expected) { '52' }
8
-
9
- it_should_behave_like "CRC"
10
- end
data/spec/crc_examples.rb DELETED
@@ -1,27 +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
- 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,9 +0,0 @@
1
- ARG RUBY_VERSION=2.7.0
2
- FROM ruby:${RUBY_VERSION}-slim
3
-
4
- RUN apt-get update -y -qq
5
- RUN apt-get install -y -qq bash
6
-
7
- COPY ./digest-crc.gem .
8
-
9
- ENTRYPOINT gem install ./digest-crc.gem
@@ -1,3 +0,0 @@
1
- FROM test-digest-crc-base
2
-
3
- RUN apt-get install -y -qq gcc
@@ -1,3 +0,0 @@
1
- FROM test-digest-crc-with-gcc
2
-
3
- RUN apt-get install -y -qq make
@@ -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
@@ -1 +0,0 @@
1
- require 'rspec'