2013-12-04 06:23:05 +11:00
|
|
|
require 'yaml'
|
2010-11-22 14:53:35 +11:00
|
|
|
|
2008-08-26 08:43:57 +10:00
|
|
|
desc "install the dot files into user's home directory"
|
|
|
|
task :install do
|
2013-12-04 06:23:05 +11:00
|
|
|
dot_files = File.dirname(__FILE__)
|
|
|
|
install = proc do |files, cmd|
|
|
|
|
files.each do |source, destination|
|
|
|
|
source = File.expand_path(source, dot_files)
|
|
|
|
destination = File.expand_path(destination, ENV['HOME'])
|
|
|
|
system 'mkdir', '-p', File.dirname(destination)
|
|
|
|
# puts [*cmd, source, destination].join(" ")
|
|
|
|
system *cmd, source, destination
|
2008-08-26 08:43:57 +10:00
|
|
|
end
|
|
|
|
end
|
2010-11-22 14:53:35 +11:00
|
|
|
|
2013-12-04 06:23:05 +11:00
|
|
|
plan = YAML.load_file(File.expand_path("install.yml", dot_files))
|
2010-11-22 14:53:35 +11:00
|
|
|
|
2013-12-04 06:23:05 +11:00
|
|
|
install.call plan[:link], %w[ln -sinF]
|
2015-08-11 17:54:41 +10:00
|
|
|
install.call plan[:copy], %w[cp -i]
|
2010-06-25 17:02:29 +10:00
|
|
|
end
|