Class: Escobar::Heroku::PipelinePromotionTargets
- Inherits:
-
Object
- Object
- Escobar::Heroku::PipelinePromotionTargets
- Defined in:
- lib/escobar/heroku/pipeline_promotion_targets.rb
Overview
Class reperesenting a Heroku Pipeline Promotion Targets
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
-
#promotion ⇒ Object
readonly
Returns the value of attribute promotion.
Instance Method Summary collapse
- #app_id ⇒ Object
- #info ⇒ Object
-
#initialize(pipeline, promotion) ⇒ PipelinePromotionTargets
constructor
A new instance of PipelinePromotionTargets.
- #ref ⇒ Object
- #release_id ⇒ Object
- #releases ⇒ Object
- #retry? ⇒ Boolean
- #source_release ⇒ Object
- #targets_path ⇒ Object
Constructor Details
#initialize(pipeline, promotion) ⇒ PipelinePromotionTargets
Returns a new instance of PipelinePromotionTargets.
7 8 9 10 11 12 13 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 7 def initialize(pipeline, promotion) @id = promotion["id"] @name = pipeline.name @client = pipeline.client @pipeline = pipeline @retries = 30 end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5 def client @client end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5 def name @name end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5 def pipeline @pipeline end |
#promotion ⇒ Object (readonly)
Returns the value of attribute promotion.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5 def promotion @promotion end |
Instance Method Details
#app_id ⇒ Object
19 20 21 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 19 def app_id promotion["source"]["app"]["id"] end |
#info ⇒ Object
37 38 39 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 37 def info @info ||= client.heroku.get(targets_path) end |
#ref ⇒ Object
29 30 31 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 29 def ref @ref ||= source_release.ref end |
#release_id ⇒ Object
15 16 17 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 15 def release_id promotion["source"]["release"]["id"] end |
#releases ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 41 def releases info.map do |target| target_app_id = target["app"]["id"] target_release_id = target["release"]["id"] Escobar::Heroku::Release.new( client, target_app_id, nil, target_release_id ) end rescue NoMethodError raise(ArgumentError, info.to_json) unless retry? sleep 0.5 @retries -= 1 @info = nil retry end |
#retry? ⇒ Boolean
57 58 59 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 57 def retry? @retries.positive? end |
#source_release ⇒ Object
23 24 25 26 27 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 23 def source_release @release ||= Escobar::Heroku::Release.new( client, app_id, nil, release_id ) end |
#targets_path ⇒ Object
33 34 35 |
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 33 def targets_path "/pipeline-promotions/#{id}/promotion-targets" end |