<commit_before># coding: utf-8
module Tekido
  module Methods
    module ClassMethods
      UPPER_CHARS = ('A'..'Z').to_a
      LOWER_CHARS = ('a'..'z').to_a
      NUMBER_CHARS = ('0'..'9').to_a
      EXAMPLE_DOMAINS = ["example.com", "exmple.net", "example.org"] +
                        ["example.jp", "example.co.jp", "example.ne.jp"] +
                        (0..9).map { |i| ["example#{i}.jp", "example#{i}.co.jp", "example#{i}.ne.jp"] }.flatten

      def string(options = {})
        size = size_from(options[:size])
        chars = chars_from(options[:chars], *options[:components])

        "".tap do |str|
          size.times do
            str << chars.sample
          end
        end
      end

      def email(*bases)
        local = string(size: 3..32, components: [:lower, :number])
        domains = bases.empty? ? EXAMPLE_DOMAINS : bases.map { |b| b.index("@") ? b[b.index('@').to_i+1..b.size] : b }
        "#{local}@#{domains.sample}"
      end

      private
      def size_from(option)
        base_size = integer(1..255)
        if option.nil?
          base_size
        elsif option.is_a?(Integer)
          option > 0 ? option : base
        elsif option.is_a?(Range)
          new_size = integer(option)
          new_size > 0 ? new_size : base
        end<commit_msg>refactored<commit_after># coding: utf-8
module Tekido
  module Methods
    module ClassMethods
      UPPER_CHARS  = [*'A'..'Z'].freeze
      LOWER_CHARS  = [*'a'..'z'].freeze
      NUMBER_CHARS = [*'0'..'9'].freeze
      EXAMPLE_DOMAINS = ["example.com", "exmple.net", "example.org"] +
                        ["example.jp", "example.co.jp", "example.ne.jp"] +
                        (0..9).map { |i| ["example#{i}.jp", "example#{i}.co.jp", "example#{i}.ne.jp"] }.flatten
      EXAMPLE_DOMAINS.freeze

      def string(options = {})
        size = size_from(options[:size])
        chars = chars_from(options[:chars], *options[:components])
        size.times.map { chars.sample }.join
      end

      def email(*bases)
        local = string(size: 3..32, components: [:lower, :number])
        domains = bases.empty? ? EXAMPLE_DOMAINS : bases.map { |b| b.index("@") ? b[b.index('@').to_i+1..b.size] : b }
        "#{local}@#{domains.sample}"
      end

      private
      def size_from(option)
        base_size = integer(1..255)
        if option.nil?
          base_size
        elsif option.is_a?(Integer)
          option > 0 ? option : base
        elsif option.is_a?(Range)
          new_size = integer(option)
          new_size > 0 ? new_size : base
        end
{'fraction_non_alphanumeric': 0.1676390509529366, 'fraction_numerical': 0.011668611435239206, 'mean_word_length': 2.008187134502924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7363585', 'n_tokens_mistral': 918, 'n_tokens_neox': 877, 'n_words': 166}