Module: DeployPin::DeploymentState

Included in:
DeployPin
Defined in:
lib/deploy_pin/deployment_state.rb

Overview

The mixin that extends DeployPin module with @ongoing_deployment? & @pending_deployment? methods

Constant Summary collapse

STORE_KEY =
'deploy_pin:deployment'
ONGOING =
'ongoing'
PENDING =
'pending'
DEPLOYMENT_OVER_TASK =
%(
  # no_file_task
  # -10:%<group>s:recurring
  # task_title: Cleanup DeployPin.state

  DeployPin.send(:deployment_over!)
).strip
DEPLOYMENT_ONGOING_TASK =
%(
  # no_file_task
  # 0:%<group>s:recurring
  # task_title: Set DeployPin.state to 'ongoing'

  DeployPin.send(:deployment_ongoing!)
).strip
DEPLOYMENT_PENDING_TASK =
%(
  # no_file_task
  # 0:%<group>s:recurring
  # task_title: Set DeployPin.state to 'pending'

  DeployPin.send(:deployment_pending!)
).strip

Instance Method Summary collapse

Instance Method Details

#deployment_tasks_codeObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/deploy_pin/deployment_state.rb', line 47

def deployment_tasks_code
  return [] unless DeployPin.enabled?(:deployment_state_transition)

  ongoing_start_group, ongoing_end_group = DeployPin.deployment_state_transition[:ongoing]
  rollback_group = DeployPin.deployment_state_transition[:pending]

  [
    format(DEPLOYMENT_ONGOING_TASK, group: ongoing_start_group),
    format(DEPLOYMENT_OVER_TASK, group: ongoing_end_group),
    format(DEPLOYMENT_PENDING_TASK, group: rollback_group)
  ]
end

#ongoing_deployment?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/deploy_pin/deployment_state.rb', line 39

def ongoing_deployment?
  deployment_state == ONGOING
end

#pending_deployment?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/deploy_pin/deployment_state.rb', line 43

def pending_deployment?
  deployment_state == PENDING
end