Class: Udb::PortfolioGroup

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, T::Sig
Defined in:
lib/udb/obj/portfolio.rb

Overview

A portfolio group consists of a one or more profiles. Contains common code to aggregrate multiple portfolios for Profile Releases and PortfolioDesign classes. This not the base class for ProfileRelease but it does contain one of these. This is not a DatabaseObject.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, portfolios) ⇒ PortfolioGroup

Returns a new instance of PortfolioGroup.

Parameters:

Raises:

  • (ArgumentError)


100
101
102
103
104
105
106
# File 'lib/udb/obj/portfolio.rb', line 100

def initialize(name, portfolios)
  raise ArgumentError, "name is a class #{name.class} but must be a String" unless name.is_a?(String)
  raise ArgumentError, "Need at least one portfolio" if portfolios.empty?

  @name = name
  @portfolios = portfolios
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



93
94
95
# File 'lib/udb/obj/portfolio.rb', line 93

def name
  @name
end

Instance Method Details

#all_in_scope_exts_with_param(param) ⇒ Array<Extension>

Returns Sorted list of all in-scope extensions that define this parameter in the database and the parameter is in-scope.

Parameters:

Returns:

  • (Array<Extension>)

    Sorted list of all in-scope extensions that define this parameter in the database and the parameter is in-scope.



347
348
349
350
351
352
353
354
# File 'lib/udb/obj/portfolio.rb', line 347

def all_in_scope_exts_with_param(param)
  @ret = []
  portfolios.each do |portfolio|
    @ret += portfolio.all_in_scope_exts_with_param(param)
  end

  @ret = @ret.uniq.sort
end

#all_in_scope_exts_without_param(param) ⇒ Array<Extension>

Returns List of all in-scope extensions that define this parameter in the database but the parameter is out-of-scope.

Parameters:

Returns:

  • (Array<Extension>)

    List of all in-scope extensions that define this parameter in the database but the parameter is out-of-scope.



359
360
361
362
363
364
365
366
# File 'lib/udb/obj/portfolio.rb', line 359

def all_in_scope_exts_without_param(param)
  @ret = []
  portfolios.each do |portfolio|
    @ret += portfolio.all_in_scope_exts_without_param(param)
  end

  @ret = @ret.uniq.sort
end

#all_in_scope_paramsArray<InScopeParameter>

Returns Sorted list of parameters specified by any extension in portfolio.

Returns:

  • (Array<InScopeParameter>)

    Sorted list of parameters specified by any extension in portfolio.



303
304
305
306
307
308
309
310
# File 'lib/udb/obj/portfolio.rb', line 303

def all_in_scope_params
  @ret = []
  portfolios.each do |portfolio|
    @ret += portfolio.all_in_scope_params
  end

  @ret = @ret.uniq.sort
end

#all_out_of_scope_paramsArray<Parameter>

Returns Sorted list of parameters out of scope across all in scope extensions.

Returns:

  • (Array<Parameter>)

    Sorted list of parameters out of scope across all in scope extensions.



324
325
326
327
328
329
330
331
# File 'lib/udb/obj/portfolio.rb', line 324

def all_out_of_scope_params
  @ret = []
  portfolios.each do |portfolio|
    @ret += portfolio.all_out_of_scope_params
  end

  @ret = @ret.uniq.sort
end

#csr_presence(csr_name) ⇒ String

Given an CSR csr_name, return the presence as a string. Returns the greatest presence string across all profiles in the group. If the CSR name isn’t found in the release, return “-”.

Returns:

  • (String)

    Given an CSR csr_name, return the presence as a string. Returns the greatest presence string across all profiles in the group. If the CSR name isn’t found in the release, return “-”.



287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/udb/obj/portfolio.rb', line 287

def csr_presence(csr_name)
  greatest_presence = T.let(nil, T.nilable(Presence))

  portfolios.each do |portfolio|
    presence = portfolio.csr_presence_obj(csr_name)

    unless presence.nil?
      return presence.to_s_concise if presence == Presence::Mandatory
      greatest_presence = presence
    end
  end

  greatest_presence.nil? ? "-" : greatest_presence.to_s_concise
end

#extension_presence(ext_name) ⇒ String

Given an extension ext_name, return the presence as a string. returns the greatest presence string across all profiles in the group. If the extension name isn’t found in the release, return “-”.

Parameters:

  • ext_name (String)

Returns:

  • (String)

    Given an extension ext_name, return the presence as a string. returns the greatest presence string across all profiles in the group. If the extension name isn’t found in the release, return “-”.



251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/udb/obj/portfolio.rb', line 251

def extension_presence(ext_name)
  greatest_presence = T.let(nil, T.nilable(Presence))

  portfolios.each do |portfolio|
    presence = portfolio.extension_presence_obj(ext_name)

    unless presence.nil?
      return presence.to_s_concise if presence == Presence::Mandatory
      greatest_presence = presence
    end
  end

  greatest_presence.nil? ? "-" : greatest_presence.to_s_concise
end

