Sha256: d032a9d3b95daaea299c390270a069666fd0a25a1fffee51d7fd50591847ea0a

Contents?: true

Size: 1.9 KB

Versions: 18

Compression:

Stored size: 1.9 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
        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("/")
        dir = application
        dir = Rails.application.class.module_parent_name.underscore.dasherize unless ENV["MAIN_COMPONENT_GUIDE"]
        app = AuditApplications.new(application_path, application, dir)
        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

18 entries across 18 versions & 1 rubygems

Version Path
govuk_publishing_components-39.2.1 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-39.2.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-39.1.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-39.0.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-38.4.2 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-38.1.1 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-38.1.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-38.0.1 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-38.0.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.10.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.9.1 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.9.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.8.1 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.8.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.7.1 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.7.0 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.6.1 app/controllers/govuk_publishing_components/audit_controller.rb
govuk_publishing_components-37.6.0 app/controllers/govuk_publishing_components/audit_controller.rb