Method: PDQTest::Skeleton.install_skeleton

Defined in:
lib/pdqtest/skeleton.rb

.install_skeleton(target_file, skeleton, replace = true) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/pdqtest/skeleton.rb', line 81

def self.install_skeleton(target_file, skeleton, replace=true)
  skeleton_file = Util.resource_path(File.join(SKELETON_DIR, skeleton))
  install = false
  if File.exists?(target_file)
    if replace && should_replace_file(target_file, skeleton_file)
      install = true
    else
      $logger.debug "#{target_file} exists and will not be replaced"
    end
  else
    install = true
  end
  if install
    $logger.debug "Installing skeleton file at #{target_file}"
    FileUtils.cp(skeleton_file, target_file)
  end
end