Class: Continuum::AccessibilityConcern

Inherits:
Object
  • Object
show all
Defined in:
src/lib/continuum/accessibility_concern.rb

Overview

This class represents an accessibility concern identified by Access Engine. At minimum, it contains both information about the concern that was identified and well as where on the page the problem is located. It may also include best practice data from AMP, e.g. how severe or noticeable the issue might be, along with an AMP URL that can be visited for more info.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, engine_test_id, attribute, best_practice_id, element, fix_type, needs_review, raw_engine_json_object, best_practice_description, severity, noticeability, tractability, best_practice_details_url, best_practice_standards) ⇒ AccessibilityConcern

Returns a new instance of AccessibilityConcern.

Parameters:

  • path (String)

    A CSS selector to the element with this accessibility concern

  • engine_test_id (Integer)

    The automatic Access Engine test ID that failed and produced this accessibility concern

  • attribute (String)

    A brief human-readable description of this accessibility concern

  • best_practice_id (Integer)

    The best practice ID that corresponds to this accessibility concern

  • element (String)

    The source code of the HTML node corresponding to this accessibility concern

  • fix_type (FixType)

    The remediation steps suggested by Access Engine for resolving this accessibility concern

  • needs_review (Boolean)

    Whether or not this accessibility concern requires manual review

  • raw_engine_json_object (Hash)

    The raw JSON object from Access Engine that was originally used to build this accessibility concern

  • best_practice_description (String)

    The name of the best practice that corresponds to this accessibility concern

  • severity (Integer)

    The severity of the best practice that corresponds to this accessibility concern

  • noticeability (Integer)

    The noticeability of the best practice that corresponds to this accessibility concern

  • tractability (Integer)

    The tractability of the best practice that corresponds to this accessibility concern

  • best_practice_details_url (String)

    The URL of the best practice page in AMP that corresponds to this accessibility concern

  • best_practice_standards (Array<Standard>)

    The array of accessibility standards associated with the best practice that corresponds to this accessibility concern



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'src/lib/continuum/accessibility_concern.rb', line 122

def initialize(path, engine_test_id, attribute, best_practice_id, element,
               fix_type, needs_review, raw_engine_json_object, best_practice_description,
               severity, noticeability, tractability, best_practice_details_url,
               best_practice_standards)
  @path = path
  @engine_test_id = engine_test_id
  @attribute = attribute
  @best_practice_id = best_practice_id
  @element = element
  @fix_type = fix_type
  @needs_review = needs_review
  @raw_engine_json_object = raw_engine_json_object
  @best_practice_description = best_practice_description
  @severity = severity
  @noticeability = noticeability
  @tractability = tractability
  @best_practice_details_url = best_practice_details_url
  @best_practice_standards = best_practice_standards
end

Instance Attribute Details

#attributeString

Gets a brief human-readable description of this accessibility concern. Visit the URL returned by #best_practice_details_url for more information.

Returns:

  • (String)

    A brief human-readable description of this accessibility concern



32
33
34
# File 'src/lib/continuum/accessibility_concern.rb', line 32

def attribute
  @attribute
end

#best_practice_descriptionString

Gets the name of the best practice that corresponds to this accessibility concern. Visit the URL returned by #best_practice_details_url for more information.

Returns:

  • (String)

    The name of the best practice that corresponds to this accessibility concern



72
73
74
# File 'src/lib/continuum/accessibility_concern.rb', line 72

def best_practice_description
  @best_practice_description
end

#best_practice_details_urlString

Gets the URL of the best practice page in AMP that corresponds to this accessibility concern. An AMP license is not required to visit this URL, but if you’re logged into AMP, you’ll be presented with additional information beyond what’s publicly available.

Returns:

  • (String)

    The URL of the best practice page in AMP that corresponds to this accessibility concern



97
98
99
# File 'src/lib/continuum/accessibility_concern.rb', line 97

def best_practice_details_url
  @best_practice_details_url
end

#best_practice_idInteger

Gets the best practice ID that corresponds to this accessibility concern. Visit the URL returned by #best_practice_details_url for more information.

Returns:

  • (Integer)

    The best practice ID that corresponds to this accessibility concern



38
39
40
# File 'src/lib/continuum/accessibility_concern.rb', line 38

def best_practice_id
  @best_practice_id
end

#best_practice_standardsArray<Standard>

Gets the set of accessibility standards associated with the best practice that corresponds to this accessibility concern, ordered alphabetically by name. Visit the URL returned by #best_practice_details_url for more information.

Returns:

  • (Array<Standard>)

    The set of accessibility standards associated with the best practice that corresponds to this accessibility concern



105
106
107
# File 'src/lib/continuum/accessibility_concern.rb', line 105

