torid 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +4 -0
- data/lib/torid.rb +1 -1
- data/lib/torid/uuid.rb +29 -0
- data/test/test_uuid.rb +34 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afed761e9019552f02faa3669e3f495a4cf28545
|
4
|
+
data.tar.gz: 4d35d92decf2c3ea6cc1f905f26e2ec298acbe4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d33560130ca1e6f3d6c6a82cd19ee2bd5d90ef8ced357ccc44777b6c285b88fa1cf756972ebe1d88e5b5a8ae395e1001c862bf0ae7e9be4e66dd8f0bb21eddaf
|
7
|
+
data.tar.gz: 94af487b8ba0c1533c998d08c34f65e5bfc803fc5527cf382bca181e52d576547cb4a8cfdd2927bfebee062c1e6f212b5ce17ccad475922a8299ba2ec30abefc
|
data/HISTORY.md
CHANGED
data/lib/torid.rb
CHANGED
data/lib/torid/uuid.rb
CHANGED
@@ -150,5 +150,34 @@ module Torid
|
|
150
150
|
elements[-1] = '%02x%02x%02x%02x%02x%02x' % node
|
151
151
|
"%08x-%04x-%04x-%02x%02x-%s" % elements
|
152
152
|
end
|
153
|
+
|
154
|
+
# Public: Compare the equality of UUID's
|
155
|
+
#
|
156
|
+
# Examples
|
157
|
+
#
|
158
|
+
# uuid == other_uuid
|
159
|
+
#
|
160
|
+
# Returns true or false
|
161
|
+
def ==(other)
|
162
|
+
other.is_a?(::Torid::UUID) &&
|
163
|
+
other.node_id == self.node_id &&
|
164
|
+
other.timestamp == self.timestamp
|
165
|
+
end
|
166
|
+
alias :eql? :==
|
167
|
+
|
168
|
+
# Public: Generate the hash of the UUID for ruby hash equality
|
169
|
+
#
|
170
|
+
# This allows two UUID objects that have the same node_id and timestamp to
|
171
|
+
# be considered the same object for keys in Hash.
|
172
|
+
#
|
173
|
+
# Examples
|
174
|
+
# one = Torid.uuid
|
175
|
+
# other = Torid::UUID.from( one.bytes )
|
176
|
+
# h = { one => "a value" }
|
177
|
+
# h.has_key?( other ) # => true
|
178
|
+
def hash
|
179
|
+
[node_id, timestamp, ::Torid::UUID].hash
|
180
|
+
end
|
181
|
+
|
153
182
|
end
|
154
183
|
end
|
data/test/test_uuid.rb
CHANGED
@@ -71,5 +71,39 @@ module Torid
|
|
71
71
|
assert_equal( time, uuid.time )
|
72
72
|
end
|
73
73
|
|
74
|
+
def test_standard_equality
|
75
|
+
one = ::Torid::UUID.from( @guid )
|
76
|
+
other = ::Torid::UUID.from( @guid )
|
77
|
+
assert( one == other )
|
78
|
+
assert( other == one )
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_case_equality
|
82
|
+
one = ::Torid::UUID.from( @guid )
|
83
|
+
other = ::Torid::UUID.from( @guid )
|
84
|
+
assert( one === other )
|
85
|
+
assert( other === one )
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_hash
|
89
|
+
one = ::Torid::UUID.from( @guid )
|
90
|
+
other = ::Torid::UUID.from( @guid )
|
91
|
+
assert( one.hash == other.hash )
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_hash_equality
|
95
|
+
one = ::Torid::UUID.from( @guid )
|
96
|
+
other = ::Torid::UUID.from( @guid )
|
97
|
+
assert( one.eql?(other) )
|
98
|
+
assert( other.eql?(one) )
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_identity_comparison
|
102
|
+
one = ::Torid::UUID.from( @guid )
|
103
|
+
other = ::Torid::UUID.from( @guid )
|
104
|
+
assert( !one.equal?(other) )
|
105
|
+
assert( !other.equal?(one) )
|
106
|
+
end
|
107
|
+
|
74
108
|
end
|
75
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Hinegardner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fnv
|