Class: GovukPublishingComponents::AuditComponents

Inherits:
Object
  • Object
show all
Defined in:
app/models/govuk_publishing_components/audit_components.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ AuditComponents

Returns a new instance of AuditComponents.



5
6
7
8
9
10
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
# File 'app/models/govuk_publishing_components/audit_components.rb', line 5

def initialize(path, options = {})
  # paths to key file locations
  @templates_path = options[:templates_path] || "app/views/govuk_publishing_components/components"
  @stylesheets_path = options[:stylesheets_path] || "app/assets/stylesheets/govuk_publishing_components/components"
  @print_stylesheets_path = options[:print_stylesheets_path] || "app/assets/stylesheets/govuk_publishing_components/components/print"
  @javascripts_path = options[:javascripts_path] || "app/assets/javascripts/govuk_publishing_components/components"
  @tests_path = options[:tests_path] || "spec/components"
  @javascript_tests_path = options[:javascript_tests_path] || "spec/javascripts/components"
  @helpers_path = options[:helpers_path] || "lib/govuk_publishing_components/presenters"

  @application_name = options[:application_name] || "govuk_publishing_components"
  @application_dir = options[:application_dir] || "govuk_publishing_components"
  @all_templates = Dir["#{path}/#{@templates_path}/*.erb"].sort
  @templates_full_path = "#{path}/#{@templates_path}/"

  @component_numbers = {
    template: 0,
    stylesheet: 0,
    print_stylesheet: 0,
    javascript: 0,
    uses_govuk_frontend_js: 0,
    uses_govuk_frontend_css: 0,
    test: 0,
    javascript_test: 0,
    helper: 0,
  }

  @data = {
    gem_found: false,
  }
  @auditing_an_application = true unless @application_name == "govuk_publishing_components"
  @data = compile_data(path) if Dir.exist?(path)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'app/models/govuk_publishing_components/audit_components.rb', line 3

def data
  @data
end