html_cs_run_parse 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/html_compilation/classes/builders/app_html.rb +62 -0
- data/lib/html_compilation/classes/builders/graph.rb +70 -0
- data/lib/html_compilation/classes/builders/html_builder.rb +27 -0
- data/lib/html_compilation/classes/builders/page_html.rb +91 -0
- data/lib/html_compilation/classes/builders/row_html.rb +13 -0
- data/lib/html_compilation/classes/objects/app.rb +28 -0
- data/lib/html_compilation/classes/objects/base_object.rb +12 -0
- data/lib/html_compilation/classes/objects/page.rb +99 -0
- data/lib/html_compilation/classes/objects/row.rb +22 -0
- data/lib/html_compilation/classes/setup/conditioning.rb +23 -0
- data/lib/html_compilation/classes/setup/output_generation.rb +21 -0
- data/lib/html_compilation/classes/setup/retrieval.rb +90 -0
- data/lib/html_compilation/classes/setup/setup.rb +83 -0
- data/lib/html_compilation/classes/struct_classes/score_collection.rb +33 -0
- data/lib/html_compilation/classes/struct_classes/suppressed_page_rules.rb +8 -0
- data/lib/html_compilation/data/html_data/app_data.yaml +39 -0
- data/lib/html_compilation/data/html_data/page_data.yaml +37 -0
- data/lib/html_compilation/data/html_data/row_data.yaml +4 -0
- data/lib/html_compilation/data/html_data/style_script.yaml +167 -0
- data/lib/html_compilation/modules/image_interaction.rb +14 -0
- data/lib/html_compilation/modules/yaml_interaction.rb +26 -0
- data/lib/html_cs_run_parse.rb +6 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75f61290e75acd7df13f3363cf932e53f8db0a5f9b0dccd0160941ad2f65d4ad
|
4
|
+
data.tar.gz: af6678fafe7699aa40ef7d84a7fb37e070891169dbfae67ff3a18f8e06e008a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85a11b4d7dd079f785532d1927bfc7e1fbcdb16cb80d163e039e184c8487e5ac61229ad826c9775977117c8b5184def079afea1ac3f9cd4d84fcfcd905b7f20e
|
7
|
+
data.tar.gz: db47675fa6cbb476b86c65293bfcf6f91e96067cfc4714975161d3651d71ceaa054c0746f58bf796a5e02e3670ac23aac6ae192b5f58d6ed0677df07f922d213
|
@@ -0,0 +1,62 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'page_html'
|
3
|
+
class AppHTML < HTML
|
4
|
+
attr_accessor(:pages)
|
5
|
+
def initialize(object)
|
6
|
+
self.send("data_location=", File.expand_path("../../../data/html_data/app_data.yaml", __FILE__))
|
7
|
+
self.send("pages=", object.pages)
|
8
|
+
super(object)
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
#build the adr section
|
13
|
+
adr = read_yaml(data_location, "APPLICATION_DATA_ROW")
|
14
|
+
score = object.calculate_app_score
|
15
|
+
errors = object.calculate_total_errors
|
16
|
+
page_number = object.pages.length
|
17
|
+
adrs = [score, errors, page_number].map do |section|
|
18
|
+
adr.gsub('sample', section.to_s)
|
19
|
+
end.join
|
20
|
+
|
21
|
+
#build the ADS Section
|
22
|
+
ads = read_yaml(data_location, "APPLICATION_DATA_SECTION")
|
23
|
+
ads.gsub!("sample", adrs)
|
24
|
+
|
25
|
+
#build the AOTS Section
|
26
|
+
aots = read_yaml(data_location, "APPLICATION_OVERVIEW_TABLE_SECTION")
|
27
|
+
aots.gsub!("sample", ads)
|
28
|
+
|
29
|
+
#build the CI section
|
30
|
+
ci = read_yaml(data_location, "CHART_IMAGE")
|
31
|
+
|
32
|
+
#build the AOS section
|
33
|
+
aos = read_yaml(data_location, "APPLICATION_OVERVIEW_SECTION")
|
34
|
+
aos.gsub!("sample", aots + ci)
|
35
|
+
|
36
|
+
#building the page sections
|
37
|
+
page_rows = object.pages.map do |page|
|
38
|
+
PageHTML.new(page).build
|
39
|
+
end.join
|
40
|
+
|
41
|
+
#build the HB section
|
42
|
+
hb = read_yaml(data_location, "HTML_BODY")
|
43
|
+
hb.gsub!("sample", aos + page_rows)
|
44
|
+
|
45
|
+
#build the app section
|
46
|
+
ats = read_yaml(data_location, "APPLICATION_TITLE_SECTION")
|
47
|
+
ats.gsub!('sample', object.application_name + " utilizing: " + object.env)
|
48
|
+
|
49
|
+
#build the html section
|
50
|
+
html = read_yaml(data_location, "HTML")
|
51
|
+
html.gsub!("sample", ats + hb)
|
52
|
+
|
53
|
+
#add the style sheet to the beginning
|
54
|
+
ssloc = File.expand_path("../../../data/html_data/style_script.yaml", __FILE__)
|
55
|
+
style = read_yaml(ssloc, "STYLE")
|
56
|
+
html = style + html
|
57
|
+
|
58
|
+
#add the script to the end
|
59
|
+
script = read_yaml(ssloc, "SCRIPT")
|
60
|
+
html = html + script
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../../modules'
|
2
|
+
require 'yaml_interaction'
|
3
|
+
require 'gchart'
|
4
|
+
|
5
|
+
class Graph
|
6
|
+
attr_accessor(:chart)
|
7
|
+
include YAMLInteraction
|
8
|
+
attr_reader(:graph_length)
|
9
|
+
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@graph_length = 30
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate_graph(app_object, ddl = "./data")
|
16
|
+
gs = "/graph_scores.yaml"
|
17
|
+
app = app_object.application_name.upcase.tr(' ', '_')
|
18
|
+
score = app_object.calculate_app_score
|
19
|
+
update_yaml(app, score, ddl + gs)
|
20
|
+
values = array_slicer(read_yaml(ddl + gs, app).split(',').map(&:to_i))
|
21
|
+
max = values.sort.last.to_i
|
22
|
+
split = (max / 5).to_i
|
23
|
+
value = 0
|
24
|
+
string = '0|'
|
25
|
+
values.length > graph_length ? end_range = graph_length : end_range = values.length
|
26
|
+
4.times {value += split; string += value.to_s + '|'}
|
27
|
+
self.send("chart=", Gchart.new({:type => 'bar',
|
28
|
+
:data => values,
|
29
|
+
:axis_with_labels => 'x,y',
|
30
|
+
:axis_labels => [(1..end_range).to_a.reverse, string],
|
31
|
+
:axis_range => [nil, [0, max]],
|
32
|
+
:title => "#{app.downcase.tr('_', ' ')} #{app_object.env}",
|
33
|
+
:legend => ['total score'],
|
34
|
+
:bg => {:color => 'white', :type => 'solid'},
|
35
|
+
:bar_colors => 'ADEFD1FF', :size => '1000x200',
|
36
|
+
:filename => "#{ddl}/output/files/chart.png"}))
|
37
|
+
end
|
38
|
+
|
39
|
+
def populate_graph
|
40
|
+
chart.file
|
41
|
+
end
|
42
|
+
|
43
|
+
def array_slicer(values)
|
44
|
+
if values.length > graph_length
|
45
|
+
output = values[((values.length - 1) - (graph_length - 1))..(values.length - 1)]
|
46
|
+
else
|
47
|
+
output = values
|
48
|
+
end
|
49
|
+
output
|
50
|
+
end
|
51
|
+
|
52
|
+
def update_yaml(app, score, dl)
|
53
|
+
app_up = app.upcase.tr(' ', '_')
|
54
|
+
if !app_listed(app_up, dl)
|
55
|
+
key_value_add(dl, app_up, score.to_s)
|
56
|
+
else
|
57
|
+
cur_val = read_yaml(dl, app_up)
|
58
|
+
key_value_add(dl, app_up, cur_val + "," + score.to_s)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def app_listed(app, dl)
|
63
|
+
if read_yaml(dl, app) != nil
|
64
|
+
true
|
65
|
+
else
|
66
|
+
false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../../modules'
|
2
|
+
require 'yaml_interaction'
|
3
|
+
|
4
|
+
class HTML
|
5
|
+
attr_accessor(:data_location, :object)
|
6
|
+
include YAMLInteraction
|
7
|
+
|
8
|
+
def initialize(object)
|
9
|
+
@object = object
|
10
|
+
end
|
11
|
+
|
12
|
+
def htmlify(string)
|
13
|
+
subs = {"&" => "&", '<' => "<", '>' => ">"}
|
14
|
+
subs.each do |key, value|
|
15
|
+
if string.to_s.include?(key)
|
16
|
+
begin
|
17
|
+
string.gsub!(key, value)
|
18
|
+
rescue NoMethodError => e
|
19
|
+
print e.message
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
string
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,91 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'row_html'
|
3
|
+
class PageHTML < HTML
|
4
|
+
attr_accessor(:rows)
|
5
|
+
def initialize(object)
|
6
|
+
self.send("data_location=", File.expand_path("../../../data/html_data/page_data.yaml", __FILE__))
|
7
|
+
self.send("rows=", object.rows)
|
8
|
+
super(object)
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
#populate warning headers
|
13
|
+
row_headers = warning_header_gen
|
14
|
+
|
15
|
+
#populate list of warning from the row
|
16
|
+
row_content = rows.map do |row|
|
17
|
+
rhtml = RowHTML.new(row)
|
18
|
+
rhtml.build
|
19
|
+
end.join
|
20
|
+
|
21
|
+
#populate the warning list area as a whole.
|
22
|
+
warn_list = read_yaml(data_location, "WARNING_LIST_AREA")
|
23
|
+
warn_list.gsub!('header_sample', row_headers)
|
24
|
+
warn_list.gsub!('rows_sample', row_content)
|
25
|
+
|
26
|
+
#generate the page info section
|
27
|
+
page_info = read_yaml(data_location, "PAGE_INFO")
|
28
|
+
url = gen_url_section
|
29
|
+
image = gen_image_section
|
30
|
+
sup_rule_area = gen_sup_rules_area
|
31
|
+
page_info.gsub!('sample', url + image + sup_rule_area)
|
32
|
+
|
33
|
+
#generate the content section which combines page_info and warn_list
|
34
|
+
content = read_yaml(data_location, "CONTENT")
|
35
|
+
content.gsub!('sample', page_info + warn_list)
|
36
|
+
|
37
|
+
#generate the collapsible_button_section
|
38
|
+
cb = read_yaml(data_location, "COLLAPSIBLE_BUTTON")
|
39
|
+
cb.gsub!("Sample Page Name", object.page)
|
40
|
+
cb.gsub!("sample total number of errors", object.rows.length.to_s)
|
41
|
+
cb.gsub!("sample page score", object.score.to_s)
|
42
|
+
|
43
|
+
#generate the whole page content section
|
44
|
+
cls = read_yaml(data_location, "COLLAPSIBLE_LIST_SECTION")
|
45
|
+
cls.gsub!("sample", cb + content)
|
46
|
+
|
47
|
+
cls
|
48
|
+
end
|
49
|
+
|
50
|
+
def warning_header_gen
|
51
|
+
headers = read_yaml(data_location, "WARNING_LIST_HEADERS")
|
52
|
+
output = rows[0].values.map do |key|
|
53
|
+
headers.gsub("sample", key)
|
54
|
+
end
|
55
|
+
output.push(headers.gsub("sample", "instances"))
|
56
|
+
output.join.to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
def gen_image_section
|
60
|
+
if object.image != nil
|
61
|
+
html = read_yaml(data_location, "PAGE_IMAGE")
|
62
|
+
output = html.gsub("sample", htmlify(object.page))
|
63
|
+
else
|
64
|
+
output = ""
|
65
|
+
end
|
66
|
+
output
|
67
|
+
end
|
68
|
+
|
69
|
+
def gen_url_section
|
70
|
+
if object.url != nil
|
71
|
+
html = read_yaml(data_location, "PAGE_URL")
|
72
|
+
output = html.gsub("sample", htmlify(object.url))
|
73
|
+
else
|
74
|
+
output = ""
|
75
|
+
end
|
76
|
+
output
|
77
|
+
end
|
78
|
+
|
79
|
+
def gen_sup_rules_area
|
80
|
+
if object.page_suppressed_rules != nil
|
81
|
+
table_value = read_yaml(data_location, "PAGE_SUPPRESSED_RULES_TABLE_VALUES")
|
82
|
+
psr = object.page_suppressed_rules.map do |rule|
|
83
|
+
table_value.gsub("sample","<strong>Guideline: </strong>" + htmlify(rule.guideline) + "<strong> Content: </strong>" + htmlify(rule.content))
|
84
|
+
end
|
85
|
+
output = read_yaml(data_location, "PAGE_SUPPRESSED_RULES_AREA").gsub("sample", psr.join.to_s)
|
86
|
+
else
|
87
|
+
output = ""
|
88
|
+
end
|
89
|
+
output
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class RowHTML < HTML
|
2
|
+
def build
|
3
|
+
self.send("data_location=", File.expand_path("../../../data/html_data/row_data.yaml", __FILE__))
|
4
|
+
row = read_yaml(data_location, "TR")
|
5
|
+
data_cell = read_yaml(data_location, "TD")
|
6
|
+
cells = object.values.map do |key|
|
7
|
+
data_cell.gsub("sample", (htmlify(object.send(key)).to_s))
|
8
|
+
end
|
9
|
+
cells.push(data_cell.gsub("sample", htmlify(object.instances.to_i.to_s)))
|
10
|
+
row.gsub("sample", cells.join.to_s)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'base_object'
|
3
|
+
class Application < BaseObject
|
4
|
+
attr_accessor(:values, :application_name, :pages, :graph, :env)
|
5
|
+
|
6
|
+
def calculate_app_score
|
7
|
+
counter = 0
|
8
|
+
pages.each do |page|
|
9
|
+
counter += page.score
|
10
|
+
end
|
11
|
+
counter
|
12
|
+
end
|
13
|
+
|
14
|
+
def calculate_total_errors
|
15
|
+
counter = 0
|
16
|
+
pages.each do |page|
|
17
|
+
counter += page.rows.length
|
18
|
+
end
|
19
|
+
counter
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_duplicates
|
23
|
+
pages.reverse.each do |page|
|
24
|
+
page.remove_duplicates(self)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
$:.unshift File.dirname(__FILE__) + '/../../modules'
|
3
|
+
$:.unshift File.dirname(__FILE__) + '/../struct_classes'
|
4
|
+
require 'base_object'
|
5
|
+
require 'yaml_interaction'
|
6
|
+
require 'suppressed_page_rules'
|
7
|
+
class Page < BaseObject
|
8
|
+
include YAMLInteraction
|
9
|
+
attr_accessor(:page, :url, :image, :rows, :values, :page_suppressed_rules, :app, :score)
|
10
|
+
|
11
|
+
def access_spr(df_yaml_loc = "./data/suppressed_rules.yaml")
|
12
|
+
yaml = read_yaml(df_yaml_loc, app.application_name)
|
13
|
+
output = []
|
14
|
+
levels = ["GLOBAL", "APP", page.upcase.tr(' ', '_')]
|
15
|
+
yaml.each do |key, value|
|
16
|
+
if levels.include?(key)
|
17
|
+
value.each do |value|
|
18
|
+
hash = eval(value)
|
19
|
+
output.push(SuppressedPageRules.new(hash[:guideline], hash[:content]))
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
set_value("page_suppressed_rules", output)
|
25
|
+
page_suppressed_rules
|
26
|
+
end
|
27
|
+
|
28
|
+
def remove_suppressed_rows
|
29
|
+
page_suppressed_rules.each do |rule|
|
30
|
+
rows.delete_if do |row|
|
31
|
+
include_content?(row, rule)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def remove_duplicates(app)
|
37
|
+
remove_duplicate_rows_external(app, self)
|
38
|
+
remove_duplicate_rows_internal
|
39
|
+
end
|
40
|
+
|
41
|
+
def remove_duplicate_rows_external(app, page)
|
42
|
+
app.pages.each do |app_page|
|
43
|
+
unless (app_page == page)
|
44
|
+
app_page.rows.each do |app_row|
|
45
|
+
page.rows.delete_if do |row|
|
46
|
+
same = same_content?(app_row, row)
|
47
|
+
if same
|
48
|
+
app_row.send("instances=", app_row.instances.to_i + 1)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def remove_duplicate_rows_internal
|
57
|
+
duplicate_rows = rows.clone.keep_if do |row_a|
|
58
|
+
rows.each do |row_b|
|
59
|
+
if row_a == row_b
|
60
|
+
@same = false
|
61
|
+
else
|
62
|
+
@same = same_content?(row_b, row_a)
|
63
|
+
if @same
|
64
|
+
row_a.send("instances=", row_b.instances.to_f + 0.5)
|
65
|
+
row_b.send("instances=", row_a.instances.to_f + 0.5)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
@same
|
70
|
+
end
|
71
|
+
duplicate_rows.each do |duplicate_row|
|
72
|
+
rows.delete_if do |row|
|
73
|
+
duplicate_row == row
|
74
|
+
end
|
75
|
+
end
|
76
|
+
duplicate_rows
|
77
|
+
end
|
78
|
+
|
79
|
+
def calc_page_score
|
80
|
+
page_score = 0
|
81
|
+
rows.each do |row|
|
82
|
+
page_score += row.score
|
83
|
+
end
|
84
|
+
page_score
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def include_content?(base, comparison)
|
90
|
+
base.guideline.include?(comparison.guideline) && base.content.include?(comparison.content)
|
91
|
+
end
|
92
|
+
|
93
|
+
def same_content?(base, comparison)
|
94
|
+
base.guideline == comparison.guideline && base.content == comparison.content
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'base_object'
|
3
|
+
|
4
|
+
class Row < BaseObject
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
send("instances=", 1)
|
8
|
+
end
|
9
|
+
attr_accessor(:error_warning, :guideline, :error_description, :html_path, :content, :score, :values, :instances)
|
10
|
+
|
11
|
+
def calculate_score_value(collection_element)
|
12
|
+
dv = 1
|
13
|
+
collection_element.guidelines.each do |sg|
|
14
|
+
if guideline.include?(sg.guideline)
|
15
|
+
dv = sg.score
|
16
|
+
end
|
17
|
+
end
|
18
|
+
set_value("score", dv)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../builders'
|
2
|
+
require 'graph'
|
3
|
+
|
4
|
+
class Conditioning
|
5
|
+
def main_condition(app, skip_value = false, ddl = "./data")
|
6
|
+
app.pages.each do |page|
|
7
|
+
unless skip_value == 'suppressed_rows'
|
8
|
+
page.remove_suppressed_rows
|
9
|
+
end
|
10
|
+
unless skip_value == 'duplicates'
|
11
|
+
app.remove_duplicates
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
app.pages.each do |page|
|
16
|
+
page.set_value('score', page.calc_page_score)
|
17
|
+
end
|
18
|
+
|
19
|
+
gp = Graph.new
|
20
|
+
gp.generate_graph(app, ddl)
|
21
|
+
app.set_value("graph", gp)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../../modules'
|
2
|
+
$:.unshift File.dirname(__FILE__) + '/../builders'
|
3
|
+
require 'image_interaction'
|
4
|
+
require 'html_builder'
|
5
|
+
require 'page_html'
|
6
|
+
require 'app_html'
|
7
|
+
require 'row_html'
|
8
|
+
class OutputGeneration
|
9
|
+
include ImageInteraction
|
10
|
+
|
11
|
+
def initialize(app, ddl = "./data/output/files/")
|
12
|
+
app.graph.populate_graph
|
13
|
+
app.pages.each do |page|
|
14
|
+
place_image_content(ddl + page.page, page.image)
|
15
|
+
end
|
16
|
+
app_html = AppHTML.new(app)
|
17
|
+
html = app_html.build
|
18
|
+
place_image_content(ddl.split("files/")[0] + "pa11y_" + app.application_name + '_' + app.env, html, ".html")
|
19
|
+
#put html in the output folder need to remove files from ddl
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../../modules'
|
2
|
+
require 'image_interaction'
|
3
|
+
class Retrieval
|
4
|
+
include ImageInteraction
|
5
|
+
attr_accessor(:ddl)
|
6
|
+
|
7
|
+
def initialize(ddl)
|
8
|
+
@ddl = ddl
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve_csv_collection
|
12
|
+
output = []
|
13
|
+
file_locations = return_all_files(ddl, 'csv')
|
14
|
+
file_locations.each do |file_location|
|
15
|
+
t_output = []
|
16
|
+
File.open(file_location, 'r') { |file|
|
17
|
+
content = file.read
|
18
|
+
split = content.split("\n")
|
19
|
+
split.delete_at(0)
|
20
|
+
split.each do |row|
|
21
|
+
components = row.split(',')
|
22
|
+
csv_o = CSVObject.new(components[0].tr('"', ''), components[1], components[2], components[3], components[4])
|
23
|
+
t_output.push(csv_o)
|
24
|
+
end
|
25
|
+
output.push(t_output)
|
26
|
+
}
|
27
|
+
end
|
28
|
+
output
|
29
|
+
end
|
30
|
+
|
31
|
+
def retrieve_url_collection
|
32
|
+
output = []
|
33
|
+
file_locations = return_all_files(ddl, 'txt')
|
34
|
+
file_locations.each do |file_location|
|
35
|
+
File.open(file_location, 'r') { |file|
|
36
|
+
output.push(file.read) }
|
37
|
+
end
|
38
|
+
output
|
39
|
+
end
|
40
|
+
|
41
|
+
def retrieve_image_collection
|
42
|
+
output = []
|
43
|
+
file_locations = return_all_files(ddl, 'png')
|
44
|
+
file_locations.each do |file_location|
|
45
|
+
File.open(file_location, 'r') { |file|
|
46
|
+
output.push(retrieve_image_content(file)) }
|
47
|
+
end
|
48
|
+
output
|
49
|
+
end
|
50
|
+
|
51
|
+
def retrieve_app_name
|
52
|
+
file = return_all_files(ddl, 'csv')[0]
|
53
|
+
split = split_on_underscores(file)
|
54
|
+
split[0]
|
55
|
+
end
|
56
|
+
|
57
|
+
def retrieve_page_names
|
58
|
+
files = return_all_files(ddl, 'csv')
|
59
|
+
output = []
|
60
|
+
files.each do |file|
|
61
|
+
output.push(split_on_underscores(file)[1])
|
62
|
+
end
|
63
|
+
output
|
64
|
+
end
|
65
|
+
|
66
|
+
def retrieve_env
|
67
|
+
file = return_all_files(ddl, 'csv')[0]
|
68
|
+
split = split_on_underscores(file)
|
69
|
+
split[2].split('.')[0]
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def split_on_underscores(file)
|
75
|
+
file.split('/').last.split('_')
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
class CSVObject
|
81
|
+
attr_accessor(:error_warning, :guideline, :error_description, :html_path, :content)
|
82
|
+
|
83
|
+
def initialize(error_warning, guideline, error_description, content, html_path)
|
84
|
+
@error_warning = error_warning
|
85
|
+
@guideline = guideline
|
86
|
+
@error_description = error_description
|
87
|
+
@content = content
|
88
|
+
@html_path = html_path
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../struct_classes'
|
2
|
+
$:.unshift File.dirname(__FILE__) + '/../setup'
|
3
|
+
$:.unshift File.dirname(__FILE__) + '/../objects'
|
4
|
+
require 'score_collection'
|
5
|
+
require 'retrieval'
|
6
|
+
require 'page'
|
7
|
+
require 'row'
|
8
|
+
class Setup
|
9
|
+
attr_accessor(:csv_collection, :url_collection, :image_collection, :app_name, :page_name_collection, :env, :score_collection)
|
10
|
+
|
11
|
+
def initialize(file_location = "./data/input")
|
12
|
+
rt = Retrieval.new(file_location)
|
13
|
+
@csv_collection = rt.retrieve_csv_collection
|
14
|
+
@url_collection = rt.retrieve_url_collection
|
15
|
+
@image_collection = rt.retrieve_image_collection
|
16
|
+
@app_name = rt.retrieve_app_name
|
17
|
+
@page_name_collection = rt.retrieve_page_names
|
18
|
+
@env = rt.retrieve_env
|
19
|
+
end
|
20
|
+
|
21
|
+
def main_setup(app, file_prefix = "./data/")
|
22
|
+
app_initial_setup(app)
|
23
|
+
pages = page_initial_setup
|
24
|
+
app_additional_setup(app, pages)
|
25
|
+
pages.each_with_index do |page, index|
|
26
|
+
rows = row_initial_setup(index)
|
27
|
+
row_additional_setup(rows, file_prefix + "scores.yaml")
|
28
|
+
page_additional_setup(app, page, rows, file_prefix + "suppressed_rules.yaml")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def row_initial_setup(index)
|
33
|
+
output = []
|
34
|
+
@csv_collection[index].each do |csv|
|
35
|
+
@row = Row.new
|
36
|
+
@row.set_value("error_warning", csv.error_warning)
|
37
|
+
@row.set_value("guideline", csv.guideline)
|
38
|
+
@row.set_value("error_description", csv.error_description)
|
39
|
+
@row.set_value("html_path", csv.html_path)
|
40
|
+
@row.set_value("content", csv.content)
|
41
|
+
output.push(@row)
|
42
|
+
end
|
43
|
+
output
|
44
|
+
end
|
45
|
+
|
46
|
+
def app_initial_setup(app)
|
47
|
+
app.set_value("application_name", app_name)
|
48
|
+
app.set_value("env", env)
|
49
|
+
end
|
50
|
+
|
51
|
+
def page_initial_setup
|
52
|
+
counter = 0
|
53
|
+
output = page_name_collection.map do |page_name|
|
54
|
+
page = Page.new
|
55
|
+
page.set_value("page", page_name)
|
56
|
+
page.set_value("url", url_collection[counter])
|
57
|
+
page.set_value("image", image_collection[counter])
|
58
|
+
counter += 1
|
59
|
+
page
|
60
|
+
end
|
61
|
+
output
|
62
|
+
end
|
63
|
+
|
64
|
+
def row_additional_setup(rows, ddl = "./data/scores.yaml")
|
65
|
+
@score_collection = ScoreCollection.new(ddl)
|
66
|
+
rows.each do |row|
|
67
|
+
row.calculate_score_value(@score_collection)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def app_additional_setup(app, pages)
|
72
|
+
app.set_value("pages", pages)
|
73
|
+
end
|
74
|
+
|
75
|
+
def page_additional_setup(app, page, rows, psr_location = "./data/suppressed_rules.yaml")
|
76
|
+
page.set_value("rows", rows)
|
77
|
+
score = page.calc_page_score
|
78
|
+
page.set_value("score", score)
|
79
|
+
page.set_value("app", app)
|
80
|
+
page.access_spr(psr_location)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../../modules'
|
2
|
+
require 'yaml_interaction'
|
3
|
+
class ScoreCollection
|
4
|
+
include YAMLInteraction
|
5
|
+
attr_accessor(:guidelines)
|
6
|
+
|
7
|
+
def initialize(ddl="./data/scores.yaml")
|
8
|
+
send("guidelines=", get_guidelines(ddl))
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_guidelines(ddl)
|
12
|
+
output = []
|
13
|
+
collections = read_yaml(ddl, "GUIDELINES")
|
14
|
+
collections.each do |key, value|
|
15
|
+
score = read_yaml(ddl, "SCORES")[key]
|
16
|
+
value.each do |guideline|
|
17
|
+
temp = ScoreElement.new(key, score, guideline)
|
18
|
+
output.push(temp)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
output
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class ScoreElement
|
26
|
+
attr_accessor(:guideline, :score, :categorization)
|
27
|
+
|
28
|
+
def initialize(categorization, score, guideline)
|
29
|
+
send("guideline=", guideline)
|
30
|
+
send("categorization=", categorization)
|
31
|
+
send("score=", score)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
APPLICATION:
|
2
|
+
|
3
|
+
#includes everything
|
4
|
+
HTML: "<html>sample</html>"
|
5
|
+
|
6
|
+
# Style sheet goes here
|
7
|
+
|
8
|
+
#goes in HTML
|
9
|
+
APPLICATION_TITLE_SECTION: "<h1 id=\"page_header\">sample</h1>"
|
10
|
+
|
11
|
+
#goes in HTML, holds all other content. including page content
|
12
|
+
HTML_BODY: "<body id=\"whole body\">sample</body>"
|
13
|
+
|
14
|
+
#goes in HTML body
|
15
|
+
APPLICATION_OVERVIEW_SECTION: "<div id=\"application_overview_section\">sample</div>"
|
16
|
+
|
17
|
+
#goes in application overview section
|
18
|
+
CHART_IMAGE: '<img src=".\files\chart.png" alt="tracking chart" id="chart_image">'
|
19
|
+
|
20
|
+
#goes in application overview section
|
21
|
+
APPLICATION_OVERVIEW_TABLE_SECTION: "<div id=\"application_overview_table_section\">sample</div>"
|
22
|
+
|
23
|
+
#goes in application overview table section
|
24
|
+
APPLICATION_DATA_SECTION: "<table id=\"application_overview_information_table\">
|
25
|
+
<tbody id=\"application_overview_information_table_body\">
|
26
|
+
<tr>
|
27
|
+
<th>Application Score</th>
|
28
|
+
<th>Number of Errors</th>
|
29
|
+
<th>Number of Pages</th>
|
30
|
+
</tr>
|
31
|
+
|
32
|
+
sample
|
33
|
+
|
34
|
+
</tbody>
|
35
|
+
</table>"
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
APPLICATION_DATA_ROW: "<td>sample</td>"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
##OPTIONAL VALUES
|
2
|
+
PAGE_IMAGE: '<img src=".\files\sample.png" class="content_image">'
|
3
|
+
PAGE_URL: "<h1 class=\"url-for-page\">URL: sample</h1>"
|
4
|
+
PAGE_SUPPRESSED_RULES_AREA: "<table class=\"page_suppressed_rules_table\">
|
5
|
+
<tbody class=\"page_suppressed_rules_table_body\">
|
6
|
+
<tr>
|
7
|
+
<th><strong>Suppressed Page Rules</strong></th>
|
8
|
+
</tr>
|
9
|
+
sample
|
10
|
+
</tbody> </table>"
|
11
|
+
PAGE_SUPPRESSED_RULES_TABLE_VALUES: "<tr><td>sample</td></tr>"
|
12
|
+
|
13
|
+
|
14
|
+
##LIST SECTION
|
15
|
+
COLLAPSIBLE_LIST_SECTION: "<div class=\"collapsible-list\">sample</div>"
|
16
|
+
COLLAPSIBLE_BUTTON: "<button class=\"collapsible\">
|
17
|
+
<Strong>Sample Page Name</Strong>
|
18
|
+
<strong>Total Number of Errors = </strong> sample total number of errors
|
19
|
+
<strong>Page Score = </strong>sample page score
|
20
|
+
</button>"
|
21
|
+
|
22
|
+
|
23
|
+
CONTENT: "<div class=\"content\"> sample </div>"
|
24
|
+
PAGE_INFO: "<div class=\"content_image_and_suppressed_rules_area\"> sample </div>"
|
25
|
+
|
26
|
+
WARNING_LIST_AREA: "<div class=\"warning_list_area_div\">
|
27
|
+
<table class=\"warning_list_item_table\">
|
28
|
+
<tbody class=\"warning_list_table_body\">
|
29
|
+
<tr>
|
30
|
+
header_sample
|
31
|
+
</tr>
|
32
|
+
rows_sample
|
33
|
+
</tbody>
|
34
|
+
</table>
|
35
|
+
</div>"
|
36
|
+
|
37
|
+
WARNING_LIST_HEADERS: "<th>sample</th>"
|
@@ -0,0 +1,167 @@
|
|
1
|
+
SCRIPT: "<script>
|
2
|
+
var coll = document.getElementsByClassName(\"collapsible\");
|
3
|
+
var i;
|
4
|
+
|
5
|
+
for (i = 0; i < coll.length; i++) {
|
6
|
+
coll[i].addEventListener(\"click\", function () {
|
7
|
+
this.classList.toggle(\"active\");
|
8
|
+
var content = this.nextElementSibling;
|
9
|
+
if (content.style.display === \"block\") {
|
10
|
+
content.style.display = \"none\";
|
11
|
+
} else {
|
12
|
+
content.style.display = \"block\";
|
13
|
+
}
|
14
|
+
});
|
15
|
+
}
|
16
|
+
|
17
|
+
</script>"
|
18
|
+
|
19
|
+
STYLE: "<style>
|
20
|
+
/*page header section*/
|
21
|
+
#page_header {
|
22
|
+
display: block;
|
23
|
+
text-align: center;
|
24
|
+
font-family: Apex New Bold, sans-serif;
|
25
|
+
font-weight: bold
|
26
|
+
}
|
27
|
+
|
28
|
+
/*application overview section*/
|
29
|
+
#application_overview_section {
|
30
|
+
display: block;
|
31
|
+
padding-top: 10px
|
32
|
+
}
|
33
|
+
|
34
|
+
#chart_image {
|
35
|
+
margin-left: auto;
|
36
|
+
margin-right: auto;
|
37
|
+
display: inline-block;
|
38
|
+
width: 47%;
|
39
|
+
padding-bottom: 10px
|
40
|
+
}
|
41
|
+
|
42
|
+
#application_overview_table_section {
|
43
|
+
display: inline;
|
44
|
+
margin-bottom: 10px;
|
45
|
+
font-family: Apex New Bold, sans-serif;
|
46
|
+
}
|
47
|
+
|
48
|
+
#suppressed_application_errors_table {
|
49
|
+
border-color: #5ba63c;
|
50
|
+
display: inline-block;
|
51
|
+
padding-top: 10px;
|
52
|
+
width: 49%;
|
53
|
+
vertical-align: top;
|
54
|
+
}
|
55
|
+
|
56
|
+
#suppressed_application_errors_table_body {
|
57
|
+
display: block;
|
58
|
+
overflow-y: scroll;
|
59
|
+
height: 70px
|
60
|
+
}
|
61
|
+
|
62
|
+
#application_overview_information_table {
|
63
|
+
display: inline-block;
|
64
|
+
border-color: #5ba63c;
|
65
|
+
padding-top: 10px;
|
66
|
+
width: 49%;
|
67
|
+
vertical-align: top;
|
68
|
+
}
|
69
|
+
|
70
|
+
#application_overview_information_table_body {
|
71
|
+
display: inline-block;
|
72
|
+
height: 70px;
|
73
|
+
}
|
74
|
+
/*Collapsible Section*/
|
75
|
+
.collapsible {
|
76
|
+
background-color: #ffffff;
|
77
|
+
color: black;
|
78
|
+
cursor: pointer;
|
79
|
+
padding: 18px;
|
80
|
+
width: 100%;
|
81
|
+
text-align: left;
|
82
|
+
outline: none;
|
83
|
+
font-size: 15px;
|
84
|
+
font-family: Apex New Bold, sans-serif;
|
85
|
+
}
|
86
|
+
|
87
|
+
.active, .collapsible:hover {
|
88
|
+
background-color: #ADEFD1FF;
|
89
|
+
}
|
90
|
+
|
91
|
+
.collapsible-list {
|
92
|
+
position: static;
|
93
|
+
font-family: Apex New Bold, sans-serif;
|
94
|
+
border-color: #F0EAD6;
|
95
|
+
border-style: solid;
|
96
|
+
border-width: thick;
|
97
|
+
border-collapse: collapse;
|
98
|
+
}
|
99
|
+
/*Collapsible Content Section*/
|
100
|
+
.content {
|
101
|
+
padding: 18px;
|
102
|
+
display: none;
|
103
|
+
overflow: hidden;
|
104
|
+
background-color: #F0EAD6;
|
105
|
+
}
|
106
|
+
/*Collapsible Content image and suppressed rules Section*/
|
107
|
+
.content_image_and_suppressed_rules_area {
|
108
|
+
width: 100%;
|
109
|
+
display: block;
|
110
|
+
}
|
111
|
+
|
112
|
+
.url-for-page {
|
113
|
+
font-size: 18px;
|
114
|
+
font-family: Apex New Bold, sans-serif;
|
115
|
+
}
|
116
|
+
|
117
|
+
.content_image {
|
118
|
+
display: inline-block;
|
119
|
+
margin-left: auto;
|
120
|
+
margin-right: auto;
|
121
|
+
width: 100%;
|
122
|
+
}
|
123
|
+
|
124
|
+
.page_suppressed_rules_table {
|
125
|
+
display: inline-block;
|
126
|
+
vertical-align: top;
|
127
|
+
border-collapse: collapse;
|
128
|
+
padding-left: 1%;
|
129
|
+
width: 50%
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
.page_suppressed_rules_table_body {
|
134
|
+
display: block;
|
135
|
+
width: 100%
|
136
|
+
}
|
137
|
+
|
138
|
+
.warning_list_area_div {
|
139
|
+
display: block;
|
140
|
+
width: 100%;
|
141
|
+
overflow-x: scroll;
|
142
|
+
}
|
143
|
+
|
144
|
+
.warning_list_table_body {
|
145
|
+
display: block;
|
146
|
+
border-collapse: collapse;
|
147
|
+
|
148
|
+
}
|
149
|
+
|
150
|
+
.warning_list_item_table {
|
151
|
+
table-layout:fixed;
|
152
|
+
}
|
153
|
+
|
154
|
+
|
155
|
+
.warning_list_table_body > tr {
|
156
|
+
border-style: solid;
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
.warning_list_table_body > tr > td {
|
161
|
+
border-style: solid;}
|
162
|
+
|
163
|
+
|
164
|
+
</style>"
|
165
|
+
|
166
|
+
|
167
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ImageInteraction
|
2
|
+
#wonkavision
|
3
|
+
def retrieve_image_content(file_location)
|
4
|
+
File.read(file_location, mode: "rb")
|
5
|
+
end
|
6
|
+
|
7
|
+
def place_image_content(file_name, content, extension =".png")
|
8
|
+
File.write(file_name + extension, content, mode: "wb:ASCII-8BIT")
|
9
|
+
end
|
10
|
+
|
11
|
+
def return_all_files(current_location, file_type = '*', filter = '*')
|
12
|
+
Dir.glob("#{current_location}/#{filter}.#{file_type}")
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module YAMLInteraction
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
def read_yaml(relative_location, data)
|
5
|
+
return_yaml(relative_location)[data.upcase.tr(' ', '_')]
|
6
|
+
end
|
7
|
+
|
8
|
+
def key_value_add(file_location, key, value)
|
9
|
+
hash = return_yaml(file_location)
|
10
|
+
hash.store(key.upcase.tr(' ', '_'), value.to_s)
|
11
|
+
yaml_dump(file_location, hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def return_yaml(relative_location)
|
17
|
+
YAML.load(File.read(relative_location))
|
18
|
+
end
|
19
|
+
|
20
|
+
def yaml_dump(file_location, hash)
|
21
|
+
File.open(file_location, 'w+') {
|
22
|
+
|file| YAML.dump(hash, file)}
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
data/lib/html_cs_run_parse.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'utility/parse_machine'
|
2
|
+
require 'html_compilation/execution'
|
2
3
|
|
3
4
|
#this gem is specifically for running HTMLCS
|
4
5
|
class HTMLCS
|
@@ -9,4 +10,9 @@ class HTMLCS
|
|
9
10
|
parse = ParseMachine.new
|
10
11
|
parse.htmlcs_parse(output, file_name)
|
11
12
|
end
|
13
|
+
|
14
|
+
def self.compile_html_cs(data_location)
|
15
|
+
exec = Execution.new
|
16
|
+
exec.build(data_location)
|
17
|
+
end
|
12
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_cs_run_parse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerren Every
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email: jerren1122@hotmail.com
|
@@ -17,6 +17,27 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/HTMLCS.js
|
20
|
+
- lib/html_compilation/classes/builders/app_html.rb
|
21
|
+
- lib/html_compilation/classes/builders/graph.rb
|
22
|
+
- lib/html_compilation/classes/builders/html_builder.rb
|
23
|
+
- lib/html_compilation/classes/builders/page_html.rb
|
24
|
+
- lib/html_compilation/classes/builders/row_html.rb
|
25
|
+
- lib/html_compilation/classes/objects/app.rb
|
26
|
+
- lib/html_compilation/classes/objects/base_object.rb
|
27
|
+
- lib/html_compilation/classes/objects/page.rb
|
28
|
+
- lib/html_compilation/classes/objects/row.rb
|
29
|
+
- lib/html_compilation/classes/setup/conditioning.rb
|
30
|
+
- lib/html_compilation/classes/setup/output_generation.rb
|
31
|
+
- lib/html_compilation/classes/setup/retrieval.rb
|
32
|
+
- lib/html_compilation/classes/setup/setup.rb
|
33
|
+
- lib/html_compilation/classes/struct_classes/score_collection.rb
|
34
|
+
- lib/html_compilation/classes/struct_classes/suppressed_page_rules.rb
|
35
|
+
- lib/html_compilation/data/html_data/app_data.yaml
|
36
|
+
- lib/html_compilation/data/html_data/page_data.yaml
|
37
|
+
- lib/html_compilation/data/html_data/row_data.yaml
|
38
|
+
- lib/html_compilation/data/html_data/style_script.yaml
|
39
|
+
- lib/html_compilation/modules/image_interaction.rb
|
40
|
+
- lib/html_compilation/modules/yaml_interaction.rb
|
20
41
|
- lib/html_cs_run_parse.rb
|
21
42
|
- lib/licence.txt
|
22
43
|
- lib/utility/parse_machine.rb
|