Sha256: 548db25f3999c11cbb90dd947afd31061f3b7a82817a3aefcea0d0e1e609a96e

Contents?: true

Size: 454 Bytes

Versions: 19

Compression:

Stored size: 454 Bytes

Contents

# Microtime based uuids to be sortable
class BMC::SortableUUIDGenerator
  REGEX_WITH_DASHES    = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/
  REGEX_WITHOUT_DASHES = /^([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})$/

  def self.call
    prefix = Time.zone.now.strftime("%s%9N").to_i.to_s(16)
    suffix = SecureRandom.hex(8)
    (prefix + suffix).gsub(REGEX_WITHOUT_DASHES, '\1-\2-\3-\4-\5')
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bmc-1.6.1 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.6.0 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.5.1 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.5.0 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.4.3 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.4.2 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.4.1 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.4.0 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.3.5 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.3.4 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.3.3 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.3.2 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.3.1 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.3.0 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.2.1 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.2.0 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.1.0 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.0.1 app/libs/bmc/sortable_uuid_generator.rb
bmc-1.0.0 app/libs/bmc/sortable_uuid_generator.rb