uuidtools 2.1.4 → 2.1.5
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.
- checksums.yaml +7 -0
- data/CHANGELOG +4 -0
- data/README.md +3 -2
- data/Rakefile +5 -4
- data/lib/uuidtools.rb +19 -10
- data/lib/uuidtools/version.rb +2 -2
- data/spec/uuidtools/mac_address_spec.rb +66 -71
- data/spec/uuidtools/utility_spec.rb +4 -4
- data/spec/uuidtools/uuid_creation_spec.rb +43 -41
- data/spec/uuidtools/uuid_parsing_spec.rb +43 -42
- data/tasks/gem.rake +3 -3
- data/tasks/rspec.rake +0 -3
- metadata +23 -35
- data/tasks/rubyforge.rake +0 -89
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebf635496c48e173f29b09b4719846a83ab15d19
|
4
|
+
data.tar.gz: cdf833d1f98797978853ee0d700277704ec9ad86
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33c70bffe56bd16152da53299f283067ec0087070a3b4a94347a01d30bceada03b879e3cf2df697e168deff94789c5c69933641f77707764d187debf52bad7e7
|
7
|
+
data.tar.gz: dd36f05b2ec9f696c6c1a1c413df01f0372e504be3c09d4db77340c7db3bd68253e326b835913ef2cf9f35fd534ccb777ea00d043b47a272da46a461607bc3fe
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
# UUIDTools
|
2
2
|
|
3
3
|
<dl>
|
4
|
-
<dt>Homepage</dt><dd><a href="
|
4
|
+
<dt>Homepage</dt><dd><a href="https://github.com/sporkmonger/uuidtools">sporkmonger/uuidtools</a></dd>
|
5
5
|
<dt>Author</dt><dd><a href="mailto:bob@sporkmonger.com">Bob Aman</a></dd>
|
6
|
-
<dt>Copyright</dt><dd>Copyright © 2005-
|
6
|
+
<dt>Copyright</dt><dd>Copyright © 2005-2014 Bob Aman</dd>
|
7
7
|
<dt>License</dt><dd>Apache 2.0</dd>
|
8
8
|
</dl>
|
9
9
|
|
10
10
|
[](http://travis-ci.org/sporkmonger/uuidtools)
|
11
11
|
[](https://gemnasium.com/sporkmonger/uuidtools)
|
12
|
+
[](https://www.gittip.com/sporkmonger/ "Support Open Source Development w/ Gittip")
|
12
13
|
|
13
14
|
# Description
|
14
15
|
|
data/Rakefile
CHANGED
@@ -10,11 +10,12 @@ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
10
10
|
|
11
11
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
RUBY_FORGE_PATH = "/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}"
|
16
|
-
RUBY_FORGE_URL = "http://#{RUBY_FORGE_PROJECT}.rubyforge.org/"
|
13
|
+
GIT_HUB_USER = "sporkmonger"
|
14
|
+
GIT_HUB_URL = "https://github.com/#{GIT_HUB_USER}/#{PKG_NAME}"
|
17
15
|
|
16
|
+
PKG_AUTHOR = "Bob Aman"
|
17
|
+
PKG_AUTHOR_EMAIL = "bob@sporkmonger.com"
|
18
|
+
PKG_HOMEPAGE = GIT_HUB_URL
|
18
19
|
PKG_SUMMARY = "UUID generator"
|
19
20
|
PKG_DESCRIPTION = <<-TEXT
|
20
21
|
A simple universally unique ID generation library.
|
data/lib/uuidtools.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding:utf-8
|
2
2
|
#--
|
3
|
-
# Copyright (C) 2005-
|
3
|
+
# Copyright (C) 2005-2014 Bob Aman
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -156,9 +156,7 @@ module UUIDTools
|
|
156
156
|
raise TypeError,
|
157
157
|
"Expected String, got #{uuid_string.class.name} instead."
|
158
158
|
end
|
159
|
-
uuid_components = uuid_string.downcase.scan(
|
160
|
-
Regexp.new("^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-" +
|
161
|
-
"([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})$")).first
|
159
|
+
uuid_components = uuid_string.downcase.scan(UUIDTools::UUID_REGEXP).first
|
162
160
|
raise ArgumentError, "Invalid UUID format." if uuid_components.nil?
|
163
161
|
time_low = uuid_components[0].to_i(16)
|
164
162
|
time_mid = uuid_components[1].to_i(16)
|
@@ -395,6 +393,7 @@ module UUIDTools
|
|
395
393
|
##
|
396
394
|
# Compares two UUIDs lexically
|
397
395
|
def <=>(other_uuid)
|
396
|
+
return nil unless other_uuid.is_a?(UUIDTools::UUID)
|
398
397
|
check = self.time_low <=> other_uuid.time_low
|
399
398
|
return check if check != 0
|
400
399
|
check = self.time_mid <=> other_uuid.time_mid
|
@@ -554,7 +553,7 @@ module UUIDTools
|
|
554
553
|
|
555
554
|
#
|
556
555
|
# Find the path of the ifconfig(8) command if it is present
|
557
|
-
#
|
556
|
+
#
|
558
557
|
def self.ifconfig_path
|
559
558
|
path = `which #{UUID.ifconfig_command} 2>/dev/null`.strip
|
560
559
|
path = UUID.ifconfig_path_default if (path == "" && File.exist?(UUID.ifconfig_path_default))
|
@@ -579,7 +578,7 @@ module UUIDTools
|
|
579
578
|
|
580
579
|
# if it does not exist, try the ip command
|
581
580
|
if ifconfig_path == nil
|
582
|
-
ifconfig_path = UUID.ip_path
|
581
|
+
ifconfig_path = "#{UUID.ip_path} addr list"
|
583
582
|
# all makes no sense when using ip(1)
|
584
583
|
all = nil
|
585
584
|
end
|
@@ -607,9 +606,14 @@ module UUIDTools
|
|
607
606
|
end
|
608
607
|
|
609
608
|
mac = parse_mac.call(instring)
|
610
|
-
|
611
|
-
|
612
|
-
|
609
|
+
if mac
|
610
|
+
# expand octets that were compressed (solaris)
|
611
|
+
return (mac.split(':').map do |octet|
|
612
|
+
(octet.length == 1 ? "0#{octet}" : octet)
|
613
|
+
end).join(':')
|
614
|
+
else
|
615
|
+
return nil
|
616
|
+
end
|
613
617
|
end
|
614
618
|
|
615
619
|
##
|
@@ -618,7 +622,7 @@ module UUIDTools
|
|
618
622
|
def self.mac_address
|
619
623
|
if !defined?(@@mac_address)
|
620
624
|
require 'rbconfig'
|
621
|
-
|
625
|
+
|
622
626
|
os_class = UUID.os_class
|
623
627
|
|
624
628
|
if os_class == :windows
|
@@ -718,6 +722,11 @@ module UUIDTools
|
|
718
722
|
end
|
719
723
|
end
|
720
724
|
|
725
|
+
##
|
726
|
+
# Constant Regexp that matches a UUID and captures its components.
|
727
|
+
UUID_REGEXP = Regexp.new("^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-" +
|
728
|
+
"([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})$")
|
729
|
+
|
721
730
|
##
|
722
731
|
# Constant that represents the DNS namespace.
|
723
732
|
UUID_DNS_NAMESPACE = UUID.parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
|
data/lib/uuidtools/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding:utf-8
|
2
2
|
#--
|
3
|
-
# Copyright (C) 2005-
|
3
|
+
# Copyright (C) 2005-2014 Bob Aman
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -22,7 +22,7 @@ unless defined? UUIDTools::VERSION
|
|
22
22
|
module VERSION #:nodoc:
|
23
23
|
MAJOR = 2
|
24
24
|
MINOR = 1
|
25
|
-
TINY =
|
25
|
+
TINY = 5
|
26
26
|
|
27
27
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
28
28
|
end
|
@@ -22,10 +22,10 @@ end
|
|
22
22
|
#
|
23
23
|
solaris_sample = <<EOF
|
24
24
|
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
|
25
|
-
inet 127.0.0.1 netmask ff000000
|
25
|
+
inet 127.0.0.1 netmask ff000000
|
26
26
|
igb1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
|
27
27
|
inet 10.51.0.18 netmask ffffff00 broadcast 10.51.0.255
|
28
|
-
ether 0:21:28:fa:c6:65
|
28
|
+
ether 0:21:28:fa:c6:65
|
29
29
|
igb2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
|
30
30
|
inet 10.99.0.12 netmask ffffff00 broadcast 10.99.0.255
|
31
31
|
ether 0:21:28:fa:c6:66
|
@@ -40,14 +40,14 @@ windows_sample = <<EOF
|
|
40
40
|
Windows IP Configuration
|
41
41
|
|
42
42
|
Host Name . . . . . . . . . . . . : OFFICE
|
43
|
-
Primary Dns Suffix . . . . . . . :
|
43
|
+
Primary Dns Suffix . . . . . . . :
|
44
44
|
Node Type . . . . . . . . . . . . : Unknown
|
45
45
|
IP Routing Enabled. . . . . . . . : No
|
46
46
|
WINS Proxy Enabled. . . . . . . . : No
|
47
47
|
|
48
48
|
Ethernet adapter Local Area Connection:
|
49
49
|
|
50
|
-
Connection-specific DNS Suffix . :
|
50
|
+
Connection-specific DNS Suffix . :
|
51
51
|
Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller
|
52
52
|
Physical Address. . . . . . . . . : E0-CB-4E-5D-BC-E9
|
53
53
|
Dhcp Enabled. . . . . . . . . . . : No
|
@@ -72,7 +72,7 @@ eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
|
72
72
|
RX errors 0 dropped 0 overruns 0 frame 0
|
73
73
|
TX packets 99075 bytes 23551085 (22.4 MiB)
|
74
74
|
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
75
|
-
device interrupt 20 memory 0xf2600000-f2620000
|
75
|
+
device interrupt 20 memory 0xf2600000-f2620000
|
76
76
|
|
77
77
|
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
|
78
78
|
inet 127.0.0.1 netmask 255.0.0.0
|
@@ -95,35 +95,35 @@ eth0 Link encap:Ethernet HWaddr 00:80:C8:F8:4A:51
|
|
95
95
|
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
96
96
|
RX packets:190312 errors:0 dropped:0 overruns:0 frame:0
|
97
97
|
TX packets:86955 errors:0 dropped:0 overruns:0 carrier:0
|
98
|
-
collisions:0 txqueuelen:100
|
98
|
+
collisions:0 txqueuelen:100
|
99
99
|
RX bytes:30701229 (29.2 Mb) TX bytes:7878951 (7.5 Mb)
|
100
|
-
Interrupt:9 Base address:0x5000
|
100
|
+
Interrupt:9 Base address:0x5000
|
101
101
|
|
102
|
-
lo Link encap:Local Loopback
|
102
|
+
lo Link encap:Local Loopback
|
103
103
|
inet addr:127.0.0.1 Mask:255.0.0.0
|
104
104
|
UP LOOPBACK RUNNING MTU:16436 Metric:1
|
105
105
|
RX packets:306 errors:0 dropped:0 overruns:0 frame:0
|
106
106
|
TX packets:306 errors:0 dropped:0 overruns:0 carrier:0
|
107
|
-
collisions:0 txqueuelen:0
|
107
|
+
collisions:0 txqueuelen:0
|
108
108
|
RX bytes:29504 (28.8 Kb) TX bytes:29504 (28.8 Kb)
|
109
109
|
EOF
|
110
110
|
|
111
111
|
linux_mac_2 = "00:80:c8:f8:4a:51"
|
112
112
|
|
113
113
|
linux_ip_sample = <<EOF
|
114
|
-
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
|
114
|
+
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
|
115
115
|
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
116
116
|
inet 127.0.0.1/8 scope host lo
|
117
|
-
inet6 ::1/128 scope host
|
117
|
+
inet6 ::1/128 scope host
|
118
118
|
valid_lft forever preferred_lft forever
|
119
119
|
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
|
120
120
|
link/ether 00:26:2d:f6:0b:94 brd ff:ff:ff:ff:ff:ff
|
121
121
|
inet 10.16.187.125/22 brd 10.16.187.255 scope global eth0
|
122
|
-
inet6 fe80::226:2dff:fef6:b94/64 scope link
|
122
|
+
inet6 fe80::226:2dff:fef6:b94/64 scope link
|
123
123
|
valid_lft forever preferred_lft forever
|
124
124
|
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen 1000
|
125
125
|
link/ether 00:26:c6:c6:1a:b4 brd ff:ff:ff:ff:ff:ff
|
126
|
-
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
|
126
|
+
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
|
127
127
|
link/ether 52:54:00:e3:cf:d3 brd ff:ff:ff:ff:ff:ff
|
128
128
|
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
|
129
129
|
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500
|
@@ -139,14 +139,14 @@ freebsd_sample = <<EOF
|
|
139
139
|
igb0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
140
140
|
options=401bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,VLAN_HWTSO>
|
141
141
|
ether 00:25:90:2b:81:32
|
142
|
-
inet6 fe80::225:90ff:fe2b:8132%igb0 prefixlen 64 scopeid 0x1
|
142
|
+
inet6 fe80::225:90ff:fe2b:8132%igb0 prefixlen 64 scopeid 0x1
|
143
143
|
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
|
144
144
|
media: Ethernet autoselect (1000baseT <full-duplex>)
|
145
145
|
status: active
|
146
146
|
igb1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
147
147
|
options=401bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,VLAN_HWTSO>
|
148
148
|
ether 00:25:90:2b:81:32
|
149
|
-
inet6 fe80::225:90ff:fe2b:8133%igb1 prefixlen 64 scopeid 0x2
|
149
|
+
inet6 fe80::225:90ff:fe2b:8133%igb1 prefixlen 64 scopeid 0x2
|
150
150
|
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
|
151
151
|
media: Ethernet autoselect (1000baseT <full-duplex>)
|
152
152
|
EOF
|
@@ -180,24 +180,24 @@ openbsd_mac = "00:0d:b9:28:ab:44"
|
|
180
180
|
macos_sample = <<EOF
|
181
181
|
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
|
182
182
|
options=3<RXCSUM,TXCSUM>
|
183
|
-
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
|
184
|
-
inet 127.0.0.1 netmask 0xff000000
|
185
|
-
inet6 ::1 prefixlen 128
|
183
|
+
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
|
184
|
+
inet 127.0.0.1 netmask 0xff000000
|
185
|
+
inet6 ::1 prefixlen 128
|
186
186
|
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
|
187
187
|
stf0: flags=0<> mtu 1280
|
188
188
|
en0: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
|
189
189
|
options=27<RXCSUM,TXCSUM,VLAN_MTU,TSO4>
|
190
|
-
ether 58:b0:35:a4:cd:0c
|
191
|
-
inet6 fe80::5ab0:35ff:fea4:cd0c%en0 prefixlen 64 scopeid 0x4
|
190
|
+
ether 58:b0:35:a4:cd:0c
|
191
|
+
inet6 fe80::5ab0:35ff:fea4:cd0c%en0 prefixlen 64 scopeid 0x4
|
192
192
|
inet 192.168.142.136 netmask 0xfffffff0 broadcast 192.168.142.143
|
193
193
|
media: autoselect (1000baseT <full-duplex,flow-control>)
|
194
194
|
status: active
|
195
195
|
en1: flags=8823<UP,BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
|
196
|
-
ether d8:30:62:51:dd:3d
|
196
|
+
ether d8:30:62:51:dd:3d
|
197
197
|
media: autoselect (<unknown type>)
|
198
198
|
status: inactive
|
199
199
|
p2p0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 2304
|
200
|
-
ether 0a:30:62:51:dd:3d
|
200
|
+
ether 0a:30:62:51:dd:3d
|
201
201
|
media: autoselect
|
202
202
|
status: inactive
|
203
203
|
EOF
|
@@ -205,7 +205,7 @@ EOF
|
|
205
205
|
macos_mac = "58:b0:35:a4:cd:0c"
|
206
206
|
|
207
207
|
# Gather the samples and MAC addresses for simple access
|
208
|
-
samples = {
|
208
|
+
samples = {
|
209
209
|
:macos => macos_sample,
|
210
210
|
:windows => windows_sample,
|
211
211
|
:solaris => solaris_sample,
|
@@ -240,14 +240,13 @@ describe UUIDTools::UUID, "when obtaining a MAC address" do
|
|
240
240
|
|
241
241
|
it "should obtain a MAC address" do
|
242
242
|
pending_if_root_required()
|
243
|
-
@mac_address.
|
243
|
+
expect(@mac_address).not_to be_nil
|
244
244
|
end
|
245
245
|
|
246
246
|
it "should cache the MAC address" do
|
247
247
|
pending_if_root_required()
|
248
|
-
@mac_address.object_id.
|
248
|
+
expect(@mac_address.object_id).to eql(UUIDTools::UUID.mac_address.object_id)
|
249
249
|
end
|
250
|
-
|
251
250
|
end
|
252
251
|
|
253
252
|
describe UUIDTools::UUID, "before obtaining a MAC address" do
|
@@ -262,51 +261,51 @@ describe UUIDTools::UUID, "before obtaining a MAC address" do
|
|
262
261
|
|
263
262
|
it "should parse windows MAC addresses" do
|
264
263
|
# mock ifconfig() to return the windows sample
|
265
|
-
UUIDTools::UUID.
|
264
|
+
allow(UUIDTools::UUID).to receive(:ifconfig) { samples[:windows] }
|
266
265
|
mac = UUIDTools::UUID.mac_address
|
267
|
-
mac.
|
266
|
+
expect(mac).to eql(macs[:windows])
|
268
267
|
end
|
269
268
|
|
270
269
|
it "should parse solaris MAC addresses" do
|
271
|
-
UUIDTools::UUID.
|
270
|
+
allow(UUIDTools::UUID).to receive(:ifconfig) { samples[:solaris] }
|
272
271
|
mac = UUIDTools::UUID.mac_address
|
273
|
-
mac.
|
272
|
+
expect(mac).to eql(macs[:solaris])
|
274
273
|
end
|
275
274
|
|
276
275
|
it "should parse freebsd MAC addresses" do
|
277
|
-
UUIDTools::UUID.
|
276
|
+
allow(UUIDTools::UUID).to receive(:ifconfig) { samples[:freebsd] }
|
278
277
|
mac = UUIDTools::UUID.mac_address
|
279
|
-
mac.
|
278
|
+
expect(mac).to eql(macs[:freebsd])
|
280
279
|
end
|
281
280
|
|
282
281
|
it "should parse openbsd MAC addresses" do
|
283
|
-
UUIDTools::UUID.
|
282
|
+
allow(UUIDTools::UUID).to receive(:ifconfig) { samples[:openbsd] }
|
284
283
|
mac = UUIDTools::UUID.mac_address
|
285
|
-
mac.
|
284
|
+
expect(mac).to eql(macs[:openbsd])
|
286
285
|
end
|
287
286
|
|
288
287
|
it "should parse linux MAC addresses with ifconfig" do
|
289
|
-
UUIDTools::UUID.
|
288
|
+
allow(UUIDTools::UUID).to receive(:ifconfig) { samples[:linux] }
|
290
289
|
mac = UUIDTools::UUID.mac_address
|
291
|
-
mac.
|
290
|
+
expect(mac).to eql(macs[:linux])
|
292
291
|
end
|
293
292
|
|
294
293
|
it "should parse a linux HWaddr address with ifconfig" do
|
295
|
-
UUIDTools::UUID.
|
294
|
+
allow(UUIDTools::UUID).to receive(:ifconfig) { samples[:linux2] }
|
296
295
|
mac = UUIDTools::UUID.mac_address
|
297
|
-
mac.
|
296
|
+
expect(mac).to eql(macs[:linux2])
|
298
297
|
end
|
299
298
|
|
300
299
|
it "should parse macos MAC addresses with ifconfig" do
|
301
|
-
UUIDTools::UUID.
|
300
|
+
allow(UUIDTools::UUID).to receive(:ifconfig) { samples[:macos] }
|
302
301
|
mac = UUIDTools::UUID.mac_address
|
303
|
-
mac.
|
302
|
+
expect(mac).to eql(macs[:macos])
|
304
303
|
end
|
305
304
|
|
306
305
|
it "should parse linux MAC addresses with ip" do
|
307
|
-
UUIDTools::UUID.
|
306
|
+
allow(UUIDTools::UUID).to receive(:ifconfig) { samples[:linuxip] }
|
308
307
|
mac = UUIDTools::UUID.mac_address
|
309
|
-
mac.
|
308
|
+
expect(mac).to eql(macs[:linuxip])
|
310
309
|
end
|
311
310
|
|
312
311
|
it "should identify the default os classes" do
|
@@ -315,15 +314,15 @@ describe UUIDTools::UUID, "before obtaining a MAC address" do
|
|
315
314
|
end
|
316
315
|
|
317
316
|
os_class = UUIDTools::UUID.os_class
|
318
|
-
os_class.
|
317
|
+
expect(os_class).to be_nil
|
319
318
|
|
320
319
|
RbConfig::CONFIG['target_os'] = 'linux'
|
321
320
|
os_class = UUIDTools::UUID.os_class
|
322
|
-
os_class.
|
321
|
+
expect(os_class).to be_nil
|
323
322
|
|
324
323
|
RbConfig::CONFIG['target_os'] = 'darwin'
|
325
324
|
os_class = UUIDTools::UUID.os_class
|
326
|
-
os_class.
|
325
|
+
expect(os_class).to be_nil
|
327
326
|
end
|
328
327
|
|
329
328
|
it "should identify the solaris os classes" do
|
@@ -332,7 +331,7 @@ describe UUIDTools::UUID, "before obtaining a MAC address" do
|
|
332
331
|
end
|
333
332
|
|
334
333
|
os_class = UUIDTools::UUID.os_class
|
335
|
-
os_class.
|
334
|
+
expect(os_class).to eql(:solaris)
|
336
335
|
end
|
337
336
|
|
338
337
|
it "should identify the BSD os classes" do
|
@@ -341,11 +340,11 @@ describe UUIDTools::UUID, "before obtaining a MAC address" do
|
|
341
340
|
end
|
342
341
|
|
343
342
|
os_class = UUIDTools::UUID.os_class
|
344
|
-
os_class.
|
343
|
+
expect(os_class).to eql(:netbsd)
|
345
344
|
|
346
345
|
RbConfig::CONFIG['target_os'] = "openbsd"
|
347
346
|
os_class = UUIDTools::UUID.os_class
|
348
|
-
os_class.
|
347
|
+
expect(os_class).to eql(:openbsd)
|
349
348
|
|
350
349
|
end
|
351
350
|
|
@@ -354,15 +353,15 @@ describe UUIDTools::UUID, "before obtaining a MAC address" do
|
|
354
353
|
CONFIG['target_os'] = "win"
|
355
354
|
end
|
356
355
|
os_class = UUIDTools::UUID.os_class
|
357
|
-
os_class.
|
356
|
+
expect(os_class).to eql(:windows)
|
358
357
|
|
359
358
|
RbConfig::CONFIG['target_os'] = "w32"
|
360
359
|
os_class = UUIDTools::UUID.os_class
|
361
|
-
os_class.
|
360
|
+
expect(os_class).to eql(:windows)
|
362
361
|
|
363
362
|
RbConfig::CONFIG['target_os'] = "darwin"
|
364
363
|
os_class = UUIDTools::UUID.os_class
|
365
|
-
os_class.
|
364
|
+
expect(os_class).to be_nil
|
366
365
|
|
367
366
|
end
|
368
367
|
|
@@ -374,17 +373,17 @@ describe UUIDTools::UUID, "before obtaining a MAC address" do
|
|
374
373
|
UUIDTools::UUID.ifconfig_command="sh"
|
375
374
|
UUIDTools::UUID.ifconfig_path_default="notfound"
|
376
375
|
ifconfig_path = UUIDTools::UUID.ifconfig_path
|
377
|
-
# ifconfig_path.
|
376
|
+
# expect(ifconfig_path).to eql("/usr/bin/sh")
|
378
377
|
|
379
378
|
# Test what happens if it does not
|
380
379
|
UUIDTools::UUID.ifconfig_command="nosuchthing"
|
381
380
|
UUIDTools::UUID.ifconfig_path_default="default"
|
382
|
-
|
381
|
+
|
383
382
|
# ifconfig_path checks if the IFCONFIG_PATH command file exists
|
384
|
-
File.
|
383
|
+
allow(File).to receive(:exist?) { true }
|
385
384
|
|
386
385
|
ifconfig_path = UUIDTools::UUID.ifconfig_path
|
387
|
-
# ifconfig_path.
|
386
|
+
# expect(ifconfig_path).to eql("default")
|
388
387
|
|
389
388
|
UUIDTools::UUID.ifconfig_command=save_ifconfig_command
|
390
389
|
UUIDTools::UUID.ifconfig_path_default=save_ifconfig_path
|
@@ -399,61 +398,57 @@ describe UUIDTools::UUID, "before obtaining a MAC address" do
|
|
399
398
|
UUIDTools::UUID.ip_command="sh"
|
400
399
|
UUIDTools::UUID.ip_path_default="notfound"
|
401
400
|
ip_path = UUIDTools::UUID.ip_path
|
402
|
-
# ip_path.
|
401
|
+
# expect(ip_path).to eql("/usr/bin/sh")
|
403
402
|
|
404
403
|
# Test what happens if it does not
|
405
404
|
UUIDTools::UUID.ip_command="nosuchthing"
|
406
405
|
UUIDTools::UUID.ip_path_default="default"
|
407
|
-
|
406
|
+
|
408
407
|
# ifconfig_path checks if the IP_PATH command file exists
|
409
|
-
File.
|
408
|
+
allow(File).to receive(:exist?) { true }
|
410
409
|
|
411
410
|
ifconfig_path = UUIDTools::UUID.ip_path
|
412
|
-
# ifconfig_path.
|
411
|
+
# expect(ifconfig_path).to eql("default")
|
413
412
|
|
414
413
|
UUIDTools::UUID.ip_command=save_ip_command
|
415
414
|
UUIDTools::UUID.ip_path_default=save_ip_path
|
416
415
|
end
|
417
416
|
|
418
|
-
it "should return the output of the ifconfig program" do
|
419
|
-
pending "I'm not quite sure how to mock backticks"
|
420
|
-
end
|
421
|
-
|
422
417
|
it "should be able to parse windows ipconfig output" do
|
423
418
|
mac = UUIDTools::UUID.first_mac samples[:windows]
|
424
|
-
mac.
|
419
|
+
expect(mac).to eql(macs[:windows])
|
425
420
|
end
|
426
421
|
|
427
422
|
it "should be able to parse solaris ifconfig output" do
|
428
423
|
mac = UUIDTools::UUID.first_mac samples[:solaris]
|
429
|
-
mac.
|
424
|
+
expect(mac).to eql(macs[:solaris])
|
430
425
|
end
|
431
426
|
|
432
427
|
it "should be able to parse freebsd ifconfig output" do
|
433
428
|
mac = UUIDTools::UUID.first_mac samples[:freebsd]
|
434
|
-
mac.
|
429
|
+
expect(mac).to eql(macs[:freebsd])
|
435
430
|
end
|
436
431
|
|
437
432
|
it "should be able to parse openbsd ifconfig output" do
|
438
433
|
mac = UUIDTools::UUID.first_mac samples[:openbsd]
|
439
|
-
mac.
|
434
|
+
expect(mac).to eql(macs[:openbsd])
|
440
435
|
end
|
441
436
|
|
442
437
|
it "should be able to parse linux ifconfig output" do
|
443
438
|
mac = UUIDTools::UUID.first_mac samples[:linux]
|
444
|
-
mac.
|
439
|
+
expect(mac).to eql(macs[:linux])
|
445
440
|
|
446
441
|
mac2 = UUIDTools::UUID.first_mac samples[:linux2]
|
447
|
-
mac2.
|
442
|
+
expect(mac2).to eql(macs[:linux2])
|
448
443
|
end
|
449
444
|
|
450
445
|
it "should be able to parse macos ifconfig output" do
|
451
446
|
mac = UUIDTools::UUID.first_mac samples[:macos]
|
452
|
-
mac.
|
447
|
+
expect(mac).to eql(macs[:macos])
|
453
448
|
end
|
454
449
|
|
455
450
|
it "should be able to parse ip addr output" do
|
456
451
|
mac = UUIDTools::UUID.first_mac samples[:linuxip]
|
457
|
-
mac.
|
452
|
+
expect(mac).to eql(macs[:linuxip])
|
458
453
|
end
|
459
454
|
end
|
@@ -7,15 +7,15 @@ describe SecureRandom do
|
|
7
7
|
bits << SecureRandom.random_bytes(16)
|
8
8
|
end
|
9
9
|
# Check to make sure that none of the 10,000 strings were duplicates
|
10
|
-
(bits.map {|x| x.to_s}).uniq.size.
|
10
|
+
expect((bits.map {|x| x.to_s}).uniq.size).to eql(bits.size)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return the correct number of random bits" do
|
14
|
-
SecureRandom.random_bytes(16).size.
|
15
|
-
SecureRandom.random_bytes(6).size.
|
14
|
+
expect(SecureRandom.random_bytes(16).size).to eql(16)
|
15
|
+
expect(SecureRandom.random_bytes(6).size).to eql(6)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return a sane random number" do
|
19
|
-
SecureRandom.random_number(5000).
|
19
|
+
expect(SecureRandom.random_number(5000)).to be < 5000
|
20
20
|
end
|
21
21
|
end
|
@@ -2,36 +2,38 @@ require File.expand_path("../../spec_helper.rb", __FILE__)
|
|
2
2
|
|
3
3
|
describe UUIDTools::UUID, "when generating" do
|
4
4
|
it "should correctly generate SHA1 variant UUIDs" do
|
5
|
-
UUIDTools::UUID.sha1_create(
|
5
|
+
expect(UUIDTools::UUID.sha1_create(
|
6
6
|
UUIDTools::UUID_URL_NAMESPACE, 'http://sporkmonger.com'
|
7
|
-
).to_s.
|
7
|
+
).to_s).to eql('f2d04685-b787-55da-8644-9bd28a6f5a53')
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should correctly generate MD5 variant UUIDs" do
|
11
|
-
UUIDTools::UUID.md5_create(
|
11
|
+
expect(UUIDTools::UUID.md5_create(
|
12
12
|
UUIDTools::UUID_URL_NAMESPACE, 'http://sporkmonger.com'
|
13
|
-
).to_s.
|
13
|
+
).to_s).to eql('15074785-9071-3fe3-89bd-876e4b9e919b')
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should correctly generate timestamp variant UUIDs" do
|
17
|
-
UUIDTools::UUID.timestamp_create.
|
18
|
-
UUIDTools::UUID.timestamp_create.to_s.
|
17
|
+
expect(UUIDTools::UUID.timestamp_create).not_to be_random_node_id
|
18
|
+
expect(UUIDTools::UUID.timestamp_create.to_s).not_to eql(
|
19
19
|
UUIDTools::UUID.timestamp_create.to_s
|
20
|
+
)
|
20
21
|
current_time = Time.now
|
21
|
-
UUIDTools::UUID.timestamp_create(current_time).to_s.
|
22
|
+
expect(UUIDTools::UUID.timestamp_create(current_time).to_s).not_to eql(
|
22
23
|
UUIDTools::UUID.timestamp_create(current_time).to_s
|
24
|
+
)
|
23
25
|
uuids = []
|
24
26
|
1000.times do
|
25
27
|
uuids << UUIDTools::UUID.timestamp_create
|
26
28
|
end
|
27
29
|
# Check to make sure that none of the 1,000 UUIDs were duplicates
|
28
|
-
(uuids.map {|x| x.to_s}).uniq.size.
|
30
|
+
expect((uuids.map {|x| x.to_s}).uniq.size).to eql(uuids.size)
|
29
31
|
end
|
30
32
|
|
31
33
|
it "should correctly generate UUIDs without a MAC address" do
|
32
34
|
mac_address = UUIDTools::UUID.mac_address
|
33
35
|
UUIDTools::UUID.mac_address = nil
|
34
|
-
UUIDTools::UUID.timestamp_create.
|
36
|
+
expect(UUIDTools::UUID.timestamp_create).to be_random_node_id
|
35
37
|
UUIDTools::UUID.mac_address = mac_address
|
36
38
|
end
|
37
39
|
|
@@ -41,88 +43,88 @@ describe UUIDTools::UUID, "when generating" do
|
|
41
43
|
uuids << UUIDTools::UUID.random_create
|
42
44
|
end
|
43
45
|
# Check to make sure that none of the 1,000 UUIDs were duplicates
|
44
|
-
(uuids.map {|x| x.to_s}).uniq.size.
|
46
|
+
expect((uuids.map {|x| x.to_s}).uniq.size).to eql(uuids.size)
|
45
47
|
end
|
46
48
|
|
47
49
|
it "should not have internal state used in string representations" do
|
48
50
|
uuid = UUIDTools::UUID.random_create
|
49
51
|
uuid_string = uuid.to_s.dup
|
50
52
|
uuid.to_s.gsub!("-", "/")
|
51
|
-
uuid.to_s.
|
53
|
+
expect(uuid.to_s).to eql(uuid_string)
|
52
54
|
end
|
53
55
|
|
54
56
|
it "should throw an exception if a segment has an invalid value" do
|
55
|
-
(lambda do
|
57
|
+
expect(lambda do
|
56
58
|
UUIDTools::UUID.new(-1, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])
|
57
|
-
end).
|
58
|
-
(lambda do
|
59
|
+
end).to raise_error(ArgumentError)
|
60
|
+
expect(lambda do
|
59
61
|
UUIDTools::UUID.new(4294967296, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])
|
60
|
-
end).
|
62
|
+
end).to raise_error(ArgumentError)
|
61
63
|
end
|
62
64
|
|
63
65
|
it "should throw an exception if a segment has an invalid value" do
|
64
|
-
(lambda do
|
66
|
+
expect(lambda do
|
65
67
|
UUIDTools::UUID.new(0, -1, 0, 0, 0, [0, 0, 0, 0, 0, 0])
|
66
|
-
end).
|
67
|
-
(lambda do
|
68
|
+
end).to raise_error(ArgumentError)
|
69
|
+
expect(lambda do
|
68
70
|
UUIDTools::UUID.new(0, 65536, 0, 0, 0, [0, 0, 0, 0, 0, 0])
|
69
|
-
end).
|
71
|
+
end).to raise_error(ArgumentError)
|
70
72
|
end
|
71
73
|
|
72
74
|
it "should throw an exception if a segment has an invalid value" do
|
73
|
-
(lambda do
|
75
|
+
expect(lambda do
|
74
76
|
UUIDTools::UUID.new(0, 0, -1, 0, 0, [0, 0, 0, 0, 0, 0])
|
75
|
-
end).
|
76
|
-
(lambda do
|
77
|
+
end).to raise_error(ArgumentError)
|
78
|
+
expect(lambda do
|
77
79
|
UUIDTools::UUID.new(0, 0, 65536, 0, 0, [0, 0, 0, 0, 0, 0])
|
78
|
-
end).
|
80
|
+
end).to raise_error(ArgumentError)
|
79
81
|
end
|
80
82
|
|
81
83
|
it "should throw an exception if a segment has an invalid value" do
|
82
|
-
(lambda do
|
84
|
+
expect(lambda do
|
83
85
|
UUIDTools::UUID.new(0, 0, 0, -1, 0, [0, 0, 0, 0, 0, 0])
|
84
|
-
end).
|
85
|
-
(lambda do
|
86
|
+
end).to raise_error(ArgumentError)
|
87
|
+
expect(lambda do
|
86
88
|
UUIDTools::UUID.new(0, 0, 0, 256, 0, [0, 0, 0, 0, 0, 0])
|
87
|
-
end).
|
89
|
+
end).to raise_error(ArgumentError)
|
88
90
|
end
|
89
91
|
|
90
92
|
it "should throw an exception if a segment has an invalid value" do
|
91
|
-
(lambda do
|
93
|
+
expect(lambda do
|
92
94
|
UUIDTools::UUID.new(0, 0, 0, 0, -1, [0, 0, 0, 0, 0, 0])
|
93
|
-
end).
|
94
|
-
(lambda do
|
95
|
+
end).to raise_error(ArgumentError)
|
96
|
+
expect(lambda do
|
95
97
|
UUIDTools::UUID.new(0, 0, 0, 0, 256, [0, 0, 0, 0, 0, 0])
|
96
|
-
end).
|
98
|
+
end).to raise_error(ArgumentError)
|
97
99
|
end
|
98
100
|
|
99
101
|
it "should throw an exception if nodes are not a collection" do
|
100
|
-
(lambda do
|
102
|
+
expect(lambda do
|
101
103
|
UUIDTools::UUID.new(0, 0, 0, 0, 0, :bogus)
|
102
|
-
end).
|
104
|
+
end).to raise_error(TypeError)
|
103
105
|
end
|
104
106
|
|
105
107
|
it "should throw an exception if nodes are the wrong size" do
|
106
|
-
(lambda do
|
108
|
+
expect(lambda do
|
107
109
|
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0])
|
108
|
-
end).
|
110
|
+
end).to raise_error(ArgumentError)
|
109
111
|
end
|
110
112
|
|
111
113
|
it "should throw an exception if any nodes have invalid values" do
|
112
|
-
(lambda do
|
114
|
+
expect(lambda do
|
113
115
|
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 256])
|
114
|
-
end).
|
116
|
+
end).to raise_error(ArgumentError)
|
115
117
|
end
|
116
118
|
|
117
119
|
it "should throw an exception if parsing anything but a String" do
|
118
|
-
(lambda do
|
120
|
+
expect(lambda do
|
119
121
|
UUIDTools::UUID.parse(:bogus)
|
120
|
-
end).
|
122
|
+
end).to raise_error(TypeError)
|
121
123
|
end
|
122
124
|
|
123
125
|
it "should throw an exception if raw parsing anything but a String" do
|
124
|
-
(lambda do
|
126
|
+
expect(lambda do
|
125
127
|
UUIDTools::UUID.parse_raw(:bogus)
|
126
|
-
end).
|
128
|
+
end).to raise_error(TypeError)
|
127
129
|
end
|
128
130
|
end
|
@@ -2,65 +2,66 @@ require File.expand_path("../../spec_helper.rb", __FILE__)
|
|
2
2
|
|
3
3
|
describe UUIDTools::UUID, "when parsing" do
|
4
4
|
it "should correctly parse the MAC address from a timestamp version UUID" do
|
5
|
-
UUIDTools::UUID.timestamp_create.mac_address.
|
5
|
+
expect(UUIDTools::UUID.timestamp_create.mac_address).to eql(
|
6
6
|
UUIDTools::UUID.mac_address
|
7
|
+
)
|
7
8
|
end
|
8
9
|
|
9
10
|
it "should correctly parse the variant from a timestamp version UUID" do
|
10
|
-
UUIDTools::UUID.timestamp_create.variant.
|
11
|
+
expect(UUIDTools::UUID.timestamp_create.variant).to eql(0b100)
|
11
12
|
end
|
12
13
|
|
13
14
|
it "should correctly parse the version from a timestamp version UUID" do
|
14
|
-
UUIDTools::UUID.timestamp_create.version.
|
15
|
+
expect(UUIDTools::UUID.timestamp_create.version).to eql(1)
|
15
16
|
end
|
16
17
|
|
17
18
|
it "should correctly parse the timestamp from a timestamp version UUID" do
|
18
|
-
UUIDTools::UUID.timestamp_create.timestamp.
|
19
|
-
UUIDTools::UUID.timestamp_create.timestamp.
|
19
|
+
expect(UUIDTools::UUID.timestamp_create.timestamp).to be < (Time.now + 1)
|
20
|
+
expect(UUIDTools::UUID.timestamp_create.timestamp).to be > (Time.now - 1)
|
20
21
|
end
|
21
22
|
|
22
23
|
it "should not treat a timestamp version UUID as a nil UUID" do
|
23
|
-
UUIDTools::UUID.timestamp_create.
|
24
|
+
expect(UUIDTools::UUID.timestamp_create).not_to be_nil_uuid
|
24
25
|
end
|
25
26
|
|
26
27
|
it "should not treat a timestamp version UUID as a random node UUID" do
|
27
|
-
UUIDTools::UUID.timestamp_create.
|
28
|
+
expect(UUIDTools::UUID.timestamp_create).not_to be_random_node_id
|
28
29
|
end
|
29
30
|
|
30
31
|
it "should treat a timestamp version UUID as a random node UUID " +
|
31
32
|
"if there is no MAC address" do
|
32
33
|
old_mac_address = UUIDTools::UUID.mac_address
|
33
34
|
UUIDTools::UUID.mac_address = nil
|
34
|
-
UUIDTools::UUID.timestamp_create.
|
35
|
+
expect(UUIDTools::UUID.timestamp_create).to be_random_node_id
|
35
36
|
UUIDTools::UUID.mac_address = old_mac_address
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should correctly identify the nil UUID" do
|
39
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).
|
40
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])).to be_nil_uuid
|
40
41
|
end
|
41
42
|
|
42
43
|
it "should correctly identify timestamp version UUIDs as valid" do
|
43
|
-
UUIDTools::UUID.timestamp_create.
|
44
|
+
expect(UUIDTools::UUID.timestamp_create).to be_valid
|
44
45
|
end
|
45
46
|
|
46
47
|
it "should correctly identify random number version UUIDs as valid" do
|
47
|
-
UUIDTools::UUID.random_create.
|
48
|
+
expect(UUIDTools::UUID.random_create).to be_valid
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should correctly identify SHA1 hash version UUIDs as valid" do
|
51
|
-
UUIDTools::UUID.sha1_create(
|
52
|
+
expect(UUIDTools::UUID.sha1_create(
|
52
53
|
UUIDTools::UUID_URL_NAMESPACE, 'http://sporkmonger.com'
|
53
|
-
).
|
54
|
+
)).to be_valid
|
54
55
|
end
|
55
56
|
|
56
57
|
it "should correctly identify MD5 hash version UUIDs as valid" do
|
57
|
-
UUIDTools::UUID.md5_create(
|
58
|
+
expect(UUIDTools::UUID.md5_create(
|
58
59
|
UUIDTools::UUID_URL_NAMESPACE, 'http://sporkmonger.com'
|
59
|
-
).
|
60
|
+
)).to be_valid
|
60
61
|
end
|
61
62
|
|
62
63
|
it "should not identify the nil UUID as valid" do
|
63
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).
|
64
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])).not_to be_valid
|
64
65
|
end
|
65
66
|
|
66
67
|
it "should allow for sorting of UUID arrays" do
|
@@ -69,59 +70,59 @@ describe UUIDTools::UUID, "when parsing" do
|
|
69
70
|
uuids << UUIDTools::UUID.timestamp_create
|
70
71
|
end
|
71
72
|
uuids.sort!
|
72
|
-
uuids.first.
|
73
|
-
uuids.last.
|
73
|
+
expect(uuids.first).to be < uuids.last
|
74
|
+
expect(uuids.last).to be > uuids.first
|
74
75
|
end
|
75
76
|
|
76
77
|
it "should allow for comparison of UUIDs" do
|
77
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).
|
78
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])).to be <
|
78
79
|
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 1])
|
79
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 1]).
|
80
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])
|
81
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).should ==
|
80
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 1])).to be >
|
82
81
|
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])
|
82
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])).to eql(
|
83
|
+
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]))
|
83
84
|
end
|
84
85
|
|
85
86
|
it "should produce the correct hexdigest for a UUID" do
|
86
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).hexdigest.
|
87
|
-
|
88
|
-
UUIDTools::UUID.new(1, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).hexdigest.
|
89
|
-
|
90
|
-
UUIDTools::UUID.timestamp_create.hexdigest.size.
|
87
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).hexdigest).to eql(
|
88
|
+
'00000000000000000000000000000000')
|
89
|
+
expect(UUIDTools::UUID.new(1, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).hexdigest).to eql(
|
90
|
+
'00000001000000000000000000000000')
|
91
|
+
expect(UUIDTools::UUID.timestamp_create.hexdigest.size).to eql(32)
|
91
92
|
end
|
92
93
|
|
93
94
|
it "should produce a sane hash value for a UUID" do
|
94
95
|
uuid = UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])
|
95
|
-
uuid.to_i.
|
96
|
-
uuid.hash.
|
96
|
+
expect(uuid.to_i).to eql(0)
|
97
|
+
expect(uuid.hash).to be_kind_of(Fixnum)
|
97
98
|
end
|
98
99
|
|
99
100
|
it "should produce the correct URI for a UUID" do
|
100
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).to_uri.
|
101
|
-
|
101
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).to_uri).to eql(
|
102
|
+
'urn:uuid:00000000-0000-0000-0000-000000000000')
|
102
103
|
end
|
103
104
|
|
104
105
|
it "should correctly test UUID equality" do
|
105
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).
|
106
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])).to eql(
|
106
107
|
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])
|
107
108
|
)
|
108
109
|
end
|
109
110
|
|
110
111
|
it "should correctly parse integers" do
|
111
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).
|
112
|
-
UUIDTools::UUID.parse_int(0)
|
113
|
-
UUIDTools::UUID.parse_int(0).
|
112
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])).to eql(
|
113
|
+
UUIDTools::UUID.parse_int(0))
|
114
|
+
expect(UUIDTools::UUID.parse_int(0)).to be_nil_uuid
|
114
115
|
uuid = UUIDTools::UUID.timestamp_create
|
115
|
-
UUIDTools::UUID.parse_int(uuid.to_i).
|
116
|
+
expect(UUIDTools::UUID.parse_int(uuid.to_i)).to eql(uuid)
|
116
117
|
end
|
117
118
|
|
118
119
|
it "should correctly parse hexdigests" do
|
119
|
-
UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0]).
|
120
|
-
UUIDTools::UUID.parse_hexdigest(
|
121
|
-
UUIDTools::UUID.parse_hexdigest(
|
122
|
-
|
123
|
-
).
|
120
|
+
expect(UUIDTools::UUID.new(0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0])).to eql(
|
121
|
+
UUIDTools::UUID.parse_hexdigest('00000000000000000000000000000000'))
|
122
|
+
expect(UUIDTools::UUID.parse_hexdigest(
|
123
|
+
'00000000000000000000000000000000'
|
124
|
+
)).to be_nil_uuid
|
124
125
|
uuid = UUIDTools::UUID.timestamp_create
|
125
|
-
UUIDTools::UUID.parse_hexdigest(uuid.hexdigest).
|
126
|
+
expect(UUIDTools::UUID.parse_hexdigest(uuid.hexdigest)).to eql(uuid)
|
126
127
|
end
|
127
128
|
end
|
data/tasks/gem.rake
CHANGED
@@ -28,9 +28,9 @@ namespace :gem do
|
|
28
28
|
|
29
29
|
s.require_path = "lib"
|
30
30
|
|
31
|
-
s.author =
|
32
|
-
s.email =
|
33
|
-
s.homepage =
|
31
|
+
s.author = PKG_AUTHOR
|
32
|
+
s.email = PKG_AUTHOR_EMAIL
|
33
|
+
s.homepage = PKG_HOMEPAGE
|
34
34
|
end
|
35
35
|
|
36
36
|
Gem::PackageTask.new(GEM_SPEC) do |p|
|
data/tasks/rspec.rake
CHANGED
@@ -8,7 +8,6 @@ namespace :spec do
|
|
8
8
|
t.pattern = FileList['spec/**/*_spec.rb']
|
9
9
|
t.rspec_opts = ['--color', '--format', 'documentation']
|
10
10
|
|
11
|
-
t.rcov = true
|
12
11
|
t.rcov_opts = [
|
13
12
|
'--exclude', 'lib\\/compat',
|
14
13
|
'--exclude', 'spec',
|
@@ -23,13 +22,11 @@ namespace :spec do
|
|
23
22
|
RSpec::Core::RakeTask.new(:normal) do |t|
|
24
23
|
t.pattern = FileList['spec/**/*_spec.rb'].exclude(/compat/)
|
25
24
|
t.rspec_opts = ['--color', '--format', 'documentation']
|
26
|
-
t.rcov = false
|
27
25
|
end
|
28
26
|
|
29
27
|
RSpec::Core::RakeTask.new(:all) do |t|
|
30
28
|
t.pattern = FileList['spec/**/*_spec.rb']
|
31
29
|
t.rspec_opts = ['--color', '--format', 'documentation']
|
32
|
-
t.rcov = false
|
33
30
|
end
|
34
31
|
|
35
32
|
desc "Generate HTML Specdocs for all specs"
|
metadata
CHANGED
@@ -1,89 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuidtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Bob Aman
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-08-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.7.3
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.7.3
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 2.9.0
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 2.9.0
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: yard
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 0.8.2
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 0.8.2
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: launchy
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: 2.0.0
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 2.0.0
|
78
|
-
description:
|
79
|
-
|
80
|
-
'
|
69
|
+
description: |
|
70
|
+
A simple universally unique ID generation library.
|
81
71
|
email: bob@sporkmonger.com
|
82
72
|
executables: []
|
83
73
|
extensions: []
|
84
74
|
extra_rdoc_files:
|
85
75
|
- README.md
|
86
76
|
files:
|
77
|
+
- CHANGELOG
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
87
81
|
- lib/compat/securerandom.rb
|
88
82
|
- lib/uuidtools.rb
|
89
83
|
- lib/uuidtools/version.rb
|
@@ -98,37 +92,31 @@ files:
|
|
98
92
|
- tasks/git.rake
|
99
93
|
- tasks/metrics.rake
|
100
94
|
- tasks/rspec.rake
|
101
|
-
- tasks/rubyforge.rake
|
102
95
|
- tasks/yard.rake
|
103
96
|
- website/index.html
|
104
|
-
|
105
|
-
- LICENSE.txt
|
106
|
-
- README.md
|
107
|
-
- Rakefile
|
108
|
-
homepage: http://uuidtools.rubyforge.org/
|
97
|
+
homepage: https://github.com/sporkmonger/uuidtools
|
109
98
|
licenses: []
|
99
|
+
metadata: {}
|
110
100
|
post_install_message:
|
111
101
|
rdoc_options:
|
112
|
-
- --main
|
102
|
+
- "--main"
|
113
103
|
- README.md
|
114
104
|
require_paths:
|
115
105
|
- lib
|
116
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
107
|
requirements:
|
119
|
-
- -
|
108
|
+
- - ">="
|
120
109
|
- !ruby/object:Gem::Version
|
121
110
|
version: '0'
|
122
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
112
|
requirements:
|
125
|
-
- -
|
113
|
+
- - ">="
|
126
114
|
- !ruby/object:Gem::Version
|
127
115
|
version: '0'
|
128
116
|
requirements: []
|
129
117
|
rubyforge_project:
|
130
|
-
rubygems_version:
|
118
|
+
rubygems_version: 2.2.2
|
131
119
|
signing_key:
|
132
|
-
specification_version:
|
120
|
+
specification_version: 4
|
133
121
|
summary: UUID generator
|
134
122
|
test_files: []
|
data/tasks/rubyforge.rake
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
namespace :gem do
|
2
|
-
desc 'Package and upload to RubyForge'
|
3
|
-
task :release => ["gem:package"] do |t|
|
4
|
-
require 'rubyforge'
|
5
|
-
|
6
|
-
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
7
|
-
abort "Versions don't match #{v} vs #{PROJ.version}" if v != PKG_VERSION
|
8
|
-
pkg = "pkg/#{GEM_SPEC.full_name}"
|
9
|
-
|
10
|
-
rf = RubyForge.new
|
11
|
-
rf.configure
|
12
|
-
puts 'Logging in...'
|
13
|
-
rf.login
|
14
|
-
|
15
|
-
c = rf.userconfig
|
16
|
-
changelog = File.open("CHANGELOG") { |file| file.read }
|
17
|
-
c['release_changes'] = changelog
|
18
|
-
c['preformatted'] = true
|
19
|
-
|
20
|
-
files = ["#{pkg}.tgz", "#{pkg}.zip", "#{pkg}.gem"]
|
21
|
-
|
22
|
-
puts "Releasing #{PKG_NAME} v. #{PKG_VERSION}"
|
23
|
-
rf.add_release RUBY_FORGE_PROJECT, PKG_NAME, PKG_VERSION, *files
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
namespace :doc do
|
28
|
-
desc "Publish RDoc to RubyForge"
|
29
|
-
task :release => ["doc:yard"] do
|
30
|
-
require "rake/contrib/sshpublisher"
|
31
|
-
require "yaml"
|
32
|
-
|
33
|
-
config = YAML.load(
|
34
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
35
|
-
)
|
36
|
-
host = "#{config['username']}@rubyforge.org"
|
37
|
-
remote_dir = RUBY_FORGE_PATH + "/api"
|
38
|
-
local_dir = "doc"
|
39
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
namespace :spec do
|
44
|
-
desc "Publish specdoc to RubyForge"
|
45
|
-
task :release => ["spec:specdoc"] do
|
46
|
-
require "rake/contrib/sshpublisher"
|
47
|
-
require "yaml"
|
48
|
-
|
49
|
-
config = YAML.load(
|
50
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
51
|
-
)
|
52
|
-
host = "#{config['username']}@rubyforge.org"
|
53
|
-
remote_dir = RUBY_FORGE_PATH + "/specdoc"
|
54
|
-
local_dir = "specdoc"
|
55
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
56
|
-
end
|
57
|
-
|
58
|
-
namespace :rcov do
|
59
|
-
desc "Publish coverage report to RubyForge"
|
60
|
-
task :release => ["spec:rcov"] do
|
61
|
-
require "rake/contrib/sshpublisher"
|
62
|
-
require "yaml"
|
63
|
-
|
64
|
-
config = YAML.load(
|
65
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
66
|
-
)
|
67
|
-
host = "#{config['username']}@rubyforge.org"
|
68
|
-
remote_dir = RUBY_FORGE_PATH + "/coverage"
|
69
|
-
local_dir = "coverage"
|
70
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
namespace :website do
|
76
|
-
desc "Publish website to RubyForge"
|
77
|
-
task :release => ["doc:release", "spec:release", "spec:rcov:release"] do
|
78
|
-
require "rake/contrib/sshpublisher"
|
79
|
-
require "yaml"
|
80
|
-
|
81
|
-
config = YAML.load(
|
82
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
83
|
-
)
|
84
|
-
host = "#{config['username']}@rubyforge.org"
|
85
|
-
remote_dir = RUBY_FORGE_PATH
|
86
|
-
local_dir = "website"
|
87
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
88
|
-
end
|
89
|
-
end
|