uuidtools 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/lib/uuidtools.rb +71 -16
- data/lib/uuidtools/version.rb +1 -1
- data/spec/uuidtools/mac_address_spec.rb +1 -1
- data/spec/uuidtools/utility_spec.rb +1 -1
- data/spec/uuidtools/uuid_creation_spec.rb +1 -1
- data/spec/uuidtools/uuid_parsing_spec.rb +1 -1
- metadata +47 -17
data/CHANGELOG
CHANGED
data/lib/uuidtools.rb
CHANGED
@@ -376,28 +376,76 @@ module UUIDTools
|
|
376
376
|
|
377
377
|
# Returns the hex digest of the UUID object.
|
378
378
|
def hexdigest
|
379
|
-
return
|
379
|
+
return @hexdigest unless @hexdigest.nil?
|
380
|
+
if self.frozen?
|
381
|
+
return generate_hexdigest
|
382
|
+
else
|
383
|
+
return (@hexdigest = generate_hexdigest)
|
384
|
+
end
|
380
385
|
end
|
381
386
|
|
382
387
|
# Returns the raw bytes that represent this UUID.
|
383
388
|
def raw
|
384
|
-
return
|
389
|
+
return @raw unless @raw.nil?
|
390
|
+
if self.frozen?
|
391
|
+
return generate_raw
|
392
|
+
else
|
393
|
+
return (@raw = generate_raw)
|
394
|
+
end
|
385
395
|
end
|
386
396
|
|
387
397
|
# Returns a string representation for this UUID.
|
388
398
|
def to_s
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
399
|
+
return @string unless @string.nil?
|
400
|
+
if self.frozen?
|
401
|
+
return generate_s
|
402
|
+
else
|
403
|
+
return (@string = generate_s)
|
393
404
|
end
|
394
|
-
return result.downcase
|
395
405
|
end
|
396
406
|
alias_method :to_str, :to_s
|
397
407
|
|
398
408
|
# Returns an integer representation for this UUID.
|
399
409
|
def to_i
|
400
|
-
@integer
|
410
|
+
return @integer unless @integer.nil?
|
411
|
+
if self.frozen?
|
412
|
+
return generate_i
|
413
|
+
else
|
414
|
+
return (@integer = generate_i)
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
# Returns a URI string for this UUID.
|
419
|
+
def to_uri
|
420
|
+
return "urn:uuid:#{self.to_s}"
|
421
|
+
end
|
422
|
+
|
423
|
+
# Returns an integer hash value.
|
424
|
+
def hash
|
425
|
+
return @hash unless @hash.nil?
|
426
|
+
if self.frozen?
|
427
|
+
return generate_hash
|
428
|
+
else
|
429
|
+
return (@hash = generate_hash)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
#These methods generate the appropriate representations the above methods cache
|
434
|
+
protected
|
435
|
+
|
436
|
+
# Generates the hex digest of the UUID object.
|
437
|
+
def generate_hexdigest
|
438
|
+
return self.to_i.to_s(16).rjust(32, "0")
|
439
|
+
end
|
440
|
+
|
441
|
+
# Generates an integer hash value.
|
442
|
+
def generate_hash
|
443
|
+
return self.to_i % 0x3fffffff
|
444
|
+
end
|
445
|
+
|
446
|
+
# Generates an integer representation for this UUID.
|
447
|
+
def generate_i
|
448
|
+
return (begin
|
401
449
|
bytes = (time_low << 96) + (time_mid << 80) +
|
402
450
|
(time_hi_and_version << 64) + (clock_seq_hi_and_reserved << 56) +
|
403
451
|
(clock_seq_low << 48)
|
@@ -407,16 +455,23 @@ module UUIDTools
|
|
407
455
|
bytes
|
408
456
|
end)
|
409
457
|
end
|
410
|
-
|
411
|
-
#
|
412
|
-
def
|
413
|
-
|
458
|
+
|
459
|
+
# Generates a string representation for this UUID.
|
460
|
+
def generate_s
|
461
|
+
result = sprintf("%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", @time_low, @time_mid,
|
462
|
+
@time_hi_and_version, @clock_seq_hi_and_reserved, @clock_seq_low);
|
463
|
+
for i in 0..5
|
464
|
+
result << sprintf("%2.2x", @nodes[i])
|
465
|
+
end
|
466
|
+
return result.downcase
|
414
467
|
end
|
415
|
-
|
416
|
-
#
|
417
|
-
def
|
418
|
-
|
468
|
+
|
469
|
+
# Generates the raw bytes that represent this UUID.
|
470
|
+
def generate_raw
|
471
|
+
return self.class.convert_int_to_byte_string(self.to_i, 16)
|
419
472
|
end
|
473
|
+
|
474
|
+
public
|
420
475
|
|
421
476
|
# Returns true if this UUID is exactly equal to the other UUID.
|
422
477
|
def eql?(other)
|
data/lib/uuidtools/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuidtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 2.1.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Bob Aman
|
@@ -9,39 +15,57 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2011-02-02 00:00:00 -08:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: rake
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 57
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 8
|
33
|
+
- 3
|
23
34
|
version: 0.8.3
|
24
|
-
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
25
37
|
- !ruby/object:Gem::Dependency
|
26
38
|
name: rspec
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
30
42
|
requirements:
|
31
43
|
- - ">="
|
32
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 5
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 1
|
49
|
+
- 11
|
33
50
|
version: 1.1.11
|
34
|
-
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
35
53
|
- !ruby/object:Gem::Dependency
|
36
54
|
name: launchy
|
37
|
-
|
38
|
-
|
39
|
-
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
40
58
|
requirements:
|
41
59
|
- - ">="
|
42
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 23
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 3
|
65
|
+
- 2
|
43
66
|
version: 0.3.2
|
44
|
-
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
45
69
|
description: |
|
46
70
|
A simple universally unique ID generation library.
|
47
71
|
|
@@ -86,21 +110,27 @@ rdoc_options:
|
|
86
110
|
require_paths:
|
87
111
|
- lib
|
88
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
89
114
|
requirements:
|
90
115
|
- - ">="
|
91
116
|
- !ruby/object:Gem::Version
|
117
|
+
hash: 3
|
118
|
+
segments:
|
119
|
+
- 0
|
92
120
|
version: "0"
|
93
|
-
version:
|
94
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
95
123
|
requirements:
|
96
124
|
- - ">="
|
97
125
|
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
98
129
|
version: "0"
|
99
|
-
version:
|
100
130
|
requirements: []
|
101
131
|
|
102
132
|
rubyforge_project: uuidtools
|
103
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.4.1
|
104
134
|
signing_key:
|
105
135
|
specification_version: 3
|
106
136
|
summary: UUID generator
|