Class: PactBroker::Api::Resources::CanIDeployBadge
- Inherits:
-
BaseResource
- Object
- PactBroker::Api::Resources::CanIDeployBadge
- Defined in:
- lib/pact_broker/api/resources/can_i_deploy_badge.rb
Instance Method Summary collapse
- #allowed_methods ⇒ Object
- #content_types_provided ⇒ Object
- #forbidden? ⇒ Boolean
-
#initialize ⇒ CanIDeployBadge
constructor
A new instance of CanIDeployBadge.
- #is_authorized?(authorization_header) ⇒ Boolean
- #moved_temporarily? ⇒ Boolean
- #policy_name ⇒ Object
-
#previously_existed? ⇒ Boolean
Only called if resource_exists? returns false.
- #resource_exists? ⇒ Boolean
Constructor Details
#initialize ⇒ CanIDeployBadge
Returns a new instance of CanIDeployBadge.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 8 def initialize super selector = PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: pacticipant_name, latest: true, tag: identifier_from_path[:tag]) @options = { latestby: "cvp", latest: true, tag: identifier_from_path[:to] } @selectors = [selector] end |
Instance Method Details
#allowed_methods ⇒ Object
19 20 21 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 19 def allowed_methods ["GET", "OPTIONS"] end |
#content_types_provided ⇒ Object
23 24 25 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 23 def content_types_provided [["image/svg+xml", :to_svg]] end |
#forbidden? ⇒ Boolean
40 41 42 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 40 def forbidden? false end |
#is_authorized?(authorization_header) ⇒ Boolean
36 37 38 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 36 def () super || PactBroker.configuration.enable_public_badge_access end |
#moved_temporarily? ⇒ Boolean
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 44 def moved_temporarily? response.headers["Cache-Control"] = "no-cache" begin if pacticipant if version badge_service.can_i_deploy_badge_url(identifier_from_path[:tag], identifier_from_path[:to], label, results.deployable?) else badge_service.error_badge_url("version", "not found") end else badge_service.error_badge_url(selectors.first.pacticipant_name, "not found") end rescue StandardError => e # Want to render a badge, even if there's an error badge_service.error_badge_url("error", ErrorResponseBodyGenerator.(e, "reference: #{PactBroker::Errors.generate_error_reference}")) end end |
#policy_name ⇒ Object
62 63 64 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 62 def policy_name :'badges::badge' end |
#previously_existed? ⇒ Boolean
Only called if resource_exists? returns false
32 33 34 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 32 def previously_existed? true end |
#resource_exists? ⇒ Boolean
27 28 29 |
# File 'lib/pact_broker/api/resources/can_i_deploy_badge.rb', line 27 def resource_exists? false end |