uuidtools 0.1.0 → 0.1.1
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.
- data/CHANGELOG +3 -1
- data/README +4 -1
- data/lib/uuidtools.rb +71 -29
- data/rakefile +1 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
data/README
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
UUIDTools was designed to be a simple library for generating any
|
2
|
-
of the various types of UUIDs.
|
2
|
+
of the various types of UUIDs. It conforms to RFC 4122 whenever
|
3
|
+
possible.
|
3
4
|
|
4
5
|
== Example
|
5
6
|
UUID.md5_create(UUID_DNS_NAMESPACE, "www.widgets.com")
|
@@ -8,3 +9,5 @@
|
|
8
9
|
=> #<UUID:0x2a0116 UUID:21f7f8de-8051-5b89-8680-0195ef798b6a>
|
9
10
|
UUID.timestamp_create
|
10
11
|
=> #<UUID:0x2adfdc UUID:64a5189c-25b3-11da-a97b-00c04fd430c8>
|
12
|
+
UUID.random_create
|
13
|
+
=> #<UUID:0x19013a UUID:984265dc-4200-4f02-ae70-fe4f48964159>
|
data/lib/uuidtools.rb
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#++
|
23
23
|
|
24
|
-
UUID_TOOLS_VERSION = "0.1.
|
24
|
+
UUID_TOOLS_VERSION = "0.1.1"
|
25
25
|
|
26
26
|
$:.unshift(File.dirname(__FILE__))
|
27
27
|
|
@@ -34,34 +34,64 @@ require 'digest/md5'
|
|
34
34
|
# Because it's impossible to hype a UUID generator on its genuine merits,
|
35
35
|
# I give you... Really bad ASCII art in the comments:
|
36
36
|
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
37
|
+
#
|
38
|
+
# \
|
39
|
+
# /
|
40
|
+
# +
|
41
|
+
# ]
|
42
|
+
# ]
|
43
|
+
# |
|
44
|
+
# /
|
45
|
+
# Mp___
|
46
|
+
# `~0NNp,
|
47
|
+
# __ggM'
|
48
|
+
# g0M~"`
|
49
|
+
# ]0M*-
|
50
|
+
#
|
51
|
+
# ___
|
52
|
+
# _g000M00g,
|
53
|
+
# j0M~ ~M&
|
54
|
+
# j0M" ~N,
|
55
|
+
# j0P M&
|
56
|
+
# jM 1
|
57
|
+
# j0 ]1
|
58
|
+
# .0P 0,
|
59
|
+
# 00' M&
|
60
|
+
# 0M ]0L
|
61
|
+
# ]0f ___ M0
|
62
|
+
# M0NN0M00MMM~"'M 0&
|
63
|
+
# `~ ~0 ]0,
|
64
|
+
# ]M ]0&
|
65
|
+
# M& M0,
|
66
|
+
# ____gp_ M& M0_
|
67
|
+
# __p0MPM8MM&_ M/ ^0&_
|
68
|
+
# gN"` M0N_j0, MM&__
|
69
|
+
# _gF `~M0P` __ M00g
|
70
|
+
# g0' gM0&, ~M0&
|
71
|
+
# _pM` 0, ]M1 "00&
|
72
|
+
# _00 /g1MMgj01 ]0MI
|
73
|
+
# _0F t"M,7MMM 00I
|
74
|
+
# g0' _ N&j& 40'
|
75
|
+
# g0' _p0Mq_ ' N0QQNM#g,
|
76
|
+
# 0' _g0000000g__ ~M@MMM000g
|
77
|
+
# f _jM00@` ~M0000Mgppg, "P00&
|
78
|
+
# | g000~ `~M000000&_ ~0&
|
79
|
+
# ]M _M00F "00MM` ~#&
|
80
|
+
# `0L m000F #E "0f
|
81
|
+
# 9r j000M` 40, 00
|
82
|
+
# ]0g_ j00M` ^M0MNggp#gqpg M0&
|
83
|
+
# ~MPM0f ~M000000000g_ ,_ygg&M00f
|
84
|
+
# `~~~M00000000000000
|
85
|
+
# `M0000000000f
|
86
|
+
# ~@@@MF~`
|
87
|
+
#
|
88
|
+
#
|
60
89
|
|
61
90
|
#= uuidtools.rb
|
62
91
|
#
|
63
92
|
# UUIDTools was designed to be a simple library for generating any
|
64
|
-
# of the various types of UUIDs.
|
93
|
+
# of the various types of UUIDs. It conforms to RFC 4122 whenever
|
94
|
+
# possible.
|
65
95
|
#
|
66
96
|
#== Example
|
67
97
|
# UUID.md5_create(UUID_DNS_NAMESPACE, "www.widgets.com")
|
@@ -70,6 +100,8 @@ require 'digest/md5'
|
|
70
100
|
# => #<UUID:0x2a0116 UUID:21f7f8de-8051-5b89-8680-0195ef798b6a>
|
71
101
|
# UUID.timestamp_create
|
72
102
|
# => #<UUID:0x2adfdc UUID:64a5189c-25b3-11da-a97b-00c04fd430c8>
|
103
|
+
# UUID.random_create
|
104
|
+
# => #<UUID:0x19013a UUID:984265dc-4200-4f02-ae70-fe4f48964159>
|
73
105
|
class UUID
|
74
106
|
@@last_timestamp = nil
|
75
107
|
@@last_node_id = nil
|
@@ -279,10 +311,10 @@ class UUID
|
|
279
311
|
|
280
312
|
# Returns the UUID variant.
|
281
313
|
# Possible values:
|
282
|
-
#
|
283
|
-
#
|
284
|
-
#
|
285
|
-
#
|
314
|
+
# 0b000 - Reserved, NCS backward compatibility.
|
315
|
+
# 0b100 - The variant specified in this document.
|
316
|
+
# 0b110 - Reserved, Microsoft Corporation backward compatibility.
|
317
|
+
# 0b111 - Reserved for future definition.
|
286
318
|
def variant
|
287
319
|
variant_raw = (clock_seq_hi_and_reserved >> 5)
|
288
320
|
result = nil
|
@@ -453,6 +485,8 @@ class UUID
|
|
453
485
|
end
|
454
486
|
|
455
487
|
# Returns 128 bits of highly unpredictable data.
|
488
|
+
# The random number generator isn't perfect, but it's
|
489
|
+
# much, much better than the built-in pseudorandom number generators.
|
456
490
|
def UUID.true_random
|
457
491
|
require 'benchmark'
|
458
492
|
hash = Digest::SHA1.new
|
@@ -505,6 +539,14 @@ class UUID
|
|
505
539
|
end
|
506
540
|
return integer
|
507
541
|
end
|
542
|
+
|
543
|
+
class << self
|
544
|
+
protected :create_from_hash
|
545
|
+
protected :get_mac_address
|
546
|
+
protected :true_random
|
547
|
+
protected :convert_int_to_byte_string
|
548
|
+
protected :convert_byte_string_to_int
|
549
|
+
end
|
508
550
|
end
|
509
551
|
|
510
552
|
UUID_DNS_NAMESPACE = UUID.parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
|
data/rakefile
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: uuidtools
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2005-09-
|
6
|
+
version: 0.1.1
|
7
|
+
date: 2005-09-16 00:00:00 -04:00
|
8
8
|
summary: Generation of UUIDs.
|
9
9
|
require_paths:
|
10
10
|
- lib
|