Class: HTMLCS

Inherits:
Object
  • Object
show all
Defined in:
lib/html_cs_run_parse.rb

Overview

this gem is specifically for running HTMLCS

Class Method Summary collapse

Class Method Details

.compile_html_cs(data_location) ⇒ Object



35
36
37
38
# File 'lib/html_cs_run_parse.rb', line 35

def self.compile_html_cs(data_location)
  exec = Execution.new
  exec.build(data_location)
end

.create_empty_directories(root_directory_name) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/html_cs_run_parse.rb', line 18

def self.create_empty_directories(root_directory_name)
  html_input_location = root_directory_name + "/input"
  html_output_location = root_directory_name + "/output"
  html_file_location = root_directory_name + "/output/files"
  if Dir.exist?(html_input_location) == false
    Dir.mkdir(html_input_location)
    Dir.mkdir(html_output_location)
    Dir.mkdir(html_file_location)
  end
  [html_input_location, html_output_location, html_file_location].each { |location|
    Dir.glob("#{location}/**").each { |file|
      if file.include?('.txt') || file.include?('.png') || file.include?('.html') || file.include?('.csv')
        File.delete(file)
      end
    } }
end

.run_html_cs(browser, file_name) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/html_cs_run_parse.rb', line 6

def self.run_html_cs(browser, file_name)
  browser.execute_script(File.read(File.expand_path("../HTMLCS.js", __FILE__)))
  browser.execute_script("HTMLCS_RUNNER.run('WCAG2AA')")
  output = browser.driver.manage.logs.get(:browser)
  parse = ParseMachine.new
  parse.htmlcs_parse(output, file_name)
  browser.screenshot.save "#{file_name}.png"
  File.open(file_name + ".txt", 'w+') { |file|
    file.print(browser.url)
  }
end