Class: Kdep::Doctor::CheckGitignoreCanonical

Inherits:
Check
  • Object
show all
Defined in:
lib/kdep/doctor/check_gitignore_canonical.rb

Constant Summary collapse

ID =
"gitignore_canonical".freeze

Instance Attribute Summary

Attributes inherited from Check

#deploy_dir

Instance Method Summary collapse

Methods inherited from Check

#initialize

Constructor Details

This class inherits a constructor from Kdep::Doctor::Check

Instance Method Details

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/kdep/doctor/check_gitignore_canonical.rb', line 6

def run
  path = File.join(deploy_dir, ".gitignore")
  template_path = File.join(Kdep.templates_dir, "init", "gitignore")

  unless File.exist?(path)
    return Result.new(
      id: ID, severity: :info,
      message: "#{deploy_dir}/.gitignore missing",
      hint: "Run 'kdep doctor --fix' to create it from the canonical template."
    )
  end

  if File.read(path) == File.read(template_path)
    Result.ok(ID)
  else
    Result.new(
      id: ID, severity: :info,
      message: "#{path} differs from canonical template",
      hint: "Review differences; add new entries under the kdep-generated comment."
    )
  end
end