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 =
T.let( { 'unknown' => :on_red, 'drain' => :on_blue, 'ready' => :on_green, 'maint' => :on_yellow, }.freeze, T::Hash[String, Symbol], )
- OPERATIONAL_STATE_COLORS =
T.let( { 'unknown' => :on_red, 'up' => :on_green, 'down' => :on_red, 'stopping' => :on_yellow, }.freeze, T::Hash[String, Symbol], )
Instance Method Summary collapse
-
#force_haproxy? ⇒ Boolean
: -> bool.
-
#humanize_admin_state(state) ⇒ Object
: (String | Symbol | nil) -> String?.
-
#humanize_backend_name(backend) ⇒ Object
: (Configuration::Backend) -> String.
-
#humanize_operational_state(state) ⇒ Object
: (String | Symbol | nil) -> String?.
-
#no_haproxy? ⇒ Boolean
: -> bool.
Instance Method Details
#force_haproxy? ⇒ Boolean
: -> bool
35 36 37 38 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 35 def force_haproxy? force_haproxy = ::ENV['FORCE_HAPROXY'] !force_haproxy.nil? && !force_haproxy.empty? end |
#humanize_admin_state(state) ⇒ Object
: (String | Symbol | nil) -> String?
41 42 43 44 45 46 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 41 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) ⇒ Object
: (Configuration::Backend) -> String
57 58 59 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 57 def humanize_backend_name(backend) T.unsafe(COLORS).decorate(" #{backend.name} ", *backend.styles) # rubocop:disable Sorbet/ForbidTUnsafe end |
#humanize_operational_state(state) ⇒ Object
: (String | Symbol | nil) -> String?
49 50 51 52 53 54 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 49 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
: -> bool
29 30 31 32 |
# File 'lib/capistrano/data_plane_api/helper.rb', line 29 def no_haproxy? no_haproxy = ::ENV['NO_HAPROXY'] !no_haproxy.nil? && !no_haproxy.empty? end |