html_cs_run_parse 0.0.4 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/HTMLCS.js +33 -630
- 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/execution.rb +18 -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 +7 -1
- metadata +53 -3
@@ -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
|