Class: ChefSpec::Coverage::BerkshelfFilter
- Defined in:
- lib/chefspec/coverage/filters.rb
Overview
Instance Method Summary collapse
-
#initialize(berksfile) ⇒ BerkshelfFilter
constructor
A new instance of BerkshelfFilter.
- #matches?(resource) ⇒ Boolean
Constructor Details
#initialize(berksfile) ⇒ BerkshelfFilter
Returns a new instance of BerkshelfFilter.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/chefspec/coverage/filters.rb', line 53 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. source else nil end end.compact.map(&:name) end end |
Instance Method Details
#matches?(resource) ⇒ Boolean
72 73 74 75 76 |
# File 'lib/chefspec/coverage/filters.rb', line 72 def matches?(resource) return true if resource.source_line.nil? normalized_source_line = resource.source_line.gsub("\\", "/") normalized_source_line=~ /cookbooks\/(?!#{@metadatas.join('|')})/ end |