Sha256: 4da886d93dca8720f09668f69604a49a4d8209ce1ac09221f2677af24f4d675a

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require_relative '../support/color_themable'
require_relative 'base_presenter'

module Dsu
  module Presenters
    class ConfigurationPresenter < BasePresenter
      attr_reader :config

      def initialize(config, options: {})
        super

        @config = config
      end

      def configuration_header
        apply_theme("Configuration file contents (#{config_path})",
          theme_color: color_theme.header)
      end

      def configuration_details
        to_h.each_with_index.filter_map do |config_entry, index|
          formatted_config_entry_with_index(config_entry, index: index, theme_color: color_theme.body)
        end
      end

      private

      def config_path
        @config_path ||= config.file_path
      end

      def formatted_config_entry_with_index(config_entry, index:, theme_color:)
        "#{formatted_index(index: index)} #{formatted_config_entry(config_entry: config_entry,
          theme_color: theme_color)}"
      end

      def formatted_config_entry(config_entry:, theme_color:)
        config_entry = "#{config_entry[0]}: '#{config_entry[1]}'"
        apply_theme(config_entry, theme_color: theme_color)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dsu-2.0.8 lib/dsu/presenters/configuration_presenter.rb
dsu-2.0.7 lib/dsu/presenters/configuration_presenter.rb
dsu-2.0.6 lib/dsu/presenters/configuration_presenter.rb
dsu-2.0.5 lib/dsu/presenters/configuration_presenter.rb
dsu-2.0.4 lib/dsu/presenters/configuration_presenter.rb
dsu-2.0.3 lib/dsu/presenters/configuration_presenter.rb
dsu-2.0.2 lib/dsu/presenters/configuration_presenter.rb
dsu-2.0.1 lib/dsu/presenters/configuration_presenter.rb
dsu-2.0.0.alpha.1 lib/dsu/presenters/configuration_presenter.rb