Class: Udb::AbstractConfig Abstract
- Inherits:
-
Object
- Object
- Udb::AbstractConfig
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/udb/config.rb
Overview
It cannot be directly instantiated. Subclasses must implement the ‘abstract` methods below.
This class represents a configuration. Is is coded as an abstract base class (must be inherited by a child).
There are child classes derived from AbstractConfig to handle:
- Configurations specified by YAML files in the /cfg directory
- Configurations specified by portfolio groups (certificates and profile releases)
Direct Known Subclasses
Constant Summary collapse
- ParamValueType =
T.type_alias { T.any(Integer, String, T::Boolean, T::Array[Integer], T::Array[String], T::Array[T::Boolean]) }
Instance Attribute Summary collapse
- #info ⇒ Resolver::ConfigInfo readonly
- #type ⇒ ConfigType readonly
Class Method Summary collapse
-
.create(cfg_file_path_or_portfolio_grp, info) ⇒ AbstractConfig
Factory method to create a FullConfig, PartialConfig, or UnConfig based on the contents of cfg_file_path_or_portfolio_grp.
Instance Method Summary collapse
- #arch_overlay ⇒ nil, String
- #arch_overlay_abs ⇒ Object
- #configured? ⇒ Boolean
- #description ⇒ String
- #fully_configured? ⇒ Boolean abstract
- #initialize(data, info) constructor
- #mxlen ⇒ Integer? abstract
- #name ⇒ String
-
#overlay? ⇒ Boolean
Is an overlay present?.
-
#param_values ⇒ Hash{String => ParamValueType}
abstract
A hash mapping parameter name to value for any parameter that has been configured with a value.
- #partially_configured? ⇒ Boolean abstract
- #unconfigured? ⇒ Boolean abstract
Constructor Details
#initialize(data, info)
86 87 88 89 90 91 92 93 |
# File 'lib/udb/config.rb', line 86 def initialize(data, info) @data = data @info = info @name = @data.fetch("name") @name.freeze @type = ConfigType.deserialize(T.cast(@data.fetch("type"), String)) @type.freeze end |
Instance Attribute Details
#info ⇒ Resolver::ConfigInfo (readonly)
61 62 63 |
# File 'lib/udb/config.rb', line 61 def info @info end |
Class Method Details
.create(cfg_file_path_or_portfolio_grp, info) ⇒ AbstractConfig
Factory method to create a FullConfig, PartialConfig, or UnConfig based on the contents of cfg_file_path_or_portfolio_grp
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/udb/config.rb', line 123 def self.create(cfg_file_path_or_portfolio_grp, info) if cfg_file_path_or_portfolio_grp.is_a?(Pathname) cfg_file_path = T.cast(cfg_file_path_or_portfolio_grp, Pathname) raise ArgumentError, "Cannot find #{cfg_file_path}" unless cfg_file_path.exist? data = ::YAML.load_file(cfg_file_path) # now deep freeze the data freeze_data(data) case data["type"] when "fully configured" FullConfig.send(:new, data, info) when "partially configured" PartialConfig.send(:new, data, info) when "unconfigured" UnConfig.send(:new, data, info) else raise "Unexpected type (#{data['type']}) in config" end elsif cfg_file_path_or_portfolio_grp.is_a?(PortfolioGroup) portfolio_grp = T.cast(cfg_file_path_or_portfolio_grp, PortfolioGroup) data = { "$schema" => "config_schema.json#", "kind" => "architecture configuration", "type" => "partially configured", "name" => portfolio_grp.name, "description" => "Partial config construction from Portfolio Group #{portfolio_grp.name}", "params" => portfolio_grp.param_values, "mandatory_extensions" => portfolio_grp.mandatory_ext_reqs.map do |ext_req| { "name" => ext_req.name, "version" => ext_req.requirement_specs.map(&:to_s) } end } data.fetch("params")["MXLEN"] = portfolio_grp.max_base freeze_data(data) PartialConfig.send(:new, data, info) else T.absurd(cfg_file_path_or_portfolio_grp) end end |
Instance Method Details
#arch_overlay ⇒ nil, String
51 |
# File 'lib/udb/config.rb', line 51 def = @data["arch_overlay"] |
#arch_overlay_abs ⇒ Object
56 57 58 |
# File 'lib/udb/config.rb', line 56 def @info. end |
#configured? ⇒ Boolean
102 |
# File 'lib/udb/config.rb', line 102 def configured? = !unconfigured? |
#description ⇒ String
64 |
# File 'lib/udb/config.rb', line 64 def description = @data["description"] |
#fully_configured? ⇒ Boolean
70 |
# File 'lib/udb/config.rb', line 70 def fully_configured?; end |
#mxlen ⇒ Integer?
67 |
# File 'lib/udb/config.rb', line 67 def mxlen; end |
#name ⇒ String
99 |
# File 'lib/udb/config.rb', line 99 def name = @name |
#overlay? ⇒ Boolean
Returns Is an overlay present?.
46 |
# File 'lib/udb/config.rb', line 46 def = !(@data["arch_overlay"].nil? || @data["arch_overlay"].empty?) |
#param_values ⇒ Hash{String => ParamValueType}
Returns A hash mapping parameter name to value for any parameter that has been configured with a value. May be empty.
42 |
# File 'lib/udb/config.rb', line 42 def param_values; end |
#partially_configured? ⇒ Boolean
73 |
# File 'lib/udb/config.rb', line 73 def partially_configured?; end |
#unconfigured? ⇒ Boolean
76 |
# File 'lib/udb/config.rb', line 76 def unconfigured?; end |