Sha256: 3dedd1521fab1b1b147670e609c21970e23e62c300c9c9aa9781b1eb73e13697

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/utils/duck_utils'
require 'contrast/utils/object_share'
require 'contrast/components/config/sources'
require 'contrast/config/diagnostics/tools'

module Contrast
  module Config
    # This class will hold all the references for the configuration files. It will safe read values used to
    # identify the source of configuration in Configuration Diagnostics reported to TS.
    class ConfigurationFiles
      # @return [String] path of the main configuration file.
      attr_accessor :main_file

      # @return [Array<Contrast::Config::LocalSourceValue>]
      def source_files
        @_source_files ||= []
      end

      # @param path [String]
      # @param values [Hash]
      def add_source_file path, values
        source_files << Contrast::Config::LocalSourceValue.new(path, values)
        @main_file = path if source_files.length == 1
      end
    end

    # This class will hold all the info about the read file.
    class LocalSourceValue
      # @return [String]
      attr_reader :path
      # @return [Hash]
      attr_reader :values

      # @param path [String]
      # @param values [Hash]
      def initialize path = '', values = {}
        @path = path unless Contrast::Utils::DuckUtils.empty_duck?(path)
        @values = values
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/config/configuration_files.rb
contrast-agent-7.6.0 lib/contrast/config/configuration_files.rb
contrast-agent-7.5.0 lib/contrast/config/configuration_files.rb
contrast-agent-7.4.1 lib/contrast/config/configuration_files.rb
contrast-agent-7.4.0 lib/contrast/config/configuration_files.rb