class ChefSpec::Coverage::BerkshelfFilter
add_filter BerkshelfFilter.new(berksfile)
@example Ignore dependent cookbooks (via Berkshelf)
def initialize(berksfile)
def initialize(berksfile) @berksfile = berksfile @metadatas = if berksfile.respond_to?(:dependencies) berksfile.dependencies .select(&:metadata?) .map(&:name) else berksfile.sources.collect do |source| location = source.location if location.respond_to?(:metadata?) && location.metadata? source else nil end end.compact.map(&:name) end end
def matches?(resource)
def matches?(resource) return true if resource.source_line.nil? normalized_source_line = resource.source_line.gsub("\\", "/") normalized_source_line =~ %r{cookbooks/(?!#{@metadatas.join('|')})} end