Class: NeetoCompliance::GitignoreFileVerifier

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

Instance Method Summary collapse

Methods inherited from Base

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

Instance Method Details

#autofix_commandObject



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

def autofix_command
  "echo '#{@missing_lines.join("\n")}' >> #{local_copy}"
end

#autofix_suggestionObject



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

def autofix_suggestion
  "Add following lines to#{local_copy}: \n#{@missing_lines.join("\n")}".yellow
end

#commons_copyObject



9
10
11
# File 'lib/neeto_compliance/verifiers/gitignore_file_verifier.rb', line 9

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

#local_copyObject



5
6
7
# File 'lib/neeto_compliance/verifiers/gitignore_file_verifier.rb', line 5

def local_copy
  ".gitignore"
end

#process_data(gitignore_data) ⇒ Object



25
26
27
# File 'lib/neeto_compliance/verifiers/gitignore_file_verifier.rb', line 25

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

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
# File 'lib/neeto_compliance/verifiers/gitignore_file_verifier.rb', line 17

def valid?
  @missing_lines = []
  local_gitignore = process_data File.read(local_copy)
  common_gitignore = process_data File.read(NeetoCompliance::GitignoreFileVerifier.new.commons_copy)
  common_gitignore.map { |line| @missing_lines << line unless local_gitignore.include?(line) }
  @missing_lines.empty?
end

#verify_commandObject



13
14
15
# File 'lib/neeto_compliance/verifiers/gitignore_file_verifier.rb', line 13

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