class Covered::Source

def initialize(output)

def initialize(output)
	super(output)
	
	@paths = {}
	@mutex = Mutex.new
	
	@annotations = {}
	
	begin
		@trace = TracePoint.new(:script_compiled) do |trace|
			instruction_sequence = trace.instruction_sequence
			# We only track source files which begin at line 1, as these represent whole files instead of monkey patches.
			if instruction_sequence.first_lineno <= 1
				# Extract the source path and source itself and save it for later:
				if path = instruction_sequence.path and source = trace.eval_script
					@mutex.synchronize do
						@paths[path] = Script.new(path, source, instruction_sequence.first_lineno)
					end
				end
			end
		end
	rescue
		warn "Script coverage disabled: #{$!}"
		@trace = nil
	end
end