Sha256: b6336d16213de0457ca0a35a4a82046bf9385f7c037faf22fc75669e8e4cb8af

Contents?: true

Size: 954 Bytes

Versions: 3

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

module NeetoCompliance
  class GitignoreFileVerifier < Base
    def local_copy
      ".gitignore"
    end

    def commons_copy
      NeetoCompliance::NeetoCommons.path.join "common_files", local_copy
    end

    def verify_command
      "diff #{commons_copy} #{local_copy}"
    end

    def valid?
      local_gitignore = process_data File.read(local_copy)
      common_gitignore = process_data File.read(NeetoCompliance::GitignoreFileVerifier.new.commons_copy)
      common_gitignore.map { |line| return false unless local_gitignore.include?(line) }
      true
    end

    def process_data(gitignore_data)
      gitignore_data.split("\n").map { |line| line.gsub(/^#.*/, "") }
    end

    def autofix_command
      "cp #{commons_copy} #{local_copy}"
    end

    def auto_correct!
    end

    def autofix_suggestion
      "Make sure #{local_copy} contains all lines from #{commons_copy.to_s}".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/gitignore_file_verifier.rb
neetob-0.1.1 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gitignore_file_verifier.rb
neetob-0.1.0 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gitignore_file_verifier.rb