<commit_before>require File.join(File.dirname(__FILE__), 'spec_helper')

describe UUID, '#initialize' do
  it 'generates a new UUID when passed no parameters' do
    UUID.new.should_not == UUID.new
  end
  
  it 'creates a UUID from a valid string representation when passed one' do
    id = UUID.new
    UUID::FORMATS.each do |name, _|
      UUID.new(id.to_s(name)).should == id
    end
    UUID.new(UUID::Nil.to_s).should == UUID::Nil
  end
  
  it 'raises an ArgumentError when passed a value it cannot convert into a UUID' do
    lambda { UUID.new '<garbage>' }.should raise_error(ArgumentError)
  end
end

describe UUID, "#to_i" do
  it 'returns a 128-bit integer represenation of the UUID'
end

describe UUID, '#to_s' do
  
  COMPACT_FORMAT = /[0-9a-fA-F]{8}([0-9a-fA-F]{4}){3}[0-9a-fA-F]{12}/
  DEFAULT_FORMAT = /[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}/
  
  before do
    @id = UUID.new
  end

  it 'returns a UUID string in delimited hex format when passed no parameters (i.e., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' do
    @id.to_s.should =~ /^#{DEFAULT_FORMAT}$/
  end

  it 'returns a UUID string in delimited hex format when passed :default (i.e., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' do
    @id.to_s(:default).should =~ /^#{DEFAULT_FORMAT}$/
  end

  it 'returns a UUID string in undelimited hex format when passed :compact (i.e., xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)' do |variable|
    @id.to_s(:compact).should =~ /^#{COMPACT_FORMAT}$/
  end

  it 'returns a UUID string in delimited hex format with a urn prefix when passed :urn (i.e., urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' do
    @id.to_s(:urn).should =~ /^urn:uuid:#{DEFAULT_FORMAT}$/<commit_msg>fix typo<commit_after>require File.join(File.dirname(__FILE__), 'spec_helper')

describe UUID, '#initialize' do
  it 'generates a new UUID when passed no parameters' do
    UUID.new.should_not == UUID.new
  end
  
  it 'creates a UUID from a valid string representation when passed one' do
    id = UUID.new
    UUID::FORMATS.each do |name, _|
      UUID.new(id.to_s(name)).should == id
    end
    UUID.new(UUID::Nil.to_s).should == UUID::Nil
  end
  
  it 'raises an ArgumentError when passed a value it cannot convert into a UUID' do
    lambda { UUID.new '<garbage>' }.should raise_error(ArgumentError)
  end
end

describe UUID, "#to_i" do
  it 'returns a 128-bit integer representation of the UUID'
end

describe UUID, '#to_s' do
  
  COMPACT_FORMAT = /[0-9a-fA-F]{8}([0-9a-fA-F]{4}){3}[0-9a-fA-F]{12}/
  DEFAULT_FORMAT = /[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}/
  
  before do
    @id = UUID.new
  end

  it 'returns a UUID string in delimited hex format when passed no parameters (i.e., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' do
    @id.to_s.should =~ /^#{DEFAULT_FORMAT}$/
  end

  it 'returns a UUID string in delimited hex format when passed :default (i.e., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' do
    @id.to_s(:default).should =~ /^#{DEFAULT_FORMAT}$/
  end

  it 'returns a UUID string in undelimited hex format when passed :compact (i.e., xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)' do |variable|
    @id.to_s(:compact).should =~ /^#{COMPACT_FORMAT}$/
  end

  it 'returns a UUID string in delimited hex format with a urn prefix when passed :urn (i.e., urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' do
    @id.to_s(:urn).should =~ /^urn:uuid:#{DEFAULT_FORMAT}$/
{'fraction_non_alphanumeric': 0.1443850267379679, 'fraction_numerical': 0.014854426619132501, 'mean_word_length': 3.6123287671232878, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1729960', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1265, 'n_words': 342}