digest-crc 0.4.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +6 -0
  3. data/.travis.yml +24 -0
  4. data/.yardopts +0 -1
  5. data/ChangeLog.md +138 -0
  6. data/Gemfile +15 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +19 -4
  9. data/Rakefile +32 -28
  10. data/benchmarks.rb +58 -0
  11. data/digest-crc.gemspec +2 -1
  12. data/ext/digest/Rakefile +51 -0
  13. data/ext/digest/compat/ruby.h +11 -0
  14. data/ext/digest/crc12_3gpp/crc12_3gpp.c +66 -0
  15. data/ext/digest/crc12_3gpp/crc12_3gpp.h +11 -0
  16. data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +27 -0
  17. data/ext/digest/crc12_3gpp/extconf.rb +7 -0
  18. data/ext/digest/crc15/crc15.c +53 -0
  19. data/ext/digest/crc15/crc15.h +11 -0
  20. data/ext/digest/crc15/crc15_ext.c +28 -0
  21. data/ext/digest/crc15/extconf.rb +7 -0
  22. data/ext/digest/crc16/crc16.c +69 -0
  23. data/ext/digest/crc16/crc16.h +11 -0
  24. data/ext/digest/crc16/crc16_ext.c +28 -0
  25. data/ext/digest/crc16/extconf.rb +7 -0
  26. data/ext/digest/crc16_ccitt/crc16_ccitt.c +69 -0
  27. data/ext/digest/crc16_ccitt/crc16_ccitt.h +8 -0
  28. data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +28 -0
  29. data/ext/digest/crc16_ccitt/extconf.rb +7 -0
  30. data/ext/digest/crc16_dnp/crc16_dnp.c +53 -0
  31. data/ext/digest/crc16_dnp/crc16_dnp.h +8 -0
  32. data/ext/digest/crc16_dnp/crc16_dnp_ext.c +28 -0
  33. data/ext/digest/crc16_dnp/extconf.rb +7 -0
  34. data/ext/digest/crc16_genibus/crc16_genibus.c +69 -0
  35. data/ext/digest/crc16_genibus/crc16_genibus.h +8 -0
  36. data/ext/digest/crc16_genibus/crc16_genibus_ext.c +28 -0
  37. data/ext/digest/crc16_genibus/extconf.rb +7 -0
  38. data/ext/digest/crc16_kermit/crc16_kermit.c +69 -0
  39. data/ext/digest/crc16_kermit/crc16_kermit.h +8 -0
  40. data/ext/digest/crc16_kermit/crc16_kermit_ext.c +28 -0
  41. data/ext/digest/crc16_kermit/extconf.rb +7 -0
  42. data/ext/digest/crc16_modbus/crc16_modbus.c +69 -0
  43. data/ext/digest/crc16_modbus/crc16_modbus.h +8 -0
  44. data/ext/digest/crc16_modbus/crc16_modbus_ext.c +28 -0
  45. data/ext/digest/crc16_modbus/extconf.rb +7 -0
  46. data/ext/digest/crc16_usb/crc16_usb.c +69 -0
  47. data/ext/digest/crc16_usb/crc16_usb.h +8 -0
  48. data/ext/digest/crc16_usb/crc16_usb_ext.c +28 -0
  49. data/ext/digest/crc16_usb/extconf.rb +7 -0
  50. data/ext/digest/crc16_x_25/crc16_x_25.c +69 -0
  51. data/ext/digest/crc16_x_25/crc16_x_25.h +8 -0
  52. data/ext/digest/crc16_x_25/crc16_x_25_ext.c +28 -0
  53. data/ext/digest/crc16_x_25/extconf.rb +7 -0
  54. data/ext/digest/crc16_xmodem/crc16_xmodem.c +69 -0
  55. data/ext/digest/crc16_xmodem/crc16_xmodem.h +8 -0
  56. data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +28 -0
  57. data/ext/digest/crc16_xmodem/extconf.rb +7 -0
  58. data/ext/digest/crc16_zmodem/crc16_zmodem.c +69 -0
  59. data/ext/digest/crc16_zmodem/crc16_zmodem.h +8 -0
  60. data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +28 -0
  61. data/ext/digest/crc16_zmodem/extconf.rb +7 -0
  62. data/ext/digest/crc24/crc24.c +69 -0
  63. data/ext/digest/crc24/crc24.h +11 -0
  64. data/ext/digest/crc24/crc24_ext.c +27 -0
  65. data/ext/digest/crc24/extconf.rb +7 -0
  66. data/ext/digest/crc32/crc32.c +68 -0
  67. data/ext/digest/crc32/crc32.h +11 -0
  68. data/ext/digest/crc32/crc32_ext.c +27 -0
  69. data/ext/digest/crc32/extconf.rb +7 -0
  70. data/ext/digest/crc32_bzip2/crc32_bzip2.c +69 -0
  71. data/ext/digest/crc32_bzip2/crc32_bzip2.h +8 -0
  72. data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +27 -0
  73. data/ext/digest/crc32_bzip2/extconf.rb +7 -0
  74. data/ext/digest/crc32_jam/crc32_jam.c +69 -0
  75. data/ext/digest/crc32_jam/crc32_jam.h +8 -0
  76. data/ext/digest/crc32_jam/crc32_jam_ext.c +27 -0
  77. data/ext/digest/crc32_jam/extconf.rb +7 -0
  78. data/ext/digest/crc32_mpeg/crc32_mpeg.c +69 -0
  79. data/ext/digest/crc32_mpeg/crc32_mpeg.h +8 -0
  80. data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +27 -0
  81. data/ext/digest/crc32_mpeg/extconf.rb +7 -0
  82. data/ext/digest/crc32_posix/crc32_posix.c +69 -0
  83. data/ext/digest/crc32_posix/crc32_posix.h +8 -0
  84. data/ext/digest/crc32_posix/crc32_posix_ext.c +27 -0
  85. data/ext/digest/crc32_posix/extconf.rb +7 -0
  86. data/ext/digest/crc32_xfer/crc32_xfer.c +69 -0
  87. data/ext/digest/crc32_xfer/crc32_xfer.h +8 -0
  88. data/ext/digest/crc32_xfer/crc32_xfer_ext.c +27 -0
  89. data/ext/digest/crc32_xfer/extconf.rb +7 -0
  90. data/ext/digest/crc32c/crc32c.c +69 -0
  91. data/ext/digest/crc32c/crc32c.h +8 -0
  92. data/ext/digest/crc32c/crc32c_ext.c +27 -0
  93. data/ext/digest/crc32c/extconf.rb +7 -0
  94. data/ext/digest/crc5/crc5.c +53 -0
  95. data/ext/digest/crc5/crc5.h +11 -0
  96. data/ext/digest/crc5/crc5_ext.c +27 -0
  97. data/ext/digest/crc5/extconf.rb +7 -0
  98. data/ext/digest/crc64/crc64.c +102 -0
  99. data/ext/digest/crc64/crc64.h +11 -0
  100. data/ext/digest/crc64/crc64_ext.c +27 -0
  101. data/ext/digest/crc64/extconf.rb +7 -0
  102. data/ext/digest/crc64_jones/crc64_jones.c +102 -0
  103. data/ext/digest/crc64_jones/crc64_jones.h +8 -0
  104. data/ext/digest/crc64_jones/crc64_jones_ext.c +27 -0
  105. data/ext/digest/crc64_jones/extconf.rb +7 -0
  106. data/ext/digest/crc64_xz/crc64_xz.c +102 -0
  107. data/ext/digest/crc64_xz/crc64_xz.h +8 -0
  108. data/ext/digest/crc64_xz/crc64_xz_ext.c +27 -0
  109. data/ext/digest/crc64_xz/extconf.rb +7 -0
  110. data/ext/digest/crc8/crc8.c +53 -0
  111. data/ext/digest/crc8/crc8.h +11 -0
  112. data/ext/digest/crc8/crc8_ext.c +27 -0
  113. data/ext/digest/crc8/extconf.rb +7 -0
  114. data/ext/digest/crc8_1wire/crc8_1wire.c +53 -0
  115. data/ext/digest/crc8_1wire/crc8_1wire.h +8 -0
  116. data/ext/digest/crc8_1wire/crc8_1wire_ext.c +27 -0
  117. data/ext/digest/crc8_1wire/extconf.rb +7 -0
  118. data/gemspec.yml +14 -6
  119. data/lib/digest/crc.rb +11 -3
  120. data/lib/digest/crc15.rb +70 -0
  121. data/lib/digest/crc16.rb +4 -0
  122. data/lib/digest/crc16_ccitt.rb +5 -1
  123. data/lib/digest/crc16_dnp.rb +4 -0
  124. data/lib/digest/crc16_genibus.rb +72 -0
  125. data/lib/digest/crc16_kermit.rb +66 -0
  126. data/lib/digest/crc16_modbus.rb +4 -0
  127. data/lib/digest/crc16_qt.rb +3 -58
  128. data/lib/digest/crc16_usb.rb +4 -0
  129. data/lib/digest/crc16_x_25.rb +56 -0
  130. data/lib/digest/crc16_xmodem.rb +4 -0
  131. data/lib/digest/crc16_zmodem.rb +4 -0
  132. data/lib/digest/crc24.rb +4 -0
  133. data/lib/digest/crc32.rb +6 -2
  134. data/lib/digest/crc32_bzip2.rb +64 -0
  135. data/lib/digest/crc32_jam.rb +16 -0
  136. data/lib/digest/crc32_mpeg.rb +9 -1
  137. data/lib/digest/crc32_posix.rb +65 -0
  138. data/lib/digest/crc32_xfer.rb +68 -0
  139. data/lib/digest/crc32c.rb +4 -0
  140. data/lib/digest/crc5.rb +17 -0
  141. data/lib/digest/crc64.rb +4 -0
  142. data/lib/digest/crc64_jones.rb +88 -0
  143. data/lib/digest/crc64_xz.rb +90 -0
  144. data/lib/digest/crc8.rb +4 -0
  145. data/lib/digest/crc8_1wire.rb +9 -2
  146. data/spec/crc15_spec.rb +10 -0
  147. data/spec/crc16_genibus_spec.rb +10 -0
  148. data/spec/crc16_kermit_spec.rb +10 -0
  149. data/spec/crc16_qt_spec.rb +5 -5
  150. data/spec/crc16_x_25_spec.rb +10 -0
  151. data/spec/crc32_bzip2_spec.rb +10 -0
  152. data/spec/crc32_jam_spec.rb +10 -0
  153. data/spec/crc32_mpeg_spec.rb +7 -1
  154. data/spec/crc32_posix_spec.rb +10 -0
  155. data/spec/crc32_xfer_spec.rb +10 -0
  156. data/spec/crc64_jones_spec.rb +10 -0
  157. data/spec/crc64_xz_spec.rb +10 -0
  158. data/spec/crc8_1wire_spec.rb +7 -1
  159. data/spec/crc_examples.rb +3 -3
  160. data/spec/crc_spec.rb +21 -13
  161. data/spec/spec_helper.rb +0 -1
  162. metadata +150 -45
  163. data/.gemtest +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5090c17bdfb58a94270e81bab8753095324379c5
