<commit_before>#---------------------------------------------------------------------------
# desc: It is the library for the IMAP initialization and related stuffs
# created at: 28/08/2012
#---------------------------------------------------------------------------

require 'net/imap'

module WmailUtils

  class WmailImapUtils
    attr_accessor :user_email, :user_password, :connected

    def initialize(options)
      @user_email = options[:user_email] ||= nil
      @user_password = options[:user_password] ||= nil
      @connected = false
    end

    def imap_authenticate(email, password)
      
      unless @connected

        begin
          @imap = Net::IMAP.new('imap.gmail.com', 993, true)
          @imap.login(email, password)
          @connected = true
        rescue Exception => e
          # here you can add code to customize it.
        end

      end

      @connected
    end

    def imap
      @imap
    end

    def self.current_imap=(imap_obj)
      @current_imap = imap_obj
    end

    def self.current_imap
      @current_imap
    end

  end

end<commit_msg>add the methods for reconnecting the imap<commit_after>#---------------------------------------------------------------------------
# desc: It is the library for the IMAP initialization and related stuffs
# created at: 28/08/2012
#---------------------------------------------------------------------------

require 'net/imap'

module WmailUtils

  class WmailImapUtils
    attr_accessor :user_email, :user_password, :connected

    def initialize(options)
      @user_email = options[:user_email] ||= nil
      @user_password = options[:user_password] ||= nil
      @connected = false
    end

    def imap_authenticate(email, password)
      
      unless @connected

        begin
          @imap = Net::IMAP.new('imap.gmail.com', 993, true)
          @imap.login(email, password)
          @connected = true
          @current_imap = @imap
        rescue Exception => e
          # here you can add code to customize it.
        end

      end

      @connected
    end

    def imap
      @imap
    end

    def self.current_imap
      @current_imap
    end

    def self.is_connected?
      connection_flag = false
      connection_flag = !@current_imap.disconnected? unless @current_imap.blank? unless @connected
      return connection_flag
    end

    def self.reconnect
      self.new(@user_email, @user_password).imap_authenticate(@user_email, @user_password)
    end

  end

end
{'fraction_non_alphanumeric': 0.1917808219178082, 'fraction_numerical': 0.008863819500402902, 'mean_word_length': 1.6275132275132276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3468600', 'n_tokens_mistral': 714, 'n_tokens_neox': 673, 'n_words': 183}