Module: PactBroker::Badges::Service

Extended by:
Service
Includes:
Logging
Included in:
Service
Defined in:
lib/pact_broker/badges/service.rb

Constant Summary collapse

SPACE_DASH_UNDERSCORE =
/[\s_\-]/
CACHE =
{}

Instance Method Summary collapse

Methods included from Logging

included, #log_error, #log_with_tag, #measure_info

Instance Method Details

#can_i_deploy_badge_url(tag, environment_tag, label, deployable) ⇒ Object



36
37
38
39
40
41
# File 'lib/pact_broker/badges/service.rb', line 36

def can_i_deploy_badge_url(tag, environment_tag, label, deployable)
  title = label || "can-i-deploy"
  status = "#{tag} to #{environment_tag}"
  color = deployable ? "brightgreen" : "red"
  build_shield_io_uri(title, status, color)
end

#can_i_merge_badge_url(deployable: nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pact_broker/badges/service.rb', line 43

def can_i_merge_badge_url(deployable: nil)
  title = "can-i-merge"
  
  # rubocop:disable Layout/EndAlignment
  color, status = case deployable
  when nil
    [ "lightgrey", "unknown" ]
  when true
    [ "brightgreen", "success" ]
  else
    [ "red", "failed" ]
  end
  # rubocop:enable Layout/EndAlignment

  # left text is "can-i-merge", right text is the version number
  build_shield_io_uri(title, status, color)
end

#can_provide_badge_using_redirect?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/pact_broker/badges/service.rb', line 19

def can_provide_badge_using_redirect?
  PactBroker.configuration.badge_provider_mode == :redirect && !!PactBroker.configuration.shields_io_base_url
end

#clear_cacheObject



65
66
67
# File 'lib/pact_broker/badges/service.rb', line 65

def clear_cache
  CACHE.clear
end

#error_badge_url(left_text, right_text) ⇒ Object



61
62
63
# File 'lib/pact_broker/badges/service.rb', line 61

def error_badge_url(left_text, right_text)
  build_shield_io_uri(left_text, right_text, "lightgrey")
end

#pact_verification_badge(pact, label, initials, pseudo_branch_verification_status, metadata = {}) ⇒ Object



23
24
25
26
27
# File 'lib/pact_broker/badges/service.rb', line 23

def pact_verification_badge pact, label, initials, pseudo_branch_verification_status,  = {}
  return static_svg(pact, pseudo_branch_verification_status) unless pact

  dynamic_svg(pact, label, initials, pseudo_branch_verification_status, ) || static_svg(pact, pseudo_branch_verification_status)
end

#pact_verification_badge_url(pact, label, initials, pseudo_branch_verification_status, metadata = {}) ⇒ Object



29
30
31
32
33
34
# File 'lib/pact_broker/badges/service.rb', line 29

def pact_verification_badge_url(pact, label, initials, pseudo_branch_verification_status,  = {})
  title = badge_title(pact, label, initials, )
  status = badge_status(pseudo_branch_verification_status)
  color = badge_color(pseudo_branch_verification_status)
  build_shield_io_uri(title, status, color)
end