Class: GovukPublishingComponents::AuditApplications
- Inherits:
-
Object
- Object
- GovukPublishingComponents::AuditApplications
- Defined in:
- app/models/govuk_publishing_components/audit_applications.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(path, name, dir) ⇒ AuditApplications
constructor
A new instance of AuditApplications.
Constructor Details
#initialize(path, name, dir) ⇒ AuditApplications
Returns a new instance of AuditApplications.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/models/govuk_publishing_components/audit_applications.rb', line 5 def initialize(path, name, dir) @path = path application_found = application_exists(path) components_found = [] @component_locations = {} @gem_style_references = [] @jquery_references = [] @helper_references = {} if application_found templates = Dir["#{path}/app/views/**/*.erb"] stylesheets = Dir["#{path}/app/assets/stylesheets/**/*.scss"] javascripts = Dir["#{path}/app/assets/javascripts/**/*.js"] find_components = /(?<=govuk_publishing_components\/components\/)[a-zA-Z_-]+(?=['"])/ @find_all_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components/ # if using the all stylesheets option @find_individual_asset_model = /render_component_stylesheets/ # if using per page component asset loading @uses_individual_asset_model = false find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print\/)+[a-zA-Z_-]+(?=['"])/ @find_all_javascripts = /\/\/ *= require govuk_publishing_components\/all_components/ find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/ components_in_templates = find_components(templates, find_components, "template", true) || [] components_in_stylesheets = find_components(stylesheets, find_stylesheets, "stylesheet", false) || [] components_in_javascripts = find_components(javascripts, find_javascripts, "javascript", false) || [] ruby_paths = %w[/app/helpers/ /app/presenters/ /lib/] components_in_ruby = [] ruby_paths.each do |ruby_path| components_in_ruby << find_components(Dir["#{path}#{ruby_path}**/*.{rb,erb}"], find_components, "ruby", true) || [] end components_in_ruby = components_in_ruby.flatten.uniq components_found = [ { location: "template", components: components_in_templates, }, { location: "stylesheet", components: components_in_stylesheets, }, { location: "javascript", components: components_in_javascripts, }, { location: "ruby", components: components_in_ruby, }, ] # applications might not have all of these things for all components = { application_name: name, application_dir: dir, templates_path: "app/views/components", stylesheets_path: "app/assets/stylesheets/components", javascripts_path: "app/assets/javascripts/components/", tests_path: "spec/components/", javascript_tests_path: "spec/javascripts/components/", helpers_path: "app/helpers/", } application_components = AuditComponents.new(path, ) application_components = application_components.data if application_components end @data = { name:, dir:, application_found:, components_found:, gem_style_references: @gem_style_references.flatten.uniq.sort, jquery_references: @jquery_references.flatten.uniq.sort, component_locations: @component_locations, helper_references: @helper_references, uses_individual_asset_model: @uses_individual_asset_model, application_components: application_components || [], } end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'app/models/govuk_publishing_components/audit_applications.rb', line 3 def data @data end |