<commit_before># encoding: utf-8
module Faker
  class Internet < Base
    class << self
      def email(name = nil)
        [user_name(name), domain_name].join('@')
      end

      def free_email(name = nil)
        [user_name(name), fetch('internet.free_email')].join('@')
      end

      def safe_email(name = nil)
        [user_name(name), 'example.'+ %w[org com net].shuffle.first].join('@')
      end

      def user_name(specifier = nil, separators = %w(. _))
        with_locale(:en) do
          if specifier.kind_of? String
            return specifier.scan(/\w+/).shuffle.join(separators.sample).downcase
          elsif specifier.kind_of? Integer
            # If specifier is Integer and has large value, Argument error exception is raised to overcome memory full error 
            raise ArgumentError, "Given argument is too large" if specifier > 10**6
            tries = 0 # Don't try forever in case we get something like 1_000_000.
            begin
              result = user_name nil, separators
              tries += 1
            end while result.length < specifier and tries < 7
            result = result * (specifier/result.length + 1) if specifier > 0
            return result
          elsif specifier.kind_of? Range
            tries = 0
            begin
              result = user_name specifier.min, separators
              tries += 1
            end while not specifier.include? result.length and tries < 7
            return result[0...specifier.max]
          end

          [
            Char.prepare(Name.first_name),
            [Name.first_name, Name.last_name].map{ |name|
              Char.prepare name
            }.join(separators.sample)
          ].sample
        end
      end

      def password(min_length = 8, max_length = 16, mix_case = true, special_chars = false)
        temp = Lorem.characters(min_length)
        diff_length = max_length - min_length
        if diff_length > 0
          diff_rand = rand(diff_length + 1)
          temp += Lorem.characters(diff_rand)
        end
        temp = temp[0..min_length] if min_length > 0

        if mix_case
          temp.chars.each_with_index do |char, index|
            temp[index] = char.upcase if index % 2 == 0
          end
        end

        if special_chars
          chars = %w(! @ # $ % ^ & *)
          Random.rand(min_length).times do |i|
            temp[i] = chars[Random.rand(chars.length)]
          end
        end

        return temp
      end<commit_msg>Delete unneeded line for Faker::Internet.password (#751)<commit_after># encoding: utf-8
module Faker
  class Internet < Base
    class << self
      def email(name = nil)
        [user_name(name), domain_name].join('@')
      end

      def free_email(name = nil)
        [user_name(name), fetch('internet.free_email')].join('@')
      end

      def safe_email(name = nil)
        [user_name(name), 'example.'+ %w[org com net].shuffle.first].join('@')
      end

      def user_name(specifier = nil, separators = %w(. _))
        with_locale(:en) do
          if specifier.kind_of? String
            return specifier.scan(/\w+/).shuffle.join(separators.sample).downcase
          elsif specifier.kind_of? Integer
            # If specifier is Integer and has large value, Argument error exception is raised to overcome memory full error 
            raise ArgumentError, "Given argument is too large" if specifier > 10**6
            tries = 0 # Don't try forever in case we get something like 1_000_000.
            begin
              result = user_name nil, separators
              tries += 1
            end while result.length < specifier and tries < 7
            result = result * (specifier/result.length + 1) if specifier > 0
            return result
          elsif specifier.kind_of? Range
            tries = 0
            begin
              result = user_name specifier.min, separators
              tries += 1
            end while not specifier.include? result.length and tries < 7
            return result[0...specifier.max]
          end

          [
            Char.prepare(Name.first_name),
            [Name.first_name, Name.last_name].map{ |name|
              Char.prepare name
            }.join(separators.sample)
          ].sample
        end
      end

      def password(min_length = 8, max_length = 16, mix_case = true, special_chars = false)
        temp = Lorem.characters(min_length)
        diff_length = max_length - min_length
        if diff_length > 0
          diff_rand = rand(diff_length + 1)
          temp += Lorem.characters(diff_rand)
        end

        if mix_case
          temp.chars.each_with_index do |char, index|
            temp[index] = char.upcase if index % 2 == 0
          end
        end

        if special_chars
          chars = %w(! @ # $ % ^ & *)
          Random.rand(min_length).times do |i|
            temp[i] = chars[Random.rand(chars.length)]
          end
        end

        return temp
      end
{'fraction_non_alphanumeric': 0.09347300564061241, 'fraction_numerical': 0.011885576148267527, 'mean_word_length': 1.7799552071668534, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 10, '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': '5152748', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1388, 'n_words': 395}