torid 1.1.0 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f00dde7601ef49bef1988ca71448d7e177adeca8
4
- data.tar.gz: 46b76fc71876f3e580d99e480c925bfb5ff1b9aa
3
+ metadata.gz: afed761e9019552f02faa3669e3f495a4cf28545
4
+ data.tar.gz: 4d35d92decf2c3ea6cc1f905f26e2ec298acbe4e
5
5
  SHA512:
6
- metadata.gz: 4869b5ba0b7f952ad70b80d6b6113b12f96294ecaa309224c32b00d85afb13d215748407924c8d7da4f99c1b7da57b138a57fbe867df7b50ea07fc8e119e1315
7
- data.tar.gz: 775f96e810c9e85fa4e7a17ecfc1f58926315f458d085ed01a8a8a5e008e25a25fc77419196aa94c70b7fb113e4303bce681447f731d1d6571b83a4a8c898fb7
6
+ metadata.gz: d33560130ca1e6f3d6c6a82cd19ee2bd5d90ef8ced357ccc44777b6c285b88fa1cf756972ebe1d88e5b5a8ae395e1001c862bf0ae7e9be4e66dd8f0bb21eddaf
7
+ data.tar.gz: 94af487b8ba0c1533c998d08c34f65e5bfc803fc5527cf382bca181e52d576547cb4a8cfdd2927bfebee062c1e6f212b5ce17ccad475922a8299ba2ec30abefc
data/HISTORY.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # Torid Changelog
2
+ ## Version 1.2.0 - 2014-09-04
3
+
4
+ * Added equivalence checking
5
+
2
6
  ## Version 1.1.0 - 2014-07-17
3
7
 
4
8
  * Added Torid::UUID.match
@@ -2,7 +2,7 @@
2
2
  # that sort lexically in time order.
3
3
  module Torid
4
4
  # Public: The Version of the Torid library as a String
5
- VERSION = "1.1.0"
5
+ VERSION = "1.2.0"
6
6
 
7
7
  # Public: return the next Torid::UUID from the default Generator
8
8
  #
@@ -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
@@ -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.1.0
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-07-17 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fnv