Class: Covered::Include
Overview
Includes coverage for files matching a glob pattern.
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
- #The glob pattern to include.(globpatterntoinclude.) ⇒ Object readonly
Attributes inherited from Wrapper
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Enumerate existing coverage and synthesize empty coverage for unmatched included files.
-
#glob ⇒ Object
Resolve the include pattern to real file paths.
-
#initialize(output, pattern, base = "") ⇒ Include
constructor
Initialize an include filter for the given glob pattern.
Methods inherited from Wrapper
#accept?, #add, #clear, #expand_path, #finish, #mark, #relative_path, #start, #to_h
Methods inherited from Base
#accept?, #add, #clear, #expand_path, #finish, #mark, #relative_path, #start
Constructor Details
#initialize(output, pattern, base = "") ⇒ Include
Initialize an include filter for the given glob pattern.
84 85 86 87 88 89 |
# File 'lib/covered/files.rb', line 84 def initialize(output, pattern, base = "") super(output) @pattern = pattern @base = base end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
92 93 94 |
# File 'lib/covered/files.rb', line 92 def pattern @pattern end |
#The glob pattern to include.(globpatterntoinclude.) ⇒ Object (readonly)
92 |
# File 'lib/covered/files.rb', line 92 attr :pattern |
Instance Method Details
#each(&block) ⇒ Object
Enumerate existing coverage and synthesize empty coverage for unmatched included files.
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/covered/files.rb', line 113 def each(&block) paths = glob super do |coverage| paths.delete(coverage.path) yield coverage end paths.each do |path| yield Coverage.for(path) end end |
#glob ⇒ Object
Resolve the include pattern to real file paths.
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/covered/files.rb', line 96 def glob paths = Set.new root = self.(@base) pattern = File.(@pattern, root) Dir.glob(pattern) do |path| unless File.directory?(path) paths << File.realpath(path) end end return paths end |