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)


111
112
113
114
115
116
117
# File 'lib/udb/obj/portfolio.rb', line 111

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.



104
105
106
# File 'lib/udb/obj/portfolio.rb', line 104

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.



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

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.



370
371
372
373
374
375
376
377
# File 'lib/udb/obj/portfolio.rb', line 370

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.



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

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.



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

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 “-”.



298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/udb/obj/portfolio.rb', line 298

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) ⇒ Object



262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/udb/obj/portfolio.rb', line 262

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)


215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/udb/obj/portfolio.rb', line 215

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)


230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/udb/obj/portfolio.rb', line 230

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:



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

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.



181
182
183
184
185
186
187
188
189
190
191
# File 'lib/udb/obj/portfolio.rb', line 181

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)


197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/udb/obj/portfolio.rb', line 197

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)


245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/udb/obj/portfolio.rb', line 245

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.



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

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 “-”.



280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/udb/obj/portfolio.rb', line 280

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.



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

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)


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

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.



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

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.



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

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).



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

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



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

def portfolios = @portfolios