class Profile
Attributes
folder[RW]
Public Class Methods
new(folder)
click to toggle source
# File lib/profile.rb, line 4 def initialize(folder) @folder = folder end
Public Instance Methods
create_symlinks(files)
click to toggle source
# File lib/profile.rb, line 37 def create_symlinks(files) files.each do |file| File.symlink("#{path}/#{file}", "#{path}/../#{file}") puts "symlink created for #{file}" end end
execute()
click to toggle source
# File lib/profile.rb, line 8 def execute prepare_folder create_symlinks(@files) end
path()
click to toggle source
# File lib/profile.rb, line 44 def path File.expand_path("~/#{folder}") end
prepare_folder()
click to toggle source
# File lib/profile.rb, line 13 def prepare_folder @files = [] Dir.foreach(path) do |file| unless file == '.git' remove_old_symlinks(file) remove_existing_files(file) end end end
remove_existing_files(file)
click to toggle source
# File lib/profile.rb, line 29 def remove_existing_files(file) if File.exist?("#{path}/../#{file}") puts "The #{file} already exists" else @files << file end end
remove_old_symlinks(file)
click to toggle source
# File lib/profile.rb, line 23 def remove_old_symlinks(file) if File.symlink?("#{path}/../#{file}") system("rm #{path}/../#{file}") end end