Class: NeetoCompliance::Base

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

Instance Method Summary collapse

Instance Method Details

#app_is_exception?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/neeto_compliance/verifiers/base.rb', line 65

def app_is_exception?
  apps_exception_list.include?(app_name)
end

#app_nameObject



69
70
71
# File 'lib/neeto_compliance/verifiers/base.rb', line 69

def app_name
  @_app_name ||= `git config --get remote.origin.url`.split("/").last.strip.split(".git").first
end

#apps_exception_listObject



73
74
75
# File 'lib/neeto_compliance/verifiers/base.rb', line 73

def apps_exception_list
  []
end

#auditObject



54
55
56
57
58
59
60
61
62
63
# File 'lib/neeto_compliance/verifiers/base.rb', line 54

def audit
  print_description
  errors = []

  unless valid?
    errors << [error_message, autofix_suggestion, "\n"].join("\n")
  end

  [errors.length == 0, errors]
end

#auto_correct!Object



37
38
39
40
41
42
43
44
# File 'lib/neeto_compliance/verifiers/base.rb', line 37

def auto_correct!
  return true if app_is_exception?

  unless valid?
    puts autofix_command
    system autofix_command
  end
end

#autofix_suggestionObject



46
47
48
# File 'lib/neeto_compliance/verifiers/base.rb', line 46

def autofix_suggestion
  "To fix run: #{autofix_command.yellow}"
end

#error_messageObject



50
51
52
# File 'lib/neeto_compliance/verifiers/base.rb', line 50

def error_message
  "[FAIL]".red
end


33
34
35
# File 'lib/neeto_compliance/verifiers/base.rb', line 33

def print_description
  print "%-80s" % [verifier_name]
end

#processObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/neeto_compliance/verifiers/base.rb', line 10

def process
  return true if app_is_exception?

  # preload the path
  NeetoCompliance::NeetoCommons.path

  success, errors = audit

  unless success
    errors.each do |error|
      puts error
    end
  else
    print "[PASS]\n".green
  end

  success
end

#verifier_nameObject



29
30
31
# File 'lib/neeto_compliance/verifiers/base.rb', line 29

def verifier_name
  self.class.to_s
end