uuidtools 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +3 -0
  2. data/lib/uuidtools.rb +33 -4
  3. data/rakefile +40 -11
  4. metadata +3 -3
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == UUIDTools 1.0.2
2
+ * improved code for obtaining a MAC address for Solaris and OpenBSD
3
+ * added hash and eql? methods
1
4
  == UUIDTools 1.0.1
2
5
  * improved code for obtaining a MAC address for Solaris and NetBSD
3
6
  * MAC addresses can now be set manually
@@ -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 = "1.0.1"
24
+ UUID_TOOLS_VERSION = "1.0.2"
25
25
 
26
26
  $:.unshift(File.dirname(__FILE__))
27
27
 
@@ -233,7 +233,13 @@ class UUID
233
233
  # Convert to 100 nanosecond blocks
234
234
  gmt_timestamp_100_nanoseconds = (gmt_timestamp.tv_sec * 10000000) +
235
235
  (gmt_timestamp.tv_usec * 10) + 0x01B21DD213814000
236
- nodes = self.get_mac_address.split(":").collect do |octet|
236
+ mac_address = self.get_mac_address
237
+ if mac_address == nil || mac_address == ""
238
+ raise StandardError,
239
+ "MAC address could not be autodetected. " +
240
+ "Set the MAC address manually."
241
+ end
242
+ nodes = mac_address.split(":").collect do |octet|
237
243
  octet.to_i(16)
238
244
  end
239
245
  node_id = 0
@@ -429,6 +435,16 @@ class UUID
429
435
  def to_uri
430
436
  return "urn:uuid:#{self.to_s}"
431
437
  end
438
+
439
+ # Returns an integer hash value.
440
+ def hash
441
+ return self.to_i
442
+ end
443
+
444
+ # Returns true if this UUID is exactly equal to the other UUID.
445
+ def eql?(other)
446
+ return (self <=> other) == 0
447
+ end
432
448
 
433
449
  def self.create_from_hash(hash_class, namespace, name) #:nodoc:
434
450
  if hash_class == Digest::MD5
@@ -455,7 +471,7 @@ class UUID
455
471
 
456
472
  # Returns the MAC address of the current computer's network card.
457
473
  # Returns nil if a MAC address could not be found.
458
- def self.get_mac_address #:nodoc:
474
+ def self.mac_address #:nodoc:
459
475
  if @@mac_address.nil?
460
476
  if RUBY_PLATFORM =~ /solaris/
461
477
  begin
@@ -466,6 +482,15 @@ class UUID
466
482
  @@mac_address = `/usr/sbin/arp #{ip}`.split(' ')[3]
467
483
  rescue Exception
468
484
  end
485
+ if @@mac_address == "" || @@mac_address == nil
486
+ begin
487
+ ifconfig_output = `ifconfig -a`.split(' ')
488
+ index = ifconfig_output.index("inet") + 1
489
+ ip = ifconfig_output[index]
490
+ @@mac_address = `arp #{ip}`.split(' ')[3]
491
+ rescue Exception
492
+ end
493
+ end
469
494
  elsif RUBY_PLATFORM =~ /win/ && !(RUBY_PLATFORM =~ /darwin/)
470
495
  begin
471
496
  ifconfig_output = `ipconfig /all`
@@ -483,6 +508,10 @@ class UUID
483
508
  ifconfig_output = `/sbin/ifconfig -a 2>&1`
484
509
  mac_addresses = ifconfig_output.scan(
485
510
  Regexp.new("address\: (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
511
+ elsif RUBY_PLATFORM =~ /openbsd/
512
+ ifconfig_output = `/sbin/ifconfig -a 2>&1`
513
+ mac_addresses = ifconfig_output.scan(
514
+ Regexp.new("addr (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
486
515
  elsif File.exists?('/sbin/ifconfig')
487
516
  ifconfig_output = `/sbin/ifconfig 2>&1`
488
517
  mac_addresses = ifconfig_output.scan(
@@ -534,7 +563,7 @@ class UUID
534
563
  return @@mac_address
535
564
  end
536
565
  class <<self
537
- alias_method :mac_address, :get_mac_address
566
+ alias_method :get_mac_address, :mac_address
538
567
  end
539
568
 
540
569
  # Allows users to set the MAC address manually in cases where the MAC
data/rakefile CHANGED
@@ -7,13 +7,14 @@ require 'rake/gempackagetask'
7
7
  require 'rake/contrib/rubyforgepublisher'
8
8
 
9
9
  PKG_NAME = 'uuidtools'
10
- PKG_VERSION = '1.0.1'
10
+ PKG_VERSION = '1.0.2'
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
 
13
13
  RELEASE_NAME = "REL #{PKG_VERSION}"
14
14
 
15
- RUBY_FORGE_PROJECT = "uuidtools"
16
- RUBY_FORGE_USER = "vacindak"
15
+ RUBY_FORGE_PROJECT = PKG_NAME
16
+ RUBY_FORGE_USER = "sporkmonger"
17
+ RUBY_FORGE_PATH = "/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}"
17
18
 
18
19
  PKG_FILES = FileList[
19
20
  "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "rakefile"
@@ -142,12 +143,40 @@ task :benchmark do
142
143
  end
143
144
 
144
145
 
145
- # Publishing ------------------------------------------------------
146
+ namespace :publish do
147
+ desc "Publish the API documentation"
148
+ task :api => [ "rdoc" ] do
149
+ Rake::SshDirPublisher.new(
150
+ "#{RUBY_FORGE_USER}@rubyforge.org",
151
+ "#{RUBY_FORGE_PATH}/",
152
+ "doc"
153
+ ).upload
154
+ end
155
+
156
+ desc "Runs all of the publishing tasks"
157
+ task :all => ["publish:api"] do
158
+ end
159
+ end
160
+
161
+ task :lines do
162
+ lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
163
+
164
+ for file_name in FileList["lib/**/*.rb"]
165
+ f = File.open(file_name)
166
+
167
+ while line = f.gets
168
+ lines += 1
169
+ next if line =~ /^\s*$/
170
+ next if line =~ /^\s*#/
171
+ codelines += 1
172
+ end
173
+ puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
174
+
175
+ total_lines += lines
176
+ total_codelines += codelines
177
+
178
+ lines, codelines = 0, 0
179
+ end
146
180
 
147
- desc "Publish the API documentation"
148
- task :pdoc => [:rdoc] do
149
- Rake::SshDirPublisher.new(
150
- "vacindak@sporkmonger.com",
151
- "public_html/projects/uuidtools/api",
152
- "doc").upload
153
- end
181
+ puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
182
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: uuidtools
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.1
7
- date: 2007-04-28 00:00:00 -04:00
6
+ version: 1.0.2
7
+ date: 2007-11-07 00:00:00 -05:00
8
8
  summary: Generation of UUIDs.
9
9
  require_paths:
10
10
  - lib