4
- data.tar.gz: ec891e2886a61cd48e28f2a119ebb48bd01f68b7
2
+ SHA256:
3
+ metadata.gz: 1fe46270c7eae650508a5502eebb79a4869fbae54d0fbe839821d10875fb0ecf
4
+ data.tar.gz: 4beab2099969546a407771454e5ded1a5490372418b33b078140f8cac82a2c97
5
5
  SHA512:
6
- metadata.gz: 5539def533acad46a8a1ac25c602bee61832c9912598975884c25388e369658ce59245f6160ef1341b216a8b3e6aceb59c23f9b8b1e62dece990dad3ac3d2742
7
- data.tar.gz: bf09d57ef56303bd70d0df44fa20a1e2d2fd107bf052fa31ba6191a827cbaa81659eb7aa2fb795f694f0f036abd653b425cd60388106df30275aadb343eaeded
6
+ metadata.gz: e62799bcab7e38e635d5619beb1ac13c9c4cc5c0017604b5e060672190fc7c5fdc6bfbdc48d164bf191d5906d868f4552a6318930a6fa3d1983cac63acdf8aa5
7
+ data.tar.gz: ff41e5f57d9f9b523105b72f76662b8fac5a1df7485742378bb93ed3e982fb8d69eae14199e7d285e38102d7e3970708b6615919502783f6050278a029666360
data/.gitignore CHANGED
@@ -1,4 +1,10 @@
1
+ Gemfile.lock
1
2
  doc
