uuidtools 0.1.1 → 0.1.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 +5 -0
  2. data/lib/uuidtools.rb +17 -3
  3. data/rakefile +1 -1
  4. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == UUIDTools 0.1.2
2
+ * fixed variant method
3
+ * added valid? method
4
+ * changed timestamp_create method to allow creation of UUIDs from
5
+ arbitrary timestamps
1
6
  == UUIDTools 0.1.1
2
7
  * changed helper methods to be protected like they should have been
3
8
  == UUIDTools 0.1.0
data/lib/uuidtools.rb CHANGED
@@ -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 = "0.1.1"
24
+ UUID_TOOLS_VERSION = "0.1.2"
25
25
 
26
26
  $:.unshift(File.dirname(__FILE__))
27
27
 
@@ -224,7 +224,11 @@ class UUID
224
224
  # getting the same timestamp.
225
225
  @@mutex.synchronize do
226
226
  # Always use GMT to generate UUIDs.
227
- gmt_timestamp = Time.now.gmtime
227
+ if timestamp.nil?
228
+ gmt_timestamp = Time.now.gmtime
229
+ else
230
+ gmt_timestamp = timestamp.gmtime
231
+ end
228
232
  # Convert to 100 nanosecond blocks
229
233
  gmt_timestamp_100_nanoseconds = (gmt_timestamp.tv_sec * 10000000) +
230
234
  (gmt_timestamp.tv_usec * 10) + 0x01B21DD213814000
@@ -325,7 +329,17 @@ class UUID
325
329
  else
326
330
  result = variant_raw
327
331
  end
328
- return result
332
+ return (result >> 6)
333
+ end
334
+
335
+ # Returns true if this UUID is valid.
336
+ def valid?
337
+ if [0b000, 0b100, 0b110, 0b111].include?(self.variant) &&
338
+ (1..5).include?(self.version)
339
+ return true
340
+ else
341
+ return false
342
+ end
329
343
  end
330
344
 
331
345
  # Returns the IEEE 802 address used to generate this UUID or
data/rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/gempackagetask'
7
7
  require 'rake/contrib/rubyforgepublisher'
8
8
 
9
9
  PKG_NAME = 'uuidtools'
10
- PKG_VERSION = '0.1.1'
10
+ PKG_VERSION = '0.1.2'
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
 
13
13
  RELEASE_NAME = "REL #{PKG_VERSION}"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: uuidtools
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2005-09-16 00:00:00 -04:00
6
+ version: 0.1.2
7
+ date: 2005-09-25 00:00:00 -04:00
8
8
  summary: Generation of UUIDs.
9
9
  require_paths:
10
10
  - lib