Module: PolyrunCoverageMerge
- Defined in:
- ext/polyrun_coverage_merge/coverage_merge.c
Class Method Summary collapse
- .line_counts(file_entry) ⇒ Object
- .merge_line_arrays(left, right) ⇒ Object
- .merge_two(left, right) ⇒ Object
Class Method Details
.line_counts(file_entry) ⇒ Object
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'ext/polyrun_coverage_merge/coverage_merge.c', line 422
static VALUE
line_counts(VALUE module, VALUE file_entry)
{
(void)module;
file_entry = normalize_file_entry(file_entry);
long relevant = 0;
long covered = 0;
if (!NIL_P(file_entry)) {
VALUE lines = entry_lines_for_count(file_entry);
long length = RARRAY_LEN(lines);
for (long index = 0; index < length; index++) {
VALUE hit = rb_ary_entry(lines, index);
if (NIL_P(hit) || ignored_hit_p(hit)) {
continue;
}
relevant += 1;
if (line_hit_positive_p(hit)) {
covered += 1;
}
}
}
VALUE counts = rb_hash_new();
rb_hash_aset(counts, ID2SYM(id_relevant), LONG2FIX(relevant));
rb_hash_aset(counts, ID2SYM(id_covered), LONG2FIX(covered));
return counts;
}
|
.merge_line_arrays(left, right) ⇒ Object
455 456 457 458 459 460 461 |
# File 'ext/polyrun_coverage_merge/coverage_merge.c', line 455
static VALUE
merge_line_arrays_method(VALUE module, VALUE left, VALUE right)
{
(void)module;
return merge_line_arrays(left, right);
}
|
.merge_two(left, right) ⇒ Object
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'ext/polyrun_coverage_merge/coverage_merge.c', line 383
static VALUE
merge_two(VALUE module, VALUE left, VALUE right)
{
(void)module;
left = ensure_hash(left, "left");
right = ensure_hash(right, "right");
VALUE primary = left;
VALUE secondary = right;
if (RHASH_SIZE(right) > RHASH_SIZE(left)) {
primary = right;
secondary = left;
}
VALUE out = rb_hash_new();
VALUE primary_keys = hash_keys(primary);
long primary_length = RARRAY_LEN(primary_keys);
for (long index = 0; index < primary_length; index++) {
VALUE key = rb_ary_entry(primary_keys, index);
VALUE value = rb_hash_aref(primary, key);
VALUE right_entry = rb_hash_aref(secondary, key);
rb_hash_aset(out, key, merge_file_entry(value, right_entry));
}
VALUE secondary_keys = hash_keys(secondary);
long secondary_length = RARRAY_LEN(secondary_keys);
for (long index = 0; index < secondary_length; index++) {
VALUE key = rb_ary_entry(secondary_keys, index);
if (NIL_P(rb_hash_aref(out, key))) {
rb_hash_aset(out, key, rb_hash_aref(secondary, key));
}
}
return out;
}
|