Module: Dots::Persistence
Instance Method Summary collapse
-
#forget_dot_file(file_name) ⇒ Object
Restores the given configuration file that’s in the repo back to an unremembered state.
-
#link_dot_files ⇒ Object
Run through every file in ~/.dots/config and symlink them to ~/..
-
#persist_dot_file(file_name) ⇒ Object
Moves the given ~/.file to the repo, while saving its original location.
Instance Method Details
#forget_dot_file(file_name) ⇒ Object
Restores the given configuration file that’s in the repo back to an unremembered state. Deletes the symlink and places the file back to its perceived original location in ~/.file.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby/dots/persistence.rb', line 30 def forget_dot_file file_name dot_file = Dots::DotFile.find file_name if dot_file.destroy say "#{dot_file} is no longer being persisted." else say "Error: #{dot_file} could not be forgotten:" dot_file.errors..each { |msg| say "- #{msg}" } end end |
#link_dot_files ⇒ Object
Run through every file in ~/.dots/config and symlink them to ~/..
7 8 9 10 11 |
# File 'lib/ruby/dots/persistence.rb', line 7 def link_dot_files Dir[File.("~/.dots/config/*")].each do |config_file| persist_dot_file config_file end end |
#persist_dot_file(file_name) ⇒ Object
Moves the given ~/.file to the repo, while saving its original location. It then symlinks the new location to the old location so applications will continue to run.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby/dots/persistence.rb', line 16 def persist_dot_file file_name dot_file = Dots::DotFile.new file_name if dot_file.save say "#{dot_file} saved to DOTS!" else say "Error: #{dot_file} could not be symlinked:" dot_file.errors..each { |msg| say "- #{msg}" } end end |