Skip to content
This repository
Newer
Older
100644 51 lines (46 sloc) 1.31 kb
d37cf80a »
2008-06-20 initial file structure
1 require 'rake'
4677f3a4 »
2009-09-04 using erb to generate gitconfig so we don't have my name in there any…
2 require 'erb'
d37cf80a »
2008-06-20 initial file structure
3
981bbc96 »
2008-06-20 implementing rake install task
4 desc "install the dot files into user's home directory"
d37cf80a »
2008-06-20 initial file structure
5 task :install do
a8123019 »
2008-06-20 rewriting install script with fancy replace options
6 replace_all = false
981bbc96 »
2008-06-20 implementing rake install task
7 Dir['*'].each do |file|
ec7377cb »
2009-09-04 ignoring readme.rdoc file when installing
8 next if %w[Rakefile README.rdoc LICENSE].include? file
a8123019 »
2008-06-20 rewriting install script with fancy replace options
9
4677f3a4 »
2009-09-04 using erb to generate gitconfig so we don't have my name in there any…
10 if File.exist?(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}"))
fa90385f »
2010-03-02 skip over identical files on install
11 if File.identical? file, File.join(ENV['HOME'], ".#{file.sub('.erb', '')}")
12 puts "identical ~/.#{file.sub('.erb', '')}"
13 elsif replace_all
a8123019 »
2008-06-20 rewriting install script with fancy replace options
14 replace_file(file)
15 else
4677f3a4 »
2009-09-04 using erb to generate gitconfig so we don't have my name in there any…
16 print "overwrite ~/.#{file.sub('.erb', '')}? [ynaq] "
a8123019 »
2008-06-20 rewriting install script with fancy replace options
17 case $stdin.gets.chomp
18 when 'a'
19 replace_all = true
20 replace_file(file)
21 when 'y'
22 replace_file(file)
23 when 'q'
24 exit
25 else
4677f3a4 »
2009-09-04 using erb to generate gitconfig so we don't have my name in there any…
26 puts "skipping ~/.#{file.sub('.erb', '')}"
a8123019 »
2008-06-20 rewriting install script with fancy replace options
27 end
28 end
29 else
30 link_file(file)
31 end
981bbc96 »
2008-06-20 implementing rake install task
32 end
d37cf80a »
2008-06-20 initial file structure
33 end
a8123019 »
2008-06-20 rewriting install script with fancy replace options
34
35 def replace_file(file)
2f738bb0 »
2010-05-20 Rakefile: replace_file: add -rf to remove dirs.
36 system %Q{rm -rf "$HOME/.#{file.sub('.erb', '')}"}
a8123019 »
2008-06-20 rewriting install script with fancy replace options
37 link_file(file)
38 end
39
40 def link_file(file)
4677f3a4 »
2009-09-04 using erb to generate gitconfig so we don't have my name in there any…
41 if file =~ /.erb$/
42 puts "generating ~/.#{file.sub('.erb', '')}"
43 File.open(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}"), 'w') do |new_file|
44 new_file.write ERB.new(File.read(file)).result(binding)
45 end
46 else
47 puts "linking ~/.#{file}"
48 system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
49 end
a8123019 »
2008-06-20 rewriting install script with fancy replace options
50 end
Something went wrong with that request. Please try again.