Module: RScale::UUID

Included in:
RScale
Defined in:
lib/rscale/uuid.rb

Instance Method Summary collapse

Instance Method Details

#uuidObject

Generate uuid based on current configuration



4
5
6
# File 'lib/rscale/uuid.rb', line 4

def uuid
  RScale.config.uuid_system ? uuid_system : uuid_local
end

#uuid_localObject

Generate pseudo-unique string if local system does not have uuid binary installed



9
10
11
12
13
14
15
16
17
# File 'lib/rscale/uuid.rb', line 9

def uuid_local
  values = [
    rand(0x0010000), rand(0x0010000),
    rand(0x0010000), rand(0x0010000),
    rand(0x0010000), rand(0x1000000),
    rand(0x1000000),
  ]
  "%04x%04x%04x%04x%04x%06x%06x" % values
end

#uuid_systemObject

Generate uuid using system binary



20
21
22
# File 'lib/rscale/uuid.rb', line 20

def uuid_system
  `uuidgen`.strip.gsub(/-/,'')
end