Compact warnings emmited on namespace matching

This commit is contained in:
Markus Schirp 2014-06-26 20:57:14 +00:00
parent c6a509edd5
commit 9c492d89d3

View file

@ -2,6 +2,8 @@ module Mutant
class Matcher class Matcher
# Matcher for specific namespace # Matcher for specific namespace
#
# rubocop:disable LineLength
class Namespace < self class Namespace < self
include Concord::Public.new(:cache, :namespace) include Concord::Public.new(:cache, :namespace)
@ -64,14 +66,12 @@ module Mutant
# #
# @api private # @api private
# #
# rubocop:disable LineLength
#
def self.scope_name(scope) def self.scope_name(scope)
scope.name scope.name
rescue => exception rescue => exception
$stderr.puts <<-MESSAGE $stderr.puts("WARNING: While optaining #{scope.class}#name from: #{scope.inspect} It raised an error: #{exception.inspect} fix your lib!")
WARNING:
While optaining #{scope.class}#name from: #{scope.inspect}
It raised an error: #{exception.inspect} fix your lib!
MESSAGE
nil nil
end end
@ -86,11 +86,7 @@ It raised an error: #{exception.inspect} fix your lib!
def emit_scope(scope) def emit_scope(scope)
name = self.class.scope_name(scope) name = self.class.scope_name(scope)
unless name.nil? or name.kind_of?(String) unless name.nil? or name.kind_of?(String)
$stderr.puts <<-MESSAGE $stderr.puts("WARNING: #{scope.class}#name from: #{scope.inspect} did not return a String or nil. Fix your lib to support normal ruby semantics!")
WARNING:
#{scope.class}#name from: #{scope.inspect} did not return a String or nil.
Fix your lib to support normal ruby semantics!
MESSAGE
return return
end end
yield scope if pattern =~ name yield scope if pattern =~ name