uuidtools 0.1.2 → 0.1.3
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 +2 -0
- data/lib/uuidtools.rb +6 -14
- data/rakefile +1 -1
- data/test/create_test.rb +35 -0
- data/test/parse_test.rb +0 -0
- metadata +4 -2
data/CHANGELOG
CHANGED
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.3"
|
25
25
|
|
26
26
|
$:.unshift(File.dirname(__FILE__))
|
27
27
|
|
@@ -434,7 +434,7 @@ class UUID
|
|
434
434
|
return "urn:uuid:#{self.to_s}"
|
435
435
|
end
|
436
436
|
|
437
|
-
def UUID.create_from_hash(hash_class, namespace, name)
|
437
|
+
def UUID.create_from_hash(hash_class, namespace, name) #:nodoc:
|
438
438
|
if hash_class == Digest::MD5
|
439
439
|
version = 3
|
440
440
|
elsif hash_class == Digest::SHA1
|
@@ -459,7 +459,7 @@ class UUID
|
|
459
459
|
|
460
460
|
# Returns the MAC address of the current computer's network card.
|
461
461
|
# Returns nil if a MAC address could not be found.
|
462
|
-
def UUID.get_mac_address
|
462
|
+
def UUID.get_mac_address #:nodoc:
|
463
463
|
if RUBY_PLATFORM =~ /win/ && !(RUBY_PLATFORM =~ /darwin/)
|
464
464
|
begin
|
465
465
|
ifconfig_output = `ipconfig /all`
|
@@ -501,7 +501,7 @@ class UUID
|
|
501
501
|
# Returns 128 bits of highly unpredictable data.
|
502
502
|
# The random number generator isn't perfect, but it's
|
503
503
|
# much, much better than the built-in pseudorandom number generators.
|
504
|
-
def UUID.true_random
|
504
|
+
def UUID.true_random #:nodoc:
|
505
505
|
require 'benchmark'
|
506
506
|
hash = Digest::SHA1.new
|
507
507
|
performance = Benchmark.measure do
|
@@ -537,7 +537,7 @@ class UUID
|
|
537
537
|
return UUID.convert_int_to_byte_string(hash.to_s[4..35].to_i(16), 16)
|
538
538
|
end
|
539
539
|
|
540
|
-
def UUID.convert_int_to_byte_string(integer, size)
|
540
|
+
def UUID.convert_int_to_byte_string(integer, size) #:nodoc:
|
541
541
|
byte_string = ""
|
542
542
|
for i in 0..(size - 1)
|
543
543
|
byte_string << ((integer >> (((size - 1) - i) * 8)) & 0xFF)
|
@@ -545,7 +545,7 @@ class UUID
|
|
545
545
|
return byte_string
|
546
546
|
end
|
547
547
|
|
548
|
-
def UUID.convert_byte_string_to_int(byte_string)
|
548
|
+
def UUID.convert_byte_string_to_int(byte_string) #:nodoc:
|
549
549
|
integer = 0
|
550
550
|
size = byte_string.size
|
551
551
|
for i in 0..(size - 1)
|
@@ -553,14 +553,6 @@ class UUID
|
|
553
553
|
end
|
554
554
|
return integer
|
555
555
|
end
|
556
|
-
|
557
|
-
class << self
|
558
|
-
protected :create_from_hash
|
559
|
-
protected :get_mac_address
|
560
|
-
protected :true_random
|
561
|
-
protected :convert_int_to_byte_string
|
562
|
-
protected :convert_byte_string_to_int
|
563
|
-
end
|
564
556
|
end
|
565
557
|
|
566
558
|
UUID_DNS_NAMESPACE = UUID.parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
|
data/rakefile
CHANGED
data/test/create_test.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'uuidtools'
|
3
|
+
|
4
|
+
class CreateTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_sha1_create
|
9
|
+
assert_equal(
|
10
|
+
"f2d04685-b787-55da-8644-9bd28a6f5a53",
|
11
|
+
UUID.sha1_create(UUID_URL_NAMESPACE, 'http://sporkmonger.com').to_s)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_md5_create
|
15
|
+
assert_equal(
|
16
|
+
"15074785-9071-3fe3-89bd-876e4b9e919b",
|
17
|
+
UUID.md5_create(UUID_URL_NAMESPACE, 'http://sporkmonger.com').to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_timestamp_create
|
21
|
+
assert_not_equal(
|
22
|
+
UUID.timestamp_create.to_s,
|
23
|
+
UUID.timestamp_create.to_s)
|
24
|
+
current_time = Time.now
|
25
|
+
assert_equal(
|
26
|
+
UUID.timestamp_create(current_time).to_s,
|
27
|
+
UUID.timestamp_create(current_time).to_s)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_random_create
|
31
|
+
assert_not_equal(
|
32
|
+
UUID.random_create.to_s,
|
33
|
+
UUID.random_create.to_s)
|
34
|
+
end
|
35
|
+
end
|
data/test/parse_test.rb
ADDED
File without changes
|
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.3
|
7
|
+
date: 2005-09-28 00:00:00 -04:00
|
8
8
|
summary: Generation of UUIDs.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -34,6 +34,8 @@ files:
|
|
34
34
|
- README
|
35
35
|
- CHANGELOG
|
36
36
|
- lib/uuidtools.rb
|
37
|
+
- test/create_test.rb
|
38
|
+
- test/parse_test.rb
|
37
39
|
test_files: []
|
38
40
|
rdoc_options:
|
39
41
|
- "--main"
|