ruby-xxHash 0.1.1 → 0.4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9166f045e1d36804e8c47a926f439d057294ad8ab680491efa6e9c9152e0eb71
4
+ data.tar.gz: dae6a2bc9ba43cb4e38753d8f670caa83d79a3800ebb5c44f0091e0c9a0f2767
5
+ SHA512:
6
+ metadata.gz: a9f8e8326dce8c1d8e94e0902b900cb86c9526a2d427020fc7fae0da159b7a2c12d5775e62c9c6cd318ff1787658e0bb745f02dd4f7ce9a365a207c23ce26b77
7
+ data.tar.gz: 7f9aaa93e9222de63661ecda365373142cffe79dda430763dba42b495663fb85cc0d40fbce177255c16b79a145791cf0129c767366210108f2457e55918cfb0c
data/.gitignore CHANGED
@@ -1,5 +1,8 @@
1
1
  *.gem
2
2
  *.rbc
3
+ **/*.iml
4
+ .idea/
5
+ ruby-xxhash/
3
6
  .bundle
4
7
  .config
5
8
  .yardoc
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # XXhash
1
+ # XXhash [![Build Status](https://travis-ci.org/justinwsmith/ruby-xxhash.svg?branch=master)](https://travis-ci.org/justinwsmith/ruby-xxhash)
2
2
 
3
- This gem provides a pure Ruby implementation of the XXhash32 hashing algorithm described here: https://code.google.com/p/xxhash/.
3
+ This gem provides a pure Ruby implementation of the XXhash32 and XXhash64 hashing algorithms described here: https://code.google.com/p/xxhash/.
4
4
 
5
5
  It's intended to be (mostly) source compatible with the Gem provided by nashby: https://github.com/nashby/xxhash
6
6
 
@@ -27,6 +27,7 @@ text = "test"
27
27
  seed = 12345
28
28
 
29
29
  XXhash.xxh32(text, seed) # => 3834992036
30
+ XXhash.xxh64(text, seed) # => 7624679986283906467
30
31
  ```
31
32
 
32
33
  ## Contributing
@@ -1,3 +1,3 @@
1
- class XXhash
2
- VERSION = "0.1.1"
1
+ module XXhash
2
+ VERSION = "0.4.0.2"
3
3
  end
data/lib/ruby-xxhash.rb CHANGED
@@ -1,128 +1,96 @@
1
- require "ruby-xxhash/version"
1
+ # Copyright 2014 Justin W. Smith
2
2
 
3
- class XXhash
4
- @@mem_total_size = 16
5
- @@prime32_1 = 2654435761
6
- @@prime32_2 = 2246822519
7
- @@prime32_3 = 3266489917
8
- @@prime32_4 = 668265263
9
- @@prime32_5 = 374761393
3
+ require "ruby-xxhash/version"
4
+ require "digest"
5
+ require "ruby-xxhash32"
6
+ require "ruby-xxhash64"
10
7
 
11
- @@thirtytwo1s = (2**32-1)
12
8
 
13
- def XXhash.xxh32(input, seed = 0)
14
- xxh = XXhash.new(seed)
15
- xxh.feed(input)
16
- xxh.sum32
9
+ module XXhash
10
+ def self.xxh32(input, seed = 0)
11
+ xxh = XXhashInternal::XXhash32.new(seed)
12
+ xxh.update(input)
13
+ xxh.digest
17
14
  end
18
15
 
19
- def XXhash.xxh32_stream(io, seed = 0, chunk = 32)
20
- xxh = XXhash.new(seed)
16
+ def self.xxh32_stream(io, seed = 0, chunk = 32)
17
+ xxh = XXhashInternal::XXhash32.new(seed)
21
18
 
22
19
  while(data = io.read(chunk))
23
- xxh.feed(data)
20
+ xxh.update(data)
24
21
  end
25
22
 
26
- xxh.sum32
23
+ xxh.digest
27
24
  end
28
25
 
29
- def initialize seed
30
- @seed = seed
31
- @v1 = seed + @@prime32_1 + @@prime32_2
32
- @v2 = seed + @@prime32_2
33
- @v3 = seed + 0
34
- @v4 = seed - @@prime32_1
35
- @total_len = 0
36
- @memory = Array.new(@@mem_total_size)
37
- @memsize = 0
26
+ def self.xxh64(input, seed = 0)
27
+ xxh = XXhashInternal::XXhash64.new(seed)
28
+ xxh.update(input)
29
+ xxh.digest
38
30
  end
39
31
 
32
+ def self.xxh64_stream(io, seed = 0, chunk = 32)
33
+ xxh = XXhashInternal::XXhash64.new(seed)
40
34
 
41
- def feed bytes
42
- if String === bytes
43
- bytes = bytes.unpack("C*")
35
+ while(data = io.read(chunk))
36
+ xxh.update(data)
44
37
  end
45
38
 
46
- @total_len += bytes.length
47
-
48
- p = 0
49
-
50
- while (remaining = (bytes.length - p)) > 0
51
-
52
- mem_avail = @@mem_total_size - @memsize
53
-
54
- if(remaining < mem_avail)
55
- @memory[@memsize, remaining] = bytes[p, remaining]
56
- @memsize += remaining
57
- break
58
- end
39
+ xxh.digest
40
+ end
59
41
 
60
- @memory[@memsize, mem_avail] = bytes[p, mem_avail]
42
+ end
61
43
 
62
- i = 0
63
- [:v1, :v2, :v3, :v4].each do |m|
64
- p32 = uint32(
65
- @memory[i] |
66
- (@memory[i+1] << 8) |
67
- (@memory[i+2] << 16) |
68
- (@memory[i+3] << 24))
69
44
 
70
- v = uint32(self.send(m) + p32 * @@prime32_2)
71
- v = uint32(uint32((v << 13) | (v >> (32 - 13))) * @@prime32_1)
72
- self.send((m.to_s + "=").to_sym, v)
73
- i += 4
45
+ module Digest
46
+ class XXHash < Digest::Class
47
+ attr_reader :digest_length
48
+ def initialize bitlen, seed = 0
49
+ case bitlen
50
+ when 32
51
+ @hash = XXhash::XXhashInternal::XXhash32.new(seed)
52
+ when 64
53
+ @hash = XXhash::XXhashInternal::XXhash64.new(seed)
54
+ else
55
+ raise ArgumentError, "Unsupported bit length: %s" % bitlen.inspect
74
56
  end
57
+ @digest_length = bitlen
58
+ end
75
59
 
76
- p += mem_avail
77
- @memsize = 0
60
+ def update chunk
61
+ @hash.update(chunk)
78
62
  end
79
63
 
80
- return true
81
- end
64
+ def digest val=nil
65
+ if val
66
+ @hash.update val
67
+ end
82
68
 
83
- def sum32
84
- if @total_len >= 16
85
- h32 = ((@v1 << 1) | (@v1 >> (32 - 1))) +
86
- ((@v2 << 7) | (@v2 >> (32 - 7))) +
87
- ((@v3 << 12) | (@v3 >> (32 - 12))) +
88
- ((@v4 << 18) | (@v4 >> (32 - 18)))
89
- else
90
- h32 = @seed + @@prime32_5
69
+ @hash.digest
91
70
  end
92
71
 
93
- h32 = uint32(h32 + @total_len)
94
-
95
- p = 0
96
- while p <= (@memsize - 4)
97
- p32 = uint32(@memory[p] |
98
- (@memory[p+1] << 8) |
99
- (@memory[p+2] << 16) |
100
- (@memory[p+3] << 24))
101
- h32 = uint32(h32 + p32 * @@prime32_3)
102
- h32 = uint32(uint32((h32 << 17) | (h32 >> (32 - 17))) * @@prime32_4)
103
- p += 4
72
+ def digest! val=nil
73
+ result = digest(val)
74
+ @hash.reset
75
+ result
104
76
  end
105
77
 
106
- while p < @memsize
107
- h32 = uint32(h32 + @memory[p] * @@prime32_5)
108
- h32 = uint32(uint32((h32 << 11) | (h32 >> (32 - 11))) * @@prime32_1)
109
- p += 1
78
+ def reset
79
+ @hash.reset
110
80
  end
111
81
 
112
- h32 ^= h32 >> 15
113
- h32 = uint32(h32 * @@prime32_2)
114
- h32 ^= h32 >> 13
115
- h32 = uint32(h32 * @@prime32_3)
116
- h32 ^= h32 >> 16
117
-
118
- h32
119
82
  end
120
83
 
121
- private
122
-
123
- attr_accessor :v1, :v2, :v3, :v4
84
+ class XXHash32 < Digest::XXHash
85
+ def initialize seed = 0
86
+ super(32, seed)
87
+ end
88
+ end
124
89
 
125
- def uint32(x)
126
- x & @@thirtytwo1s
90
+ class XXHash64 < Digest::XXHash
91
+ def initialize seed = 0
92
+ super(64, seed)
93
+ end
127
94
  end
95
+
128
96
  end
@@ -0,0 +1,123 @@
1
+
2
+
3
+ module XXhash
4
+ module XXhashInternal
5
+ class XXhash32
6
+ @@mem_total_size = 16
7
+ @@prime32_1 = 2654435761
8
+ @@prime32_2 = 2246822519
9
+ @@prime32_3 = 3266489917
10
+ @@prime32_4 = 668265263
11
+ @@prime32_5 = 374761393
12
+
13
+ @@thirtytwo1s = (2**32-1)
14
+
15
+ def initialize seed
16
+ @seed = seed
17
+ reset
18
+ end
19
+
20
+ def reset
21
+ @v1 = @seed + @@prime32_1 + @@prime32_2
22
+ @v2 = @seed + @@prime32_2
23
+ @v3 = @seed + 0
24
+ @v4 = @seed - @@prime32_1
25
+ @total_len = 0
26
+ @memory = Array.new(@@mem_total_size)
27
+ @memsize = 0
28
+ end
29
+
30
+ def update bytes
31
+ if String === bytes
32
+ bytes = bytes.unpack("C*")
33
+ end
34
+
35
+ @total_len += bytes.length
36
+
37
+ p = 0
38
+
39
+ while (remaining = (bytes.length - p)) > 0
40
+
41
+ mem_avail = @@mem_total_size - @memsize
42
+
43
+ if(remaining < mem_avail)
44
+ @memory[@memsize, remaining] = bytes[p, remaining]
45
+ @memsize += remaining
46
+ break
47
+ end
48
+
49
+ @memory[@memsize, mem_avail] = bytes[p, mem_avail]
50
+
51
+ i = 0
52
+ [:v1, :v2, :v3, :v4].each do |m|
53
+ p32 = uint32(
54
+ @memory[i] |
55
+ (@memory[i+1] << 8) |
56
+ (@memory[i+2] << 16) |
57
+ (@memory[i+3] << 24))
58
+
59
+ v = uint32(self.send(m) + p32 * @@prime32_2)
60
+ v = uint32(uint32((v << 13) | (v >> (32 - 13))) * @@prime32_1)
61
+ self.send((m.to_s + "=").to_sym, v)
62
+ i += 4
63
+ end
64
+
65
+ p += mem_avail
66
+ @memsize = 0
67
+ end
68
+
69
+ return true
70
+ end
71
+
72
+ def digest val=nil
73
+ if val
74
+ update val
75
+ end
76
+
77
+ if @total_len >= 16
78
+ h32 = ((@v1 << 1) | (@v1 >> (32 - 1))) +
79
+ ((@v2 << 7) | (@v2 >> (32 - 7))) +
80
+ ((@v3 << 12) | (@v3 >> (32 - 12))) +
81
+ ((@v4 << 18) | (@v4 >> (32 - 18)))
82
+ else
83
+ h32 = @seed + @@prime32_5
84
+ end
85
+
86
+ h32 = uint32(h32 + @total_len)
87
+
88
+ p = 0
89
+ while p <= (@memsize - 4)
90
+ p32 = uint32(@memory[p] |
91
+ (@memory[p+1] << 8) |
92
+ (@memory[p+2] << 16) |
93
+ (@memory[p+3] << 24))
94
+ h32 = uint32(h32 + p32 * @@prime32_3)
95
+ h32 = uint32(uint32((h32 << 17) | (h32 >> (32 - 17))) * @@prime32_4)
96
+ p += 4
97
+ end
98
+
99
+ while p < @memsize
100
+ h32 = uint32(h32 + @memory[p] * @@prime32_5)
101
+ h32 = uint32(uint32((h32 << 11) | (h32 >> (32 - 11))) * @@prime32_1)
102
+ p += 1
103
+ end
104
+
105
+ h32 ^= h32 >> 15
106
+ h32 = uint32(h32 * @@prime32_2)
107
+ h32 ^= h32 >> 13
108
+ h32 = uint32(h32 * @@prime32_3)
109
+ h32 ^= h32 >> 16
110
+
111
+ h32
112
+ end
113
+
114
+ private
115
+
116
+ attr_accessor :v1, :v2, :v3, :v4
117
+
118
+ def uint32(x)
119
+ x & @@thirtytwo1s
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,147 @@
1
+ require "ruby-xxhash/version"
2
+
3
+ module XXhash
4
+ module XXhashInternal
5
+ class XXhash64
6
+ @@mem_total_size = 32
7
+ @@prime64_1 = 11400714785074694791
8
+ @@prime64_2 = 14029467366897019727
9
+ @@prime64_3 = 1609587929392839161
10
+ @@prime64_4 = 9650029242287828579
11
+ @@prime64_5 = 2870177450012600261
12
+
13
+ @@sixtyfour1s = (2**64-1)
14
+
15
+ def initialize seed
16
+ @seed = seed
17
+ reset
18
+ end
19
+
20
+ def reset
21
+ @v1 = @seed + @@prime64_1 + @@prime64_2;
22
+ @v2 = @seed + @@prime64_2;
23
+ @v3 = @seed + 0;
24
+ @v4 = @seed - @@prime64_1;
25
+ @total_len = 0
26
+ @memory = Array.new(@@mem_total_size)
27
+ @memsize = 0
28
+ end
29
+
30
+ def update bytes
31
+ if String === bytes
32
+ bytes = bytes.unpack("C*")
33
+ end
34
+
35
+ @total_len += bytes.length
36
+
37
+ p = 0
38
+ while (remaining = (bytes.length - p)) > 0
39
+ mem_avail = @@mem_total_size - @memsize
40
+
41
+ if(remaining < mem_avail)
42
+ @memory[@memsize, remaining] = bytes[p, remaining]
43
+ @memsize += remaining
44
+ break
45
+ end
46
+
47
+ @memory[@memsize, mem_avail] = bytes[p, mem_avail]
48
+
49
+ i = 0
50
+ [:v1, :v2, :v3, :v4].each do |m|
51
+ p64 = uint64(
52
+ @memory[i] |
53
+ (@memory[i+1] << 8) |
54
+ (@memory[i+2] << 16) |
55
+ (@memory[i+3] << 24) |
56
+ (@memory[i+4] << 32) |
57
+ (@memory[i+5] << 40) |
58
+ (@memory[i+6] << 48) |
59
+ (@memory[i+7] << 56))
60
+
61
+ v = uint64(self.send(m) + p64 * @@prime64_2)
62
+ v = uint64(uint64((v << 31) | (v >> (64 - 31))) * @@prime64_1)
63
+ self.send((m.to_s + "=").to_sym, v)
64
+ i += 8
65
+ end
66
+
67
+ p += mem_avail
68
+ @memsize = 0
69
+ end
70
+ end
71
+
72
+ def digest val=nil
73
+ if val
74
+ update val
75
+ end
76
+
77
+ if @total_len >= 32
78
+ h64 = ((@v1 << 1) | (@v1 >> (64 - 1))) +
79
+ ((@v2 << 7) | (@v2 >> (64 - 7))) +
80
+ ((@v3 << 12) | (@v3 >> (64 - 12))) +
81
+ ((@v4 << 18) | (@v4 >> (64 - 18)))
82
+
83
+ [:v1, :v2, :v3, :v4].each do |m|
84
+ v = uint64(self.send(m) * @@prime64_2)
85
+ v = uint64((v << 31) | (v >> (64 - 31)))
86
+ h64 ^= uint64(v * @@prime64_1)
87
+ h64 = h64 * @@prime64_1 + @@prime64_4
88
+ end
89
+ else
90
+ h64 = @seed + @@prime64_5
91
+ end
92
+
93
+ h64 = uint64(h64 + @total_len)
94
+
95
+ i = 0
96
+ while i <= (@memsize - 8)
97
+ v = uint64(
98
+ @memory[i] |
99
+ (@memory[i+1] << 8) |
100
+ (@memory[i+2] << 16) |
101
+ (@memory[i+3] << 24) |
102
+ (@memory[i+4] << 32) |
103
+ (@memory[i+5] << 40) |
104
+ (@memory[i+6] << 48) |
105
+ (@memory[i+7] << 56))
106
+
107
+ v = uint64(v * @@prime64_2)
108
+ h64 ^= uint64(uint64((v << 31) | (v >> (64 - 31))) * @@prime64_1)
109
+ h64 = uint64(uint64((h64 << 27) | (h64 >> (64 - 27))) * @@prime64_1 + @@prime64_4)
110
+ i += 8
111
+ end
112
+
113
+ if i <= (@memsize - 4)
114
+ v = @memory[i] |
115
+ (@memory[i+1] << 8) |
116
+ (@memory[i+2] << 16) |
117
+ (@memory[i+3] << 24)
118
+ h64 ^= uint64(v * @@prime64_1)
119
+ h64 = uint64(uint64((h64 << 23) | (h64 >> (64-23))) * @@prime64_2 + @@prime64_3)
120
+ i += 4
121
+ end
122
+
123
+ while i < @memsize
124
+ h64 ^= uint64(@memory[i] * @@prime64_5)
125
+ h64 = uint64(uint64((h64 << 11) | (h64 >> (64 - 11))) * @@prime64_1)
126
+ i += 1
127
+ end
128
+
129
+ h64 ^= h64 >> 33
130
+ h64 = uint64(h64 * @@prime64_2)
131
+ h64 ^= h64 >> 29
132
+ h64 = uint64(h64 * @@prime64_3)
133
+ h64 ^= h64 >> 32
134
+
135
+ h64
136
+ end
137
+
138
+ private
139
+
140
+ attr_accessor :v1, :v2, :v3, :v4
141
+
142
+ def uint64(x)
143
+ x & @@sixtyfour1s
144
+ end
145
+ end
146
+ end
147
+ end
data/ruby-xxHash.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
24
  end
File without changes
@@ -0,0 +1,16 @@
1
+ ---
2
+ ? - test
3
+ - 123
4
+ : 3134990500624303823
5
+ ? - ! 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, '
6
+ - 0
7
+ : 17031984226649854695
8
+ ? - ! 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, '
9
+ - 1471
10
+ : 13163341760735734472
11
+ ? - ! 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.'
12
+ - 0
13
+ : 14967567540383795520
14
+ ? - ! 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.'
15
+ - 1471
16
+ : 4189552183125498197
data/spec/xxhash_spec.rb CHANGED
@@ -1,34 +1,112 @@
1
1
  #Copyright (c) 2012 Vasiliy Ermolovich
2
+ #Copyright (c) 2014 Justin W Smith
2
3
 
3
4
  require 'spec_helper'
4
5
  require 'stringio'
5
6
  require 'yaml'
6
7
 
7
8
  describe XXhash do
8
- hash = YAML.load(IO.read "spec/results.yaml")
9
+ hash32 = YAML.load(IO.read "spec/results32.yaml")
10
+ hash64 = YAML.load(IO.read "spec/results64.yaml")
9
11
 
10
- hash.each do |key, value|
12
+ hash32.each do |key, value|
11
13
  it 'returns correct hash' do
12
- XXhash.xxh32(key[0], key[1]).should eq(value)
14
+ expect(XXhash.xxh32(key[0], key[1])).to eq(value)
13
15
  end
14
16
  end
15
17
 
18
+ hash64.each do |key, value|
19
+ it 'returns correct hash' do
20
+ expect(XXhash.xxh64(key[0], key[1])).to eq(value)
21
+ end
22
+ end
16
23
 
17
24
  describe 'StreamingHash' do
18
- it 'raises error if argument is not an IO object' do
19
- expect { XXhash.xxh32_stream('test', 123)}.to raise_error
20
- end
21
25
 
22
- hash.each do |key, value|
26
+ hash32.each do |key, value|
23
27
  it 'returns correct hash' do
24
- XXhash.xxh32_stream(StringIO.new(key[0]), key[1]).should eq(value)
28
+ expect(XXhash.xxh32_stream(StringIO.new(key[0]), key[1])).to eq(value)
25
29
  end
26
30
  end
27
31
 
28
32
  it 'returns same hash for streamed files' do
29
33
  h1 = XXhash.xxh32(File.read(__FILE__), 123)
30
34
  h2 = XXhash.xxh32_stream(File.open(__FILE__), 123)
31
- h1.should eq(h2)
35
+ expect(h1).to eq(h2)
36
+ end
37
+
38
+ hash64.each do |key, value|
39
+ it 'returns correct hash' do
40
+ expect(XXhash.xxh64_stream(StringIO.new(key[0]), key[1])).to eq(value)
41
+ end
42
+ end
43
+
44
+ it 'returns same hash for streamed files' do
45
+ h1 = XXhash.xxh64(File.read(__FILE__), 123)
46
+ h2 = XXhash.xxh64_stream(File.open(__FILE__), 123)
47
+ expect(h1).to eq(h2)
48
+ end
49
+ end
50
+
51
+ def use_external_hash hash, io, chunk_size=1024
52
+ while chunk=io.read(chunk_size)
53
+ hash.update(chunk)
32
54
  end
55
+ hash.digest
33
56
  end
57
+
58
+ describe 'Digest::XXHash32' do
59
+
60
+ it 'returns the hash for streamed strings' do
61
+ StringIO.open('test') do |io|
62
+ xxhash = Digest::XXHash32.new(123)
63
+ result = use_external_hash xxhash, io
64
+ expect(result).to eq(2758658570)
65
+ end
66
+ end
67
+
68
+ it 'returns the hash for streamed files' do
69
+ h1 = XXhash.xxh32(File.read(__FILE__), 123)
70
+ xxhash = Digest::XXHash32.new(123)
71
+ result = use_external_hash xxhash, File.open(__FILE__)
72
+ expect(result).to eq(h1)
73
+ end
74
+
75
+ it 'returns correct hash after a reset' do
76
+ h1 = XXhash.xxh32(File.read(__FILE__), 123)
77
+ xxhash = Digest::XXHash32.new(123)
78
+ expect(xxhash.digest('test')).to eq(2758658570)
79
+ xxhash.reset
80
+ result = use_external_hash xxhash, File.open(__FILE__)
81
+ expect(result).to eq(h1)
82
+ end
83
+ end
84
+
85
+ describe 'Digest::XXHash64' do
86
+
87
+ it 'returns the hash for streamed strings' do
88
+ StringIO.open('test') do |io|
89
+ xxhash = Digest::XXHash64.new(123)
90
+ result = use_external_hash xxhash, io
91
+ expect(result).to eq(3134990500624303823)
92
+ end
93
+ end
94
+
95
+ it 'returns the hash for streamed files' do
96
+ h1 = XXhash.xxh64(File.read(__FILE__), 123)
97
+ xxhash = Digest::XXHash64.new(123)
98
+ result = use_external_hash xxhash, File.open(__FILE__)
99
+ expect(result).to eq(h1)
100
+ end
101
+
102
+ it 'returns correct hash after a reset' do
103
+ h1 = XXhash.xxh64(File.read(__FILE__), 123)
104
+ xxhash = Digest::XXHash64.new(123)
105
+ expect(xxhash.digest('test')).to eq(3134990500624303823)
106
+ xxhash.reset
107
+ result = use_external_hash xxhash, File.open(__FILE__)
108
+ expect(result).to eq(h1)
109
+ end
110
+ end
111
+
34
112
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-xxHash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.4.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Justin W Smith
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '1.3'
19
+ version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '1.3'
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: A pure Ruby implementation of xxhash.
@@ -66,43 +59,46 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - .gitignore
62
+ - ".gitignore"
63
+ - ".travis.yml"
70
64
  - Gemfile
71
65
  - LICENSE.txt
72
66
  - README.md
73
67
  - Rakefile
74
68
  - lib/ruby-xxhash.rb
75
69
  - lib/ruby-xxhash/version.rb
70
+ - lib/ruby-xxhash32.rb
71
+ - lib/ruby-xxhash64.rb
76
72
  - ruby-xxHash.gemspec
77
- - spec/results.yaml
73
+ - spec/results32.yaml
74
+ - spec/results64.yaml
78
75
  - spec/spec_helper.rb
79
76
  - spec/xxhash_spec.rb
80
77
  homepage: https://github.com/justinwsmith/ruby-xxhash
81
78
  licenses:
82
79
  - MIT
83
- post_install_message:
80
+ metadata: {}
81
+ post_install_message:
84
82
  rdoc_options: []
85
83
  require_paths:
86
84
  - lib
87
85
  required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
86
  requirements:
90
- - - ! '>='
87
+ - - ">="
91
88
  - !ruby/object:Gem::Version
92
89
  version: '0'
93
90
  required_rubygems_version: !ruby/object:Gem::Requirement
94
- none: false
95
91
  requirements:
96
- - - ! '>='
92
+ - - ">="
97
93
  - !ruby/object:Gem::Version
98
94
  version: '0'
99
95
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 1.8.23
102
- signing_key:
103
- specification_version: 3
96
+ rubygems_version: 3.2.32
97
+ signing_key:
98
+ specification_version: 4
104
99
  summary: A pure Ruby implementation of xxhash.
105
100
  test_files:
106
- - spec/results.yaml
101
+ - spec/results32.yaml
102
+ - spec/results64.yaml
107
103
  - spec/spec_helper.rb
108
104
  - spec/xxhash_spec.rb