def best_practice_standards
  @best_practice_standards
end

#elementString?

Gets the source code of the offending HTML node of this accessibility concern. If the presence of an offending element is not applicable to this accessibility concern, this will be nil.

Returns:

  • (String, nil)

    The source code of the offending HTML node of this accessibility concern



44
45
46
# File 'src/lib/continuum/accessibility_concern.rb', line 44

def element
  @element
end

#engine_test_idInteger

Gets the automatic Access Engine test ID that failed and produced this accessibility concern. Visit the URL returned by #best_practice_details_url for more information.

Returns:

  • (Integer)

    The automatic Access Engine test ID that failed and produced this accessibility concern



26
27
28
# File 'src/lib/continuum/accessibility_concern.rb', line 26

def engine_test_id
  @engine_test_id
end

#fix_typeFixType

Gets the remediation steps suggested by Access Engine for resolving this accessibility concern.

Returns:

  • (FixType)

    The remediation steps suggested by Access Engine for resolving this accessibility concern



49
50
51
# File 'src/lib/continuum/accessibility_concern.rb', line 49

def fix_type
  @fix_type
end

#needs_reviewBoolean

Gets whether or not this accessibility concern requires manual review, i.e. whether the user should manually use AMP to determine whether or not this accessibility concern is actually a legitimate violation given the context of the offending element (See #element). If this returns true, visit the URL returned by #best_practice_details_url for more information on how to manually validate the applicability of this accessibility concern relative to the offending element (#element); it may be that this accessibility concern is not applicable given this context. Accessibility concerns that require manual review will only ever be returned (and thus this function will only ever possibly return false for a given accessibility concern) if Configuration#include_potential_accessibility_concerns returns true.

Returns:

  • (Boolean)

    Whether or not this accessibility concern requires manual review



61
62
63
# File 'src/lib/continuum/accessibility_concern.rb', line 61

def needs_review
  @needs_review
end

#noticeabilityInteger

Gets the noticeability of this accessibility concern on a scale of 1 to 10, where 1 is the least noticeable and 10 is the most noticeable. Visit the URL returned by #best_practice_details_url for more information.

Returns:

  • (Integer)

    The noticeability of the best practice that corresponds to this accessibility concern



84
85
86
# File 'src/lib/continuum/accessibility_concern.rb', line 84

def noticeability
  @noticeability
end

#pathString

Gets a CSS selector to the element with this accessibility concern.

Returns:

  • (String)

    A CSS selector to the element with this accessibility concern



20
21
22
# File 'src/lib/continuum/accessibility_concern.rb', line 20

def path
  @path
end

#raw_engine_json_objectHash

Gets the raw JSON object from Access Engine that was originally used to build this accessibility concern.

Returns:

  • (Hash)

    The raw JSON object from Access Engine that was originally used to build this accessibility concern



66
67
68
# File 'src/lib/continuum/accessibility_concern.rb', line 66

def raw_engine_json_object
  @raw_engine_json_object
end

#severityInteger

Gets the severity of this accessibility concern on a scale of 1 to 10, where 1 is the least severe and 10 is the most severe. Visit the URL returned by #best_practice_details_url for more information.

Returns:

  • (Integer)

    The severity of the best practice that corresponds to this accessibility concern



78
79
80
# File 'src/lib/continuum/accessibility_concern.rb', line 78

def severity
  @severity
end

#tractabilityInteger

Gets the tractability of this accessibility concern on a scale of 1 to 10, where 1 is the least tractable and 10 is the most tractable. Visit the URL returned by #best_practice_details_url for more information.

Returns:

  • (Integer)

    The tractability of the best practice that corresponds to this accessibility concern



90
91
92
# File 'src/lib/continuum/accessibility_concern.rb', line 90

def tractability
  @tractability
end

Class Method Details

.from_json(json_data) ⇒ AccessibilityConcern

Parameters:

  • json_data (String, Hash)

Returns:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'src/lib/continuum/accessibility_concern.rb', line 144

def self.from_json(json_data)
  parsed = DataUtil.parse_json(json_data) || {}

  return new(
    parsed['path'],
    parsed['engineTestId'].to_i,
    parsed['attribute'],
    parsed['bestPracticeId'].to_i,
    parsed['element'],
    FixType.from_json(parsed['fixType']),
    parsed['needsReview'],
    parsed['rawEngineJsonObject'],
    parsed['bestPracticeDescription'],
    parsed['severity'].to_i,
    parsed['noticeability'].to_i,
    parsed['tractability'].to_i,
    parsed['bestPracticeDetailsUrl'],
    parsed['bestPracticeStandards'].nil? ? nil : parsed['bestPracticeStandards'].map { |standard| Standard.from_json(standard) }
  )
end