Sha256: 40c2225bac39890078353d731e2f95df3564a6388c24d9999ac21316e049d5de

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 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!
      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?
      current_app = `git config --get remote.origin.url`.split("/").last.strip
      apps_exception_list.include?(current_app)
    end

    def apps_exception_list
      []
    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/base.rb
neetob-0.1.1 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/base.rb
neetob-0.1.0 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/base.rb