Created
August 2, 2013 16:02
-
-
Save andredublin/6141066 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pathname' | |
module Muxie | |
module FileSystem | |
extend self | |
def symlink_data_files | |
p 'Saving configuration files to ' + ENV['HOME'] | |
symlink_files(get_conf_files) | |
end | |
private | |
def symlink_files(data_folder) | |
scan_data_folder(data_folder).each do |file| | |
renamed_file_path = set_file_to_home_path(file) | |
orig_file_path = file.to_s | |
link_file(orig_file_path, renamed_file_path) | |
end | |
end | |
def get_conf_files | |
::Pathname.new(File.expand_path(File.join("..", "..", "data"), __FILE__)) | |
end | |
def scan_data_folder(data_folder) | |
::Pathname.glob(data_folder.to_s + "/*") | |
end | |
def set_file_to_home_path(file) | |
ENV['HOME'] + '/' + '.' + file.basename.to_s.gsub(".example", ".foo") | |
end | |
def link_file(orig_file_path, renamed_file_path) | |
::FileUtils.ln_s orig_file_path, renamed_file_path, force: true | |
p "Symlinked #{file.basename} to #{renamed_file_path}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
probably returning an empty array on line 23, will have to test it out.