Class: Inferno::DSL::RequirementSet

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.suite_options ||= []
end

Instance Attribute Details

#actorObject

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.suite_options ||= []
  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 expand_requirement_ids
    Entities::Requirement.expand_requirement_ids(requirements, identifier)
  end
end

#identifierObject

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.suite_options ||= []
  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 expand_requirement_ids
    Entities::Requirement.expand_requirement_ids(requirements, identifier)
  end
end

#requirementsObject

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.suite_options ||= []
  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 expand_requirement_ids
    Entities::Requirement.expand_requirement_ids(requirements, identifier)
  end
end

#suite_optionsObject

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.suite_options ||= []
  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 expand_requirement_ids
    Entities::Requirement.expand_requirement_ids(requirements, identifier)
  end
end

#titleObject

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.suite_options ||= []
  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 expand_requirement_ids
    Entities::Requirement.expand_requirement_ids(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

Returns:

  • (Boolean)


55
56
57
# File 'lib/inferno/dsl/requirement_set.rb', line 55

def complete?
  requirements.blank? || requirements.casecmp?('all')
end

#expand_requirement_idsObject

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 expand_requirement_ids
  Entities::Requirement.expand_requirement_ids(requirements, identifier)
end

#filtered?Boolean

Returns true when the RequirementSet only includes requirements specified in a list

Returns:

  • (Boolean)


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 RequirementSets

Returns:

  • (Boolean)


63
64
65
# File 'lib/inferno/dsl/requirement_set.rb', line 63

def referenced?
  requirements&.casecmp? 'referenced'
end