Sha256: 20c8d4b5717260759901a6f4a91f90cf9af47e05cd932f6aee45c017da680293

Contents?: true

Size: 458 Bytes

Versions: 46

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

46 entries across 43 versions & 3 rubygems

Version Path
fog-core-2.3.0 lib/fog/core/uuid.rb
fog-core-2.2.4 lib/fog/core/uuid.rb
fog-core-2.2.3 lib/fog/core/uuid.rb
fog-core-2.2.2 lib/fog/core/uuid.rb
fog-core-2.2.1 lib/fog/core/uuid.rb
fog-core-2.2.0 lib/fog/core/uuid.rb
fog-core-2.1.2 lib/fog/core/uuid.rb
fog-core-2.1.1 lib/fog/core/uuid.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/lib/fog/core/uuid.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-core-1.45.0/lib/fog/core/uuid.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-core-2.1.0/lib/fog/core/uuid.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-core-1.45.0/lib/fog/core/uuid.rb
fog-core-2.1.0 lib/fog/core/uuid.rb
fog-core-2.0.0 lib/fog/core/uuid.rb
fog-core-1.45.0 lib/fog/core/uuid.rb
fog-core-1.44.3 lib/fog/core/uuid.rb
fog-core-1.44.2 lib/fog/core/uuid.rb
fog-core-1.44.1 lib/fog/core/uuid.rb
fog-core-1.44.0 lib/fog/core/uuid.rb
fog-core-1.43.0 lib/fog/core/uuid.rb