<commit_before>module LdapMapper
  module Base
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods

      def _load(marshalled)
        new(Marshal.load(marshalled))
      end

      def base(type)
        class_eval <<-EOS, __FILE__, __LINE__
          def base
            "#{type.to_s}"
          end
        EOS
        @control = type.to_s
      end

      def objectclasses
        @objectclasses ||= []
      end

      def objectclass(name)
        objectclasses << name 
      end

      def connection
        @conn ||= ldap_connection
      end

      def ldap_connection
        ldap = Net::LDAP.new
        ldap.host = LDAP_MAPPER_HOST
        ldap.port = LDAP_MAPPER_PORT
        ldap.auth LDAP_MAPPER_ADMIN, LDAP_MAPPER_ADMIN_PASSWORD
        ldap
      end

      def attributes
        @attributes ||= []
      end

      def attribute(name, options = {})
        class_eval <<-EOS, __FILE__, __LINE__
          def #{name}
            attributes[:#{name}]
          end
        EOS
        case options[:type]
        when :integer
          class_eval <<-EOS, __FILE__, __LINE__
            def #{name}=(new_#{name})
              attributes[:#{name}] = new_#{name}.to_i
            end
          EOS
          class_eval <<-EOS, __FILE__, __LINE__
            def #{name}_convert
              attributes[:#{name}].to_s
            end
          EOS
        when :password
          class_eval <<-EOS, __FILE__, __LINE__
            def #{name}=(new_#{name})
              if new_#{name} =~ /^{SSHA}/
                attributes[:#{name}] = nil
                attributes[:#{name}_encrypted] = new_#{name}<commit_msg>fixed regex for older ruby<commit_after>module LdapMapper
  module Base
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods

      def _load(marshalled)
        new(Marshal.load(marshalled))
      end

      def base(type)
        class_eval <<-EOS, __FILE__, __LINE__
          def base
            "#{type.to_s}"
          end
        EOS
        @control = type.to_s
      end

      def objectclasses
        @objectclasses ||= []
      end

      def objectclass(name)
        objectclasses << name 
      end

      def connection
        @conn ||= ldap_connection
      end

      def ldap_connection
        ldap = Net::LDAP.new
        ldap.host = LDAP_MAPPER_HOST
        ldap.port = LDAP_MAPPER_PORT
        ldap.auth LDAP_MAPPER_ADMIN, LDAP_MAPPER_ADMIN_PASSWORD
        ldap
      end

      def attributes
        @attributes ||= []
      end

      def attribute(name, options = {})
        class_eval <<-EOS, __FILE__, __LINE__
          def #{name}
            attributes[:#{name}]
          end
        EOS
        case options[:type]
        when :integer
          class_eval <<-EOS, __FILE__, __LINE__
            def #{name}=(new_#{name})
              attributes[:#{name}] = new_#{name}.to_i
            end
          EOS
          class_eval <<-EOS, __FILE__, __LINE__
            def #{name}_convert
              attributes[:#{name}].to_s
            end
          EOS
        when :password
          class_eval <<-EOS, __FILE__, __LINE__
            def #{name}=(new_#{name})
              if new_#{name} =~ /^\{SSHA\}/
                attributes[:#{name}] = nil
                attributes[:#{name}_encrypted] = new_#{name}
{'fraction_non_alphanumeric': 0.10032650638171564, 'fraction_numerical': 0.0, 'mean_word_length': 1.5627376425855513, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 3, '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': '7114091', 'n_tokens_mistral': 1014, 'n_tokens_neox': 1007, 'n_words': 221}