identifier 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/identifier.rb CHANGED
@@ -1,4 +1,28 @@
1
1
  require 'identifier/identifier'
2
2
 
3
+ begin
4
+ require 'securerandom'
5
+ rescue LoadError
6
+ end
7
+
3
8
  module Identifier
9
+
10
+ def generate
11
+ SecureRandom.uuid if defined? SecureRandom
12
+
13
+ bytes = [
14
+ rand(0xFFFFFFFF),
15
+ rand(0x0000FFFF),
16
+ rand(0x0000FFFF),
17
+ rand(0x0000FFFF),
18
+ rand(0x0000FFFF),
19
+ rand(0xFFFFFFFF),
20
+ ]
21
+
22
+ bytes[2] = (bytes[2] & 0x0FFF) | 0x4000
23
+ bytes[3] = (bytes[3] & 0x3FFF) | 0x8000
24
+
25
+ "%08x-%04x-%04x-%04x-%04x%08x" % bytes
26
+ end
27
+
4
28
  end
Binary file
@@ -1,3 +1,3 @@
1
1
  module Identifier
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: identifier
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.8
5
+ version: 1.0.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kevin Sylvestre
@@ -25,6 +25,7 @@ extra_rdoc_files: []
25
25
  files:
26
26
  - ext/identifier/extconf.rb
27
27
  - ext/identifier/identifier.c
28
+ - lib/identifier/identifier.bundle
28
29
  - lib/identifier/version.rb
29
30
  - lib/identifier.rb
30
31
  - README.rdoc