free_mutant/lib/mutant/loader.rb

41 lines
653 B
Ruby
Raw Normal View History

module Mutant
# Base class for code loaders
class Loader
2014-03-14 16:56:04 -04:00
include AbstractType, Concord.new(:root, :subject), Procto.call
2012-08-19 23:01:26 -04:00
# Eval based loader
class Eval < self
2013-01-04 14:07:41 -05:00
# Call loader
#
# @return [undefined]
#
# @api private
#
def call
2013-07-28 13:24:00 -04:00
eval(
source,
TOPLEVEL_BINDING,
2014-03-14 16:56:04 -04:00
subject.source_path.to_s,
subject.source_line
2013-07-28 13:24:00 -04:00
)
2014-11-17 15:31:12 -05:00
self
end
private
# Return source
#
# @return [String]
#
# @api private
#
def source
2014-03-14 16:56:04 -04:00
Unparser.unparse(root)
end
end # Eval
end # Loader
end # Mutant