<commit_before>require 'colorize'
require 'date'
require 'forwardable'

module HipchatSearcher
  class SearchProxy
    class Grep
      extend Forwardable

      def initialize(pattern, result, options={})
        @simple     = Simple.new(pattern, result, options)
        @options    = options
        @print_room = false
        @print_item = {}
      end

      def_delegators :@simple, :before?, :items, :option_user?, :option_date?, :option_date, :pattern, :print_room?, :puts_room, :room

      def self.search(pattern, result, options)
        new(pattern, result, options).search
      end

      def around_items(index)
        items[range(index)].map do |itm|
          itm.extend(HipchatSearcher::ItemExtention).tap do |i|
            i.pattern = pattern
          end
        end
      end

      def puts_search_result(item)
        if option_user?
          if @options[:user] == item.mention_name
            puts_contents(item)
          end
        else
          puts_contents(item)
        end
      end

      def search
        items.each_with_index do |item, idx|
          if before?(item.date)
            @options[:end] = true
            break
          end

          if pattern =~ item.message<commit_msg>* Use inferitance instead of delegation because delegates are many methods from Simple<commit_after>require 'colorize'
require 'date'

module HipchatSearcher
  class SearchProxy
    class Grep < Simple

      def initialize(pattern, result, options={})
        super
        @print_room = false
        @print_item = {}
      end

      def self.search(pattern, result, options)
        new(pattern, result, options).search
      end

      def around_items(index)
        items[range(index)].map do |itm|
          itm.extend(HipchatSearcher::ItemExtention).tap do |i|
            i.pattern = pattern
          end
        end
      end

      def puts_search_result(item)
        if option_user?
          if @options[:user] == item.mention_name
            puts_contents(item)
          end
        else
          puts_contents(item)
        end
      end

      def search
        items.each_with_index do |item, idx|
          if before?(item.date)
            @options[:end] = true
            break
          end

          if pattern =~ item.message
{'fraction_non_alphanumeric': 0.0851528384279476, 'fraction_numerical': 0.0, 'mean_word_length': 1.9221938775510203, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2481225', 'n_tokens_mistral': 657, 'n_tokens_neox': 644, 'n_words': 168}