Skip to content

Instantly share code, notes, and snippets.

@andredublin
Created August 2, 2013 16:02
Show Gist options
  • Save andredublin/6141066 to your computer and use it in GitHub Desktop.
Save andredublin/6141066 to your computer and use it in GitHub Desktop.
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
@andredublin
Copy link
Author

probably returning an empty array on line 23, will have to test it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment