uuid 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README +76 -76
  3. data/Rakefile +135 -136
  4. data/bin/uuid-setup +3 -4
  5. data/changelog.txt +6 -0
  6. data/lib/uuid.rb +407 -384
  7. data/test/test-uuid.rb +26 -26
  8. metadata +30 -24
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005 Assaf Arkin
1
+ Copyright (c) 2005,2006 Assaf Arkin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README CHANGED
@@ -1,81 +1,81 @@
1
- = UUID Generator
2
-
3
- Generates universally unique identifiers (UUIDs) for use in distributed
4
- applications. Based on {RFC 4122}[http://www.ietf.org/rfc/rfc4122.txt].
5
-
6
-
7
- == Download
8
-
9
- The latest version of the UUID generator can be found in the Reliable
10
- Messaging project
11
-
12
- * http://rubyforge.org/projects/reliable-msg/
13
-
14
- For more information
15
-
16
- * http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/UuidGenerator
17
-
1
+ = UUID Generator
2
+
3
+ Generates universally unique identifiers (UUIDs) for use in distributed
4
+ applications. Based on {RFC 4122}[http://www.ietf.org/rfc/rfc4122.txt].
5
+
6
+
7
+ == Download
8
+
9
+ The latest version of the UUID generator can be found in the Reliable
10
+ Messaging project
11
+
12
+ * http://rubyforge.org/projects/reliable-msg/
13
+
14
+ For more information
15
+
16
+ * http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/UuidGenerator
17
+
18
18
 
19
19
  == Installation
20
-
21
- You can download the sources directly, or install the GEM package
22
- (recommended) with
23
-
24
- gem install uuid
25
-
26
- Once installed, create a <tt>uuid.state</tt> file by running
27
-
28
- uuid-setup
29
-
30
-
31
- == Example
32
-
33
- require_gem 'uuid'
34
-
35
- 10.times do
36
- p UUID.new
37
- end
38
-
39
-
40
- == UUID state file
41
-
42
- The UUID generator uses a state file (<tt>uuid.state</tt>) to hold the
43
- MAC address and sequence number.
44
-
45
- The MAC address is used to generate identifiers that are unique to your
46
- machine, preventing conflicts in distributed applications. The MAC
47
- address is six bytes (48 bit) long. It is automatically extracted from
48
- one of the network cards on your machine by running +ipconfig+
49
- (Windows) or +ifconfig+ (Linux, UNIX, et al). You can override the MAC
50
- address by editing the <tt>uuid.state</tt> file yourself.
51
-
52
- The sequence number is incremented each time the UUID generator is
53
- first used by the application, to prevent multiple processes from
54
- generating the same set of identifiers, and deal with changes to the
55
- system clock.
56
-
57
- The UUID state file is created with
58
-
59
- uuid-setup
60
-
61
- It is created in the installation directory. If you installed the UUID
62
- generator as a Gem, it will be created in the Gem's directory. However,
63
- the UUID generator will look for the <tt>uuid.state</tt> first in the
64
- local directory, and then in the installation directory. You can use
65
- that to maintain separate state files for different applications.
66
- However, make sure they generate unique identifiers by using different
67
- MAC addresses in each state file.
68
-
69
-
70
- == Change log
71
-
72
- :include: changelog.txt
73
-
20
+
21
+ You can download the sources directly, or install the GEM package
22
+ (recommended) with
23
+
24
+ gem install uuid
25
+
26
+ Once installed, create a <tt>uuid.state</tt> file by running
27
+
28
+ uuid-setup
29
+
30
+
31
+ == Example
32
+
33
+ require_gem 'uuid'
34
+
35
+ 10.times do
36
+ p UUID.new
37
+ end
38
+
39
+
40
+ == UUID state file
41
+
42
+ The UUID generator uses a state file (<tt>uuid.state</tt>) to hold the
43
+ MAC address and sequence number.
44
+
45
+ The MAC address is used to generate identifiers that are unique to your
46
+ machine, preventing conflicts in distributed applications. The MAC
47
+ address is six bytes (48 bit) long. It is automatically extracted from
48
+ one of the network cards on your machine by running +ipconfig+
49
+ (Windows) or +ifconfig+ (Linux, UNIX, et al). You can override the MAC
50
+ address by editing the <tt>uuid.state</tt> file yourself.
51
+
52
+ The sequence number is incremented each time the UUID generator is
53
+ first used by the application, to prevent multiple processes from
54
+ generating the same set of identifiers, and deal with changes to the
55
+ system clock.
56
+
57
+ The UUID state file is created with
58
+
59
+ uuid-setup
60
+
61
+ It is created in the installation directory. If you installed the UUID
62
+ generator as a Gem, it will be created in the Gem's directory. However,
63
+ the UUID generator will look for the <tt>uuid.state</tt> first in the
64
+ local directory, and then in the installation directory. You can use
65
+ that to maintain separate state files for different applications.
66
+ However, make sure they generate unique identifiers by using different
67
+ MAC addresses in each state file.
68
+
69
+
70
+ == Change log
71
+
72
+ :include: changelog.txt
73
+
74
74
 
75
75
  == License
76
-
77
- This package is licensed under the MIT license and/or the {Creative
78
- Commons Attribution-ShareAlike}[http://creativecommons.org/licenses/by-sa/2.5/legalcode].
79
-
80
- :include: MIT-LICENSE
76
+
77
+ This package is licensed under the MIT license and/or the {Creative
78
+ Commons Attribution-ShareAlike}[http://creativecommons.org/licenses/by-sa/2.5/legalcode].
79
+
80
+ :include: MIT-LICENSE
81
81
 
data/Rakefile CHANGED
@@ -1,149 +1,148 @@
1
- # Adapted from the rake Rakefile.
2
-
3
- require "rubygems"
4
- Gem::manage_gems
5
- require "rake/testtask"
6
- require "rake/rdoctask"
7
- require "rake/gempackagetask"
8
-
9
-
1
+ # Adapted from the rake Rakefile.
2
+
3
+ require "rubygems"
4
+ Gem::manage_gems
5
+ require "rake/testtask"
6
+ require "rake/rdoctask"
7
+ require "rake/gempackagetask"
8
+
9
+
10
10
  desc "Default Task"
11
- task :default => [:test, :rdoc]
12
-
13
-
14
- desc "Run all test cases"
15
- Rake::TestTask.new do |test|
16
- test.verbose = true
17
- test.test_files = ["test/test-uuid.rb"]
18
- #test.warning = true
19
- end
20
-
21
-
22
- # Create the documentation.
23
- Rake::RDocTask.new do |rdoc|
24
- rdoc.main = "README"
25
- rdoc.rdoc_files.include("README", "lib/**/*.rb")
26
- rdoc.title = "UUID generator"
27
- end
28
-
29
- # Handle version number.
30
- class Version
31
-
32
- PATTERN = /(\s*)VERSION.*(\d+\.\d+\.\d+)/
33
-
34
- def initialize file, new_version
35
- @file = file
36
- @version = File.open @file, "r" do |file|
37
- version = nil
38
- file.each_line do |line|
39
- match = line.match PATTERN
40
- if match
41
- version = match[2]
42
- break
43
- end
44
- end
45
- version
46
- end
47
- fail "Can't determine version number" unless @version
48
- @new_version = new_version || @version
49
- end
50
-
51
- def changed?
52
- @version != @new_version
53
- end
54
-
55
- def number
56
- @version
57
- end
58
-
59
- def next
60
- @new_version
61
- end
62
-
63
- def update
64
- puts "Updating to version #{@new_version}"
65
- copy = "#{@file}.new"
66
- open @file, "r" do |input|
67
- open copy, "w" do |output|
68
- input.each_line do |line|
69
- match = line.match PATTERN
70
- if match
71
- output.puts "#{match[1]}VERSION = '#{@new_version}'"
72
- else
73
- output.puts line
74
- end
75
- end
76
- end
11
+ task :default => [:test, :rdoc]
12
+
13
+
14
+ desc "Run all test cases"
15
+ Rake::TestTask.new do |test|
16
+ test.verbose = true
17
+ test.test_files = ["test/test-uuid.rb"]
18
+ #test.warning = true
19
+ end
20
+
21
+
22
+ # Create the documentation.
23
+ Rake::RDocTask.new do |rdoc|
24
+ rdoc.main = "README"
25
+ rdoc.rdoc_files.include("README", "lib/**/*.rb")
26
+ rdoc.title = "UUID generator"
27
+ end
28
+
29
+ # Handle version number.
30
+ class Version
31
+
32
+ PATTERN = /(\s*)VERSION.*(\d+\.\d+\.\d+)/
33
+
34
+ def initialize file, new_version
35
+ @file = file
36
+ @version = File.open @file, "r" do |file|
37
+ version = nil
38
+ file.each_line do |line|
39
+ match = line.match PATTERN
40
+ if match
41
+ version = match[2]
42
+ break
43
+ end
44
+ end
45
+ version
46
+ end
47
+ fail "Can't determine version number" unless @version
48
+ @new_version = new_version || @version
49
+ end
50
+
51
+ def changed?
52
+ @version != @new_version
53
+ end
54
+
55
+ def number
56
+ @version
57
+ end
58
+
59
+ def next
60
+ @new_version
61
+ end
62
+
63
+ def update
64
+ puts "Updating to version #{@new_version}"
65
+ copy = "#{@file}.new"
66
+ open @file, "r" do |input|
67
+ open copy, "w" do |output|
68
+ input.each_line do |line|
69
+ match = line.match PATTERN
70
+ if match
71
+ output.puts "#{match[1]}VERSION = '#{@new_version}'"
72
+ else
73
+ output.puts line
74
+ end
77
75
  end
78
- mv copy, @file
79
- @version = @new_version
80
- end
81
-
82
- end
83
- version = Version.new "lib/uuid.rb", ENV["version"]
84
-
85
-
86
- # Create the GEM package.
87
- gem_spec = Gem::Specification.new do |spec|
88
- spec.name = "uuid"
89
- spec.version = version.next
90
- spec.summary = "UUID generator"
91
- spec.description = <<-EOF
92
- UUID generator for producing universally unique identifiers based
93
- on RFC 4122 (http://www.ietf.org/rfc/rfc4122.txt).
94
- EOF
95
- spec.author = "Assaf Arkin"
96
- spec.email = "assaf@labnotes.org"
97
- spec.homepage = "http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/UuidGenerator"
98
-
99
- spec.files = FileList["{bin,test,lib,docs}/**/*", "README", "MIT-LICENSE", "Rakefile", "changelog.txt"].to_a
100
- spec.require_path = "lib"
101
- spec.autorequire = "uuid.rb"
102
- spec.bindir = "bin"
103
- spec.executables = ["uuid-setup"]
104
- spec.default_executable = "uuid-setup"
105
- spec.has_rdoc = true
106
- spec.rdoc_options << "--main" << "README" << "--title" << "UUID generator" << "--line-numbers"
107
- spec.extra_rdoc_files = ["README"]
108
- spec.rubyforge_project = "reliable-msg"
109
- end
110
-
111
- gem = Rake::GemPackageTask.new(gem_spec) do |pkg|
112
- pkg.need_tar = true
113
- pkg.need_zip = true
114
- end
115
-
116
-
76
+ end
77
+ end
78
+ mv copy, @file
79
+ @version = @new_version
80
+ end
81
+
82
+ end
83
+ version = Version.new "lib/uuid.rb", ENV["version"]
84
+
85
+
86
+ # Create the GEM package.
87
+ gem_spec = Gem::Specification.new do |spec|
88
+ spec.name = "uuid"
89
+ spec.version = version.next
90
+ spec.summary = "UUID generator"
91
+ spec.description = <<-EOF
92
+ UUID generator for producing universally unique identifiers based
93
+ on RFC 4122 (http://www.ietf.org/rfc/rfc4122.txt).
94
+ EOF
95
+ spec.author = "Assaf Arkin"
96
+ spec.email = "assaf@labnotes.org"
97
+ spec.homepage = "http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/UuidGenerator"
98
+ spec.files = FileList["{bin,test,lib,docs}/**/*", "README", "MIT-LICENSE", "Rakefile", "changelog.txt"].to_a
99
+ spec.require_path = "lib"
100
+ spec.autorequire = "uuid.rb"
101
+ spec.bindir = "bin"
102
+ spec.executables = ["uuid-setup"]
103
+ spec.default_executable = "uuid-setup"
104
+ spec.has_rdoc = true
105
+ spec.rdoc_options << "--main" << "README" << "--title" << "UUID generator" << "--line-numbers"
106
+ spec.extra_rdoc_files = ["README"]
107
+ spec.rubyforge_project = "reliable-msg"
108
+ end
109
+
110
+ gem = Rake::GemPackageTask.new(gem_spec) do |pkg|
111
+ pkg.need_tar = true
112
+ pkg.need_zip = true
113
+ end
114
+
115
+
117
116
  desc "Look for TODO and FIXME tags in the code"
118
117
  task :todo do
119
118
  FileList["**/*.rb"].egrep /#.*(FIXME|TODO|TBD)/
120
119
  end
121
-
122
-
120
+
121
+
123
122
  # --------------------------------------------------------------------
124
123
  # Creating a release
125
124
 
126
125
  desc "Make a new release"
127
126
  task :release => [:test, :prerelease, :clobber, :update_version, :package] do
128
- puts
129
- puts "**************************************************************"
130
- puts "* Release #{version.number} Complete."
131
- puts "* Packages ready to upload."
132
- puts "**************************************************************"
133
- puts
134
- end
135
-
136
- task :prerelease do
137
- if !version.changed? && ENV["reuse"] != version.number
138
- fail "Current version is #{version.number}, must specify reuse=ver to reuse existing version"
139
- end
127
+ puts
128
+ puts "**************************************************************"
129
+ puts "* Release #{version.number} Complete."
130
+ puts "* Packages ready to upload."
131
+ puts "**************************************************************"
132
+ puts
140
133
  end
141
-
142
- task :update_version => [:prerelease] do
143
- if !version.changed?
144
- puts "No version change ... skipping version update"
145
- else
146
- version.update
147
- end
134
+
135
+ task :prerelease do
136
+ if !version.changed? && ENV["reuse"] != version.number
137
+ fail "Current version is #{version.number}, must specify reuse=ver to reuse existing version"
138
+ end
139
+ end
140
+
141
+ task :update_version => [:prerelease] do
142
+ if !version.changed?
143
+ puts "No version change ... skipping version update"
144
+ else
145
+ version.update
146
+ end
148
147
  end
149
-
148
+
@@ -1,8 +1,7 @@
1
1
  begin
2
2
  require 'uuid'
3
- rescue LoadError
3
+ rescue LoadError
4
4
  require 'rubygems'
5
5
  require_gem 'uuid'
6
- end
7
- UUID::setup
8
-
6
+ end
7
+ UUID::setup