Sha256: 395590e7746b04206c54f2a77a03be90172488359859fdb2381dee64490f34e4

Contents?: true

Size: 686 Bytes

Versions: 20

Compression:

Stored size: 686 Bytes

Contents

module ASIR
# Provides an RFC4122-compliant random (version 4) UUID service.
module UUID
  # Return an RFC4122-compliant random (version 4) UUID,
  # represented as a string of 36 characters.
  #
  # Possible (but unlikely!) return value:
  #   "e29fc859-8d6d-4c5d-aa5a-1ab726f4a192".
  #
  # Possible exceptions:
  #   Errno::ENOENT
  #
  PROC_SYS_FILE = "/proc/sys/kernel/random/uuid".freeze
  case
  when File.exist?(PROC_SYS_FILE)
    def self.generate
      File.read(PROC_SYS_FILE).chomp!
    end
  when (gem 'uuid' rescue nil)
    require 'uuid'
    def self.generate
      ::UUID.generate
    end
  else
    def self.generate
      raise "Unimplemented"
    end
  end
end
end


Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
asir-1.1.12 lib/asir/uuid.rb
asir-1.1.11 lib/asir/uuid.rb
asir-1.1.10 lib/asir/uuid.rb
asir-1.1.9 lib/asir/uuid.rb
asir-1.1.8 lib/asir/uuid.rb
asir-1.1.7 lib/asir/uuid.rb
asir-1.1.6 lib/asir/uuid.rb
asir-1.1.5 lib/asir/uuid.rb
asir-1.1.4 lib/asir/uuid.rb
asir-1.1.3 lib/asir/uuid.rb
asir-1.1.2 lib/asir/uuid.rb
asir-1.1.1 lib/asir/uuid.rb
asir-1.1.0 lib/asir/uuid.rb
asir-1.0.8 lib/asir/uuid.rb
asir-1.0.7 lib/asir/uuid.rb
asir-1.0.6 lib/asir/uuid.rb
asir-1.0.5 lib/asir/uuid.rb
asir-1.0.4 lib/asir/uuid.rb
asir-1.0.1 lib/asir/uuid.rb
asir-0.2.0 lib/asir/uuid.rb