digest-crc 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/ChangeLog.md +4 -0
- data/README.md +16 -15
- data/Rakefile +2 -2
- data/digest-crc.gemspec +125 -13
- data/gemspec.yml +1 -1
- data/lib/digest/crc8_1wire.rb +61 -0
- data/spec/crc16_ccitt_spec.rb +2 -5
- data/spec/crc16_modbus_spec.rb +2 -5
- data/spec/crc16_spec.rb +2 -5
- data/spec/crc16_usb_spec.rb +2 -5
- data/spec/crc16_xmodem_spec.rb +2 -5
- data/spec/crc16_zmodem_spec.rb +2 -5
- data/spec/crc1_spec.rb +2 -5
- data/spec/crc24_spec.rb +2 -5
- data/spec/crc32_mpeg_spec.rb +2 -5
- data/spec/crc32_spec.rb +2 -5
- data/spec/crc32c_spec.rb +2 -5
- data/spec/crc5_spec.rb +2 -5
- data/spec/crc64_spec.rb +2 -5
- data/spec/crc8_1wire_spec.rb +10 -0
- data/spec/crc8_spec.rb +2 -5
- data/spec/crc_examples.rb +9 -9
- data/spec/crc_spec.rb +2 -2
- metadata +59 -58
data/.gitignore
ADDED
data/ChangeLog.md
CHANGED
data/README.md
CHANGED
@@ -13,21 +13,22 @@ module.
|
|
13
13
|
## Features
|
14
14
|
|
15
15
|
* Provides support for the following CRC algorithms:
|
16
|
-
* CRC1
|
17
|
-
* CRC5
|
18
|
-
* CRC8
|
19
|
-
*
|
20
|
-
* CRC16
|
21
|
-
* CRC16
|
22
|
-
* CRC16
|
23
|
-
* CRC16
|
24
|
-
* CRC16
|
25
|
-
* CRC16
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
*
|
30
|
-
*
|
16
|
+
* {Digest::CRC1 CRC1}
|
17
|
+
* {Digest::CRC5 CRC5}
|
18
|
+
* {Digest::CRC8 CRC8}
|
19
|
+
* {Digest::CRC81Wire CRC8 1-Wire}
|
20
|
+
* {Digest::CRC16 CRC16}
|
21
|
+
* {Digest::CRC16CCITT CRC16 CCITT}
|
22
|
+
* {Digest::CRC16DNP CRC16 DNP}
|
23
|
+
* {Digest::CRC16Modbus CRC16 Modbus}
|
24
|
+
* {Digest::CRC16USB CRC16 USB}
|
25
|
+
* {Digest::CRC16XModem CRC16 XModem}
|
26
|
+
* {Digest::CRC16ZModem CRC16 ZModem}
|
27
|
+
* {Digest::CRC24 CRC24}
|
28
|
+
* {Digest::CRC32 CRC32}
|
29
|
+
* {Digest::CRC32c CRC32c}
|
30
|
+
* {Digest::CRC32Mpeg CRC32 Mpeg}
|
31
|
+
* {Digest::CRC64 CRC64}
|
31
32
|
* Pure Ruby implementation.
|
32
33
|
* Provides CRC Tables for optimized calculations.
|
33
34
|
|
data/Rakefile
CHANGED
data/digest-crc.gemspec
CHANGED
@@ -1,15 +1,127 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gemspec|
|
6
|
+
files = if File.directory?('.git')
|
7
|
+
`git ls-files`.split($/)
|
8
|
+
elsif File.directory?('.hg')
|
9
|
+
`hg manifest`.split($/)
|
10
|
+
elsif File.directory?('.svn')
|
11
|
+
`svn ls -R`.split($/).select { |path| File.file?(path) }
|
12
|
+
else
|
13
|
+
Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
|
14
|
+
end
|
15
|
+
|
16
|
+
filter_files = lambda { |paths|
|
17
|
+
case paths
|
18
|
+
when Array
|
19
|
+
(files & paths)
|
20
|
+
when String
|
21
|
+
(files & Dir[paths])
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
version = {
|
26
|
+
:file => 'lib/digest/crc/version.rb',
|
27
|
+
:constant => 'Digest::CRC::VERSION'
|
28
|
+
}
|
29
|
+
|
30
|
+
defaults = {
|
31
|
+
'name' => File.basename(File.dirname(__FILE__)),
|
32
|
+
'files' => files,
|
33
|
+
'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
|
34
|
+
'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
|
35
|
+
'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
|
36
|
+
}
|
37
|
+
|
38
|
+
metadata = defaults.merge(YAML.load_file('gemspec.yml'))
|
39
|
+
|
40
|
+
gemspec.name = metadata.fetch('name',defaults[:name])
|
41
|
+
gemspec.version = if metadata['version']
|
42
|
+
metadata['version']
|
43
|
+
elsif File.file?(version[:file])
|
44
|
+
require File.join('.',version[:file])
|
45
|
+
eval(version[:constant])
|
46
|
+
end
|
47
|
+
|
48
|
+
gemspec.summary = metadata.fetch('summary',metadata['description'])
|
49
|
+
gemspec.description = metadata.fetch('description',metadata['summary'])
|
50
|
+
|
51
|
+
case metadata['license']
|
52
|
+
when Array
|
53
|
+
gemspec.licenses = metadata['license']
|
54
|
+
when String
|
55
|
+
gemspec.license = metadata['license']
|
56
|
+
end
|
57
|
+
|
58
|
+
case metadata['authors']
|
59
|
+
when Array
|
60
|
+
gemspec.authors = metadata['authors']
|
61
|
+
when String
|
62
|
+
gemspec.author = metadata['authors']
|
63
|
+
end
|
64
|
+
|
65
|
+
gemspec.email = metadata['email']
|
66
|
+
gemspec.homepage = metadata['homepage']
|
67
|
+
|
68
|
+
case metadata['require_paths']
|
69
|
+
when Array
|
70
|
+
gemspec.require_paths = metadata['require_paths']
|
71
|
+
when String
|
72
|
+
gemspec.require_path = metadata['require_paths']
|
73
|
+
end
|
74
|
+
|
75
|
+
gemspec.files = filter_files[metadata['files']]
|
76
|
+
|
77
|
+
gemspec.executables = metadata['executables']
|
78
|
+
gemspec.extensions = metadata['extensions']
|
79
|
+
|
80
|
+
if Gem::VERSION < '1.7.'
|
81
|
+
gemspec.default_executable = gemspec.executables.first
|
82
|
+
end
|
83
|
+
|
84
|
+
gemspec.test_files = filter_files[metadata['test_files']]
|
85
|
+
|
86
|
+
unless gemspec.files.include?('.document')
|
87
|
+
gemspec.extra_rdoc_files = metadata['extra_doc_files']
|
88
|
+
end
|
89
|
+
|
90
|
+
gemspec.post_install_message = metadata['post_install_message']
|
91
|
+
gemspec.requirements = metadata['requirements']
|
92
|
+
|
93
|
+
if gemspec.respond_to?(:required_ruby_version=)
|
94
|
+
gemspec.required_ruby_version = metadata['required_ruby_version']
|
95
|
+
end
|
96
|
+
|
97
|
+
if gemspec.respond_to?(:required_rubygems_version=)
|
98
|
+
gemspec.required_rubygems_version = metadata['required_ruby_version']
|
99
|
+
end
|
100
|
+
|
101
|
+
parse_versions = lambda { |versions|
|
102
|
+
case versions
|
103
|
+
when Array
|
104
|
+
versions.map { |v| v.to_s }
|
105
|
+
when String
|
106
|
+
versions.split(/,\s*/)
|
107
|
+
end
|
108
|
+
}
|
109
|
+
|
110
|
+
if metadata['dependencies']
|
111
|
+
metadata['dependencies'].each do |name,versions|
|
112
|
+
gemspec.add_dependency(name,parse_versions[versions])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
if metadata['runtime_dependencies']
|
117
|
+
metadata['runtime_dependencies'].each do |name,versions|
|
118
|
+
gemspec.add_runtime_dependency(name,parse_versions[versions])
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
if metadata['development_dependencies']
|
123
|
+
metadata['development_dependencies'].each do |name,versions|
|
124
|
+
gemspec.add_development_dependency(name,parse_versions[versions])
|
125
|
+
end
|
14
126
|
end
|
15
127
|
end
|
data/gemspec.yml
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'digest/crc'
|
2
|
+
|
3
|
+
module Digest
|
4
|
+
#
|
5
|
+
# Implements the CRC8 1-Wire algorithm.
|
6
|
+
#
|
7
|
+
class CRC81Wire < CRC
|
8
|
+
|
9
|
+
WIDTH = 8
|
10
|
+
|
11
|
+
INIT_CRC = 0x00
|
12
|
+
|
13
|
+
# Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c`
|
14
|
+
TABLE = [
|
15
|
+
0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41,
|
16
|
+
0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc,
|
17
|
+
0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62,
|
18
|
+
0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff,
|
19
|
+
0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07,
|
20
|
+
0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a,
|
21
|
+
0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24,
|
22
|
+
0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9,
|
23
|
+
0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd,
|
24
|
+
0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50,
|
25
|
+
0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee,
|
26
|
+
0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73,
|
27
|
+
0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b,
|
28
|
+
0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16,
|
29
|
+
0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8,
|
30
|
+
0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35
|
31
|
+
]
|
32
|
+
|
33
|
+
#
|
34
|
+
# Packs the CRC8 checksum.
|
35
|
+
#
|
36
|
+
# @param [Integer] crc
|
37
|
+
# The checksum to pack.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
# The packed checksum.
|
41
|
+
#
|
42
|
+
def self.pack(crc)
|
43
|
+
(crc & 0xff).chr
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Updates the CRC8 checksum.
|
48
|
+
#
|
49
|
+
# @param [String] data
|
50
|
+
# The data to update the checksum with.
|
51
|
+
#
|
52
|
+
def update(data)
|
53
|
+
data.each_byte do |b|
|
54
|
+
@crc = ((TABLE[(@crc ^ b) & 0xff] ^ (@crc << 8)) & 0xff)
|
55
|
+
end
|
56
|
+
|
57
|
+
return self
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
data/spec/crc16_ccitt_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc16_ccitt'
|
4
4
|
|
5
5
|
describe Digest::CRC16CCITT do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = '3218'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { '3218' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc16_modbus_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc16_modbus'
|
4
4
|
|
5
5
|
describe Digest::CRC16Modbus do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = 'c20a'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { 'c20a' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc16_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc16'
|
4
4
|
|
5
5
|
describe Digest::CRC16 do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = 'c57a'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { 'c57a' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc16_usb_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc16_usb'
|
4
4
|
|
5
5
|
describe Digest::CRC16USB do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = '3df5'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { '3df5' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc16_xmodem_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc16_xmodem'
|
4
4
|
|
5
5
|
describe Digest::CRC16XModem do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = 'd321'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { 'd321' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc16_zmodem_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc16_zmodem'
|
4
4
|
|
5
5
|
describe Digest::CRC16ZModem do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = 'd321'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { 'd321' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc1_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc1'
|
4
4
|
|
5
5
|
describe Digest::CRC1 do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = '0d'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { '0d' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc24_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc24'
|
4
4
|
|
5
5
|
describe Digest::CRC24 do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = '8c0072'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { '8c0072' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc32_mpeg_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc32_mpeg'
|
4
4
|
|
5
5
|
describe Digest::CRC32Mpeg do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = 'af97ac49'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { 'af97ac49' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc32_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc32'
|
4
4
|
|
5
5
|
describe Digest::CRC32 do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = '261daee5'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { '261daee5' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc32c_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc32c'
|
4
4
|
|
5
5
|
describe Digest::CRC32c do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = 'f3dbd4fe'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { 'f3dbd4fe' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc5_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc5'
|
4
4
|
|
5
5
|
describe Digest::CRC5 do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = '1'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { '1' }
|
11
8
|
|
12
9
|
pending "Implementation of CRC5 does not match pycrc.py" do
|
13
10
|
it_should_behave_like "CRC"
|
data/spec/crc64_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc64'
|
4
4
|
|
5
5
|
describe Digest::CRC64 do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = 'bc66a5a9388a5bef'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { 'bc66a5a9388a5bef' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc8_spec.rb
CHANGED
@@ -3,11 +3,8 @@ require 'crc_examples'
|
|
3
3
|
require 'digest/crc8'
|
4
4
|
|
5
5
|
describe Digest::CRC8 do
|
6
|
-
|
7
|
-
|
8
|
-
@string = '1234567890'
|
9
|
-
@expected = '52'
|
10
|
-
end
|
6
|
+
let(:string) { '1234567890' }
|
7
|
+
let(:expected) { '52' }
|
11
8
|
|
12
9
|
it_should_behave_like "CRC"
|
13
10
|
end
|
data/spec/crc_examples.rb
CHANGED
@@ -2,26 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
shared_examples_for "CRC" do
|
4
4
|
it "should calculate a checksum for text" do
|
5
|
-
|
5
|
+
described_class.hexdigest(string).should == expected
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should calculate a checksum for multiple data" do
|
9
|
-
middle = (
|
9
|
+
middle = (string.length / 2)
|
10
10
|
|
11
|
-
chunk1 =
|
12
|
-
chunk2 =
|
11
|
+
chunk1 = string[0...middle]
|
12
|
+
chunk2 = string[middle..-1]
|
13
13
|
|
14
|
-
crc =
|
14
|
+
crc = subject
|
15
15
|
crc << chunk1
|
16
16
|
crc << chunk2
|
17
17
|
|
18
|
-
crc.hexdigest.should ==
|
18
|
+
crc.hexdigest.should == expected
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should provide direct access to the checksum value" do
|
22
|
-
crc =
|
23
|
-
crc <<
|
22
|
+
crc = subject
|
23
|
+
crc << string
|
24
24
|
|
25
|
-
crc.checksum.should ==
|
25
|
+
crc.checksum.should == expected.to_i(16)
|
26
26
|
end
|
27
27
|
end
|
data/spec/crc_spec.rb
CHANGED
@@ -3,12 +3,12 @@ require 'digest/crc'
|
|
3
3
|
|
4
4
|
describe Digest::CRC do
|
5
5
|
it "should define block_length of 1" do
|
6
|
-
crc =
|
6
|
+
crc = subject
|
7
7
|
|
8
8
|
crc.block_length.should == 1
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should pack to an empty String by default" do
|
12
|
-
|
12
|
+
described_class.pack(0).should be_empty
|
13
13
|
end
|
14
14
|
end
|
metadata
CHANGED
@@ -1,61 +1,61 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: digest-crc
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Postmodern
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-24 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: ore-tasks
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &22462380 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
18
|
+
requirements:
|
21
19
|
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.4'
|
24
22
|
type: :development
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rspec
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *22462380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &22461360 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
29
|
+
requirements:
|
32
30
|
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version:
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.4'
|
35
33
|
type: :development
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: yard
|
39
34
|
prerelease: false
|
40
|
-
|
35
|
+
version_requirements: *22461360
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: yard
|
38
|
+
requirement: &22459440 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
|
-
requirements:
|
40
|
+
requirements:
|
43
41
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
45
43
|
version: 0.6.0
|
46
44
|
type: :development
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *22459440
|
47
|
+
description: Adds support for calculating Cyclic Redundancy Check (CRC) to the Digest
|
48
|
+
module.
|
49
|
+
email: postmodern.mod3@gmail.com
|
51
50
|
executables: []
|
52
|
-
|
53
51
|
extensions: []
|
54
|
-
|
55
|
-
|
52
|
+
extra_rdoc_files:
|
53
|
+
- ChangeLog.md
|
54
|
+
- LICENSE.txt
|
56
55
|
- README.md
|
57
|
-
files:
|
56
|
+
files:
|
58
57
|
- .gemtest
|
58
|
+
- .gitignore
|
59
59
|
- .rspec
|
60
60
|
- .yardopts
|
61
61
|
- ChangeLog.md
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/digest/crc5.rb
|
81
81
|
- lib/digest/crc64.rb
|
82
82
|
- lib/digest/crc8.rb
|
83
|
+
- lib/digest/crc8_1wire.rb
|
83
84
|
- spec/crc16_ccitt_spec.rb
|
84
85
|
- spec/crc16_modbus_spec.rb
|
85
86
|
- spec/crc16_spec.rb
|
@@ -93,50 +94,50 @@ files:
|
|
93
94
|
- spec/crc32c_spec.rb
|
94
95
|
- spec/crc5_spec.rb
|
95
96
|
- spec/crc64_spec.rb
|
97
|
+
- spec/crc8_1wire_spec.rb
|
96
98
|
- spec/crc8_spec.rb
|
97
99
|
- spec/crc_examples.rb
|
98
100
|
- spec/crc_spec.rb
|
99
101
|
- spec/spec_helper.rb
|
100
102
|
homepage: http://github.com/postmodern/digest-crc
|
101
|
-
licenses:
|
103
|
+
licenses:
|
102
104
|
- MIT
|
103
105
|
post_install_message:
|
104
106
|
rdoc_options: []
|
105
|
-
|
106
|
-
require_paths:
|
107
|
+
require_paths:
|
107
108
|
- lib
|
108
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
110
|
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version:
|
114
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
116
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version:
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
120
121
|
requirements: []
|
121
|
-
|
122
|
-
|
123
|
-
rubygems_version: 1.8.1
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.8.10
|
124
124
|
signing_key:
|
125
125
|
specification_version: 3
|
126
126
|
summary: A Cyclic Redundancy Check (CRC) library for Ruby.
|
127
|
-
test_files:
|
128
|
-
- spec/crc64_spec.rb
|
129
|
-
- spec/crc32_spec.rb
|
127
|
+
test_files:
|
130
128
|
- spec/crc16_ccitt_spec.rb
|
131
|
-
- spec/crc32_mpeg_spec.rb
|
132
129
|
- spec/crc16_modbus_spec.rb
|
133
|
-
- spec/crc1_spec.rb
|
134
|
-
- spec/crc_spec.rb
|
135
|
-
- spec/crc16_usb_spec.rb
|
136
130
|
- spec/crc16_spec.rb
|
131
|
+
- spec/crc16_usb_spec.rb
|
137
132
|
- spec/crc16_xmodem_spec.rb
|
138
|
-
- spec/crc8_spec.rb
|
139
133
|
- spec/crc16_zmodem_spec.rb
|
134
|
+
- spec/crc1_spec.rb
|
140
135
|
- spec/crc24_spec.rb
|
136
|
+
- spec/crc32_mpeg_spec.rb
|
137
|
+
- spec/crc32_spec.rb
|
141
138
|
- spec/crc32c_spec.rb
|
142
139
|
- spec/crc5_spec.rb
|
140
|
+
- spec/crc64_spec.rb
|
141
|
+
- spec/crc8_1wire_spec.rb
|
142
|
+
- spec/crc8_spec.rb
|
143
|
+
- spec/crc_spec.rb
|