uuid4r 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/extconf.rb +7 -2
- data/test/test_uuid.rb~ +120 -0
- metadata +22 -6
data/ext/extconf.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
+
lib="uuid"
|
4
|
+
|
3
5
|
if File.exist?(`which uuid-config`.chomp)
|
6
|
+
lib = `uuid-config --libs`.chomp.gsub(/-l/, '')
|
4
7
|
$CFLAGS << " -Wall " << `uuid-config --cflags`.chomp
|
5
8
|
$LDFLAGS << " " << `uuid-config --ldflags`.chomp
|
6
9
|
end
|
7
10
|
|
8
|
-
|
9
|
-
puts "OSSP uuid library required -- not found."
|
11
|
+
unless have_library(lib, 'uuid_export')
|
12
|
+
puts "OSSP uuid library '#{lib}' required -- not found."
|
10
13
|
exit 1
|
11
14
|
end
|
15
|
+
|
12
16
|
create_makefile('uuid4r')
|
17
|
+
|
13
18
|
File.open("Makefile", "a") << <<-EOT
|
14
19
|
|
15
20
|
check: $(DLLIB)
|
data/test/test_uuid.rb~
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require './uuid4r.so'
|
3
|
+
|
4
|
+
class UUIDTest < Test::Unit::TestCase
|
5
|
+
def test_uuid_v1_default
|
6
|
+
assert_kind_of(String, UUID4R::uuid_v1)
|
7
|
+
assert_kind_of(String, UUID4R::uuid(1))
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_uuid_v4_default
|
11
|
+
assert_kind_of(String, UUID4R::uuid_v4)
|
12
|
+
assert_kind_of(String, UUID4R::uuid(4))
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_uuid_v1_str
|
16
|
+
assert_kind_of(String, UUID4R::uuid_v1(:str))
|
17
|
+
assert(UUID4R::uuid_v1(:str).length > 0)
|
18
|
+
assert_not_equal(UUID4R::uuid_v1(:str), UUID4R::uuid_v1(:str))
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_uuid_v1_bin
|
22
|
+
assert_kind_of(String, UUID4R::uuid_v1(:bin))
|
23
|
+
assert_equal(16, UUID4R::uuid_v1(:bin).length)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_uuid_v1_txt
|
27
|
+
assert_kind_of(String, UUID4R::uuid_v1(:txt))
|
28
|
+
assert(/^variant:/ =~ UUID4R::uuid_v1(:txt))
|
29
|
+
assert(/^version:/ =~ UUID4R::uuid_v1(:txt))
|
30
|
+
assert(/^content:/ =~ UUID4R::uuid_v1(:txt))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_uuid_v3_str
|
34
|
+
a = UUID4R::uuid(3, "ns:URL", "www.sgtpepper.net", :str)
|
35
|
+
b = UUID4R::uuid(3, "ns:URL", "www.sgtpepper.net", :str)
|
36
|
+
c = UUID4R::uuid_v3("ns:URL", "www.sgtpepper.net", :str)
|
37
|
+
d = UUID4R::uuid_v3("ns:URL", "www.sgtpepper.net")
|
38
|
+
assert_kind_of(String, a)
|
39
|
+
assert(a.length > 0)
|
40
|
+
assert_equal(a, b)
|
41
|
+
assert_equal(a, c)
|
42
|
+
assert_equal(a, d)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_uuid_v5_str
|
46
|
+
a = UUID4R::uuid(5, "ns:URL", "www.sgtpepper.net", :str)
|
47
|
+
b = UUID4R::uuid(5, "ns:URL", "www.sgtpepper.net", :str)
|
48
|
+
c = UUID4R::uuid_v5("ns:URL", "www.sgtpepper.net", :str)
|
49
|
+
d = UUID4R::uuid_v5("ns:URL", "www.sgtpepper.net")
|
50
|
+
assert_kind_of(String, a)
|
51
|
+
assert(a.length > 0)
|
52
|
+
assert_equal(a, b)
|
53
|
+
assert_equal(a, c)
|
54
|
+
assert_equal(a, d)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_import
|
58
|
+
uuid = UUID4R::import(:str, "266eb9ae-ea6e-11da-8113-0030134d803d")
|
59
|
+
assert_kind_of(UUID4R::UUID4RCommon, uuid)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
class UUID4Rv1Test < Test::Unit::TestCase
|
65
|
+
def setup
|
66
|
+
@uuid = UUID4R::UUID4Rv1.new
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_export_str
|
70
|
+
assert_kind_of(String, @uuid.export(:str))
|
71
|
+
assert_equal(@uuid.export, @uuid.export(:str))
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_compare
|
75
|
+
uuid2 = UUID4R::UUID4Rv1.new
|
76
|
+
assert(@uuid.compare(uuid2) < 0)
|
77
|
+
assert(@uuid.compare(@uuid) == 0)
|
78
|
+
assert(uuid2.compare(@uuid) > 0)
|
79
|
+
assert_equal(-1, @uuid <=> uuid2)
|
80
|
+
assert_equal( 0, @uuid <=> @uuid)
|
81
|
+
assert_equal( 1, uuid2 <=> @uuid)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
class UUID4Rv4Test < Test::Unit::TestCase
|
87
|
+
def setup
|
88
|
+
@uuid = UUID4R::UUID4Rv4.new
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_export_str
|
92
|
+
assert_kind_of(String, @uuid.export(:str))
|
93
|
+
assert_equal(@uuid.export, @uuid.export(:str))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
class UUID4Rv3Test < Test::Unit::TestCase
|
99
|
+
def setup
|
100
|
+
@uuid = UUID4R::UUID4Rv3.new("ns:URL", "www.sgtpepper.net")
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_export_str
|
104
|
+
assert_kind_of(String, @uuid.export(:str))
|
105
|
+
assert_equal(@uuid.export, @uuid.export(:str))
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
class UUID4Rv5Test < Test::Unit::TestCase
|
111
|
+
def setup
|
112
|
+
@uuid = UUID4R::UUID4Rv5.new("ns:URL", "www.sgtpepper.net")
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_export_str
|
116
|
+
assert_kind_of(String, @uuid.export(:str))
|
117
|
+
assert_equal(@uuid.export, @uuid.export(:str))
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
metadata
CHANGED
@@ -1,20 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuid4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Daigo Moriwaki
|
14
|
+
- Stefan Kaes
|
8
15
|
autorequire:
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date:
|
19
|
+
date: 2011-05-15 00:00:00 +02:00
|
13
20
|
default_executable:
|
14
21
|
dependencies: []
|
15
22
|
|
16
23
|
description: " This library generates and parses Universally Unique Identifier (UUID),\n based on OSSP uuid C library. So, libossp-uuid library is pre-required.\n OSSP uuid (http://www.ossp.org/pkg/lib/uuid/) is a ISO-C:1999 application\n programming interface (API) for the generation of DCE 1.1, ISO/IEC\n 11578:1996 and RFC 4122 compliant UUID. It supports DCE 1.1 variant UUIDs\n of version 1 (time and node based), version 3 (name based, MD5), version 4\n (random number based) and version 5 (name based, SHA-1).\n"
|
17
|
-
email:
|
24
|
+
email:
|
25
|
+
- daigo@debian.org
|
26
|
+
- skaes@railsexpress.de
|
18
27
|
executables: []
|
19
28
|
|
20
29
|
extensions:
|
@@ -25,6 +34,7 @@ files:
|
|
25
34
|
- ext/extconf.rb
|
26
35
|
- ext/uuid4r.c
|
27
36
|
- test/test_uuid.rb
|
37
|
+
- test/test_uuid.rb~
|
28
38
|
- README
|
29
39
|
has_rdoc: true
|
30
40
|
homepage: http://uuid4r.rubyforge.org
|
@@ -40,21 +50,27 @@ rdoc_options:
|
|
40
50
|
require_paths:
|
41
51
|
- .
|
42
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
43
54
|
requirements:
|
44
55
|
- - ">="
|
45
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
46
60
|
version: "0"
|
47
|
-
version:
|
48
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
49
63
|
requirements:
|
50
64
|
- - ">="
|
51
65
|
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
52
69
|
version: "0"
|
53
|
-
version:
|
54
70
|
requirements: []
|
55
71
|
|
56
72
|
rubyforge_project: uuid4r
|
57
|
-
rubygems_version: 1.3.
|
73
|
+
rubygems_version: 1.3.7
|
58
74
|
signing_key:
|
59
75
|
specification_version: 3
|
60
76
|
summary: This generates and parses UUID, based on OSSP uuid C library.
|