<commit_before>require 'logger'

module MIT
  module LDAP

    class << self
      attr_accessor :logger

      def logger
        @logger ||= Logger.new('mit-ldap.log')

        adapter_present? ? adapter.logger : @logger
      end

      def search(options = {})
        []
      end

      def connect!
        if MIT.on_campus? && !adapter_present?
          include Ldaptic::Module(
            :adapter => :ldap_conn,
            :connection => ::LDAP::Conn.new('ldap-too.mit.edu'),
            :host => 'ldap-too.mit.edu',
            :base => 'dc=mit,dc=edu',
            :logger => logger
          )

          instance_eval do
            def search(options = {})
              connected? || reconnect! ? super : []
            end
          end
        elsif MIT.on_campus? && adapter_present?
          reconnect!
        end

        connected?
      end

      def connected?
        !connection.nil?
      end

      def reconnect!
        if adapter_present?
          adapter.instance_variable_set(:@connection, ::LDAP::Conn.new('ldap-too.mit.edu'))
        elsif !adapter_present?
          connect!
        end
      end

      private

      def connection
        adapter.instance_variable_get(:@connection) if adapter_present?
      end

      def adapter_present?
        respond_to?(:adapter)
      end
    end
  end
end<commit_msg>Decrease indentation<commit_after>require 'logger'

module MIT::LDAP
  class << self
    attr_accessor :logger

    def logger
      @logger ||= Logger.new('mit-ldap.log')

      adapter_present? ? adapter.logger : @logger
    end

    def search(options = {})
      []
    end

    def connect!
      if MIT.on_campus? && !adapter_present?
        include Ldaptic::Module(
          :adapter => :ldap_conn,
          :connection => ::LDAP::Conn.new('ldap-too.mit.edu'),
          :host => 'ldap-too.mit.edu',
          :base => 'dc=mit,dc=edu',
          :logger => logger
        )

        instance_eval do
          def search(options = {})
            connected? || reconnect! ? super : []
          end
        end
      elsif MIT.on_campus? && adapter_present?
        reconnect!
      end

      connected?
    end

    def connected?
      !connection.nil?
    end

    def reconnect!
      if adapter_present?
        adapter.instance_variable_set(:@connection, ::LDAP::Conn.new('ldap-too.mit.edu'))
      elsif !adapter_present?
        connect!
      end
    end

    private

    def connection
      adapter.instance_variable_get(:@connection) if adapter_present?
    end

    def adapter_present?
      respond_to?(:adapter)
    end
  end
end
{'fraction_non_alphanumeric': 0.10941086457536343, 'fraction_numerical': 0.0, 'mean_word_length': 1.7997858672376874, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '865096', 'n_tokens_mistral': 787, 'n_tokens_neox': 765, 'n_words': 163}