free_mutant/lib/mutant.rb
Markus Schirp dc893bfd7d Progress on method matching
* Adjust metrics
* Add initial integration spec on method matching
* Yard and Heckle coverage is at 100% (heckle cov is disputable)
* Rcov does not really make sense as MRI 1.8 cannot reach all code
  paths.
2012-07-24 01:41:08 +02:00

56 lines
1.3 KiB
Ruby

# 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
#
def self.not_implemented(object)
method = caller(1).first[/`(.*)'/,1].to_sym
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
end
private_class_method :not_implemented_info
end
require 'mutant/matcher'
require 'mutant/matcher/method'
require 'mutant/matcher/method/singleton'
require 'mutant/matcher/method/instance'
require 'mutant/matcher/method/classifier'