Sha256: 85b29df4dea39b831d6a206be0e4bc034012828a1271261bb15db82ee0d59f79

Contents?: true

Size: 834 Bytes

Versions: 14

Compression:

Stored size: 834 Bytes

Contents

# Right now Adhearsion also defines this method. The eventual solution will be to extract the Adhearsion features on which
# Theatre depends and make that a dependent library.

unless respond_to? :new_guid
  
  def random_character
    case random_digit = rand(62)
      when  0...10 : random_digit.to_s
      when 10...36 : (random_digit + 55).chr
      when 36...62 : (random_digit + 61).chr
    end
  end
  
  def random_string(length_of_string=8)
    Array.new(length_of_string) { random_character }.join
  end
  
  # This GUID implementation doesn't adhere to the RFC which wants to make certain segments based on the MAC address of a
  # network interface card and other wackiness. It's sufficiently random for our needs.
  def new_guid
    [8,4,4,4,12].map { |segment_length| random_string(segment_length) }.join('-')
  end
end

Version data entries

14 entries across 14 versions & 8 rubygems

Version Path
eric-adhearsion-0.8.0 lib/theatre/guid.rb
jicksta-adhearsion-0.7.999 lib/theatre/guid.rb
jicksta-adhearsion-0.8.0 lib/theatre/guid.rb
jicksta-adhearsion-0.8.2 lib/theatre/guid.rb
jicksta-adhearsion-0.8.3 lib/theatre/guid.rb
jicksta-theatre-0.8.0 lib/theatre/guid.rb
kenwiesner-adhearsioncw-0.8.3 lib/theatre/guid.rb
mtrudel-adhearsion-0.8.3 lib/theatre/guid.rb
sevenscale-adhearsion-0.8.0 lib/theatre/guid.rb
adhearsion-0.8.3 lib/theatre/guid.rb
adhearsion-0.8.2 lib/theatre/guid.rb
adhearsion-0.8.0 lib/theatre/guid.rb
adhearsion-0.8.1 lib/theatre/guid.rb
theatre-0.8.0 lib/theatre/guid.rb