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
-
#can_i_deploy_badge_url(tag, environment_tag, label, deployable) ⇒ Object
-
#can_i_merge_badge_url(deployable: nil) ⇒ Object
-
#can_provide_badge_using_redirect? ⇒ Boolean
-
#clear_cache ⇒ Object
-
#error_badge_url(left_text, right_text) ⇒ Object
-
#pact_verification_badge(pact, label, initials, pseudo_branch_verification_status, metadata = {}) ⇒ Object
-
#pact_verification_badge_url(pact, label, initials, pseudo_branch_verification_status, metadata = {}) ⇒ Object
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"
color, status = case deployable
when nil
[ "lightgrey", "unknown" ]
when true
[ "brightgreen", "success" ]
else
[ "red", "failed" ]
end
build_shield_io_uri(title, status, color)
end
|
#can_provide_badge_using_redirect? ⇒ Boolean
#clear_cache ⇒ Object
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, metadata = {}
return static_svg(pact, pseudo_branch_verification_status) unless pact
dynamic_svg(pact, label, initials, pseudo_branch_verification_status, metadata) || 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, metadata = {})
title = badge_title(pact, label, initials, metadata)
status = badge_status(pseudo_branch_verification_status)
color = badge_color(pseudo_branch_verification_status)
build_shield_io_uri(title, status, color)
end
|