⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Coverage
/
View File Name :
cdesc-Coverage.ri
U:RDoc::NormalModule[iI" Coverage:ET@0o:RDoc::Markup::Document:@parts[o;;[6o:RDoc::Markup::Paragraph;[I">Coverage provides coverage measurement feature for Ruby. ;TI"JThis feature is experimental, so these APIs may be changed in future.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI" Usage;T@o:RDoc::Markup::List: @type:NUMBER:@items[ o:RDoc::Markup::ListItem:@label0;[o; ;[I"require "coverage";To;;0;[o; ;[I"do Coverage.start;To;;0;[o; ;[I"%require or load Ruby source file;To;;0;[o; ;[ I"JCoverage.result will return a hash that contains filename as key and ;TI"Icoverage array as value. A coverage array gives, for each line, the ;TI"Fnumber of line execution by the interpreter. A +nil+ value means ;TI"Fcoverage is disabled for this line (lines like +else+ and +end+).;T@S;;i; I" Examples;T@o:RDoc::Markup::Verbatim;[I"[foo.rb] ;TI"s = 0 ;TI"10.times do |x| ;TI" s += x ;TI" end ;TI" ;TI"if s == 45 ;TI" p :ok ;TI" else ;TI" p :ng ;TI" end ;TI"[EOF] ;TI" ;TI"require "coverage" ;TI"Coverage.start ;TI"require "foo.rb" ;TI"Pp Coverage.result #=> {"foo.rb"=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]} ;T:@format0S;;i; I"Lines Coverage;T@o; ;[I"RIf a coverage mode is not explicitly specified when starting coverage, lines ;TI"Rcoverage is what will run. It reports the number of line executions for each ;TI" line.;T@o;;[ I"require "coverage" ;TI"!Coverage.start(lines: true) ;TI"require "foo.rb" ;TI"Yp Coverage.result #=> {"foo.rb"=>{:lines=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}} ;T;0o; ;[ I"RThe value of the lines coverage result is an array containing how many times ;TI"Peach line was executed. Order in this array is important. For example, the ;TI"Qfirst item in this array, at index 0, reports how many times line 1 of this ;TI"Nfile was executed while coverage was run (which, in this example, is one ;TI"time).;T@o; ;[I"OA +nil+ value means coverage is disabled for this line (lines like +else+ ;TI"and +end+).;T@S;;i; I"Oneshot Lines Coverage;T@o; ;[I"KOneshot lines coverage tracks and reports on the executed lines while ;TI"Qcoverage is running. It will not report how many times a line was executed, ;TI"only that it was executed.;T@o;;[ I"require "coverage" ;TI")Coverage.start(oneshot_lines: true) ;TI"require "foo.rb" ;TI"Ip Coverage.result #=> {"foo.rb"=>{:oneshot_lines=>[1, 2, 3, 6, 7]}} ;T;0o; ;[I"OThe value of the oneshot lines coverage result is an array containing the ;TI"%line numbers that were executed.;T@S;;i; I"Branches Coverage;T@o; ;[I"RBranches coverage reports how many times each branch within each conditional ;TI"was executed.;T@o;;[ I"require "coverage" ;TI"$Coverage.start(branches: true) ;TI"require "foo.rb" ;TI"p Coverage.result #=> {"foo.rb"=>{:branches=>{[:if, 0, 6, 0, 10, 3]=>{[:then, 1, 7, 2, 7, 7]=>1, [:else, 2, 9, 2, 9, 7]=>0}}}} ;T;0o; ;[ I"QEach entry within the branches hash is a conditional, the value of which is ;TI"Oanother hash where each entry is a branch in that conditional. The values ;TI"Sare the number of times the method was executed, and the keys are identifying ;TI""information about the branch.;T@o; ;[I"QThe information that makes up each key identifying branches or conditionals ;TI"*is the following, from left to right:;T@o;;;;[o;;0;[o; ;[I"3A label for the type of branch or conditional.;To;;0;[o; ;[I"A unique identifier.;To;;0;[o; ;[I"8The starting line number it appears on in the file.;To;;0;[o; ;[I":The starting column number it appears on in the file.;To;;0;[o; ;[I"6The ending line number it appears on in the file.;To;;0;[o; ;[I"8The ending column number it appears on in the file.;T@S;;i; I"Methods Coverage;T@o; ;[I"FMethods coverage reports how many times each method was executed.;T@o;;[I"[foo_method.rb] ;TI"class Greeter ;TI" def greet ;TI" "welcome!" ;TI" end ;TI" end ;TI" ;TI"def hello ;TI" "Hi" ;TI" end ;TI" ;TI" hello() ;TI"Greeter.new.greet() ;TI"[EOF] ;TI" ;TI"require "coverage" ;TI"#Coverage.start(methods: true) ;TI"require "foo_method.rb" ;TI"~p Coverage.result #=> {"foo_method.rb"=>{:methods=>{[Object, :hello, 7, 0, 9, 3]=>1, [Greeter, :greet, 2, 2, 4, 5]=>1}}} ;T;0o; ;[I"PEach entry within the methods hash represents a method. The values in this ;TI"Lhash are the number of times the method was executed, and the keys are ;TI".identifying information about the method.;T@o; ;[I"SThe information that makes up each key identifying a method is the following, ;TI"from left to right:;T@o;;;;[o;;0;[o; ;[I"The class.;To;;0;[o; ;[I"The method name.;To;;0;[o; ;[I"@The starting line number the method appears on in the file.;To;;0;[o; ;[I"BThe starting column number the method appears on in the file.;To;;0;[o; ;[I">The ending line number the method appears on in the file.;To;;0;[o; ;[I"@The ending column number the method appears on in the file.;T@S;;i; I"All Coverage Modes;T@o; ;[ I"OYou can also run all modes of coverage simultaneously with this shortcut. ;TI"NNote that running all coverage modes does not run both lines and oneshot ;TI"Olines. Those modes cannot be run simultaneously. Lines coverage is run in ;TI"Pthis case, because you can still use it to determine whether or not a line ;TI"was executed.;T@o;;[ I"require "coverage" ;TI"Coverage.start(:all) ;TI"require "foo.rb" ;TI"½p Coverage.result #=> {"foo.rb"=>{:lines=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil], :branches=>{[:if, 0, 6, 0, 10, 3]=>{[:then, 1, 7, 2, 7, 7]=>1, [:else, 2, 9, 2, 9, 7]=>0}}, :methods=>{}}};T;0: @fileI"ext/coverage/coverage.c;T:0@omit_headings_from_table_of_contents_below0o;;[ ;I"!ext/coverage/lib/coverage.rb;T;0;0;0[ [ [ [[I" class;T[[:public[ [I"line_stub;TI"!ext/coverage/lib/coverage.rb;T[I"peek_result;TI"ext/coverage/coverage.c;T[I"result;T@ÿ[I" running?;T@ÿ[I" start;T@ÿ[:protected[ [:private[ [I" instance;T[[;[ [;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@í@ð@ðcRDoc::TopLevel