uuidtools 1.0.2 → 1.0.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 +51 -19
- data/lib/uuidtools/version.rb +32 -0
- data/rakefile +5 -2
- metadata +45 -34
data/CHANGELOG
CHANGED
data/lib/uuidtools.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005 Robert Aman
|
2
|
+
# Copyright (c) 2005-2008 Robert Aman
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -21,8 +21,6 @@
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#++
|
23
23
|
|
24
|
-
UUID_TOOLS_VERSION = "1.0.2"
|
25
|
-
|
26
24
|
$:.unshift(File.dirname(__FILE__))
|
27
25
|
|
28
26
|
require 'uri'
|
@@ -31,6 +29,11 @@ require 'thread'
|
|
31
29
|
require 'digest/sha1'
|
32
30
|
require 'digest/md5'
|
33
31
|
|
32
|
+
require 'uuidtools/version'
|
33
|
+
|
34
|
+
# Backwards compatibility with old method of versioning.
|
35
|
+
UUID_TOOLS_VERSION = UUID::UUID_TOOLS_VERSION::STRING
|
36
|
+
|
34
37
|
# Because it's impossible to hype a UUID generator on its genuine merits,
|
35
38
|
# I give you... Really bad ASCII art in the comments:
|
36
39
|
#
|
@@ -417,7 +420,7 @@ class UUID
|
|
417
420
|
for i in 0..5
|
418
421
|
result << sprintf("%2.2x", @nodes[i])
|
419
422
|
end
|
420
|
-
return result
|
423
|
+
return result.downcase
|
421
424
|
end
|
422
425
|
|
423
426
|
# Returns an integer representation for this UUID.
|
@@ -473,9 +476,17 @@ class UUID
|
|
473
476
|
# Returns nil if a MAC address could not be found.
|
474
477
|
def self.mac_address #:nodoc:
|
475
478
|
if @@mac_address.nil?
|
476
|
-
|
479
|
+
require 'rbconfig'
|
480
|
+
os_platform = Config::CONFIG['target_os']
|
481
|
+
if os_platform =~ /win/ && !(os_platform =~ /darwin/)
|
482
|
+
script_in_path = true
|
483
|
+
else
|
484
|
+
script_in_path = !(`which ifconfig`.strip =~ /no .+ in/)
|
485
|
+
end
|
486
|
+
if os_platform =~ /solaris/
|
477
487
|
begin
|
478
|
-
ifconfig_output =
|
488
|
+
ifconfig_output =
|
489
|
+
(script_in_path ? `ifconfig -a` : `/sbin/ifconfig -a`)
|
479
490
|
ip_addresses = ifconfig_output.scan(
|
480
491
|
/inet\s?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)
|
481
492
|
ip = ip_addresses.find {|addr| addr[0] != '127.0.0.1'}[0]
|
@@ -484,14 +495,16 @@ class UUID
|
|
484
495
|
end
|
485
496
|
if @@mac_address == "" || @@mac_address == nil
|
486
497
|
begin
|
487
|
-
ifconfig_output =
|
498
|
+
ifconfig_output =
|
499
|
+
(script_in_path ?
|
500
|
+
`ifconfig -a` : `/sbin/ifconfig -a`).split(' ')
|
488
501
|
index = ifconfig_output.index("inet") + 1
|
489
502
|
ip = ifconfig_output[index]
|
490
503
|
@@mac_address = `arp #{ip}`.split(' ')[3]
|
491
504
|
rescue Exception
|
492
505
|
end
|
493
506
|
end
|
494
|
-
elsif
|
507
|
+
elsif os_platform =~ /win/ && !(os_platform =~ /darwin/)
|
495
508
|
begin
|
496
509
|
ifconfig_output = `ipconfig /all`
|
497
510
|
mac_addresses = ifconfig_output.scan(
|
@@ -504,43 +517,54 @@ class UUID
|
|
504
517
|
else
|
505
518
|
begin
|
506
519
|
mac_addresses = []
|
507
|
-
if
|
508
|
-
ifconfig_output =
|
520
|
+
if os_platform =~ /netbsd/
|
521
|
+
ifconfig_output =
|
522
|
+
(script_in_path ? `ifconfig -a 2>&1` : `/sbin/ifconfig -a 2>&1`)
|
509
523
|
mac_addresses = ifconfig_output.scan(
|
510
524
|
Regexp.new("address\: (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
511
|
-
elsif
|
525
|
+
elsif os_platform =~ /openbsd/
|
512
526
|
ifconfig_output = `/sbin/ifconfig -a 2>&1`
|
527
|
+
ifconfig_output =
|
528
|
+
(script_in_path ? `ifconfig -a 2>&1` : `/sbin/ifconfig -a 2>&1`)
|
513
529
|
mac_addresses = ifconfig_output.scan(
|
514
530
|
Regexp.new("addr (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
515
531
|
elsif File.exists?('/sbin/ifconfig')
|
516
|
-
ifconfig_output =
|
532
|
+
ifconfig_output =
|
533
|
+
(script_in_path ? `ifconfig 2>&1` : `/sbin/ifconfig 2>&1`)
|
517
534
|
mac_addresses = ifconfig_output.scan(
|
518
535
|
Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
519
536
|
if mac_addresses.size == 0
|
520
|
-
ifconfig_output =
|
537
|
+
ifconfig_output =
|
538
|
+
(script_in_path ?
|
539
|
+
`ifconfig -a 2>&1` : `/sbin/ifconfig -a 2>&1`)
|
521
540
|
mac_addresses = ifconfig_output.scan(
|
522
541
|
Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
523
542
|
end
|
524
543
|
if mac_addresses.size == 0
|
525
544
|
ifconfig_output =
|
526
|
-
|
545
|
+
(script_in_path ?
|
546
|
+
`ifconfig | grep HWaddr | cut -c39- 2>&1` :
|
547
|
+
`/sbin/ifconfig | grep HWaddr | cut -c39- 2>&1`)
|
527
548
|
mac_addresses = ifconfig_output.scan(
|
528
549
|
Regexp.new("(#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
529
550
|
end
|
530
551
|
else
|
531
552
|
ifconfig_output =
|
532
|
-
`ifconfig 2>&1`
|
553
|
+
(script_in_path ? `ifconfig 2>&1` : `/sbin/ifconfig 2>&1`)
|
533
554
|
mac_addresses = ifconfig_output.scan(
|
534
555
|
Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
535
556
|
if mac_addresses.size == 0
|
536
557
|
ifconfig_output =
|
537
|
-
|
558
|
+
(script_in_path ?
|
559
|
+
`ifconfig -a 2>&1` : `/sbin/ifconfig -a 2>&1`)
|
538
560
|
mac_addresses = ifconfig_output.scan(
|
539
561
|
Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
540
562
|
end
|
541
563
|
if mac_addresses.size == 0
|
542
564
|
ifconfig_output =
|
543
|
-
|
565
|
+
(script_in_path ?
|
566
|
+
`ifconfig | grep HWaddr | cut -c39- 2>&1` :
|
567
|
+
`/sbin/ifconfig | grep HWaddr | cut -c39- 2>&1`)
|
544
568
|
mac_addresses = ifconfig_output.scan(
|
545
569
|
Regexp.new("(#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
546
570
|
end
|
@@ -551,8 +575,16 @@ class UUID
|
|
551
575
|
rescue
|
552
576
|
end
|
553
577
|
end
|
554
|
-
@@mac_address
|
555
|
-
|
578
|
+
if @@mac_address != nil
|
579
|
+
if @@mac_address.respond_to?(:to_str)
|
580
|
+
@@mac_address = @@mac_address.to_str
|
581
|
+
else
|
582
|
+
@@mac_address = @@mac_address.to_s
|
583
|
+
end
|
584
|
+
@@mac_address.downcase!
|
585
|
+
@@mac_address.strip!
|
586
|
+
end
|
587
|
+
|
556
588
|
# Verify that the MAC address is in the right format.
|
557
589
|
# Nil it out if it isn't.
|
558
590
|
unless @@mac_address.respond_to?(:scan) &&
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2008 Robert Aman
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
class UUID
|
25
|
+
module UUID_TOOLS_VERSION #:nodoc:
|
26
|
+
MAJOR = 1
|
27
|
+
MINOR = 0
|
28
|
+
TINY = 3
|
29
|
+
|
30
|
+
STRING = [MAJOR, MINOR, TINY].join('.')
|
31
|
+
end
|
32
|
+
end
|
data/rakefile
CHANGED
@@ -6,8 +6,10 @@ require 'rake/packagetask'
|
|
6
6
|
require 'rake/gempackagetask'
|
7
7
|
require 'rake/contrib/rubyforgepublisher'
|
8
8
|
|
9
|
+
require File.join(File.dirname(__FILE__), 'lib/uuidtools', 'version')
|
10
|
+
|
9
11
|
PKG_NAME = 'uuidtools'
|
10
|
-
PKG_VERSION =
|
12
|
+
PKG_VERSION = UUID::UUID_TOOLS_VERSION::STRING
|
11
13
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
12
14
|
|
13
15
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
@@ -59,13 +61,14 @@ spec = Gem::Specification.new do |s|
|
|
59
61
|
item.include?( "\.svn" ) || item.include?( "database\.yml" )
|
60
62
|
end
|
61
63
|
end
|
64
|
+
s.test_files = Dir.glob('test/**/*_test.rb')
|
62
65
|
|
63
66
|
s.require_path = 'lib'
|
64
67
|
s.autorequire = 'uuidtools'
|
65
68
|
|
66
69
|
s.has_rdoc = true
|
67
70
|
s.extra_rdoc_files = %w( README )
|
68
|
-
s.rdoc_options.concat ['--main', 'README']
|
71
|
+
s.rdoc_options.concat ['--main', 'README']
|
69
72
|
|
70
73
|
s.author = "Bob Aman"
|
71
74
|
s.email = "bob@sporkmonger.com"
|
metadata
CHANGED
@@ -1,53 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: uuidtools
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2007-11-07 00:00:00 -05:00
|
8
|
-
summary: Generation of UUIDs.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: bob@sporkmonger.com
|
12
|
-
homepage: http://sporkmonger.com/projects/uuidtools
|
13
|
-
rubyforge_project: uuidtools
|
14
|
-
description: Implements a simple system for generating UUIDs.
|
15
|
-
autorequire: uuidtools
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.0.3
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Bob Aman
|
8
|
+
autorequire: uuidtools
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-04 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Implements a simple system for generating UUIDs.
|
17
|
+
email: bob@sporkmonger.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
31
24
|
files:
|
32
25
|
- rakefile
|
33
26
|
- README
|
34
27
|
- CHANGELOG
|
28
|
+
- lib/uuidtools
|
29
|
+
- lib/uuidtools/version.rb
|
35
30
|
- lib/uuidtools.rb
|
36
31
|
- test/create_test.rb
|
37
32
|
- test/mac_address_test.rb
|
38
33
|
- test/parse_test.rb
|
39
|
-
|
40
|
-
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://sporkmonger.com/projects/uuidtools
|
36
|
+
post_install_message:
|
41
37
|
rdoc_options:
|
42
38
|
- --main
|
43
39
|
- README
|
44
|
-
|
45
|
-
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
50
54
|
requirements: []
|
51
55
|
|
52
|
-
|
53
|
-
|
56
|
+
rubyforge_project: uuidtools
|
57
|
+
rubygems_version: 1.0.0
|
58
|
+
signing_key:
|
59
|
+
specification_version: 2
|
60
|
+
summary: Generation of UUIDs.
|
61
|
+
test_files:
|
62
|
+
- test/create_test.rb
|
63
|
+
- test/mac_address_test.rb
|
64
|
+
- test/parse_test.rb
|