Track now properly traverses folder structure

This commit is contained in:
Eric West
2013-05-20 19:11:48 -05:00
parent 236373b7d7
commit 49e4d2844b
2 changed files with 14 additions and 4 deletions

4
.gitignore vendored
View File

@@ -39,3 +39,7 @@ pkg
#
# For vim:
*.swp
#
# For IDEA:
.idea/
*.iml

View File

@@ -112,16 +112,22 @@ class Homesick < Thor
desc "track FILE CASTLE", "add a file to a castle"
def track(file, castle)
castle = Pathname.new(castle)
file = Pathname.new(file)
file = Pathname.new(file.chomp('/'))
check_castle_existance(castle, 'track')
absolute_path = file.expand_path
castle_path = castle_dir(castle)
relative_dir = absolute_path.relative_path_from(home_dir).dirname
castle_path = Pathname.new(castle_dir(castle)).join(relative_dir)
unless castle_path.exist?
FileUtils.mkdir_p castle_path
end
mv absolute_path, castle_path
inside home_dir do
absolute_path = castle_dir(castle) + file.basename
home_path = home_dir + file
absolute_path = castle_path + file.basename
home_path = home_dir + relative_dir + file.basename
ln_s absolute_path, home_path
end