Sha256: 2054efaab288bfac0054aad79c93034003af8a516f6c44ac855429969fc1fdb0

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 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)"
      }
    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

3 entries across 3 versions & 1 rubygems

Version Path
neetob-0.1.2 neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb
neetob-0.1.1 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb
neetob-0.1.0 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb