Class: Covered::Policy

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

Defined Under Namespace

Classes: Autoload

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Wrapper

#accept?, #add, #clear, #each, #expand_path, #mark, #relative_path, #to_h

Methods inherited from Base

#accept?, #add, #clear, #each, #expand_path, #mark, #relative_path

Constructor Details

#initializePolicy

Returns a new instance of Policy.



14
15
16
17
18
19
# File 'lib/covered/policy.rb', line 14

def initialize
	super(Files.new)
	
	@reports = []
	@capture = nil
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



21
22
23
# File 'lib/covered/policy.rb', line 21

def output
  @output
end

#reportsObject (readonly)

Returns the value of attribute reports.



66
67
68
# File 'lib/covered/policy.rb', line 66

def reports
  @reports
end

Instance Method Details

#callObject



127
128
129
130
131
# File 'lib/covered/policy.rb', line 127

def call(...)
	@reports.each do |report|
		report.call(self, ...)
	end
end

#captureObject



52
53
54
55
56
# File 'lib/covered/policy.rb', line 52

def capture
	@capture ||= Forks.new(
		Capture.new(@output)
	)
end

#finishObject



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

def finish
	capture.finish
end

#freezeObject



23
24
25
26
27
28
29
30
# File 'lib/covered/policy.rb', line 23

def freeze
	return self if frozen?
	
	capture
	@reports.freeze
	
	super
end

#includeObject



32
33
34
# File 'lib/covered/policy.rb', line 32

def include(...)
	@output = Include.new(@output, ...)
end

#onlyObject



40
41
42
# File 'lib/covered/policy.rb', line 40

def only(...)
	@output = Only.new(@output, ...)
end

#persist!Object



48
49
50
# File 'lib/covered/policy.rb', line 48

def persist!(...)
	@output = Persist.new(@output, ...)
end

#reports!(reports) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/covered/policy.rb', line 104

def reports!(reports)
	if reports.is_a?(String)
		names = reports.split(',')
		
		names.each do |name|
			begin
				klass = Covered.const_get(name)
				@reports << klass.new
			rescue NameError
				@reports << Autoload.new(name)
			end
		end
	elsif reports == true
		@reports << Covered::BriefSummary.new
	elsif reports == false
		@reports.clear
	elsif reports.is_a?(Array)
		@reports.concat(reports)
	else
		@reports << reports
	end
end

#rootObject



44
45
46
# File 'lib/covered/policy.rb', line 44

def root(...)
	@output = Root.new(@output, ...)
end

#skipObject



36
37
38
# File 'lib/covered/policy.rb', line 36

def skip(...)
	@output = Skip.new(@output, ...)
end

#startObject



58
59
60
# File 'lib/covered/policy.rb', line 58

def start
	capture.start
end