Class: Henitai::Reporter::Dashboard

Inherits:
Base
  • Object
show all
Defined in:
lib/henitai/reporter.rb

Overview

Dashboard reporter.

Constant Summary collapse

DEFAULT_BASE_URL =
"https://dashboard.stryker-mutator.io"
HTTP_TIMEOUT_SECONDS =
30

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Henitai::Reporter::Base

Class Method Details

.normalize_git_url(url) ⇒ Object



493
494
495
496
497
# File 'lib/henitai/reporter.rb', line 493

def normalize_git_url(url)
  return nil if url.nil? || url.strip.empty?

  url.strip.sub(/\.git\z/, "")
end

.project_from_git_url(url) ⇒ Object



481
482
483
484
485
486
487
488
489
490
491
# File 'lib/henitai/reporter.rb', line 481

def project_from_git_url(url)
  normalized = normalize_git_url(url)
  return nil if normalized.nil?

  return project_from_uri_url(normalized) if normalized.include?("://")
  return project_from_ssh_url(normalized) if normalized.include?("@")

  normalized
rescue URI::InvalidURIError
  nil
end

.project_from_ssh_url(normalized) ⇒ Object



505
506
507
508
509
510
511
512
513
# File 'lib/henitai/reporter.rb', line 505

def project_from_ssh_url(normalized)
  _, host_and_path = normalized.split("@", 2)
  return nil if host_and_path.nil?

  host, path = host_and_path.split(":", 2)
  return nil unless host && path

  "#{host}/#{path}"
end

.project_from_uri_url(normalized) ⇒ Object



499
500
501
502
503
# File 'lib/henitai/reporter.rb', line 499

def project_from_uri_url(normalized)
  uri = URI.parse(normalized)
  path = uri.path.to_s.sub(%r{^/}, "")
  [uri.host, path].compact.reject(&:empty?).join("/")
end

Instance Method Details

#report(result) ⇒ Object



363
364
365
366
367
368
369
# File 'lib/henitai/reporter.rb', line 363

def report(result)
  return unless ready?

  uri = dashboard_uri
  request = build_request(result, uri)
  send_request(uri, request)
end