digest-crc 0.1.0

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.
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'crc_examples'
3
+ require 'digest/crc32'
4
+
5
+ describe Digest::CRC32 do
6
+ before(:all) do
7
+ @crc_class = Digest::CRC32
8
+ @string = '1234567890'
9
+ @expected = '261daee5'
10
+ end
11
+
12
+ it_should_behave_like "CRC"
13
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'crc_examples'
3
+ require 'digest/crc5'
4
+
5
+ describe Digest::CRC5 do
6
+ before { pending }
7
+ before(:all) do
8
+ @crc_class = Digest::CRC5
9
+ @string = '1234567890'
10
+ @expected = '1'
11
+ end
12
+
13
+ it_should_behave_like "CRC"
14
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'crc_examples'
3
+ require 'digest/crc64'
4
+
5
+ describe Digest::CRC64 do
6
+ before(:all) do
7
+ @crc_class = Digest::CRC64
8
+ @string = '1234567890'
9
+ @expected = 'bc66a5a9388a5bef'
10
+ end
11
+
12
+ it_should_behave_like "CRC"
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'crc_examples'
3
+ require 'digest/crc8'
4
+
5
+ describe Digest::CRC8 do
6
+ before(:all) do
7
+ @crc_class = Digest::CRC8
8
+ @string = '1234567890'
9
+ @expected = '52'
10
+ end
11
+
12
+ it_should_behave_like "CRC"
13
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for "CRC" do
4
+ it "should calculate a checksum for text" do
5
+ @crc_class.hexdigest(@string).should == @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 = @crc_class.new
15
+ crc << chunk1
16
+ crc << chunk2
17
+
18
+ crc.hexdigest.should == @expected
19
+ end
20
+
21
+ it "should provide direct access to the checksum value" do
22
+ crc = @crc_class.new
23
+ crc << @string
24
+
25
+ crc.checksum.should == @expected.to_i(16)
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'digest/crc'
3
+
4
+ describe Digest::CRC do
5
+ it "should define block_length of 1" do
6
+ crc = Digest::CRC.new
7
+
8
+ crc.block_length.should == 1
9
+ end
10
+
11
+ it "should pack to an empty String by default" do
12
+ Digest::CRC.pack(0).should be_empty
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ gem 'rspec', '>= 1.3.0'
3
+
4
+ require 'spec'
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: digest-crc
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Postmodern
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-01 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 27
30
+ segments:
31
+ - 1
32
+ - 3
33
+ - 0
34
+ version: 1.3.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: Adds support for calculating Cyclic Redundancy Check (CRC) to the Digest module.
38
+ email: postmodern.mod3@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - ChangeLog.md
45
+ - LICENSE.txt
46
+ - README.md
47
+ files:
48
+ - .gitignore
49
+ - .specopts
50
+ - .yardopts
51
+ - ChangeLog.md
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - VERSION
56
+ - digest-crc.gemspec
57
+ - lib/digest/crc.rb
58
+ - lib/digest/crc1.rb
59
+ - lib/digest/crc16.rb
60
+ - lib/digest/crc16_ccitt.rb
61
+ - lib/digest/crc16_dnp.rb
62
+ - lib/digest/crc16_modbus.rb
63
+ - lib/digest/crc16_usb.rb
64
+ - lib/digest/crc16_xmodem.rb
65
+ - lib/digest/crc16_zmodem.rb
66
+ - lib/digest/crc24.rb
67
+ - lib/digest/crc32.rb
68
+ - lib/digest/crc32_mpeg.rb
69
+ - lib/digest/crc5.rb
70
+ - lib/digest/crc64.rb
71
+ - lib/digest/crc8.rb
72
+ - spec/crc16_ccitt_spec.rb
73
+ - spec/crc16_modbus_spec.rb
74
+ - spec/crc16_spec.rb
75
+ - spec/crc16_usb_spec.rb
76
+ - spec/crc16_xmodem_spec.rb
77
+ - spec/crc16_zmodem_spec.rb
78
+ - spec/crc1_spec.rb
79
+ - spec/crc24_spec.rb
80
+ - spec/crc32_mpeg_spec.rb
81
+ - spec/crc32_spec.rb
82
+ - spec/crc5_spec.rb
83
+ - spec/crc64_spec.rb
84
+ - spec/crc8_spec.rb
85
+ - spec/crc_examples.rb
86
+ - spec/crc_spec.rb
87
+ - spec/spec_helper.rb
88
+ has_rdoc: yard
89
+ homepage: http://github.com/postmodern/digest-crc
90
+ licenses:
91
+ - MIT
92
+ post_install_message:
93
+ rdoc_options:
94
+ - --charset=UTF-8
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ requirements: []
116
+
117
+ rubyforge_project:
118
+ rubygems_version: 1.3.7
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: A Cyclic Redundancy Check (CRC) library for Ruby.
122
+ test_files:
123
+ - spec/crc_spec.rb
124
+ - spec/crc8_spec.rb
125
+ - spec/crc64_spec.rb
126
+ - spec/spec_helper.rb
127
+ - spec/crc32_mpeg_spec.rb
128
+ - spec/crc_examples.rb
129
+ - spec/crc16_spec.rb
130
+ - spec/crc16_xmodem_spec.rb
131
+ - spec/crc5_spec.rb
132
+ - spec/crc1_spec.rb
133
+ - spec/crc16_usb_spec.rb
134
+ - spec/crc16_zmodem_spec.rb
135
+ - spec/crc32_spec.rb
136
+ - spec/crc24_spec.rb
137
+ - spec/crc16_ccitt_spec.rb
138
+ - spec/crc16_modbus_spec.rb