Module: BBC::A11y::Configuration

Defined in:
lib/bbc/a11y/configuration.rb

Defined Under Namespace

Classes: DSL, PageDSL, PageSettings, Settings

Constant Summary collapse

MissingConfigurationFileError =
Class.new(StandardError) do
  def message
    "Missing configuration file (a11y.rb).\n\n" +
    "Please visit http://www.rubydoc.info/gems/bbc-a11y " +
    "for more information."
  end
end
ParseError =
Class.new(StandardError) do
  def message
     file, line = backtrace.first.split(":")[0..1]
     file = Pathname.new(file).relative_path_from(Pathname.new(Dir.pwd))
     line = line.to_i
     source_snippet = File.read(file).lines.each_with_index.map { |content, index|
       indent = (index == line - 1) ? "=> " : "   "
       indent + content
     }[line - 2..line]

     [
       "There was an error reading your configuration file at line #{line} of '#{file}'",
       "",
       source_snippet,
       "",
       super,
       "",
       "For help learning the configuration DSL, please visit https://github.com/cucumber-ltd/bbc-a11y"
     ]
  end
end

Class Method Summary collapse

Class Method Details

.for_urls(urls) ⇒ Object



22
23
24
25
# File 'lib/bbc/a11y/configuration.rb', line 22

def self.for_urls(urls)
  page_settings = urls.map { |url| PageSettings.new(url) }
  Settings.new.with_pages(page_settings)
end

.parse(filename) ⇒ Object



18
19
20
# File 'lib/bbc/a11y/configuration.rb', line 18

def self.parse(filename)
  BBC::A11y.configure_from_file(filename)
end