<commit_before>module Vigia
  module Hooks

    def execute_hook(filter_name, rspec_context)
      hooks_for_object(filter_name).each do |hook|
        rspec_context.instance_exec(&hook)
      end
    end

    def hooks_for_object(filter_name)
      config_hooks(filter_name) + object_hooks(filter_name)
    end

    def with_hooks(rspec_context)
      instance = self

      rspec_context.before(:context) do
        instance.execute_hook(:before, self)
      end<commit_msg>add method helper to hooks<commit_after>module Vigia
  module Hooks

    def execute_hook(filter_name, rspec_context)
      hooks_for_object(filter_name).each do |hook|
        if self.is_a?(Vigia::Sail::Context)
          instance = self
          rspec_context.define_singleton_method(:vigia_context, -> { instance })
        end

        rspec_context.instance_exec(&hook)
      end
    end

    def hooks_for_object(filter_name)
      config_hooks(filter_name) + object_hooks(filter_name)
    end

    def with_hooks(rspec_context)
      instance = self

      rspec_context.before(:context) do
        instance.execute_hook(:before, self)
      end
{'fraction_non_alphanumeric': 0.07617360496014172, 'fraction_numerical': 0.0, 'mean_word_length': 3.0942028985507246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4848746', 'n_tokens_mistral': 360, 'n_tokens_neox': 359, 'n_words': 64}