Sha256: 10b02cf5a2095341333577a6788b866390119debd0b97033291f8f1484231883

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module NeetoCompliance
  class EnvironmentConfigVerifier < Base
    def environment_configs
      @_environment_configs ||= {
        "config/environments/development.rb": "NeetoCommonsBackend::Environments.development(config)",
        "config/environments/test.rb": "NeetoCommonsBackend::Environments.test(config)",
        "config/environments/heroku.rb": "NeetoCommonsBackend::Environments.heroku(config)",
        "config/environments/staging.rb": "NeetoCommonsBackend::Environments.staging(config)",
        "config/environments/production.rb": "NeetoCommonsBackend::Environments.production(config)",
        "config/application.rb": "NeetoCommonsBackend::Environments.application(config, self.routes)"
      }
    end

    def auto_correct!
    end

    def valid?
      @errors = []
      environment_configs.each_pair do |file, command|
        unless config_missing?(file, command)
          @errors << "Add #{command} to #{file}"
        end
      end

      @errors.empty?
    end

    def config_missing?(file, command)
      system("cat #{file} | grep -q '#{command}'")
    end

    def autofix_suggestion
      @errors.join("\n").yellow
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neeto-compliance-1.0.58 lib/neeto_compliance/verifiers/environment_config_verifier.rb