Class: Inferno::DSL::RequirementSet
- Inherits:
-
Object
- Object
- Inferno::DSL::RequirementSet
- Defined in:
- lib/inferno/dsl/requirement_set.rb
Overview
A RequirementSet
represents the set of requirements which are tested by
a TestSuite.
Constant Summary collapse
- ATTRIBUTES =
[ :identifier, :title, :actor, :requirements, :suite_options ].freeze
Instance Attribute Summary collapse
-
#actor ⇒ Object
The actor whose requirements are included in this
RequirementSet
. -
#identifier ⇒ Object
The unique identifier for the source of requirements included in this
RequirementSet
. -
#requirements ⇒ Object
There are three options: *
"all"
(default) - Include all of the requirements for the specified actor from the requirement source *"referenced"
- Only include requirements from this source if they are referenced by other included requirements *"1,3,5-8"
- Only include the requirements from a comma-delimited list. -
#suite_options ⇒ Object
A set of suite options which must be selected in order for this
RequirementSet
to be included. -
#title ⇒ Object
A human-readable title for this
RequirementSet
.
Instance Method Summary collapse
-
#complete? ⇒ Boolean
Returns true when the
RequirementSet
includes all of the requirements from the source for the specified actor. -
#expand_requirement_ids ⇒ Object
Expands the compressed comma-separated requirements list into an Array of full ids.
-
#filtered? ⇒ Boolean
Returns true when the
RequirementSet
only includes requirements specified in a list. -
#initialize(raw_attributes_hash) ⇒ RequirementSet
constructor
A new instance of RequirementSet.
-
#referenced? ⇒ Boolean
Returns true when the
RequirementSet
only includes requirements referenced by otherRequirementSet
s.
Constructor Details
#initialize(raw_attributes_hash) ⇒ RequirementSet
Returns a new instance of RequirementSet.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/inferno/dsl/requirement_set.rb', line 33 def initialize(raw_attributes_hash) attributes_hash = raw_attributes_hash.symbolize_keys invalid_keys = attributes_hash.keys - ATTRIBUTES raise Exceptions::UnknownAttributeException.new(invalid_keys, self.class) if invalid_keys.present? attributes_hash.each do |name, value| if name == :suite_options value = value&.map { |option_id, option_value| SuiteOption.new(id: option_id, value: option_value) } end instance_variable_set(:"@#{name}", value) end self. ||= [] end |
Instance Attribute Details
#actor ⇒ Object
The actor whose requirements are included in this
RequirementSet
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/inferno/dsl/requirement_set.rb', line 22 class RequirementSet ATTRIBUTES = [ :identifier, :title, :actor, :requirements, :suite_options ].freeze include Entities::Attributes def initialize(raw_attributes_hash) attributes_hash = raw_attributes_hash.symbolize_keys invalid_keys = attributes_hash.keys - ATTRIBUTES raise Exceptions::UnknownAttributeException.new(invalid_keys, self.class) if invalid_keys.present? attributes_hash.each do |name, value| if name == :suite_options value = value&.map { |option_id, option_value| SuiteOption.new(id: option_id, value: option_value) } end instance_variable_set(:"@#{name}", value) end self. ||= [] end # Returns true when the `RequirementSet` includes all of the requirements # from the source for the specified actor # # @return [Boolean] def complete? requirements.blank? || requirements.casecmp?('all') end # Returns true when the `RequirementSet` only includes requirements # referenced by other `RequirementSet`s # # @return [Boolean] def referenced? requirements&.casecmp? 'referenced' end # Returns true when the `RequirementSet` only includes requirements # specified in a list # # @return [Boolean] def filtered? !complete? && !referenced? end # Expands the compressed comma-separated requirements list into an Array # of full ids def Entities::Requirement.(requirements, identifier) end end |
#identifier ⇒ Object
The unique identifier for the source of
requirements included in this RequirementSet
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/inferno/dsl/requirement_set.rb', line 22 class RequirementSet ATTRIBUTES = [ :identifier, :title, :actor, :requirements, :suite_options ].freeze include Entities::Attributes def initialize(raw_attributes_hash) attributes_hash = raw_attributes_hash.symbolize_keys invalid_keys = attributes_hash.keys - ATTRIBUTES raise Exceptions::UnknownAttributeException.new(invalid_keys, self.class) if invalid_keys.present? attributes_hash.each do |name, value| if name == :suite_options value = value&.map { |option_id, option_value| SuiteOption.new(id: option_id, value: option_value) } end instance_variable_set(:"@#{name}", value) end self. ||= [] end # Returns true when the `RequirementSet` includes all of the requirements # from the source for the specified actor # # @return [Boolean] def complete? requirements.blank? || requirements.casecmp?('all') end # Returns true when the `RequirementSet` only includes requirements # referenced by other `RequirementSet`s # # @return [Boolean] def referenced? requirements&.casecmp? 'referenced' end # Returns true when the `RequirementSet` only includes requirements # specified in a list # # @return [Boolean] def filtered? !complete? && !referenced? end # Expands the compressed comma-separated requirements list into an Array # of full ids def Entities::Requirement.(requirements, identifier) end end |
#requirements ⇒ Object
There are three options:
* "all"
(default) - Include all of the requirements for the specified
actor from the requirement source
* "referenced"
- Only include requirements from this source if they
are referenced by other included requirements
* "1,3,5-8"
- Only include the requirements from a comma-delimited
list
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/inferno/dsl/requirement_set.rb', line 22 class RequirementSet ATTRIBUTES = [ :identifier, :title, :actor, :requirements, :suite_options ].freeze include Entities::Attributes def initialize(raw_attributes_hash) attributes_hash = raw_attributes_hash.symbolize_keys invalid_keys = attributes_hash.keys - ATTRIBUTES raise Exceptions::UnknownAttributeException.new(invalid_keys, self.class) if invalid_keys.present? attributes_hash.each do |name, value| if name == :suite_options value = value&.map { |option_id, option_value| SuiteOption.new(id: option_id, value: option_value) } end instance_variable_set(:"@#{name}", value) end self. ||= [] end # Returns true when the `RequirementSet` includes all of the requirements # from the source for the specified actor # # @return [Boolean] def complete? requirements.blank? || requirements.casecmp?('all') end # Returns true when the `RequirementSet` only includes requirements # referenced by other `RequirementSet`s # # @return [Boolean] def referenced? requirements&.casecmp? 'referenced' end # Returns true when the `RequirementSet` only includes requirements # specified in a list # # @return [Boolean] def filtered? !complete? && !referenced? end # Expands the compressed comma-separated requirements list into an Array # of full ids def Entities::Requirement.(requirements, identifier) end end |
#suite_options ⇒ Object
A set of suite options which must be
selected in order for this RequirementSet
to be included
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/inferno/dsl/requirement_set.rb', line 22 class RequirementSet ATTRIBUTES = [ :identifier, :title, :actor, :requirements, :suite_options ].freeze include Entities::Attributes def initialize(raw_attributes_hash) attributes_hash = raw_attributes_hash.symbolize_keys invalid_keys = attributes_hash.keys - ATTRIBUTES raise Exceptions::UnknownAttributeException.new(invalid_keys, self.class) if invalid_keys.present? attributes_hash.each do |name, value| if name == :suite_options value = value&.map { |option_id, option_value| SuiteOption.new(id: option_id, value: option_value) } end instance_variable_set(:"@#{name}", value) end self. ||= [] end # Returns true when the `RequirementSet` includes all of the requirements # from the source for the specified actor # # @return [Boolean] def complete? requirements.blank? || requirements.casecmp?('all') end # Returns true when the `RequirementSet` only includes requirements # referenced by other `RequirementSet`s # # @return [Boolean] def referenced? requirements&.casecmp? 'referenced' end # Returns true when the `RequirementSet` only includes requirements # specified in a list # # @return [Boolean] def filtered? !complete? && !referenced? end # Expands the compressed comma-separated requirements list into an Array # of full ids def Entities::Requirement.(requirements, identifier) end end |
#title ⇒ Object
A human-readable title for this RequirementSet
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/inferno/dsl/requirement_set.rb', line 22 class RequirementSet ATTRIBUTES = [ :identifier, :title, :actor, :requirements, :suite_options ].freeze include Entities::Attributes def initialize(raw_attributes_hash) attributes_hash = raw_attributes_hash.symbolize_keys invalid_keys = attributes_hash.keys - ATTRIBUTES raise Exceptions::UnknownAttributeException.new(invalid_keys, self.class) if invalid_keys.present? attributes_hash.each do |name, value| if name == :suite_options value = value&.map { |option_id, option_value| SuiteOption.new(id: option_id, value: option_value) } end instance_variable_set(:"@#{name}", value) end self. ||= [] end # Returns true when the `RequirementSet` includes all of the requirements # from the source for the specified actor # # @return [Boolean] def complete? requirements.blank? || requirements.casecmp?('all') end # Returns true when the `RequirementSet` only includes requirements # referenced by other `RequirementSet`s # # @return [Boolean] def referenced? requirements&.casecmp? 'referenced' end # Returns true when the `RequirementSet` only includes requirements # specified in a list # # @return [Boolean] def filtered? !complete? && !referenced? end # Expands the compressed comma-separated requirements list into an Array # of full ids def Entities::Requirement.(requirements, identifier) end end |
Instance Method Details
#complete? ⇒ Boolean
Returns true when the RequirementSet
includes all of the requirements
from the source for the specified actor
55 56 57 |
# File 'lib/inferno/dsl/requirement_set.rb', line 55 def complete? requirements.blank? || requirements.casecmp?('all') end |
#expand_requirement_ids ⇒ Object
Expands the compressed comma-separated requirements list into an Array of full ids
77 78 79 |
# File 'lib/inferno/dsl/requirement_set.rb', line 77 def Entities::Requirement.(requirements, identifier) end |
#filtered? ⇒ Boolean
Returns true when the RequirementSet
only includes requirements
specified in a list
71 72 73 |
# File 'lib/inferno/dsl/requirement_set.rb', line 71 def filtered? !complete? && !referenced? end |
#referenced? ⇒ Boolean
Returns true when the RequirementSet
only includes requirements
referenced by other RequirementSet
s
63 64 65 |
# File 'lib/inferno/dsl/requirement_set.rb', line 63 def referenced? requirements&.casecmp? 'referenced' end |