<commit_before>require 'crispy/received_message'
require 'crispy/spy_mixin'

module Crispy
  class SpyWrapper < Module
    include SpyMixin

    def initialize target, stubs_map = {}
      super()
      @received_messages = []
      singleton_class =
        class << target
          self
        end
      target.instance_exec self do|spy|
        @__CRISPY_SPY__ = spy
      end
      @__CRISPY_STUBBER__ = Stubber.new(stubs_map)
      @__CRISPY_STUBBER__.prepend_features singleton_class
      prepend_features singleton_class
    end

    def prepend_features klass
      super
      klass.public_instance_methods.each do|method_name|
        self.module_eval { public define_wrapper(method_name) }
      end
      klass.protected_instance_methods.each do|method_name|
        self.module_eval { protected define_wrapper(method_name) }
      end
      klass.private_instance_methods.each do|method_name|
        self.module_eval { private define_wrapper(method_name) }
      end
    end

    NOT_SPECIFIED = Object.new

    def stub *arguments, &definition
      @__CRISPY_STUBBER__.stub(*arguments, &definition)
      self
    end

    private def define_wrapper method_name
      define_method method_name do|*arguments, &attached_block|
        @__CRISPY_SPY__.received_messages << ReceivedMessage.new(method_name, *arguments, &attached_block)
        super(*arguments, &attached_block)
      end
      method_name
    end

  end
end<commit_msg>delete an unused constant<commit_after>require 'crispy/received_message'
require 'crispy/spy_mixin'

module Crispy
  class SpyWrapper < Module
    include SpyMixin

    def initialize target, stubs_map = {}
      super()
      @received_messages = []
      singleton_class =
        class << target
          self
        end
      target.instance_exec self do|spy|
        @__CRISPY_SPY__ = spy
      end
      @__CRISPY_STUBBER__ = Stubber.new(stubs_map)
      @__CRISPY_STUBBER__.prepend_features singleton_class
      prepend_features singleton_class
    end

    def prepend_features klass
      super
      klass.public_instance_methods.each do|method_name|
        self.module_eval { public define_wrapper(method_name) }
      end
      klass.protected_instance_methods.each do|method_name|
        self.module_eval { protected define_wrapper(method_name) }
      end
      klass.private_instance_methods.each do|method_name|
        self.module_eval { private define_wrapper(method_name) }
      end
    end

    def stub *arguments, &definition
      @__CRISPY_STUBBER__.stub(*arguments, &definition)
      self
    end

    private def define_wrapper method_name
      define_method method_name do|*arguments, &attached_block|
        @__CRISPY_SPY__.received_messages << ReceivedMessage.new(method_name, *arguments, &attached_block)
        super(*arguments, &attached_block)
      end
      method_name
    end

  end
end
{'fraction_non_alphanumeric': 0.06514206514206514, 'fraction_numerical': 0.0, 'mean_word_length': 2.97111416781293, 'pattern_counts': {'":': 0, '<': 13, '<?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': '3068854', 'n_tokens_mistral': 897, 'n_tokens_neox': 886, 'n_words': 174}