Sha256: 9a9bda1eaa02e544415960536bec513c0840dec0b1e7ab39b8249525a259baa7

Contents?: true

Size: 837 Bytes

Versions: 19

Compression:

Stored size: 837 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 then random_digit.to_s
      when 10...36 then (random_digit + 55).chr
      when 36...62 then (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

19 entries across 19 versions & 3 rubygems

Version Path
adhearsion-1.2.6 lib/theatre/guid.rb
adhearsion-1.2.5 lib/theatre/guid.rb
adhearsion-1.2.4 lib/theatre/guid.rb
adhearsion-1.2.3 lib/theatre/guid.rb
adhearsion-1.2.1 lib/theatre/guid.rb
adhearsion-1.2.0 lib/theatre/guid.rb
adhearsion-1.1.1 lib/theatre/guid.rb
adhearsion-1.1.0 lib/theatre/guid.rb
adhearsion-1.0.3 lib/theatre/guid.rb
adhearsion-1.0.2 lib/theatre/guid.rb
adhearsion-cw-1.0.2.3 lib/theatre/guid.rb
adhearsion-cw-1.0.2.2 lib/theatre/guid.rb
adhearsion-cw-1.0.2.1 lib/theatre/guid.rb
adhearsion-1.0.1 lib/theatre/guid.rb
adhearsion-1.0.0 lib/theatre/guid.rb
rene-adhearsion-0.8.6 lib/theatre/guid.rb
adhearsion-0.8.6 lib/theatre/guid.rb
adhearsion-0.8.5 lib/theatre/guid.rb
adhearsion-0.8.4 lib/theatre/guid.rb