Sha256: 9c2415b65ef08aed48fa8454285d68da9256e872cbe4840be219de6157d76924

Contents?: true

Size: 961 Bytes

Versions: 3

Compression:

Stored size: 961 Bytes

Contents

module Mutant
  # Base class for code loaders
  class Loader
    include AbstractType
    extend MethodObject

  private

    # Run the loader
    #
    # @return [undefined]
    #
    # @api private
    #
    abstract_method :run

    # Initialize and insert mutation into vm
    #
    # @param [Parser::AST::Node] root
    # @param [Subject] subject
    #
    # @return [undefined]
    #
    # @api private
    #
    def initialize(root, subject)
      @root, @subject = root, subject
      run
    end

    # Eval based loader
    class Eval < self

    private

      # Run loader
      #
      # @return [undefined]
      #
      # @api private
      #
      def run
        eval(source, TOPLEVEL_BINDING, @subject.source_path, @subject.source_line)
      end

      # Return source
      #
      # @return [String]
      #
      # @api private
      #
      def source
        Unparser.unparse(@root)
      end
    end # Eval

  end # Loader
end # Mutant

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutant-0.3.0.beta4 lib/mutant/loader.rb
mutant-0.3.0.beta3 lib/mutant/loader.rb
mutant-0.3.0.beta2 lib/mutant/loader.rb