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.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/chefspec/coverage/filters.rb', line 55 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
74 75 76 77 78 79 |
# File 'lib/chefspec/coverage/filters.rb', line 74 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 |