#in_scope_csrs(design) ⇒ Array<Csr>

Returns Unsorted list of all CSRs associated with extensions listed as mandatory or optional in portfolio. Uses CSRs provided by the minimum version of the extension that meets the extension requirement.

Parameters:

  • design (Design)

    The design

Returns:

  • (Array<Csr>)

    Unsorted list of all CSRs associated with extensions listed as mandatory or optional in portfolio. Uses CSRs provided by the minimum version of the extension that meets the extension requirement.

Raises:

  • (ArgumentError)


204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/udb/obj/portfolio.rb', line 204

def in_scope_csrs(design)
  raise ArgumentError, "Require an PortfolioDesign object but got a #{design.class} object" unless design.is_a?(PortfolioDesign)

  return @in_scope_csrs unless @in_scope_csrs.nil?

  @in_scope_csrs = []
  portfolios.each do |portfolio|
    @in_scope_csrs += portfolio.in_scope_csrs(design)
  end

  @in_scope_csrs.uniq(&:name)
end

#in_scope_exception_codes(design) ⇒ Array<ExceptionCode>

Returns Unsorted list of all in-scope exception codes.

Parameters:

  • design (Design)

    The design

Returns:

  • (Array<ExceptionCode>)

    Unsorted list of all in-scope exception codes.

Raises:

  • (ArgumentError)


219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/udb/obj/portfolio.rb', line 219

def in_scope_exception_codes(design)
  raise ArgumentError, "Require an PortfolioDesign object but got a #{design.class} object" unless design.is_a?(PortfolioDesign)

  return @in_scope_exception_codes unless @in_scope_exception_codes.nil?

  @in_scope_exception_codes = []
  portfolios.each do |portfolio|
    @in_scope_exception_codes += portfolio.in_scope_exception_codes(design)
  end

  @in_scope_exception_codes.uniq(&:name)
end

#in_scope_ext_reqsArray<ExtensionRequirement>

Returns Sorted list of all extension requirements listed by the group.

Returns:



134
135
136
137
138
139
140
141
142
143
# File 'lib/udb/obj/portfolio.rb', line 134

def in_scope_ext_reqs
  return @in_scope_ext_reqs unless @in_scope_ext_reqs.nil?

  @in_scope_ext_reqs = []
  portfolios.each do |portfolio|
    @in_scope_ext_reqs += portfolio.in_scope_ext_reqs
  end

  @in_scope_ext_reqs = @in_scope_ext_reqs.uniq(&:name).sort_by(&:name)
end

#in_scope_extensionsArray<Extension>

Returns Sorted list of all mandatory or optional extensions referenced by the group.

Returns:

  • (Array<Extension>)

    Sorted list of all mandatory or optional extensions referenced by the group.



170
171
172
173
174
175
176
177
178
179
180
# File 'lib/udb/obj/portfolio.rb', line 170

def in_scope_extensions
  return @in_scope_extensions unless @in_scope_extensions.nil?

  @in_scope_extensions = []
  portfolios.each do |portfolio|
    @in_scope_extensions += portfolio.in_scope_extensions
  end

  @in_scope_extensions = @in_scope_extensions.uniq(&:name).sort_by(&:name)

end

#in_scope_instructions(design) ⇒ Array<Instruction>

Returns Sorted list of all instructions associated with extensions listed as mandatory or optional in portfolio. Uses instructions provided by the minimum version of the extension that meets the extension requirement.

Parameters:

  • design (Design)

    The design

Returns:

  • (Array<Instruction>)

    Sorted list of all instructions associated with extensions listed as mandatory or optional in portfolio. Uses instructions provided by the minimum version of the extension that meets the extension requirement.

Raises:

  • (ArgumentError)


186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/udb/obj/portfolio.rb', line 186

def in_scope_instructions(design)
  raise ArgumentError, "Require an PortfolioDesign object but got a #{design.class} object" unless design.is_a?(PortfolioDesign)

  return @in_scope_instructions unless @in_scope_instructions.nil?

  @in_scope_instructions = []
  portfolios.each do |portfolio|
    @in_scope_instructions += portfolio.in_scope_instructions(design)
  end

  @in_scope_instructions =
    @in_scope_instructions.uniq(&:name).sort_by(&:name)
end

#in_scope_interrupt_codes(design) ⇒ Array<InterruptCode>

Returns Unsorted list of all in-scope interrupt codes.

Parameters:

  • design (Design)

    The design

Returns:

  • (Array<InterruptCode>)

    Unsorted list of all in-scope interrupt codes.

Raises:

  • (ArgumentError)


234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/udb/obj/portfolio.rb', line 234

def in_scope_interrupt_codes(design)
  raise ArgumentError, "Require an PortfolioDesign object but got a #{design.class} object" unless design.is_a?(PortfolioDesign)

  return @in_scope_interrupt_codes unless @in_scope_interrupt_codes.nil?

  @in_scope_interrupt_codes = []
  portfolios.each do |portfolio|
    @in_scope_interrupt_codes += portfolio.in_scope_interrupt_codes(design)
  end

  @in_scope_interrupt_codes.uniq(&:name)
