Sha256: 80526147cdae6b887bc72aa85e9f3da480a825878b0d08f0cd452ad96e9ecc2a

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

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

require 'contrast/components/base'

module Contrast
  module Components
    module Inventory
      # Interface component for Inventory settings used to store the values from
      # settings file and assert state with check methods.
      class Interface
        include Contrast::Components::ComponentBase

        CANON_NAME = 'inventory'
        CONFIG_VALUES = %w[enable analyze_libraries tags].cs__freeze

        attr_writer :tags
        # @return [String]
        attr_reader :canon_name
        # @return [Array]
        attr_reader :config_values

        def initialize hsh = {}
          @config_values = CONFIG_VALUES
          @canon_name = CANON_NAME
          return unless hsh

          @enable = !false?(hsh[:enable])
          @analyze_libraries = !false?(hsh[:analyze_libraries])
          @tags = hsh[:tags]
        end

        # return [Boolean]
        def enable
          @enable.nil? ? true : @enable
        end

        # return [Boolean]
        def analyze_libraries
          @analyze_libraries.nil? ? true : @analyze_libraries
        end

        # @return [String, nil] tags
        def tags
          stringify_array(@tags)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
contrast-agent-6.11.0 lib/contrast/components/inventory.rb
contrast-agent-6.10.0 lib/contrast/components/inventory.rb
contrast-agent-6.9.0 lib/contrast/components/inventory.rb