Class: Covered::Include

Inherits:
Wrapper show all
Defined in:
lib/covered/files.rb

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#output

Instance Method Summary collapse

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

Returns a new instance of Include.



55
56
57
58
59
60
# File 'lib/covered/files.rb', line 55

def initialize(output, pattern, base = "")
	super(output)
	
	@pattern = pattern
	@base = base
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



62
63
64
# File 'lib/covered/files.rb', line 62

def pattern
  @pattern
end

Instance Method Details

#each(&block) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/covered/files.rb', line 78

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

#globObject



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/covered/files.rb', line 64

def glob
	paths = Set.new
	root = self.expand_path(@base)
	pattern = File.expand_path(@pattern, root)
	
	Dir.glob(pattern) do |path|
		unless File.directory?(path)
			paths << File.realpath(path)
		end
	end
	
	return paths
end