Class: Cejo::Ops::Homey
- Inherits:
-
Object
- Object
- Cejo::Ops::Homey
- Defined in:
- lib/cejo/ops/homey.rb
Overview
Mirror user DATA partition folders to $HOME
Constant Summary collapse
- IGNORE_THESE =
%w[.Trash-1000 lost+found].freeze
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#target_link ⇒ Object
readonly
Returns the value of attribute target_link.
Instance Method Summary collapse
-
#cleanup_home ⇒ Object
Remove $HOME folders found in DATA.
- #folders_found ⇒ Object
-
#initialize(root) ⇒ Homey
constructor
A new instance of Homey.
-
#root_exist? ⇒ Boolean
Confirms if root is a folder or return w/ exeception.
- #run ⇒ Object
- #symlink_folders ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
9 10 11 |
# File 'lib/cejo/ops/homey.rb', line 9 def root @root end |
#target_link ⇒ Object (readonly)
Returns the value of attribute target_link.
9 10 11 |
# File 'lib/cejo/ops/homey.rb', line 9 def target_link @target_link end |
Instance Method Details
#cleanup_home ⇒ Object
Remove $HOME folders found in DATA
35 36 37 38 39 |
# File 'lib/cejo/ops/homey.rb', line 35 def cleanup_home target_link.each_key do |link_name| link_name.delete if link_name.exist? end end |
#folders_found ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cejo/ops/homey.rb', line 21 def folders_found folders_found = {} home = Pathname.new Dir.home root.each_child do |folder| next if IGNORE_THESE.include? folder.basename.to_s folders_found[folder] = home.join folder.basename end folders_found end |
#root_exist? ⇒ Boolean
Confirms if root is a folder or return w/ exeception
16 17 18 19 |
# File 'lib/cejo/ops/homey.rb', line 16 def root_exist? r = Pathname.new root r.exist? end |
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cejo/ops/homey.rb', line 47 def run unless root_exist? print "No such a directory '#{root}' exist! Exiting." exit! end @root = Pathname root @target_link = folders_found cleanup_home symlink_folders end |
#symlink_folders ⇒ Object
41 42 43 44 45 |
# File 'lib/cejo/ops/homey.rb', line 41 def symlink_folders target_link.each do |target, link_name| File.symlink target, link_name end end |