Class: Modspec::Suite
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Modspec::Suite
- Defined in:
- lib/modspec/suite.rb
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #combine(other_suite) ⇒ Object
- #resolve_conflicts(other_suite) ⇒ Object
- #setup_relationships ⇒ Object
- #validate ⇒ Object
Instance Attribute Details
#all_identifiers ⇒ Object
49 50 51 52 53 54 |
# File 'lib/modspec/suite.rb', line 49 def all_identifiers @all_identifiers ||= (normative_statements_classes.flat_map(&:normative_statements) + conformance_classes.flat_map(&:tests) + normative_statements_classes + conformance_classes).map(&:identifier) end |
Class Method Details
.from_yaml_files(*files) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/modspec/suite.rb', line 63 def self.from_yaml_files(*files) combined_suite = new files.each do |file| suite = from_yaml(File.read(file)) combined_suite = combined_suite.combine(suite) end combined_suite.name = "Combined Suite" combined_suite end |
Instance Method Details
#combine(other_suite) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/modspec/suite.rb', line 32 def combine(other_suite) raise ArgumentError, "Argument must be a Modspec::Suite" unless other_suite.is_a?(Modspec::Suite) combined_suite = dup combined_suite.all_identifiers = nil combined_suite.normative_statements_classes += other_suite.normative_statements_classes combined_suite.conformance_classes += other_suite.conformance_classes # Ensure uniqueness of identifiers combined_suite.normative_statements_classes.uniq!(&:identifier) combined_suite.conformance_classes.uniq!(&:identifier) combined_suite.name = "#{name} + #{other_suite.name}" combined_suite end |
#resolve_conflicts(other_suite) ⇒ Object
58 59 60 61 |
# File 'lib/modspec/suite.rb', line 58 def resolve_conflicts(other_suite) resolve_conflicts_for(normative_statements_classes, other_suite.normative_statements_classes) resolve_conflicts_for(conformance_classes, other_suite.conformance_classes) end |
#setup_relationships ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/modspec/suite.rb', line 73 def setup_relationships all_requirements = normative_statements_classes.flat_map(&:normative_statements) conformance_classes.each do |cc| cc.tests.each do |ct| ct.corresponding_requirements = all_requirements.select do |r| ct.targets.map(&:to_s).include?(r.identifier.to_s) end ct.parent_class = cc end end end |
#validate ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/modspec/suite.rb', line 20 def validate setup_relationships self.all_identifiers = nil errors = super() errors.concat(validate_cycles) errors.concat(validate_label_uniqueness) errors.concat(validate_dependencies) errors.concat(normative_statements_classes.flat_map { |n| n.validate(self) }) errors.concat(conformance_classes.flat_map(&:validate)) errors end |