Sha256: 6f87f2bfcb504cc9b55aae1aeefb767a511486ac93ee0479016b2d1af48f09aa

Contents?: true

Size: 458 Bytes

Versions: 42

Compression:

Stored size: 458 Bytes

Contents

require 'securerandom'

module Fog
  class UUID
    class << self

      def uuid
        if supported?
          SecureRandom.uuid
        else
          ary = SecureRandom.random_bytes(16).unpack("NnnnnN")
          ary[2] = (ary[2] & 0x0fff) | 0x4000
          ary[3] = (ary[3] & 0x3fff) | 0x8000
          "%08x-%04x-%04x-%04x-%04x%08x" % ary
        end
      end

      def supported?
        SecureRandom.respond_to?(:uuid)
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 3 rubygems

Version Path
fog-core-1.24.0 lib/fog/core/uuid.rb
fog-core-1.23.0 lib/fog/core/uuid.rb
fog-core-1.22.0 lib/fog/core/uuid.rb
fog-core-1.21.1 lib/fog/core/uuid.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/core/uuid.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/core/uuid.rb
fog-core-1.21.0 lib/fog/core/uuid.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/core/uuid.rb
fog-1.20.0 lib/fog/core/uuid.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/core/uuid.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/core/uuid.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/core/uuid.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/core/uuid.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/core/uuid.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/core/uuid.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/core/uuid.rb
fog-1.19.0 lib/fog/core/uuid.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/core/uuid.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/core/uuid.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/core/uuid.rb