end

#in_scope_params(ext_req) ⇒ Array<InScopeParameter>

Returns Sorted list of extension parameters from portfolio for given extension.

Parameters:

Returns:

  • (Array<InScopeParameter>)

    Sorted list of extension parameters from portfolio for given extension.



314
315
316
317
318
319
320
321
# File 'lib/udb/obj/portfolio.rb', line 314

def in_scope_params(ext_req)
  @ret = []
  portfolios.each do |portfolio|
    @ret += portfolio.in_scope_params(ext_req)
  end

  @ret = @ret.uniq.sort
end

#instruction_presence(inst_name) ⇒ String

Given an instruction inst_name, return the presence as a string. Returns the greatest presence string across all profiles in the group. If the instruction name isn’t found in the release, return “-”.

Returns:

  • (String)

    Given an instruction inst_name, return the presence as a string. Returns the greatest presence string across all profiles in the group. If the instruction name isn’t found in the release, return “-”.



269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/udb/obj/portfolio.rb', line 269

def instruction_presence(inst_name)
  greatest_presence = T.let(nil, T.nilable(Presence))

  portfolios.each do |portfolio|
    presence = portfolio.instruction_presence_obj(inst_name)

    unless presence.nil?
      return presence.to_s_concise if presence == Presence::Mandatory
      greatest_presence = presence
    end
  end

  greatest_presence.nil? ? "-" : greatest_presence.to_s_concise
end

#mandatory_ext_reqsArray<ExtensionRequirement>

Returns Sorted list of all mandatory extension requirements listed by the group.

Returns:

  • (Array<ExtensionRequirement>)

    Sorted list of all mandatory extension requirements listed by the group.



146
147
148
149
150
151
152
153
154
155
# File 'lib/udb/obj/portfolio.rb', line 146

def mandatory_ext_reqs
  return @mandatory_ext_reqs unless @mandatory_ext_reqs.nil?

  @mandatory_ext_reqs = []
  portfolios.each do |portfolio|
    @mandatory_ext_reqs += portfolio.mandatory_ext_reqs
  end

  @mandatory_ext_reqs = @mandatory_ext_reqs.uniq(&:name).sort_by(&:name)
end

#max_baseInteger

Returns Maximum base value (32 or 64) of all portfolios in group.

Returns:

  • (Integer)

    Maximum base value (32 or 64) of all portfolios in group.

Raises:

  • (ArgumentError)


124
125
126
127
128
129
130
131
# File 'lib/udb/obj/portfolio.rb', line 124

def max_base
  base = portfolios.map(&:base).max

  raise "All portfolios in config have a nil base" if base.nil?
  raise ArgumentError, "Calculated maximum base of #{base} across portfolios is not 32 or 64" unless base == 32 || base == 64

  return base
end

#optional_ext_reqsArray<ExtensionRequirement>

Returns Sorted list of all optional extension requirements listed by the group.

Returns:

  • (Array<ExtensionRequirement>)

    Sorted list of all optional extension requirements listed by the group.



158
159
160
161
162
163
164
165
166
167
# File 'lib/udb/obj/portfolio.rb', line 158

def optional_ext_reqs
  return @optional_ext_reqs unless @optional_ext_reqs.nil?

  @optional_ext_reqs = []
  portfolios.each do |portfolio|
    @optional_ext_reqs += portfolio.optional_ext_reqs
  end

  @optional_ext_reqs = @optional_ext_reqs.uniq(&:name).sort_by(&:name)
end

#out_of_scope_params(ext_name) ⇒ Array<Parameter>

Returns Sorted list of parameters that are out of scope for named extension.

Parameters:

  • ext_name (String)

    Extension name

Returns:

  • (Array<Parameter>)

    Sorted list of parameters that are out of scope for named extension.



335
336
337
338
339
340
341
342
# File 'lib/udb/obj/portfolio.rb', line 335

def out_of_scope_params(ext_name)
  @ret = []
  portfolios.each do |portfolio|
    @ret += portfolio.out_of_scope_params(ext_name)
  end

  @ret = @ret.uniq.sort
end

#param_valuesHash<String, String>

Returns Fully-constrained parameter values (those with just one possible value for this design).

Returns:

  • (Hash<String, String>)

    Fully-constrained parameter values (those with just one possible value for this design).



112
113
114
115
116
117
118
119
120
121
# File 'lib/udb/obj/portfolio.rb', line 112

def param_values
  return @param_values unless @param_values.nil?

  @param_values = {}
  portfolios.each do |portfolio|
    @param_values.merge!(portfolio.all_in_scope_params.select(&:single_value?).map { |p| [p.name, p.value] }.to_h)
  end

  @param_values
end

#portfoliosArray<Portfolio>

Returns All portfolios in this portfolio group.

Returns:

  • (Array<Portfolio>)

    All portfolios in this portfolio group



109
# File 'lib/udb/obj/portfolio.rb', line 109

def portfolios = @portfolios