Class: UffizziCore::ComposeFile::ConfigOptionService
- Inherits:
-
Object
- Object
- UffizziCore::ComposeFile::ConfigOptionService
- Defined in:
- app/services/uffizzi_core/compose_file/config_option_service.rb
Class Method Summary collapse
- .config_options(compose_data) ⇒ Object
- .continuous_preview_option(compose_data) ⇒ Object
- .ingress_option(compose_data) ⇒ Object
- .prepare_file_path_value(file_path) ⇒ Object
- .valid_option_format?(option) ⇒ Boolean
Class Method Details
.config_options(compose_data) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/uffizzi_core/compose_file/config_option_service.rb', line 13 def (compose_data) compose_data.each_with_object([]) do |(key, value), keys| if compose_data.equal?(value) raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.infinite_recursion', key: key) end keys << key keys.concat((value)) if value.is_a?(Hash) end end |
.continuous_preview_option(compose_data) ⇒ Object
34 35 36 37 38 39 |
# File 'app/services/uffizzi_core/compose_file/config_option_service.rb', line 34 def continuous_preview_option(compose_data) compose_data.dig('x-uffizzi', 'continuous_preview').presence || compose_data.dig('x-uffizzi', 'continuous_previews').presence || compose_data['x-uffizzi-continuous-preview'].presence || compose_data['x-uffizzi-continuous-previews'].presence end |
.ingress_option(compose_data) ⇒ Object
30 31 32 |
# File 'app/services/uffizzi_core/compose_file/config_option_service.rb', line 30 def ingress_option(compose_data) compose_data.dig('x-uffizzi', 'ingress').presence || compose_data['x-uffizzi-ingress'].presence end |
.prepare_file_path_value(file_path) ⇒ Object
24 25 26 27 28 |
# File 'app/services/uffizzi_core/compose_file/config_option_service.rb', line 24 def prepare_file_path_value(file_path) pathname = Pathname.new(file_path) pathname.cleanpath.to_s.strip.delete_prefix('/') end |
.valid_option_format?(option) ⇒ Boolean
5 6 7 8 9 10 11 |
# File 'app/services/uffizzi_core/compose_file/config_option_service.rb', line 5 def valid_option_format?(option) if option.is_a?(TrueClass) || option.is_a?(FalseClass) raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.boolean_option', value: option) end option.match(/^[\w.-]+$/).present? end |