Class: Udb::PortfolioGroup

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
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)


69
70
71
72
73
74
75
# File 'lib/udb/obj/portfolio.rb', line 69

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.



62
63
64
# File 'lib/udb/obj/portfolio.rb', line 62

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.



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

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.



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

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.



280
281
282
283
284
285
286
287
# File 'lib/udb/obj/portfolio.rb', line 280

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.



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

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



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

def csr_presence(csr_name)
  greatest_presence = nil

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

    unless presence.nil?
      if greatest_presence.nil?
        greatest_presence = presence
      elsif presence > greatest_presence
        greatest_presence = presence
      end
    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 “-”.

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



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

def extension_presence(ext_name)
  greatest_presence = nil

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

    unless presence.nil?
      if greatest_presence.nil?
        greatest_presence = presence
      elsif presence > greatest_presence
        greatest_presence = presence
      end
    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)


173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/udb/obj/portfolio.rb', line 173

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)


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

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:



103
104
105
106
107
108
109
110
111
112
# File 'lib/udb/obj/portfolio.rb', line 103

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.



139
140
141
142
143
144
145
146
147
148
149
# File 'lib/udb/obj/portfolio.rb', line 139

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)


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

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)


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

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.



291
292
293
294
295
296
297
298
# File 'lib/udb/obj/portfolio.rb', line 291

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



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

def instruction_presence(inst_name)
  greatest_presence = nil

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

    unless presence.nil?
      if greatest_presence.nil?
        greatest_presence = presence
      elsif presence > greatest_presence
        greatest_presence = presence
      end
    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.



115
116
117
118
119
120
121
122
123
124
# File 'lib/udb/obj/portfolio.rb', line 115

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)


93
94
95
96
97
98
99
100
# File 'lib/udb/obj/portfolio.rb', line 93

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.



127
128
129
130
131
132
133
134
135
136
# File 'lib/udb/obj/portfolio.rb', line 127

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.



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

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



81
82
83
84
85
86
87
88
89
90
# File 'lib/udb/obj/portfolio.rb', line 81

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



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

def portfolios = @portfolios