Sha256: 27d4a1aeef68dadb1d36d5edd419441d99b8bcf356a366554025cadca8e85e23

Contents?: true

Size: 1.57 KB

Versions: 155

Compression:

Stored size: 1.57 KB

Contents

require "forwardable"
require "json"
require_relative "../../chain_mail/chainable"
require_relative "../core"
require_relative "./audit"
require_relative "./context"
require_relative "./options"
require_relative "./results"

module Axe
  module API
    class A11yCheck
      JS_NAME = "run"
      METHOD_NAME = "#{Core::JS_NAME}.#{JS_NAME}"

      extend Forwardable
      def_delegators :@context,
                     :within,
                     :excluding
      def_delegators :@options,
                     :according_to,
                     :checking,
                     :checking_only,
                     :skipping,
                     :with_options

      extend ChainMail::Chainable
      chainable :within,
                :excluding,
                :according_to,
                :checking,
                :checking_only,
                :skipping,
                :with_options

      def initialize
        @context = Context.new
        @options = Options.new
      end

      def call(page)
        audit page do |results|
          Audit.new to_js, Results.new(results)
        end
      end

      extend Gem::Deprecate
      deprecate :initialize, "3.0"
      deprecate :call, "3.0"

      private

      def audit(page)
        yield page.execute_async_script "#{METHOD_NAME}.apply(#{Core::JS_NAME}, arguments)", *js_args
      end

      def js_args
        [@context, @options]
          .reject(&:empty?)
          .map(&:to_json)
      end

      def to_js
        str_args = (js_args + ["callback"]).join(", ")
        "#{METHOD_NAME}(#{str_args});"
      end
    end
  end
end

Version data entries

155 entries across 155 versions & 1 rubygems

Version Path
axe-core-api-4.10.1.pre.5294583 lib/axe/api/a11y_check.rb
axe-core-api-4.10.2 lib/axe/api/a11y_check.rb
axe-core-api-4.10.2.pre.2cca230 lib/axe/api/a11y_check.rb
axe-core-api-4.10.1.pre.46a0052 lib/axe/api/a11y_check.rb
axe-core-api-4.10.1.pre.7e72b19 lib/axe/api/a11y_check.rb
axe-core-api-4.10.1.pre.5e15f96 lib/axe/api/a11y_check.rb
axe-core-api-4.10.2.pre.5bd4e5c lib/axe/api/a11y_check.rb
axe-core-api-4.10.1.pre.7bf959f lib/axe/api/a11y_check.rb
axe-core-api-4.10.1 lib/axe/api/a11y_check.rb
axe-core-api-4.10.0.pre.53569f6 lib/axe/api/a11y_check.rb
axe-core-api-4.10.1.pre.7a3723a lib/axe/api/a11y_check.rb
axe-core-api-4.10.0.pre.d102edb lib/axe/api/a11y_check.rb
axe-core-api-4.9.1.pre.7a03090 lib/axe/api/a11y_check.rb
axe-core-api-4.9.1.pre.1a5838a lib/axe/api/a11y_check.rb
axe-core-api-4.10.0 lib/axe/api/a11y_check.rb
axe-core-api-4.10.0.pre.5d7eac5 lib/axe/api/a11y_check.rb
axe-core-api-4.9.1.pre.f16172e lib/axe/api/a11y_check.rb
axe-core-api-4.9.1.pre.09e659e lib/axe/api/a11y_check.rb
axe-core-api-4.9.1.pre.a80eeee lib/axe/api/a11y_check.rb
axe-core-api-4.9.0.pre.a02013a lib/axe/api/a11y_check.rb