<commit_before>module Metacrunch
  class Transformer
    require_relative "./transformer/step"
    require_relative "./transformer/helper"

    attr_accessor :source, :target, :options


    def initialize(source:nil, target:nil, options: {})
      @source  = source
      @target  = target
      @options = options
    end

    def transform(step_class = nil, &block)
      if block_given?
        Step.new(self).instance_eval(&block)
      else
        raise ArgumentError, "You need to provide a STEP or a block" if step_class.nil?
        clazz = step_class.is_a?(Class) ? step_class : step_class.to_s.constantize
        clazz.new(self).perform
      end
    end

    def helper
      @helper ||= Helper.new(self)
    end

    def register_helper(helper_module)
      raise ArgumentError, "Must be a module" unless helper_module.is_a?(Module)
      helper.class.send(:include, helper_module) # TODO: Benchmark this
    end

  end
end<commit_msg>Allow public access to the step instance.<commit_after>module Metacrunch
  class Transformer
    require_relative "./transformer/step"
    require_relative "./transformer/helper"

    attr_accessor :source, :target, :options
    attr_reader   :step


    def initialize(source:nil, target:nil, options: {})
      @source  = source
      @target  = target
      @options = options
    end

    def transform(step_class = nil, &block)
      if block_given?
        @step = Step.new(self)
        @step.instance_eval(&block)
      else
        raise ArgumentError, "You need to provide a STEP or a block" if step_class.nil?
        clazz = step_class.is_a?(Class) ? step_class : step_class.to_s.constantize
        @step = clazz.new(self)
        @step.perform
      end
    end

    def helper
      @helper ||= Helper.new(self)
    end

    def register_helper(helper_module)
      raise ArgumentError, "Must be a module" unless helper_module.is_a?(Module)
      helper.class.send(:include, helper_module) # TODO: Benchmark this
    end

  end
end
{'fraction_non_alphanumeric': 0.09218436873747494, 'fraction_numerical': 0.0, 'mean_word_length': 2.796577946768061, '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': '944158', 'n_tokens_mistral': 617, 'n_tokens_neox': 604, 'n_words': 159}