<commit_before>module Pounder
  class Server
    module Command
      def cmd_STAT(maildir, args)
        print_line "+OK #{maildir.size} #{maildir.total_octets}"
      end

      def cmd_LIST(maildir, args)
        print_line "+OK"
        maildir.messages.each do |m|
          print_line "#{m.seq} #{m.octets}"
        end
        print_line "."
      end

      def cmd_USER(maildir, args)
        # nop.
        print_line "+OK"
      end

      def cmd_PASS(maildir, args)
        # nop.
        print_line "+OK"
      end

      def cmd_DELE(maildir, args)
        # nop.
        print_line "+OK"
      end

      def cmd_QUIT(maildir, args)
        print_line "+OK"
        terminate
      end

      def cmd_RETR(maildir, args)
        message = maildir[args.first.to_i]
        print_line "+OK"
        message.each_line do |line|
          print_line_message line
        end

        # To prevent dot to become a part of the body,
        # and outputs a new line.
        print_line ""
        print_line "."
      end<commit_msg>Fix to outputs a Date header of the time it was run<commit_after>require 'date'

module Pounder
  class Server
    module Command
      def cmd_STAT(maildir, args)
        print_line "+OK #{maildir.size} #{maildir.total_octets}"
      end

      def cmd_LIST(maildir, args)
        print_line "+OK"
        maildir.messages.each do |m|
          print_line "#{m.seq} #{m.octets}"
        end
        print_line "."
      end

      def cmd_USER(maildir, args)
        # nop.
        print_line "+OK"
      end

      def cmd_PASS(maildir, args)
        # nop.
        print_line "+OK"
      end

      def cmd_DELE(maildir, args)
        # nop.
        print_line "+OK"
      end

      def cmd_QUIT(maildir, args)
        print_line "+OK"
        terminate
      end

      def cmd_RETR(maildir, args)
        message = maildir[args.first.to_i]
        print_line "+OK"
        message.each_line do |line|
          if line.match(/^Date: .*/) then
            # Outputs a Date header of the time it was run.
            print_line_message "Date: #{DateTime.now.httpdate}"
            next
          end
          print_line_message line
        end

        # To prevent dot to become a part of the body,
        # and outputs a new line.
        print_line ""
        print_line "."
      end
{'fraction_non_alphanumeric': 0.08857509627727857, 'fraction_numerical': 0.0, 'mean_word_length': 1.632882882882883, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2242106', 'n_tokens_mistral': 749, 'n_tokens_neox': 728, 'n_words': 204}