<commit_before>
Dir[ File.join( File.dirname(__FILE__), '*.rb' ) ].each do |f|
  begin
    require f
  rescue LoadError => e
    $LOG.warn "Missing required dependency to activate optional built-in extension #{File.basename(f)}\n  #{e}" if $LOG.debug?
  rescue StandardError => e
    $LOG.warn "Missing runtime configuration to activate optional built-in extension #{File.basename(f)}\n  #{e}" if $LOG.debug?
  end
end

module Awestruct
  module Extensions
    class Pipeline

      attr_reader :before_extensions
      attr_reader :extensions
      attr_reader :after_extensions
      attr_reader :helpers
      attr_reader :transformers

      def initialize(&block)
        @extensions   = []
        @helpers      = []
        @transformers = []
        begin
          instance_eval &block if block
        rescue Exception => e
          abort("Failed to initialize pipeline: #{e}")
        end
      end

      def extension(ext)
        @extensions << ext
        # TC: why? transformer and extension?
        ext.transform(@transformers) if ext.respond_to?('transform')
      end

      def helper(helper)
        @helpers << helper
      end

      def transformer(transformer)
        @transformers << transformer
      end

      def execute(site)
        extensions.each do |ext|
          ext.execute( site )
        end
      end

      def watch(watched_dirs)
        extensions.each do |ext|
          ext.watch( watched_dirs ) if ext.respond_to?('watch')
        end
      end

    end
  end
end
<commit_msg>Fixes issue #426 (`site` from _ext/pipeline)<commit_after>
Dir[ File.join( File.dirname(__FILE__), '*.rb' ) ].each do |f|
  begin
    require f
  rescue LoadError => e
    $LOG.warn "Missing required dependency to activate optional built-in extension #{File.basename(f)}\n  #{e}" if $LOG.debug?
  rescue StandardError => e
    $LOG.warn "Missing runtime configuration to activate optional built-in extension #{File.basename(f)}\n  #{e}" if $LOG.debug?
  end
end

module Awestruct
  module Extensions
    class Pipeline

      attr_reader :before_extensions
      attr_reader :extensions
      attr_reader :after_extensions
      attr_reader :helpers
      attr_reader :transformers

      def initialize(&block)
        @extensions   = []
        @helpers      = []
        @transformers = []
        begin
          instance_eval &block if block
        rescue Exception => e
          abort("Failed to initialize pipeline: #{e}")
        end
      end

      def extension(ext)
        @extensions << ext
        # TC: why? transformer and extension?
        ext.transform(@transformers) if ext.respond_to?('transform')
      end

      def helper(helper)
        @helpers << helper
      end

      def transformer(transformer)
        @transformers << transformer
      end

      def execute(site)
        extensions.each do |ext|
          ext.execute( site )
        end
      end

      def watch(watched_dirs)
        extensions.each do |ext|
          ext.watch( watched_dirs ) if ext.respond_to?('watch')
        end
      end

      private
      def site
        Awestruct::Engine.instance.site
      end

    end
  end
end

{'fraction_non_alphanumeric': 0.092317420170724, 'fraction_numerical': 0.0009484666455896301, 'mean_word_length': 2.186304128902316, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, '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': '653866', 'n_tokens_mistral': 899, 'n_tokens_neox': 890, 'n_words': 264}