free_mutant/lib/mutant/context.rb

53 lines
912 B
Ruby
Raw Normal View History

module Mutant
# An abstract context where mutations can be appied to.
class Context
2012-10-15 08:36:15 -04:00
include Adamantium, AbstractClass
# Return root ast node
#
# @param [Rubinius::AST::Node] node
#
# @return [Rubinis::AST::Script]
#
# @api private
#
abstract_method :root
2012-08-14 06:26:56 -04:00
# Return source path
#
# @return [String]
#
# @api private
#
attr_reader :source_path
2012-08-14 06:26:56 -04:00
private
# Initialize context
#
# @param [String] source_path
#
# @return [undefined]
#
# @api private
#
def initialize(source_path)
@source_path = source_path
end
# Return script node
#
# @param [Rubinius::AST::Node] node
#
# @return [Rubinius::AST::Script]
#
# @api private
#
def script(node)
Rubinius::AST::Script.new(node).tap do |script|
script.file = source_path
2012-08-14 06:26:56 -04:00
end
end
end
end