Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix Rakefile by moving methods into a class

  • Loading branch information...
commit 2797c3cbfcd795bdbb7adefaeac7e3ddbbe83bf9 1 parent 8056938
Joshua Clayton authored

Showing 1 changed file with 21 additions and 21 deletions. Show diff stats Hide diff stats

  1. +21 21 Rakefile
42 Rakefile
... ... @@ -1,29 +1,29 @@
1   -def symlink(target, link)
2   - puts "Linking #{link} => #{target}"
3   -
4   - if File.symlink?(link)
5   - unlink(link)
6   - elsif File.exist?(link)
7   - puts "ERROR: File exists: #{link}"
8   - exit 1
  1 +class Installer
  2 + def symlink(target, link)
  3 + if File.symlink?(link)
  4 + unlink(link)
  5 + elsif File.exist?(link)
  6 + puts "ERROR: File exists: #{link}"
  7 + exit 1
  8 + end
  9 + puts "Symlinking #{link} => #{target}"
  10 + File.symlink(target, link)
9 11 end
10   - File.symlink(target, link)
11   -end
12 12
13   -def delete_symlink(link)
14   - unlink(link) if File.symlink?(link)
15   -end
  13 + def delete_symlink(link)
  14 + unlink(link) if File.symlink?(link)
  15 + end
16 16
17   -def unlink(link)
18   - if File.exist?(link)
19   - descriptor = File.symlink?(link) ? "symlink" : "file"
20   - puts "Deleting #{descriptor} #{link}"
21   - File.unlink(link)
  17 + def unlink(link)
  18 + if File.exist?(link)
  19 + descriptor = File.symlink?(link) ? "symlink" : "file"
  20 + puts "Deleting #{descriptor} #{link}"
  21 + File.unlink(link)
  22 + end
22 23 end
23 24 end
24 25
25 26 def pwd; File.dirname(__FILE__); end
26   -
27 27 def target_path(file)
28 28 File.join(ENV["HOME"], ".#{file}")
29 29 end
@@ -33,14 +33,14 @@ files = File.new(File.join(pwd, "MANIFEST"), "r").read.split("\n")
33 33 desc "Install all dotfiles"
34 34 task :install => [:init_submodules, :update_submodules] do
35 35 files.each do |file|
36   - symlink(File.join(pwd, file), target_path(file))
  36 + Installer.new.symlink(File.join(pwd, file), target_path(file))
37 37 end
38 38 end
39 39
40 40 desc "Remove all dotfies"
41 41 task :uninstall do
42 42 files.each do |file|
43   - unlink(target_path(file))
  43 + Installer.new.unlink(target_path(file))
44 44 end
45 45 end
46 46

0 comments on commit 2797c3c

Please sign in to comment.
Something went wrong with that request. Please try again.