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



420
421
422
423
424
# File 'lib/henitai/reporter.rb', line 420

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



408
409
410
411
412
413
414
415
416
417
418
# File 'lib/henitai/reporter.rb', line 408

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



432
433
434
435
436
437
438
439
440
# File 'lib/henitai/reporter.rb', line 432

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



426
427
428
429
430
# File 'lib/henitai/reporter.rb', line 426

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



290
291
292
293
294
295
296
# File 'lib/henitai/reporter.rb', line 290

def report(result)
  return unless ready?

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