Class: NeetoCompliance::EnvironmentConfigVerifier

Inherits:
Base
  • Object
show all
Defined in:
lib/neeto_compliance/verifiers/environment_config_verifier.rb

Instance Method Summary collapse

Methods inherited from Base

#app_is_exception?, #app_name, #apps_exception_list, #audit, #error_message, #print_description, #process, #verifier_name

Instance Method Details

#auto_correct!Object



16
17
# File 'lib/neeto_compliance/verifiers/environment_config_verifier.rb', line 16

def auto_correct!
end

#autofix_suggestionObject



34
35
36
# File 'lib/neeto_compliance/verifiers/environment_config_verifier.rb', line 34

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

#config_missing?(file, command) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/neeto_compliance/verifiers/environment_config_verifier.rb', line 30

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

#environment_configsObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/neeto_compliance/verifiers/environment_config_verifier.rb', line 5

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

#valid?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
# File 'lib/neeto_compliance/verifiers/environment_config_verifier.rb', line 19

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