Class: AppHTML

Inherits:
HTML
  • Object
show all
Defined in:
lib/html_compilation/classes/builders/app_html.rb

Instance Attribute Summary collapse

Attributes inherited from HTML

#data_location, #object

Instance Method Summary collapse

Methods inherited from HTML

#htmlify

Methods included from YAMLInteraction

#key_value_add, #read_yaml

Constructor Details

#initialize(object) ⇒ AppHTML

Returns a new instance of AppHTML.



5
6
7
8
9
# File 'lib/html_compilation/classes/builders/app_html.rb', line 5

def initialize(object)
  self.send("data_location=", File.expand_path("../../../data/html_data/app_data.yaml", __FILE__))
  self.send("pages=", object.pages)
  super(object)
end

Instance Attribute Details

#pagesObject

Returns the value of attribute pages.



4
5
6
# File 'lib/html_compilation/classes/builders/app_html.rb', line 4

def pages
  @pages
end

Instance Method Details

#buildObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/html_compilation/classes/builders/app_html.rb', line 11

def build
  #build the adr section
  adr = read_yaml(data_location, "APPLICATION_DATA_ROW")
  score = object.calculate_app_score
  errors = object.calculate_total_errors
  page_number = object.pages.length
  adrs = [score, errors, page_number].map do |section|
    adr.gsub('sample', section.to_s)
  end.join

  #build the ADS Section
  ads = read_yaml(data_location, "APPLICATION_DATA_SECTION")
  ads.gsub!("sample", adrs)

  #build the AOTS Section
  aots = read_yaml(data_location, "APPLICATION_OVERVIEW_TABLE_SECTION")
  aots.gsub!("sample", ads)

  #build the CI section
  ci = read_yaml(data_location, "CHART_IMAGE")

  #build the AOS section
  aos = read_yaml(data_location, "APPLICATION_OVERVIEW_SECTION")
  aos.gsub!("sample", aots + ci)

  #building the page sections
  page_rows = object.pages.map do |page|
    PageHTML.new(page).build
  end.join

  #build the HB section
  hb = read_yaml(data_location, "HTML_BODY")
  hb.gsub!("sample", aos + page_rows)

  #build the app section
  ats = read_yaml(data_location, "APPLICATION_TITLE_SECTION")
  ats.gsub!('sample', object.application_name + " utilizing: " + object.env)

  #build the html section
  html = read_yaml(data_location, "HTML")
  html.gsub!("sample", ats + hb)

  #add the style sheet to the beginning
  ssloc = File.expand_path("../../../data/html_data/style_script.yaml", __FILE__)
  style = read_yaml(ssloc, "STYLE")
  html = style + html

  #add the script to the end
  script = read_yaml(ssloc, "SCRIPT")
  html = html + script
end