Sha256: 414adcea13e5e620dc6e1477e5081c786978bbde0a3057476bde567c3b5817c1

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require "net/http"
require "json"
require "yaml"
require "set"

module NeetoCompliance
  class Base
    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

    def verifier_name
      self.class.to_s
    end

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

    def auto_correct!
      return true if app_is_exception?

      unless valid?
        puts autofix_command
        system autofix_command
      end
    end

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

    def error_message
      "[FAIL]".red
    end

    def audit
      print_description
      errors = []

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

      [errors.length == 0, errors]
    end

    def app_is_exception?
      apps_exception_list.include?(app_name)
    end

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

    def apps_exception_list
      []
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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