Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix Rakefile by moving methods into a class

  • Loading branch information...
commit 2797c3cbfcd795bdbb7adefaeac7e3ddbbe83bf9 1 parent 8056938
Joshua Clayton authored
Showing with 21 additions and 21 deletions.
  1. +21 −21 Rakefile
42 Rakefile
View
@@ -1,29 +1,29 @@
-def symlink(target, link)
- puts "Linking #{link} => #{target}"
-
- if File.symlink?(link)
- unlink(link)
- elsif File.exist?(link)
- puts "ERROR: File exists: #{link}"
- exit 1
+class Installer
+ def symlink(target, link)
+ if File.symlink?(link)
+ unlink(link)
+ elsif File.exist?(link)
+ puts "ERROR: File exists: #{link}"
+ exit 1
+ end
+ puts "Symlinking #{link} => #{target}"
+ File.symlink(target, link)
end
- File.symlink(target, link)
-end
-def delete_symlink(link)
- unlink(link) if File.symlink?(link)
-end
+ def delete_symlink(link)
+ unlink(link) if File.symlink?(link)
+ end
-def unlink(link)
- if File.exist?(link)
- descriptor = File.symlink?(link) ? "symlink" : "file"
- puts "Deleting #{descriptor} #{link}"
- File.unlink(link)
+ def unlink(link)
+ if File.exist?(link)
+ descriptor = File.symlink?(link) ? "symlink" : "file"
+ puts "Deleting #{descriptor} #{link}"
+ File.unlink(link)
+ end
end
end
def pwd; File.dirname(__FILE__); end
-
def target_path(file)
File.join(ENV["HOME"], ".#{file}")
end
@@ -33,14 +33,14 @@ files = File.new(File.join(pwd, "MANIFEST"), "r").read.split("\n")
desc "Install all dotfiles"
task :install => [:init_submodules, :update_submodules] do
files.each do |file|
- symlink(File.join(pwd, file), target_path(file))
+ Installer.new.symlink(File.join(pwd, file), target_path(file))
end
end
desc "Remove all dotfies"
task :uninstall do
files.each do |file|
- unlink(target_path(file))
+ Installer.new.unlink(target_path(file))
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.