Sha256: 7bf745aa5ea9ac3e9e524730494a9ad6467244a91fdbcc91bea7458af0eb91ba

Contents?: true

Size: 1.81 KB

Versions: 13

Compression:

Stored size: 1.81 KB

Contents

module GovukPublishingComponents
  class AuditController < GovukPublishingComponents::ApplicationController
    def show
      application_dirs = %w[
        collections
        collections-publisher
        content-data-admin
        content-publisher
        datagovuk_find
        email-alert-frontend
        feedback
        finder-frontend
        frontend
        government-frontend
        govspeak-preview
        info-frontend
        licence-finder
        release
        search-admin
        signon
        smart-answers
        static
        travel-advice-publisher
        whitehall
      ]

      application_dirs = [GovukPublishingComponents::ApplicationHelper.get_application_name_from_path(Rails.root)] unless ENV["MAIN_COMPONENT_GUIDE"]

      gem_path = Gem.loaded_specs["govuk_publishing_components"].full_gem_path
      gem_path = Dir.pwd if ENV["MAIN_COMPONENT_GUIDE"]
      host_dir = File.expand_path("..")

      @in_application = false
      @in_application = true unless ENV["MAIN_COMPONENT_GUIDE"]

      components = AuditComponents.new(gem_path)
      applications = analyse_applications(host_dir, application_dirs)
      compared_data = AuditComparer.new(components.data, applications)

      @applications = compared_data.applications_data || []
      @components = compared_data.gem_data || []
    end

  private

    def analyse_applications(path, application_dirs)
      results = []
      applications_found = 0

      application_dirs.each do |application|
        application_path = [path, application].join("/")
        app = AuditApplications.new(application_path, application)
        applications_found += 1 if app.data[:application_found]
        results << app.data
      end

      @other_applications = false
      @other_applications = true if applications_found > 1

      results
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
govuk_publishing_components-35.12.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.11.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.10.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.9.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.8.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.7.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.6.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.5.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.4.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.3.5 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.3.4 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.3.3 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-35.3.2 app/controllers/govuk_publishing_components/audit_controller.rb