uuidtools 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ == UUIDTools 1.0.7
2
+ * fixed incompatible SecureRandom implementation
1
3
  == UUIDTools 1.0.6
2
4
  * fixed Bignum hash issue
3
5
  * added implicit to_str cast
@@ -160,13 +160,16 @@ if !defined?(SecureRandom)
160
160
  hex = n.to_s(16)
161
161
  hex = '0' + hex if (hex.length & 1) == 1
162
162
  bin = [hex].pack("H*")
163
- mask = bin[0].ord
163
+ first = bin[0..0]
164
+ mask = first.respond_to?(:ord) ? first.ord : first.sum(8)
164
165
  mask |= mask >> 1
165
166
  mask |= mask >> 2
166
167
  mask |= mask >> 4
167
168
  begin
168
169
  rnd = SecureRandom.random_bytes(bin.length)
169
- rnd[0] = (rnd[0].ord & mask).chr
170
+ first = rnd[0..0]
171
+ ordinal = first.respond_to?(:ord) ? first.ord : first.sum(8)
172
+ rnd[0..0] = (ordinal & mask).chr
170
173
  end until rnd < bin
171
174
  rnd.unpack("H*")[0].hex
172
175
  else
@@ -27,7 +27,7 @@ unless defined? UUID::VERSION
27
27
  module VERSION #:nodoc:
28
28
  MAJOR = 1
29
29
  MINOR = 0
30
- TINY = 6
30
+ TINY = 7
31
31
 
32
32
  STRING = [MAJOR, MINOR, TINY].join('.')
33
33
  end
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
2
2
 
3
- describe UUID, "when using utility methods" do
3
+ describe SecureRandom do
4
4
  it "should correctly obtain random bits" do
5
5
  bits = []
6
6
  1000.times do
@@ -14,4 +14,8 @@ describe UUID, "when using utility methods" do
14
14
  SecureRandom.random_bytes(16).size.should == 16
15
15
  SecureRandom.random_bytes(6).size.should == 6
16
16
  end
17
+
18
+ it "should return a sane random number" do
19
+ SecureRandom.random_number(5000).should < 5000
20
+ end
17
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuidtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Aman
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-01 00:00:00 -05:00
12
+ date: 2008-12-04 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency