diff --git a/lib/ceedling/config_matchinator.rb b/lib/ceedling/config_matchinator.rb index f6cda50f..b0b3b22e 100644 --- a/lib/ceedling/config_matchinator.rb +++ b/lib/ceedling/config_matchinator.rb @@ -10,7 +10,7 @@ class ConfigMatchinator - constructor :configurator, :streaminator + constructor :configurator, :streaminator, :reportinator def config_include?(primary:, secondary:, tertiary:nil) # Create configurator accessor method @@ -85,8 +85,8 @@ def validate_matchers(hash:, section:, context:, operation:nil) # Look for matcher keys with missing values hash.each do |k, v| if v == nil - path = matcher_path(section:section, context:context, operation:operation) - error = "ERROR: Missing list of values for [#{path}↳ '#{k}' matcher in project configuration." + path = generate_matcher_path(section, context, operation) + error = "ERROR: Missing list of values for [#{path} ↳ '#{k}' matcher in project configuration." raise CeedlingException.new(error) end end @@ -98,8 +98,8 @@ def matches?(hash:, filepath:, section:, context:, operation:nil) # Sanity check if filepath.nil? - path = matcher_path(section:section, context:context, operation:operation) - error = "ERROR: #{path}↳ #{matcher} matching provided nil #{filepath}" + path = generate_matcher_path(section, context, operation) + error = "ERROR: #{path} ↳ #{matcher} matching provided nil #{filepath}" raise CeedlingException.new(error) end @@ -145,8 +145,8 @@ def matches?(hash:, filepath:, section:, context:, operation:nil) _values += values matched_notice(section:section, context:context, operation:operation, matcher:_matcher, filepath:filepath) else # No match - path = matcher_path(section:section, context:context, operation:operation) - @streaminator.stderr_puts("#{path}↳ #{matcher} did not match #{filepath}", Verbosity::DEBUG) + path = generate_matcher_path(section, context, operation) + @streaminator.stderr_puts("#{path} ↳ `#{matcher}` did not match #{filepath}", Verbosity::DEBUG) end end @@ -158,18 +158,12 @@ def matches?(hash:, filepath:, section:, context:, operation:nil) private def matched_notice(section:, context:, operation:, matcher:, filepath:) - path = matcher_path(section:section, context:context, operation:operation) - @streaminator.stdout_puts("#{path}↳ #{matcher} matched #{filepath}", Verbosity::OBNOXIOUS) + path = generate_matcher_path(section, context, operation) + @streaminator.stdout_puts("#{path} ↳ #{matcher} matched #{filepath}", Verbosity::OBNOXIOUS) end - def matcher_path(section:, context:, operation:) - path = ":#{section} ↳ :#{context} " - - if !operation.nil? - return path + "↳ :#{operation} " - end - - return path + def generate_matcher_path(*keys) + return @reportinator.generate_config_walk(keys) end # Assumes expr is a string and has been stripped diff --git a/lib/ceedling/objects.yml b/lib/ceedling/objects.yml index 16f8a7a7..ff1b1c5f 100644 --- a/lib/ceedling/objects.yml +++ b/lib/ceedling/objects.yml @@ -209,6 +209,7 @@ config_matchinator: compose: - configurator - streaminator + - reportinator flaginator: compose: diff --git a/lib/ceedling/reportinator.rb b/lib/ceedling/reportinator.rb index 68e7450b..05130b19 100644 --- a/lib/ceedling/reportinator.rb +++ b/lib/ceedling/reportinator.rb @@ -47,6 +47,7 @@ def generate_config_walk(keys, depth=0) _keys = keys.clone _keys = _keys.slice(0, depth) if depth > 0 + _keys.reject! { |key| key.nil? } return _keys.map{|key| ":#{key}"}.join(' ↳ ') end