Class: Udb::PartialConfig

Inherits:
AbstractConfig show all
Defined in:
lib/udb/config.rb

Overview

This class represents a configuration that is “partially-configured” (e.g., portfolio or configurable IP). # It only lists mandatory & prohibited extensions and fully-constrained parameters (single value).

Instance Method Summary collapse

Constructor Details

#initialize(data, info)

NON-ABSTRACT METHODS #

Parameters:



217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/udb/config.rb', line 217

def initialize(data, info)
  super(data, info)

  @param_values = @data.key?("params") ? @data["params"] : [].freeze

  @mxlen = @data.dig("params", "MXLEN")
  if @mxlen.nil?
    Udb.logger.error "Must set MXLEN for a configured config"
    raise InvalidConfigError
  end

  @mxlen.freeze
end

Instance Method Details

#additional_extensions_allowed?Boolean

Whether or not a compliant instance of this partial config can have more extensions than those listed in mandatory_extensions/non_mandatory_extensions.

Returns:

  • (Boolean)


279
# File 'lib/udb/config.rb', line 279

def additional_extensions_allowed? = @data.key?("additional_extensions") ? @data["additional_extensions"] : true

#fully_configured?Boolean

Returns:

  • (Boolean)


242
# File 'lib/udb/config.rb', line 242

def fully_configured? = false

#mandatory_extensionsArray<Hash{String => String, Array<String>}>

Returns:

  • (Array<Hash{String => String, Array<String>}>)


251
252
253
254
255
256
257
258
259
260
261
# File 'lib/udb/config.rb', line 251

def mandatory_extensions
  @mandatory_extensions ||=
    if @data["mandatory_extensions"].nil?
      []
    else
      @data["mandatory_extensions"].map do |e|
        # convert the requirement to always be an array
        { "name" => e["name"], "version" => e["version"].is_a?(String) ? [e["version"]] : e["version"] }
      end
    end
end

#mxlenInteger

Returns:

  • (Integer)


239
# File 'lib/udb/config.rb', line 239

def mxlen = @mxlen

#param_valuesHash{String => ParamValueType}

ABSTRACT METHODS OVERRIDDEN #

Returns:



236
# File 'lib/udb/config.rb', line 236

def param_values = @param_values

#partially_configured?Boolean

Returns:

  • (Boolean)


245
# File 'lib/udb/config.rb', line 245

def partially_configured? = true

#prohibited_extensionsArray<Hash{String => String, Array<String>}>

Returns:

  • (Array<Hash{String => String, Array<String>}>)


264
265
266
267
268
269
270
271
272
273
274
# File 'lib/udb/config.rb', line 264

def prohibited_extensions
  @prohibited_extensions ||=
    if @data["prohibited_extensions"].nil?
      []
    else
      @data["prohibited_extensions"].map do |e|
        # convert the requirement to always be an array
        { "name" => e["name"], "version" => e["version"].is_a?(String) ? [e["version"]] : e["version"] }
      end
    end
end

#unconfigured?Boolean

Returns:

  • (Boolean)


248
# File 'lib/udb/config.rb', line 248

def unconfigured? = false