<commit_before>require 'protobuf/message'
require 'protobuf/enum'

module Tutorial
  class Person < Protobuf::Message
    required :string, :name, 1
    required :int32, :id, 2
    optional :string, :email, 3

    class PhoneType < Protobuf::Enum
      MOBILE = 0
      HOME = 1
      WORK = 2
    end

    class PhoneNumber < Protobuf::Message
      required :string, :number, 1
      optional :PhoneType, :type, 2, {:default => :HOME}
    end

    repeated :PhoneNumber, :phone, 4
  end

  class AddressBook < Protobuf::Message
    repeated :Person, :person, 1
  end
end

puts :PHONE_NUMBER
phone_number = Tutorial::Person::PhoneNumber.new
phone_number.type = 0
phone_number.type = 1
phone_number.type = 2
begin
  phone_number.type = 3
rescue TypeError
end

puts :PERSON<commit_msg>create Enum class to handle enum type fields<commit_after>require 'protobuf/message'
require 'protobuf/enum'

module Tutorial
  class Person < Protobuf::Message
    required :string, :name, 1
    required :int32, :id, 2
    optional :string, :email, 3

    class PhoneType < Protobuf::Enum
      MOBILE = 0
      HOME = 1
      WORK = 2
    end

    class PhoneNumber < Protobuf::Message
      required :string, :number, 1
      optional :PhoneType, :type, 2, {:default => :HOME}
    end

    repeated :PhoneNumber, :phone, 4
  end

  class AddressBook < Protobuf::Message
    repeated :Person, :person, 1
  end
end

puts :PHONE_NUMBER
phone_number = Tutorial::Person::PhoneNumber.new
phone_number.type = Tutorial::Person::PhoneType.MOBILE
phone_number.type = Tutorial::Person::PhoneType.HOME
phone_number.type = Tutorial::Person::PhoneType.WORK
phone_number.type = 0
phone_number.type = 1
phone_number.type = 2
begin
  phone_number.type = 3
rescue TypeError
end

puts :PERSON
{'fraction_non_alphanumeric': 0.0971590909090909, 'fraction_numerical': 0.01818181818181818, 'mean_word_length': 3.622047244094488, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '6497173', 'n_tokens_mistral': 606, 'n_tokens_neox': 557, 'n_words': 166}