2
3
  pkg
3
4
  .bundle
4
5
  .yardoc
6
+ /ext/digest/crc*/Makefile
7
+ /ext/digest/crc*/mkmf.log
8
+ /ext/digest/crc*/extconf.h
9
+ /ext/digest/crc*/*.o
10
+ /ext/digest/crc*/*.so
@@ -0,0 +1,24 @@
1
+ ---
2
+ before_install:
3
+ - gem update --system
4
+ - gem install bundler -v "~> 2.0"
5
+
6
+ language: ruby
7
+ sudo: false
8
+ cache:
9
+ - bundler
10
+
11
+ rvm:
12
+ - 2.5
13
+ - 2.6
14
+ - 2.7
15
+ - jruby
16
+
17
+ matrix:
18
+ include:
19
+ - os: linux
20
+ - os: osx
21
+ allow_failures:
22
+ - rvm: jruby
23
+
24
+ script: bundle exec rake spec
data/.yardopts CHANGED
@@ -1,2 +1 @@
1
- --markup-provider redcarpet
2
1
  --markup markdown --title 'Digest CRC Documentation' --protected --files ChangeLog.md,LICENSE.txt
@@ -1,3 +1,141 @@
1
+ ### 0.6.0 / 2020-07-01
2
+
3
+ * Implement _optional_ C extensions for all CRC algorithms, resulting in an
4
+ average performance improvement of ~40x. Note, if for whatever reason the
5
+ C extensions cannot be compiled, they will be skipped and the pure-Ruby
6
+ CRC algorithms will be used instead. If the C extensions were successfully
7
+ compiled, then they will be loaded and override the pure-Ruby CRC methods with
8
+ the C equivalents.
9
+ * Alias {Digest::CRC16QT} to {Digest::CRC16X25}, since they are effectively the same (@dearblue).
10
+ * Fix {Digest::CRC32::WIDTH} (@dearblue).
11
+
12
+ #### pure-Ruby (ruby 2.7.1)
13
+
14
+ Loading Digest::CRC classes ...
15
+ Generating 1000 8Kb lengthed strings ...
16
+ Benchmarking Digest::CRC classes ...
17
+ user system total real
18
+ Digest::CRC1#update 0.412953 0.000000 0.412953 ( 0.414688)
19
+ Digest::CRC5#update 1.116375 0.000003 1.116378 ( 1.120741)
20
+ Digest::CRC8#update 0.994263 0.000013 0.994276 ( 1.001079)
21
+ Digest::CRC8_1Wire#update 0.974115 0.000004 0.974119 ( 0.978186)
22
+ Digest::CRC15#update 1.139402 0.000927 1.140329 ( 1.146608)
23
+ Digest::CRC16#update 0.967836 0.000000 0.967836 ( 0.971792)
24
+ Digest::CRC16CCITT#update 1.118851 0.000000 1.118851 ( 1.123217)
25
+ Digest::CRC16DNP#update 0.922211 0.000000 0.922211 ( 0.925739)
26
+ Digest::CRC16Genibus#update 1.120580 0.000000 1.120580 ( 1.124771)
27
+ Digest::CRC16Modbus#update 0.955612 0.000000 0.955612 ( 0.959463)
28
+ Digest::CRC16QT#update 8.153403 0.000012 8.153415 ( 8.189977)
29
+ Digest::CRC16USB#update 0.952557 0.000000 0.952557 ( 0.956145)
30
+ Digest::CRC16X25#update 0.962295 0.000000 0.962295 ( 0.970401)
31
+ Digest::CRC16XModem#update 1.120531 0.000000 1.120531 ( 1.124494)
32
+ Digest::CRC16ZModem#update 1.124226 0.000000 1.124226 ( 1.128632)
33
+ Digest::CRC24#update 1.126317 0.000000 1.126317 ( 1.130794)
34
+ Digest::CRC32#update 0.960015 0.000000 0.960015 ( 0.964803)
35
+ Digest::CRC32BZip2#update 1.128626 0.000000 1.128626 ( 1.133641)
36
+ Digest::CRC32c#update 0.964047 0.000000 0.964047 ( 0.967456)
37
+ Digest::CRC32Jam#update 0.959141 0.000972 0.960113 ( 0.967444)
38
+ Digest::CRC32MPEG#update 1.131119 0.000002 1.131121 ( 1.137440)
39
+ Digest::CRC32POSIX#update 1.126019 0.000000 1.126019 ( 1.130549)
40
+ Digest::CRC32XFER#update 1.116598 0.000000 1.116598 ( 1.120595)
41
+ Digest::CRC64#update 2.665880 0.000928 2.666808 ( 2.680942)
42
+ Digest::CRC64Jones#update 2.678003 0.000000 2.678003 ( 2.691390)
43
+ Digest::CRC64XZ#update 2.671395 0.000000 2.671395 ( 2.682684)
44
+
45
+ #### pure-Ruby (jruby 9.2.11.1)
46
+
47
+ Loading Digest::CRC classes ...
48
+ Generating 1000 8Kb lengthed strings ...
49
+ Benchmarking Digest::CRC classes ...
50
+ user system total real
51
+ Digest::CRC1#update 0.700000 0.070000 0.770000 ( 0.436112)
52
+ Digest::CRC5#update 1.930000 0.050000 1.980000 ( 1.084749)
53
+ Digest::CRC8#update 1.510000 0.060000 1.570000 ( 0.979123)
54
+ Digest::CRC8_1Wire#update 0.730000 0.030000 0.760000 ( 0.761309)
55
+ Digest::CRC15#update 1.760000 0.080000 1.840000 ( 1.061413)
56
+ Digest::CRC16#update 1.560000 0.030000 1.590000 ( 0.951273)
57
+ Digest::CRC16CCITT#update 1.700000 0.010000 1.710000 ( 1.046854)
58
+ Digest::CRC16DNP#update 1.490000 0.000000 1.490000 ( 0.902434)
59
+ Digest::CRC16Genibus#update 1.820000 0.020000 1.840000 ( 1.030269)
60
+ Digest::CRC16Modbus#update 0.740000 0.010000 0.750000 ( 0.738604)
61
+ Digest::CRC16QT#update 7.280000 0.040000 7.320000 ( 6.399987)
62
+ Digest::CRC16USB#update 0.930000 0.000000 0.930000 ( 0.801541)
63
+ Digest::CRC16X25#update 0.870000 0.000000 0.870000 ( 0.805130)
64
+ Digest::CRC16XModem#update 1.320000 0.010000 1.330000 ( 0.968956)
65
+ Digest::CRC16ZModem#update 1.300000 0.010000 1.310000 ( 0.928303)
66
+ Digest::CRC24#update 1.550000 0.020000 1.570000 ( 1.024450)
67
+ Digest::CRC32#update 1.260000 0.000000 1.260000 ( 0.913814)
68
+ Digest::CRC32BZip2#update 1.210000 0.010000 1.220000 ( 0.919086)
69
+ Digest::CRC32c#update 0.770000 0.010000 0.780000 ( 0.761726)
70
+ Digest::CRC32Jam#update 0.930000 0.000000 0.930000 ( 0.800468)
71
+ Digest::CRC32MPEG#update 1.240000 0.010000 1.250000 ( 0.933962)
72
+ Digest::CRC32POSIX#update 1.290000 0.010000 1.300000 ( 0.925254)
73
+ Digest::CRC32XFER#update 1.270000 0.000000 1.270000 ( 0.920521)
74
+ Digest::CRC64#update 3.480000 0.020000 3.500000 ( 2.883794)
75
+ Digest::CRC64Jones#update 2.740000 0.000000 2.740000 ( 2.738251)
76
+ Digest::CRC64XZ#update 2.780000 0.010000 2.790000 ( 2.715833)
77
+
78
+
79
+ #### C extensions (ruby 2.7.1)
80
+
81
+ Loading Digest::CRC classes ...
82
+ Generating 1000 8Kb lengthed strings ...
83
+ Benchmarking Digest::CRC classes ...
84
+ user system total real
85
+ Digest::CRC1#update 0.407438 0.000000 0.407438 ( 0.410495)
86
+ Digest::CRC5#update 0.022873 0.000000 0.022873 ( 0.023796)
87
+ Digest::CRC8#update 0.020129 0.000000 0.020129 ( 0.020887)
88
+ Digest::CRC8_1Wire#update 0.020106 0.000000 0.020106 ( 0.020897)
89
+ Digest::CRC15#update 0.028765 0.000003 0.028768 ( 0.029549)
90
+ Digest::CRC16#update 0.022176 0.000856 0.023032 ( 0.023153)
91
+ Digest::CRC16CCITT#update 0.028570 0.000000 0.028570 ( 0.028691)
92
+ Digest::CRC16DNP#update 0.023240 0.000001 0.023241 ( 0.024008)
93
+ Digest::CRC16Genibus#update 0.028692 0.000000 0.028692 ( 0.029575)
94
+ Digest::CRC16Modbus#update 0.023928 0.000000 0.023928 ( 0.024859)
95
+ Digest::CRC16QT#update 7.965822 0.000968 7.966790 ( 8.001781)
96
+ Digest::CRC16USB#update 0.023448 0.000001 0.023449 ( 0.024420)
97
+ Digest::CRC16X25#update 0.023061 0.000000 0.023061 ( 0.023861)
98
+ Digest::CRC16XModem#update 0.029407 0.000000 0.029407 ( 0.030583)
99
+ Digest::CRC16ZModem#update 0.029522 0.000000 0.029522 ( 0.030438)
100
+ Digest::CRC24#update 0.029528 0.000000 0.029528 ( 0.030504)
101
+ Digest::CRC32#update 0.023306 0.000000 0.023306 ( 0.024278)
102
+ Digest::CRC32BZip2#update 0.026346 0.000000 0.026346 ( 0.027293)
103
+ Digest::CRC32c#update 0.023525 0.000000 0.023525 ( 0.024489)
104
+ Digest::CRC32Jam#update 0.023348 0.000000 0.023348 ( 0.023477)
105
+ Digest::CRC32MPEG#update 0.026287 0.000000 0.026287 ( 0.027394)
106
+ Digest::CRC32POSIX#update 0.026063 0.000000 0.026063 ( 0.026986)
107
+ Digest::CRC32XFER#update 0.026374 0.000000 0.026374 ( 0.027314)
108
+ Digest::CRC64#update 0.023523 0.000000 0.023523 ( 0.024484)
109
+ Digest::CRC64Jones#update 0.023479 0.000000 0.023479 ( 0.024432)
110
+ Digest::CRC64XZ#update 0.024146 0.000000 0.024146 ( 0.025129)
111
+
112
+ ### 0.5.1 / 2020-03-03
113
+
114
+ * Fixed XOR logic in {Digest::CRC16Genibus}.
115
+ * Freeze all `TABLE` constants.
116
+ * Added missing documentation.
117
+
118
+ ### 0.5.0 / 2020-03-01
119
+
120
+ * Added {Digest::CRC15}.
121
+ * Added {Digest::CRC16Genibus}.
122
+ * Added {Digest::CRC16Kermit}.
123
+ * Added {Digest::CRC16X25}.
124
+ * Added {Digest::CRC32BZip2}.
125
+ * Added {Digest::CRC32Jam}.
126
+ * Added {Digest::CRC32POSIX}.
127
+ * Added {Digest::CRC32XFER}.
128
+ * Added {Digest::CRC64Jones}.
129
+ * Added {Digest::CRC64XZ}.
130
+ * Renamed `Digest::CRC32Mpeg` to {Digest::CRC32MPEG}.
131
+ * Renamed `Digest::CRC81Wire` to {Digest::CRC8_1Wire}.
132
+
133
+ ### 0.4.2 / 2020-03-01
134
+
135
+ * Corrected the logic in {Digest::CRC32#update}.
136
+ * Added missing {Digest::CRC5.pack} method.
137
+ * Fixed a require in `digest/crc8_1wire.rb`.
138
+
1
139
  ### 0.4.1 / 2014-04-16
2
140
 
3
141
  * Allow Digest CRC classes to be extended and their constants overriden.
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ gem 'rubygems-tasks', '~> 0.2'
8
+
9
+ gem 'rspec', '~> 3.0'
10
+
11
+ gem 'yard', '~> 0.9'
12
+ gem 'kramdown'
13
+ gem 'kramdown-parser-gfm'
14
+ gem 'github-markup', '~> 1.1'
15
+ end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2014 Hal Brodigan
1
+ Copyright (c) 2010-2020 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Digest CRC
2
2
 
3
+ [![Build Status](https://travis-ci.org/postmodern/digest-crc.svg?branch=master)](https://travis-ci.org/postmodern/digest-crc)
4
+
3
5
  * [Source](https://github.com/postmodern/digest-crc)
4
6
  * [Issues](https://github.com/postmodern/digest-crc/issues)
5
7
  * [Documentation](http://rubydoc.info/gems/digest-crc/frames)
@@ -16,22 +18,35 @@ module.
16
18
  * {Digest::CRC1 CRC1}
17
19
  * {Digest::CRC5 CRC5}
18
20
  * {Digest::CRC8 CRC8}
19
- * {Digest::CRC81Wire CRC8 1-Wire}
21
+ * {Digest::CRC8_1Wire CRC8 1-Wire}
22
+ * {Digest::CRC15 CRC15}
20
23
  * {Digest::CRC16 CRC16}
21
24
  * {Digest::CRC16CCITT CRC16 CCITT}
22
25
  * {Digest::CRC16DNP CRC16 DNP}
26
+ * {Digest::CRC16Genibus CRC16 Genibus}
27
+ * {Digest::CRC16Kermit CRC16 Kermit}
23
28
  * {Digest::CRC16Modbus CRC16 Modbus}
24
29
  * {Digest::CRC16USB CRC16 USB}
30
+ * {Digest::CRC16X25 CRC16 X25}
25
31
  * {Digest::CRC16XModem CRC16 XModem}
26
32
  * {Digest::CRC16ZModem CRC16 ZModem}
27
33
  * {Digest::CRC16QT CRC16 QT}
28
34
  * {Digest::CRC24 CRC24}
29
35
  * {Digest::CRC32 CRC32}
36
+ * {Digest::CRC32BZip2 CRC32 BZip2}
30
37
  * {Digest::CRC32c CRC32c}
31
- * {Digest::CRC32Mpeg CRC32 Mpeg}
38
+ * {Digest::CRC32Jam CRC32 Jam}
39
+ * {Digest::CRC32MPEG CRC32 MPEG}
40
+ * {Digest::CRC32POSIX CRC32 POSIX}
41
+ * {Digest::CRC32XFER CRC32 XFER}
32
42
  * {Digest::CRC64 CRC64}
43
+ * {Digest::CRC64Jones CRC64 Jones}
44
+ * {Digest::CRC64XZ CRC64 XZ}
33
45
  * Pure Ruby implementation.
34
46
  * Provides CRC Tables for optimized calculations.
47
+ * Supports _optional_ C extensions which increases performance by ~40x.
48
+ * If the C extensions cannot be compiled for whatever reason, digest-crc
49
+ will automatically fallback to the pure-Ruby implementation.
35
50
 
36
51
  ## Install
37
52
 
@@ -112,6 +127,6 @@ including their CRC Tables.
112
127
 
113
128
  ## License
114
129
 
115
- Copyright (c) 2010-2014 Hal Brodigan
130
+ Copyright (c) 2010-2020 Hal Brodigan
116
131
 
117
- See [LICENSE.txt](LICENSE.txt) for license information.
132
+ See {file:LICENSE.txt} for license information.
data/Rakefile CHANGED
@@ -1,40 +1,44 @@
1
1
  require 'rubygems'
2
- require 'rake'
3
2
 
4
3
  begin
5
- gem 'rubygems-tasks', '~> 0.1'
6
- require 'rubygems/tasks'
7
-
8
- Gem::Tasks.new
4
+ require 'bundler/setup'
9
5
  rescue LoadError => e
10
- warn e.message
11
- warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
6
+ abort e.message
12
7
  end
13
8
 
14
- begin
15
- gem 'rspec', '~> 2.4'
16
- require 'rspec/core/rake_task'
9
+ require 'rake'
10
+ require 'rubygems/tasks'
11
+ Gem::Tasks.new
17
12
 
18
- RSpec::Core::RakeTask.new
19
- rescue LoadError => e
20
- task :spec do
21
- puts e.message
13
+ namespace :build do
14
+ desc "Builds the C extensions"
15
+ task :c_exts do
16
+ Dir.chdir('ext/digest') { sh 'rake' }
22
17
  end
23
18
  end
24
- task :test => :spec
25
- task :default => :spec
26
19
 
27
- begin
28
- gem 'yard', '~> 0.8'
29
- gem 'redcarpet'
30
- gem 'github-markup'
31
- require 'yard'
32
- require 'redcarpet'
33
- require 'github-markup'
34
-
35
- YARD::Rake::YardocTask.new
36
- rescue LoadError => e
37
- task :yard do
38
- puts e.message
20
+ require 'rake/clean'
21
+ CLEAN.include('ext/digest/crc*/extconf.h')
22
+ CLEAN.include('ext/digest/crc*/Makefile')
23
+ CLEAN.include('ext/digest/crc*/*.o')
24
+ CLEAN.include('ext/digest/crc*/*.so')
25
+
26
+ require 'rspec/core/rake_task'
27
+ namespace :spec do
28
+ RSpec::Core::RakeTask.new(:pure)
29
+ task :pure => :clean
30
+
31
+ if RUBY_ENGINE == 'ruby'
32
+ RSpec::Core::RakeTask.new(:c_exts)
33
+ task :c_exts => 'build:c_exts'
39
34
  end
40
35
  end
36
+
37
+ task :spec => 'spec:pure'
38
+ task :spec => 'spec:c_exts' if RUBY_ENGINE == 'ruby'
39
+ task :test => :spec
40
+ task :default => :spec
41
+
42
+ require 'yard'
43
+ YARD::Rake::YardocTask.new
44
+ task :doc => :yard
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ require 'benchmark'
3
+ $LOAD_PATH.unshift(File.expand_path('../ext',__FILE__))
4
+ $LOAD_PATH.unshift(File.expand_path('../lib',__FILE__))
5
+
6
+ CRCs = {
7
+ 'crc1' => 'CRC1',
8
+ 'crc5' => 'CRC5',
9
+ 'crc8' => 'CRC8',
10
+ 'crc8_1wire' => 'CRC81Wire',
11
+ 'crc15' => 'CRC15',
12
+ 'crc16' => 'CRC16',
13
+ 'crc16_ccitt' => 'CRC16CCITT',
14
+ 'crc16_dnp' => 'CRC16DNP',
15
+ 'crc16_genibus' => 'CRC16Genibus',
16
+ 'crc16_modbus' => 'CRC16Modbus',
17
+ 'crc16_qt' => 'CRC16QT',
18
+ 'crc16_usb' => 'CRC16USB',
19
+ 'crc16_x_25' => 'CRC16X25',
20
+ 'crc16_xmodem' => 'CRC16XModem',
21
+ 'crc16_zmodem' => 'CRC16ZModem',
22
+ 'crc24' => 'CRC24',
23
+ 'crc32' => 'CRC32',
24
+ 'crc32_bzip2' => 'CRC32BZip2',
25
+ 'crc32c' => 'CRC32c',
26
+ 'crc32_jam' => 'CRC32Jam',
27
+ 'crc32_mpeg' => 'CRC32Mpeg',
28
+ 'crc32_posix' => 'CRC32POSIX',
29
+ 'crc32_xfer' => 'CRC32XFER',
30
+ 'crc64' => 'CRC64',
31
+ 'crc64_jones' => 'CRC64Jones',
32
+ 'crc64_xz' => 'CRC64XZ',
33
+ }
34
+
35
+ puts "Loading Digest::CRC classes ..."
36
+ CRCs.each_key { |crc| require "digest/#{crc}" }
37
+
38
+ N = 1000
39
+ BLOCK_SIZE = 8 * 1024
40
+
41
+ puts "Generating #{N} #{BLOCK_SIZE / 1024}Kb lengthed strings ..."
42
+ SAMPLES = Array.new(N) do
43
+ Array.new(BLOCK_SIZE) { rand(256).chr }.join
44
+ end
45
+
46
+ puts "Benchmarking Digest::CRC classes ..."
47
+ Benchmark.bm do |b|
48
+ CRCs.each_value do |crc|
49
+ crc_class = Digest.const_get(crc)
50
+ crc = crc_class.new
51
+
52
+ b.report("#{crc_class}#update") do
53
+ SAMPLES.each do |sample|
54
+ crc.update(sample)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
12
 
13
13
  require 'digest/crc/version'
14
- Digest::Crc::VERSION
14
+ Digest::CRC::VERSION
15
15
  end
16
16
 
17
17
  gem.summary = gemspec['summary']
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.authors = Array(gemspec['authors'])
21
21
  gem.email = gemspec['email']
22
22
  gem.homepage = gemspec['homepage']
23
+ gem.metadata = gemspec['metadata'] if gemspec['metadata']
23
24
 
24
25
  glob = lambda { |patterns| gem.files & Dir[*patterns] }
25
26
 
@@ -0,0 +1,51 @@
1
+ def fail_gracefully(message)
2
+ warn "#{message}. Failing gracefully ..."
3
+ exit
4
+ end
5
+
6
+ unless RUBY_ENGINE == 'ruby'
7
+ fail_gracefully "C extensions for #{RUBY_ENGINE} currently not supported"
8
+ end
9
+
10
+ begin
11
+ require "mkmf"
12
+ rescue LoadError
13
+ fail_gracefully "mkmf is not installed"
14
+ end
15
+
16
+ MAKE = $make # set by mkmf
17
+
18
+ def make(target=nil)
19
+ if target then sh(MAKE,target)
20
+ else sh(MAKE)
21
+ end
22
+ end
23
+
24
+ CRCS = Dir['crc*']
25
+ DLEXT = MakeMakefile::CONFIG['DLEXT']
26
+
27
+ CRCS.each do |crc|
28
+ crc_ext = "#{crc}_ext"
29
+
30
+ file "#{crc}/Makefile" => "#{crc}/extconf.rb" do
31
+ Dir.chdir(crc) do
32
+ unless ruby('-S', 'extconf.rb')
33
+ fail_gracefully "extconf.rb failed"
34
+ end
35
+ end
36
+ end
37
+
38
+ crc_ext_lib = "#{crc}_ext.#{DLEXT}"
39
+
40
+ file "#{crc}/#{crc_ext_lib}" => "#{crc}/Makefile" do
41
+ Dir.chdir(crc) do
42
+ make 'clean'
43
+
44
+ unless make
45
+ fail_gracefully "Unable to build C extensions"
46
+ end
47
+ end
48
+ end
49
+
50
+ task :default => "#{crc}/#{crc_ext_lib}"
51
+ end