<commit_before>module EnomAPI
  class Client
    def initialize(user, passwd, mode = :live)
      @user, @mode = user, mode
      @conn = Interface.new(user, passwd, mode)
    end
    def inspect
      "#<#{self.class} #{@user}@#{@mode}>"
    end
    def search
      @conn.search
    end

    def check(*names)
      raise ArgumentError, "maximum number of names is 30" if names.size > 30
      xml = send_recv(:Check, :DomainNames => names.join(','))

      info = (0..xml.DomainCount.to_i).map do |i|
        [xml.send("Domain#{i}"), xml.send("RRPCode#{i}") == '210']
      end.flatten

      return info[1] if info.size == 2
      Hash[*info]
    end

    def check_ns_status(name)
      xml = send_recv(:CheckNSStatus, :CheckNSName => name)

      return false if xml.RRPCode != '200'
      { :name => xml.name, :ipaddress => xml.ipaddress }
    end

    def delete_nameserver(name)
      xml = send_recv(:DeleteNameServer, :NS => name)
      return xml.RRPCode == '200' && xml.NsSuccess == '1'
    end
<commit_msg>Improve the output of the EnomAPI::Client#search method<commit_after>module EnomAPI
  class Client
    def initialize(user, passwd, mode = :live)
      @user, @mode = user, mode
      @conn = Interface.new(user, passwd, mode)
    end
    def inspect
      "#<#{self.class} #{@user}@#{@mode}>"
    end
    def search(&block)
      response = @conn.search(&block)
      xml = XML::Parser.string(response).parse

      o = Array.new
      d = Demolisher.demolish(xml)
      d.send("interface-response") do
        d.DomainSearch do
          d.Domains do
            d.Domain do
              o << {
                :id => d.DomainNameID,
                :name => "#{d.SLD}.#{d.TLD}",
                :auto_renew => d.AutoRenew?,
                :expires => Time.parse(d.ExpDate),
                :status => d.DomainRegistrationStatus,
                :nameservers => d.NameServers.split(",") }
            end
          end
        end
      end
      o
    end

    def check(*names)
      raise ArgumentError, "maximum number of names is 30" if names.size > 30
      xml = send_recv(:Check, :DomainNames => names.join(','))

      info = (0..xml.DomainCount.to_i).map do |i|
        [xml.send("Domain#{i}"), xml.send("RRPCode#{i}") == '210']
      end.flatten

      return info[1] if info.size == 2
      Hash[*info]
    end

    def check_ns_status(name)
      xml = send_recv(:CheckNSStatus, :CheckNSName => name)

      return false if xml.RRPCode != '200'
      { :name => xml.name, :ipaddress => xml.ipaddress }
    end

    def delete_nameserver(name)
      xml = send_recv(:DeleteNameServer, :NS => name)
      return xml.RRPCode == '200' && xml.NsSuccess == '1'
    end

{'fraction_non_alphanumeric': 0.14486846980363097, 'fraction_numerical': 0.012597258243793997, 'mean_word_length': 2.2104637336504163, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, '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': '2605365', 'n_tokens_mistral': 924, 'n_tokens_neox': 885, 'n_words': 213}