Class: Udb::Portfolio
- Inherits:
-
TopLevelDatabaseObject
- Object
- DatabaseObject
- TopLevelDatabaseObject
- Udb::Portfolio
- Defined in:
- lib/udb/obj/portfolio.rb
Overview
Holds information about a Portfolio (certificate or profile). The inherited “data” member is YAML data from the architecture for this portfolio object.
Direct Known Subclasses
Defined Under Namespace
Classes: ExtraNote, InScopeParameter, Recommendation, RevisionHistory
Instance Attribute Summary
Attributes inherited from DatabaseObject
#arch, #data, #data_path, #long_name, #name
Instance Method Summary collapse
-
#all_in_scope_exts_with_param(param) ⇒ Array<Extension>
Sorted list of all in-scope extensions that define this parameter in the database and the parameter is in-scope.
-
#all_in_scope_exts_without_param(param) ⇒ Array<Extension>
List of all in-scope extensions that define this parameter in the database but the parameter is out-of-scope.
-
#all_in_scope_params ⇒ Array<InScopeParameter>
List of parameters specified by any extension in portfolio.
-
#all_out_of_scope_params ⇒ Array<Parameter>
Sorted list of parameters out of scope across all in scope extensions.
-
#base ⇒ Integer
32 or 64.
- #cfg_arch_for_config_data(config_data) ⇒ Object
-
#csr_presence(csr_name) ⇒ String
Given an CSR
csr_name, return the presence as a string. -
#csr_presence_obj(csr_name) ⇒ Presence
Given an CSR
csr_name, return the presence. -
#description ⇒ String
Large enough to need its own heading (generally one level deeper than the “introduction”).
- #extension_note(ext_name) ⇒ String?
-
#extension_presence(ext_name) ⇒ String
Given an extension
ext_name, return the presence as a string. -
#extension_presence_obj(ext_name) ⇒ Presence
Given an extension
ext_name, return the presence. - #extra_notes ⇒ Object
- #extra_notes_for_presence(desired_presence_obj) ⇒ Object
-
#in_scope_csrs(design) ⇒ Array<Csr>
Unsorted list of all CSRs associated with extensions listed as mandatory or optional in portfolio.
-
#in_scope_exception_codes(design) ⇒ Array<ExceptionCode>
TODO: See github.com/riscv/riscv-unified-db/issues/291 TODO: Still needs work and haven’t created in_scope_interrupt_codes yet.
- #in_scope_ext_reqs(desired_presence = nil) ⇒ Object
-
#in_scope_extensions ⇒ Array<Extension>
Sorted list of all mandatory or optional extensions in portfolio.
-
#in_scope_instructions(design) ⇒ Array<Instruction>
Sorted list of all instructions associated with extensions listed as mandatory or optional in portfolio.
-
#in_scope_interrupt_codes(design) ⇒ Array<InterruptCode>
TODO: Actually implement this to use Design.
-
#in_scope_min_satisfying_extension_versions ⇒ ExtensionVersion
List of all mandatory or optional extensions listed in portfolio.
-
#in_scope_params(ext_req) ⇒ Array<InScopeParameter>
Sorted list of extension parameters from portfolio for given extension.
-
#initialize(obj_yaml, yaml_path, arch) ⇒ Portfolio
constructor
A new instance of Portfolio.
- #instruction_presence(inst_name) ⇒ Object
- #instruction_presence_obj(inst_name) ⇒ Object
-
#introduction ⇒ String
Small enough (~1 paragraph) to be suitable immediately after a higher-level heading.
- #mandatory_ext_reqs ⇒ Object
- #optional_ext_reqs ⇒ Object
-
#out_of_scope_params(ext_name) ⇒ Array<Parameter>
Sorted list of parameters that are out of scope for named extension.
- #recommendations ⇒ Object
- #requirements_condition ⇒ Object
- #revision_history ⇒ Object
- #to_cfg_arch ⇒ Object
- #to_cfg_arch_for_optional ⇒ Object
- #to_config(mandatory: mandatory_ext_reqs) ⇒ Object
- #to_strict_config ⇒ Object
-
#uses_optional_types? ⇒ Boolean
Does the profile differentiate between different types of optional.
-
#version ⇒ Gem::Version
Semantic version of the Portfolio.
- #version_greatest_presence(ext_name, ext_versions) ⇒ Object
Methods inherited from TopLevelDatabaseObject
create_json_schemer_resolver, #key?, #keys, #validate
Methods inherited from DatabaseObject
#<=>, #__source, #cfg_arch, #cfg_arch?, #clone, #defer, #defined_by_condition, #inspect, #kind, #source_line
Constructor Details
#initialize(obj_yaml, yaml_path, arch) ⇒ Portfolio
Returns a new instance of Portfolio.
391 392 393 |
# File 'lib/udb/obj/portfolio.rb', line 391 def initialize(obj_yaml, yaml_path, arch) super # Calls parent class with same args I got 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.
876 |
# File 'lib/udb/obj/portfolio.rb', line 876 def all_in_scope_exts_with_param(param) = [] |
#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.
881 |
# File 'lib/udb/obj/portfolio.rb', line 881 def all_in_scope_exts_without_param(param) = [] |
#all_in_scope_params ⇒ Array<InScopeParameter>
Returns List of parameters specified by any extension in portfolio.
860 |
# File 'lib/udb/obj/portfolio.rb', line 860 def all_in_scope_params = [] |
#all_out_of_scope_params ⇒ Array<Parameter>
Returns Sorted list of parameters out of scope across all in scope extensions.
867 |
# File 'lib/udb/obj/portfolio.rb', line 867 def all_out_of_scope_params = [] |
#base ⇒ Integer
Returns 32 or 64.
402 |
# File 'lib/udb/obj/portfolio.rb', line 402 def base = @data["base"] |
#cfg_arch_for_config_data(config_data) ⇒ Object
570 571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/udb/obj/portfolio.rb', line 570 def cfg_arch_for_config_data(config_data) resolver = @cfg_arch.config.info.resolver if @cfg_arch.config.info..nil? resolver.cfg_arch_for_data(config_data) else Tempfile.create do |f| f.write YAML.dump(config_data) f.fsync resolver.cfg_arch_for(Pathname.new f.path) end end end |
#csr_presence(csr_name) ⇒ String
Returns Given an CSR csr_name, return the presence as a string. If the CSR name isn’t found in the portfolio, return “-”.
637 638 639 640 641 642 643 644 645 |
# File 'lib/udb/obj/portfolio.rb', line 637 def csr_presence(csr_name) @csr_presence ||= {} return @csr_presence[csr_name] unless @csr_presence[csr_name].nil? presence_obj = csr_presence_obj(csr_name) @csr_presence[csr_name] = presence_obj.nil? ? "-" : presence_obj.to_s end |
#csr_presence_obj(csr_name) ⇒ Presence
Returns Given an CSR csr_name, return the presence. If the CSR name isn’t found in the portfolio, return nil.
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'lib/udb/obj/portfolio.rb', line 608 def csr_presence_obj(csr_name) @csr_presence_obj ||= {} return @csr_presence_obj[csr_name] unless @csr_presence_obj[csr_name].nil? csr = arch.csr(csr_name) raise "Can't find CSR object '#{csr_name}' in arch class" if csr.nil? is_mandatory = mandatory_ext_reqs.any? do |ext_req| csr.defined_by_condition.satisfied_by_cfg_arch?(to_cfg_arch) == SatisfiedResult::Yes end is_optional = !is_mandatory && optional_ext_reqs.any? do |ext_req| csr.defined_by_condition.satisfied_by_cfg_arch?(to_cfg_arch_for_optional) == SatisfiedResult::Yes end @csr_presence_obj[csr_name] = if is_mandatory Presence::Mandatory elsif is_optional Presence::Option else nil end end |
#description ⇒ String
Returns Large enough to need its own heading (generally one level deeper than the “introduction”).
399 |
# File 'lib/udb/obj/portfolio.rb', line 399 def description = @data["description"] |
#extension_note(ext_name) ⇒ String?
674 675 676 677 678 679 680 |
# File 'lib/udb/obj/portfolio.rb', line 674 def extension_note(ext_name) # Get extension information from YAML for passed in extension name. ext_data = @data["extensions"][ext_name] raise "Cannot find extension named #{ext_name}" if ext_data.nil? return ext_data["note"] unless ext_data.nil? end |
#extension_presence(ext_name) ⇒ String
Returns Given an extension ext_name, return the presence as a string. If the extension name isn’t found in the portfolio, return “-”.
418 419 420 421 422 |
# File 'lib/udb/obj/portfolio.rb', line 418 def extension_presence(ext_name) presence_obj = extension_presence_obj(ext_name) presence_obj.nil? ? "-" : presence_obj.to_s end |
#extension_presence_obj(ext_name) ⇒ Presence
Returns Given an extension ext_name, return the presence. If the extension name isn’t found in the portfolio, return nil.
409 410 411 412 413 414 |
# File 'lib/udb/obj/portfolio.rb', line 409 def extension_presence_obj(ext_name) # Get extension information from YAML for passed in extension name. ext_data = @data["extensions"][ext_name] ext_data.nil? ? nil : Presence.from_yaml(ext_data["presence"]) end |
#extra_notes ⇒ Object
983 984 985 986 987 988 989 990 991 |
# File 'lib/udb/obj/portfolio.rb', line 983 def extra_notes return @extra_notes unless @extra_notes.nil? @extra_notes = [] @data["extra_notes"]&.each do |extra_note| @extra_notes << ExtraNote.new(extra_note) end @extra_notes end |
#extra_notes_for_presence(desired_presence_obj) ⇒ Object
994 995 996 997 998 999 1000 1001 1002 |
# File 'lib/udb/obj/portfolio.rb', line 994 def extra_notes_for_presence(desired_presence_obj) extra_notes.select do |extra_note| if desired_presence_obj == Presence::Mandatory extra_note.presence_obj == desired_presence_obj else extra_note.presence_obj != Presence::Mandatory end end 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.
793 794 795 796 797 798 799 |
# File 'lib/udb/obj/portfolio.rb', line 793 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 = to_cfg_arch.in_scope_csrs() end |
#in_scope_exception_codes(design) ⇒ Array<ExceptionCode>
TODO: See github.com/riscv/riscv-unified-db/issues/291 TODO: Still needs work and haven’t created in_scope_interrupt_codes yet. TODO: Extensions should provide conditional information (“when” statements?)
that we evaluate here to determine if a particular exception code can
actually be generated in a design.
Also, probably shouldn't be calling "ext?" since that doesn't the in_scope lists of extensions.
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 |
# File 'lib/udb/obj/portfolio.rb', line 809 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 = .reduce([]) do |list, ext_version| ecodes = ext_version.exception_codes next list if ecodes.nil? ecodes.each do |ecode| list << ecode end list end.uniq end |
#in_scope_ext_reqs(desired_presence = nil) ⇒ Object
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
# File 'lib/udb/obj/portfolio.rb', line 691 def in_scope_ext_reqs(desired_presence = nil) in_scope_ext_reqs = [] # Convert desired_present argument to Presence object if not nil. desired_presence_converted = if desired_presence.nil? nil else desired_presence.is_a?(Presence) ? desired_presence : Presence.from_yaml(desired_presence) end missing_ext = T.let(false, T::Boolean) @data["extensions"]&.each do |ext_name, ext_data| next if ext_name[0] == "$" # Does extension even exist? # If not, don't raise an error right away so we can find all of the missing extensions and report them all. ext = arch.extension(ext_name) if ext.nil? Udb.logger.warn "Extension #{ext_name} for #{name} not found in database" missing_ext = true else actual_presence = ext_data["presence"] # Could be a String or Hash raise "Missing extension presence for extension #{ext_name}" if actual_presence.nil? # Convert presence String or Hash to object. actual_presence_obj = Presence.from_yaml(actual_presence) match = if desired_presence.nil? true # Always match else if desired_presence_converted == Presence::Mandatory actual_presence_obj == Presence::Mandatory else # treat all optional types as equal actual_presence_obj != Presence::Mandatory end end if match in_scope_ext_reqs << if ext_data.key?("version") PortfolioExtensionRequirement.new( ext_name, ext_data["version"], arch: @arch, presence: actual_presence_obj, note: ext_data["note"], req_id: "REQ-EXT-#{ext_name}") else PortfolioExtensionRequirement.new( ext_name, ">= 0", arch: @arch, presence: actual_presence_obj, note: ext_data["note"], req_id: "REQ-EXT-#{ext_name}") end end end end raise "One or more extensions referenced by #{name} missing in database" if missing_ext in_scope_ext_reqs.sort_by!(&:name) end |
#in_scope_extensions ⇒ Array<Extension>
Returns Sorted list of all mandatory or optional extensions in portfolio. Each extension can have multiple versions (contains ExtensionVersion array).
754 755 756 757 758 759 760 761 762 |
# File 'lib/udb/obj/portfolio.rb', line 754 def in_scope_extensions return @in_scope_extensions unless @in_scope_extensions.nil? @in_scope_extensions = in_scope_ext_reqs.map do |ext_req| ext_req.extension end.reject(&:nil?) # Filter out extensions that don't exist yet. @in_scope_extensions.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.
780 781 782 783 784 785 786 787 |
# File 'lib/udb/obj/portfolio.rb', line 780 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 = .map { |ext_ver| ext_ver.in_scope_instructions(design.possible_xlens) }.flatten.uniq.sort end |
#in_scope_interrupt_codes(design) ⇒ Array<InterruptCode>
TODO: Actually implement this to use Design. See in_scope_exception_codes() above.
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
# File 'lib/udb/obj/portfolio.rb', line 829 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 = .reduce([]) do |list, ext_version| icodes = ext_version.interrupt_codes next list if icodes.nil? icodes.each do |icode| list << icode end list end.uniq end |
#in_scope_min_satisfying_extension_versions ⇒ ExtensionVersion
Returns List of all mandatory or optional extensions listed in portfolio. The minimum version of each extension that satisfies the extension requirements is provided.
766 767 768 769 770 771 772 773 774 |
# File 'lib/udb/obj/portfolio.rb', line 766 def return @in_scope_min_satisfying_extension_versions unless @in_scope_min_satisfying_extension_versions.nil? @in_scope_min_satisfying_extension_versions = in_scope_ext_reqs.map do |ext_req| ext_req..min end.reject(&:nil?) # Filter out extensions that don't exist yet. @in_scope_min_satisfying_extension_versions end |
#in_scope_params(ext_req) ⇒ Array<InScopeParameter>
Returns Sorted list of extension parameters from portfolio for given extension.
864 |
# File 'lib/udb/obj/portfolio.rb', line 864 def in_scope_params(ext_req) = [] |
#instruction_presence(inst_name) ⇒ Object
596 597 598 599 600 601 602 603 604 |
# File 'lib/udb/obj/portfolio.rb', line 596 def instruction_presence(inst_name) @instruction_presence ||= {} return @instruction_presence[inst_name] unless @instruction_presence[inst_name].nil? presence_obj = instruction_presence_obj(inst_name) @instruction_presence[inst_name] = presence_obj.nil? ? "-" : presence_obj.to_s end |
#instruction_presence_obj(inst_name) ⇒ Object
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/udb/obj/portfolio.rb', line 427 def instruction_presence_obj(inst_name) @instruction_presence_obj ||= {} return @instruction_presence_obj[inst_name] unless @instruction_presence_obj[inst_name].nil? inst = arch.instruction(inst_name) raise "Can't find instruction object '#{inst_name}' in arch class" if inst.nil? is_mandatory = mandatory_ext_reqs.any? do |ext_req| inst.defined_by_condition.satisfied_by_cfg_arch?(to_cfg_arch) == SatisfiedResult::Yes end is_optional = !is_mandatory && optional_ext_reqs.any? do |ext_req| inst.defined_by_condition.satisfied_by_cfg_arch?(to_cfg_arch_for_optional) == SatisfiedResult::Yes end @instruction_presence_obj[inst_name] = if is_mandatory Presence::Mandatory elsif is_optional Presence::Option else nil end end |
#introduction ⇒ String
Returns Small enough (~1 paragraph) to be suitable immediately after a higher-level heading.
396 |
# File 'lib/udb/obj/portfolio.rb', line 396 def introduction = @data["introduction"] |
#mandatory_ext_reqs ⇒ Object
682 |
# File 'lib/udb/obj/portfolio.rb', line 682 def mandatory_ext_reqs = in_scope_ext_reqs(Presence::Mandatory) |
#optional_ext_reqs ⇒ Object
683 |
# File 'lib/udb/obj/portfolio.rb', line 683 def optional_ext_reqs = in_scope_ext_reqs(Presence::Option) |
#out_of_scope_params(ext_name) ⇒ Array<Parameter>
Returns Sorted list of parameters that are out of scope for named extension.
871 |
# File 'lib/udb/obj/portfolio.rb', line 871 def out_of_scope_params(ext_name) = [] |
#recommendations ⇒ Object
1016 1017 1018 1019 1020 1021 1022 1023 1024 |
# File 'lib/udb/obj/portfolio.rb', line 1016 def recommendations return @recommendations unless @recommendations.nil? @recommendations = [] @data["recommendations"]&.each do |recommendation| @recommendations << Recommendation.new(recommendation) end @recommendations end |
#requirements_condition ⇒ Object
584 585 586 587 588 589 590 591 |
# File 'lib/udb/obj/portfolio.rb', line 584 def requirements_condition @requirements_condition ||= if @data.key?("requirements") Condition.new(@data.fetch("requirements"), cfg_arch) else AlwaysTrueCondition.new(cfg_arch) end end |
#revision_history ⇒ Object
958 959 960 961 962 963 964 965 966 |
# File 'lib/udb/obj/portfolio.rb', line 958 def revision_history return @revision_history unless @revision_history.nil? @revision_history = [] @data["revision_history"].each do |rev| @revision_history << RevisionHistory.new(rev) end @revision_history end |
#to_cfg_arch ⇒ Object
526 527 528 |
# File 'lib/udb/obj/portfolio.rb', line 526 def to_cfg_arch @cfg_arch_for_mandatory ||= cfg_arch_for_config_data(to_config) end |
#to_cfg_arch_for_optional ⇒ Object
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/udb/obj/portfolio.rb', line 532 def to_cfg_arch_for_optional @cfg_arch_for_optional ||= begin contents = { "$schema" => "config_schema.json#", "kind" => "architecture configuration", "type" => "partially configured", "name" => name, "description" => description, "params" => all_in_scope_params.map do |p| if p.single_value? [p.name, p.value] else nil end end.compact.to_h, "mandatory_extensions" => optional_ext_reqs.map do |ext_req| { "name" => ext_req.name, "version" => \ if ext_req.requirement_specs.size == 1 ext_req.requirement_specs.fetch(0).to_s else ext_req.requirement_specs.map(&:to_s) end } end, "additional_extensions" => true } contents["requirements"] = requirements_condition.to_h unless requirements_condition.empty? cfg_arch_for_config_data(contents) end end |
#to_config(mandatory: mandatory_ext_reqs) ⇒ Object
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/udb/obj/portfolio.rb', line 455 def to_config(mandatory: mandatory_ext_reqs) c = { "$schema" => "config_schema.json#", "kind" => "architecture configuration", "type" => "partially configured", "name" => name, "description" => description, "params" => all_in_scope_params.sort.map do |p| if p.single_value? [p.name, p.value] else nil end end.compact.to_h, "mandatory_extensions" => mandatory.sort.map do |ext_req| { "name" => ext_req.name, "version" => \ if ext_req.requirement_specs.size == 1 ext_req.requirement_specs.fetch(0).to_s else ext_req.requirement_specs.map(&:to_s) end } end, "non_mandatory_extensions" => optional_ext_reqs.sort.map do |ext_req| { "name" => ext_req.name, "version" => \ if ext_req.requirement_specs.size == 1 ext_req.requirement_specs.fetch(0).to_s else ext_req.requirement_specs.map(&:to_s) end } end, "additional_extensions" => true } c["requirements"] = requirements_condition.to_h unless requirements_condition.empty? c end |
#to_strict_config ⇒ Object
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/udb/obj/portfolio.rb', line 499 def to_strict_config strict_mandatory_ext_reqs = mandatory_ext_reqs mandatory_ext_req_names = strict_mandatory_ext_reqs.map(&:name).to_set cfg_arch_obj = to_cfg_arch cfg_arch_obj.extensions.each do |ext| next if mandatory_ext_req_names.include?(ext.name) if (-ext.to_ext_req.to_condition & cfg_arch_obj.to_condition).unsatisfiable_by_cfg_arch?(cfg_arch_obj) # what's the minimum? min_ext_ver = ext.versions.find do |ext_ver| compat_with_ext_ver = Condition.new({ "extension" => { "name" => ext.name, "version" => "= #{ext_ver.version_str}" } }, cfg_arch_obj) c = (compat_with_ext_ver & cfg_arch_obj.to_condition) c.satisfiable_by_cfg_arch?(cfg_arch_obj) end raise "condition problem: ext is required but none of the versions are" if min_ext_ver.nil? strict_mandatory_ext_reqs << PortfolioExtensionRequirement.new(ext.name, "~> #{min_ext_ver.version_str}", arch: cfg_arch_obj) mandatory_ext_req_names.add(ext.name) end end to_config(mandatory: strict_mandatory_ext_reqs) end |
#uses_optional_types? ⇒ Boolean
Returns Does the profile differentiate between different types of optional.
847 848 849 850 851 852 |
# File 'lib/udb/obj/portfolio.rb', line 847 def uses_optional_types? return @uses_optional_types unless @uses_optional_types.nil? @uses_optional_types = in_scope_ext_reqs(Presence::Option).any? { |ext_req| ext_req.presence != Presence::Option } end |
#version ⇒ Gem::Version
Returns Semantic version of the Portfolio.
405 |
# File 'lib/udb/obj/portfolio.rb', line 405 def version = Gem::Version.new(@data["version"]) |
#version_greatest_presence(ext_name, ext_versions) ⇒ Object
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/udb/obj/portfolio.rb', line 649 def version_greatest_presence(ext_name, ext_versions) presences = [] # See if any extension requirement in this profile lists this version as either mandatory or optional. ext_versions.map do |v| greatest_presence = T.let(nil, T.nilable(Presence)) in_scope_ext_reqs.each do |ext_req| if ext_req.satisfied_by?(v) presence = extension_presence_obj(ext_name) unless presence.nil? greatest_presence = presence unless greatest_presence == Presence::Mandatory end end end presences << (greatest_presence.nil? ? "-" : greatest_presence.to_s_concise) end presences end |