2012-07-23 16:54:35 -04:00
|
|
|
# For Veritas::Immutable will be extracted soon
|
|
|
|
require 'veritas'
|
|
|
|
|
|
|
|
# Library namespace
|
|
|
|
module Mutant
|
|
|
|
# Helper method for raising not implemented exceptions
|
|
|
|
#
|
|
|
|
# @param [Object] object
|
|
|
|
# the object where method is not implemented
|
|
|
|
#
|
|
|
|
# @raise [NotImplementedError]
|
|
|
|
# raises a not implemented error with correct description
|
|
|
|
#
|
|
|
|
# @example
|
|
|
|
# class Foo
|
|
|
|
# def x
|
|
|
|
# Mutant.not_implemented(self)
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# Foo.new.x # raises NotImplementedError "Foo#x is not implemented"
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
2012-07-23 19:41:08 -04:00
|
|
|
#
|
2012-07-23 16:54:35 -04:00
|
|
|
def self.not_implemented(object)
|
|
|
|
method = caller(1).first[/`(.*)'/,1].to_sym
|
2012-07-23 19:41:08 -04:00
|
|
|
constant_name,delimiter = not_implemented_info(object)
|
|
|
|
raise NotImplementedError,"#{constant_name}#{delimiter}#{method} is not implemented"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return name and delimiter
|
|
|
|
#
|
|
|
|
# @param [Object] object
|
|
|
|
#
|
|
|
|
# @return [Array]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.not_implemented_info(object)
|
|
|
|
if object.kind_of?(Module)
|
|
|
|
[object.name,'.']
|
|
|
|
else
|
|
|
|
[object.class.name,'#']
|
|
|
|
end
|
2012-07-23 16:54:35 -04:00
|
|
|
end
|
2012-07-23 19:41:08 -04:00
|
|
|
|
|
|
|
private_class_method :not_implemented_info
|
2012-07-23 16:54:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
require 'mutant/matcher'
|
|
|
|
require 'mutant/matcher/method'
|
|
|
|
require 'mutant/matcher/method/singleton'
|
|
|
|
require 'mutant/matcher/method/instance'
|
|
|
|
require 'mutant/matcher/method/classifier'
|