<commit_before>module Munge
  module Core
    class Transform
      def initialize(source_path, layouts_path, global_data = {})
        @source_path  = source_path
        @layouts_path = layouts_path
        @global_data  = global_data
      end

      def call(item)
        item.transforms
          .map { |name, args| [resolve_transformer(name), args] }
          .inject(item.content) do |content, params|
            transformer, args = params

            t = transformer.new(@source_path, @layouts_path, @global_data)

            t.call(item, content, *args)
          end
      end

      def resolve_transformer(identifier)
        resolver = proc do |name|
          if Munge::Transformer.constants.include?(name)
            return Munge::Transformer.const_get(name)
          end
        end

        resolver.call(identifier.to_sym)

        resolver.call(underscore_to_camel(identifier.to_s).to_sym)
      end

      private

      def underscore_to_camel(string)
        string
          .split("_")
          .map(&:capitalize)
          .join("")
      end
    end
  end
end
<commit_msg>required global_data<commit_after>module Munge
  module Core
    class Transform
      def initialize(source_path, layouts_path, global_data)
        @source_path  = source_path
        @layouts_path = layouts_path
        @global_data  = global_data
      end

      def call(item)
        item.transforms
          .map { |name, args| [resolve_transformer(name), args] }
          .inject(item.content) do |content, params|
            transformer, args = params

            t = transformer.new(@source_path, @layouts_path, @global_data)

            t.call(item, content, *args)
          end
      end

      def resolve_transformer(identifier)
        resolver = proc do |name|
          if Munge::Transformer.constants.include?(name)
            return Munge::Transformer.const_get(name)
          end
        end

        resolver.call(identifier.to_sym)

        resolver.call(underscore_to_camel(identifier.to_s).to_sym)
      end

      private

      def underscore_to_camel(string)
        string
          .split("_")
          .map(&:capitalize)
          .join("")
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08799638989169675, 'fraction_numerical': 0.0, 'mean_word_length': 1.9959459459459459, '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': '2615919', 'n_tokens_mistral': 675, 'n_tokens_neox': 651, 'n_words': 135}