Module: Capistrano::DataPlaneApi::Helper
- Included in:
- Capistrano::DataPlaneApi
- Defined in:
- lib/capistrano/data_plane_api/helper.rb
Overview
Provides helper methods
Constant Summary collapse
- ADMIN_STATE_COLORS =
{ 'unknown' => :on_red, 'drain' => :on_blue, 'ready' => :on_green, 'maint' => :on_yellow }.freeze
- OPERATIONAL_STATE_COLORS =
{ 'unknown' => :on_red, 'up' => :on_green, 'down' => :on_red, 'stopping' => :on_yellow }.freeze
Instance Method Summary collapse
- #force_haproxy? ⇒ Boolean
- #humanize_admin_state(state) ⇒ String?
- #humanize_backend_name(backend) ⇒ String
- #humanize_operational_state(state) ⇒ String?
- #no_haproxy? ⇒ Boolean
Instance Method Details
#force_haproxy? ⇒ Boolean
29 30 31 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 29 def force_haproxy? !::ENV['FORCE_HAPROXY'].nil? && !::ENV['FORCE_HAPROXY'].empty? end |
#humanize_admin_state(state) ⇒ String?
35 36 37 38 39 40 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 35 def humanize_admin_state(state) return unless state state = state.to_s COLORS.decorate(" #{state.upcase} ", :bold, ADMIN_STATE_COLORS[state.downcase]) end |
#humanize_backend_name(backend) ⇒ String
53 54 55 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 53 def humanize_backend_name(backend) COLORS.decorate(" #{backend.name} ", *backend.styles) end |
#humanize_operational_state(state) ⇒ String?
44 45 46 47 48 49 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 44 def humanize_operational_state(state) return unless state state = state.to_s COLORS.decorate(" #{state.upcase} ", :bold, OPERATIONAL_STATE_COLORS[state.downcase]) end |
#no_haproxy? ⇒ Boolean
24 25 26 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 24 def no_haproxy? !::ENV['NO_HAPROXY'].nil? && !::ENV['NO_HAPROXY'].empty? end |