lexical_uuid 0.1.2 → 0.1.6
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/Rakefile +1 -1
- data/lexical_uuid.gemspec +22 -29
- data/lib/lexical_uuid.rb +6 -33
- metadata +11 -15
- data/.gitignore +0 -21
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/jamesgolick/lexical_uuid"
|
12
12
|
gem.authors = ["James Golick"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.add_dependency "
|
14
|
+
gem.add_dependency "fnv"
|
15
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
16
|
end
|
17
17
|
Jeweler::GemcutterTasks.new
|
data/lexical_uuid.gemspec
CHANGED
@@ -1,58 +1,51 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.1.
|
7
|
+
s.name = "lexical_uuid"
|
8
|
+
s.version = "0.1.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["James Golick"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2011-09-23"
|
13
|
+
s.description = "UUIDs that are byte-ordered lamport clocks (timestamp, worker_id). Much simpler than type-1 UUID's crappy, weirdo layout."
|
14
|
+
s.email = "jamesgolick@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"lib/lexical_uuid.rb",
|
28
|
-
"spec/lexical_uuid_spec.rb",
|
29
|
-
"spec/spec.opts",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/jamesgolick/lexical_uuid}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.7}
|
36
|
-
s.summary = %q{UUIDs that are byte-ordered lamport clocks (timestamp, worker_id). Much simpler than type-1 UUID's crappy, weirdo layout.}
|
37
|
-
s.test_files = [
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lexical_uuid.gemspec",
|
26
|
+
"lib/lexical_uuid.rb",
|
38
27
|
"spec/lexical_uuid_spec.rb",
|
39
|
-
|
28
|
+
"spec/spec.opts",
|
29
|
+
"spec/spec_helper.rb"
|
40
30
|
]
|
31
|
+
s.homepage = "http://github.com/jamesgolick/lexical_uuid"
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = "1.8.10"
|
34
|
+
s.summary = "UUIDs that are byte-ordered lamport clocks (timestamp, worker_id). Much simpler than type-1 UUID's crappy, weirdo layout."
|
41
35
|
|
42
36
|
if s.respond_to? :specification_version then
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
37
|
s.specification_version = 3
|
45
38
|
|
46
39
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
40
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
48
|
-
s.add_runtime_dependency(%q<RubyInline>, ["
|
41
|
+
s.add_runtime_dependency(%q<RubyInline>, ["> 3.8.4"])
|
49
42
|
else
|
50
43
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
51
|
-
s.add_dependency(%q<RubyInline>, ["
|
44
|
+
s.add_dependency(%q<RubyInline>, ["> 3.8.4"])
|
52
45
|
end
|
53
46
|
else
|
54
47
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
55
|
-
s.add_dependency(%q<RubyInline>, ["
|
48
|
+
s.add_dependency(%q<RubyInline>, ["> 3.8.4"])
|
56
49
|
end
|
57
50
|
end
|
58
51
|
|
data/lib/lexical_uuid.rb
CHANGED
@@ -1,35 +1,8 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "socket"
|
3
|
-
require "
|
4
|
-
|
5
|
-
|
6
|
-
inline :C do |builder|
|
7
|
-
builder.c <<-__END__
|
8
|
-
static long fnv1a() {
|
9
|
-
long hash = 0xcbf29ce484222325;
|
10
|
-
long i = 0;
|
11
|
-
|
12
|
-
for(i = 0; i < RSTRING_LEN(self); i++) {
|
13
|
-
hash ^= RSTRING_PTR(self)[i];
|
14
|
-
hash *= 0x100000001b3;
|
15
|
-
}
|
16
|
-
|
17
|
-
return hash;
|
18
|
-
}
|
19
|
-
__END__
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# Borrowed from the SimpleUUID gem
|
24
|
-
class Time
|
25
|
-
def self.stamp
|
26
|
-
Time.now.stamp
|
27
|
-
end
|
28
|
-
|
29
|
-
def stamp
|
30
|
-
to_i * 1_000_000 + usec
|
31
|
-
end
|
32
|
-
end
|
3
|
+
require "fnv"
|
4
|
+
require File.join(File.dirname(__FILE__), "time_ext")
|
5
|
+
require File.join(File.dirname(__FILE__), "increasing_microsecond_clock")
|
33
6
|
|
34
7
|
class LexicalUUID
|
35
8
|
class << self
|
@@ -41,13 +14,13 @@ class LexicalUUID
|
|
41
14
|
def create_worker_id
|
42
15
|
fqdn = Socket.gethostbyname(Socket.gethostname).first
|
43
16
|
pid = Process.pid
|
44
|
-
"#{fqdn}-#{pid}"
|
17
|
+
FNV.new.fnv1a_64("#{fqdn}-#{pid}")
|
45
18
|
end
|
46
19
|
end
|
47
20
|
|
48
21
|
attr_reader :worker_id, :timestamp
|
49
22
|
|
50
|
-
def initialize(timestamp = nil, worker_id = nil)
|
23
|
+
def initialize(timestamp = nil, worker_id = nil, timestamp_factory = IncreasingMicrosecondClock)
|
51
24
|
case timestamp
|
52
25
|
when Fixnum, Bignum
|
53
26
|
@timestamp = timestamp
|
@@ -68,7 +41,7 @@ class LexicalUUID
|
|
68
41
|
@worker_id = self.class.worker_id
|
69
42
|
when nil
|
70
43
|
@worker_id = self.class.worker_id
|
71
|
-
@timestamp =
|
44
|
+
@timestamp = timestamp_factory.call
|
72
45
|
end
|
73
46
|
end
|
74
47
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lexical_uuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Golick
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2011-09-23 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rspec
|
@@ -40,7 +39,7 @@ dependencies:
|
|
40
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
43
|
-
- - "
|
42
|
+
- - ">"
|
44
43
|
- !ruby/object:Gem::Version
|
45
44
|
hash: 47
|
46
45
|
segments:
|
@@ -61,7 +60,6 @@ extra_rdoc_files:
|
|
61
60
|
- README.rdoc
|
62
61
|
files:
|
63
62
|
- .document
|
64
|
-
- .gitignore
|
65
63
|
- LICENSE
|
66
64
|
- README.rdoc
|
67
65
|
- Rakefile
|
@@ -71,13 +69,12 @@ files:
|
|
71
69
|
- spec/lexical_uuid_spec.rb
|
72
70
|
- spec/spec.opts
|
73
71
|
- spec/spec_helper.rb
|
74
|
-
has_rdoc: true
|
75
72
|
homepage: http://github.com/jamesgolick/lexical_uuid
|
76
73
|
licenses: []
|
77
74
|
|
78
75
|
post_install_message:
|
79
|
-
rdoc_options:
|
80
|
-
|
76
|
+
rdoc_options: []
|
77
|
+
|
81
78
|
require_paths:
|
82
79
|
- lib
|
83
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -101,10 +98,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
98
|
requirements: []
|
102
99
|
|
103
100
|
rubyforge_project:
|
104
|
-
rubygems_version: 1.
|
101
|
+
rubygems_version: 1.8.10
|
105
102
|
signing_key:
|
106
103
|
specification_version: 3
|
107
104
|
summary: UUIDs that are byte-ordered lamport clocks (timestamp, worker_id). Much simpler than type-1 UUID's crappy, weirdo layout.
|
108
|
-
test_files:
|
109
|
-
|
110
|
-
- spec/spec_helper.rb
|
105
|
+
test_files: []
|
106
|
+
|