identifier 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.rdoc +14 -2
- data/lib/identifier.rb +9 -5
- data/lib/identifier/version.rb +1 -1
- metadata +58 -34
- data/ext/identifier/extconf.rb +0 -5
- data/ext/identifier/identifier.c +0 -21
- data/lib/identifier/identifier.bundle +0 -0
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Identifier
|
2
2
|
|
3
|
-
Identifier is a Ruby unique identifier generator that
|
3
|
+
Identifier is a Ruby universally unique identifier generator that attempts to use the UNIX, Linux and Macintosh library 'uuid'.
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
@@ -8,11 +8,23 @@ Identifier is a Ruby unique identifier generator that wraps the UNIX, Linux and
|
|
8
8
|
|
9
9
|
== Requirements
|
10
10
|
|
11
|
-
|
11
|
+
The gem is tested with:
|
12
|
+
|
13
|
+
* Ruby (MRI) 1.9.2 (p180)
|
14
|
+
* Ruby (MRI) 1.8.7 (p334)
|
15
|
+
* Ruby (REE) 1.8.7 (2011.03)
|
16
|
+
* JRuby 1.6.2
|
17
|
+
* Rubinius 1.2.4
|
12
18
|
|
13
19
|
== Examples
|
14
20
|
|
15
21
|
Identifier.generate # "CFAA3C87-38C1-4357-8FA2-D862780736AE"
|
22
|
+
|
23
|
+
== Performance
|
24
|
+
|
25
|
+
Identifier 2.628164 seconds for 100,000 generations
|
26
|
+
GUID 15.755870 seconds for 100,000 generations
|
27
|
+
UUID 10.987766 seconds for 100,000 generations
|
16
28
|
|
17
29
|
== Copyright
|
18
30
|
|
data/lib/identifier.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'identifier/identifier'
|
2
|
-
|
3
1
|
begin
|
4
2
|
require 'securerandom'
|
5
3
|
rescue LoadError
|
@@ -7,10 +5,16 @@ end
|
|
7
5
|
|
8
6
|
module Identifier
|
9
7
|
|
10
|
-
def generate
|
11
|
-
|
8
|
+
def self.generate
|
9
|
+
if defined? SecureRandom
|
10
|
+
return SecureRandom.uuid if SecureRandom.respond_to? :uuid
|
11
|
+
|
12
|
+
bytes = SecureRandom.random_bytes(16)
|
13
|
+
bytes = bytes.unpack("NnnnnN")
|
14
|
+
end
|
12
15
|
|
13
|
-
bytes
|
16
|
+
bytes ||=
|
17
|
+
[
|
14
18
|
rand(0xFFFFFFFF),
|
15
19
|
rand(0x0000FFFF),
|
16
20
|
rand(0x0000FFFF),
|
data/lib/identifier/version.rb
CHANGED
metadata
CHANGED
@@ -1,62 +1,86 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: identifier
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
4
5
|
prerelease:
|
5
|
-
version: 1.0.9
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Kevin Sylvestre
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
date: 2011-07-24 00:00:00.000000000 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: &70108861606260 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70108861606260
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
requirement: &70108861605840 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70108861605840
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
requirement: &70108861605420 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *70108861605420
|
48
|
+
description: Identifier is a Ruby unique identifier generator that wraps the UNIX,
|
49
|
+
Linux and Macintosh 'uuid' library.
|
50
|
+
email:
|
18
51
|
- kevin@ksylvest.com
|
19
52
|
executables: []
|
20
|
-
|
21
|
-
extensions:
|
22
|
-
- ext/identifier/extconf.rb
|
53
|
+
extensions: []
|
23
54
|
extra_rdoc_files: []
|
24
|
-
|
25
|
-
files:
|
26
|
-
- ext/identifier/extconf.rb
|
27
|
-
- ext/identifier/identifier.c
|
28
|
-
- lib/identifier/identifier.bundle
|
55
|
+
files:
|
29
56
|
- lib/identifier/version.rb
|
30
57
|
- lib/identifier.rb
|
31
58
|
- README.rdoc
|
32
59
|
- LICENSE
|
33
60
|
- Gemfile
|
61
|
+
has_rdoc: true
|
34
62
|
homepage: http://github.com/ksylvest/identifier
|
35
63
|
licenses: []
|
36
|
-
|
37
64
|
post_install_message:
|
38
65
|
rdoc_options: []
|
39
|
-
|
40
|
-
require_paths:
|
66
|
+
require_paths:
|
41
67
|
- lib
|
42
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
69
|
none: false
|
44
|
-
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
75
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version:
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
54
80
|
requirements: []
|
55
|
-
|
56
81
|
rubyforge_project:
|
57
|
-
rubygems_version: 1.
|
82
|
+
rubygems_version: 1.6.2
|
58
83
|
signing_key:
|
59
84
|
specification_version: 3
|
60
85
|
summary: A very basic unique identifier
|
61
86
|
test_files: []
|
62
|
-
|
data/ext/identifier/extconf.rb
DELETED
data/ext/identifier/identifier.c
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#include <ruby.h>
|
2
|
-
#include <uuid/uuid.h>
|
3
|
-
|
4
|
-
VALUE Identifier;
|
5
|
-
|
6
|
-
VALUE method_generate(VALUE self)
|
7
|
-
{
|
8
|
-
char result[] = "00000000-0000-0000-0000-000000000000";
|
9
|
-
|
10
|
-
uuid_t uuid;
|
11
|
-
uuid_generate(uuid);
|
12
|
-
uuid_unparse(uuid, result);
|
13
|
-
|
14
|
-
return rb_str_new(result, strlen(result));
|
15
|
-
}
|
16
|
-
|
17
|
-
void Init_identifier()
|
18
|
-
{
|
19
|
-
Identifier = rb_define_module("Identifier");
|
20
|
-
rb_define_singleton_method(Identifier, "generate", method_generate, 0);
|
21
|
-
}
|
Binary file
|