class RBT::CheckForInvalidCurrentSymlinks
Public Class Methods
[](i = ARGV)
click to toggle source
Public Instance Methods
autocorrect_erroneous_entries()
click to toggle source
#¶ ↑
autocorrect_erroneous_entries
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/check_for_invalid_current_symlinks.rb, line 115 def autocorrect_erroneous_entries _ = main_array? unless _.empty? _.each {|entry| opne "Next autocorrecting `#{sfancy(entry)}`." # =================================================================== # # First, determine the possible targets. One of these targets will # become our new main symlink. # =================================================================== # dirname = File.dirname(entry) possible_targets = Dir[dirname+'/*'].select {|line| File.basename(line) =~ /^\d+/ }.sort_by {|line| File.basename(line) }.reverse this_target = possible_targets.first # =================================================================== # # Then, remove that directory. # =================================================================== # if File.directory? entry remove_directory(entry) end # =================================================================== # # Finally, set up the new symlink there. The old_target is the # current program version of the program in question, such # as "/Programs/Htop/2.0.2". # =================================================================== # old_target = this_target new_target = entry # This is the entry, yup. if File.exist? old_target symlink(old_target, new_target) else opnn; no_target_exists_at(old_target) end } end end
discover_which_entries_are_not_symlinks()
click to toggle source
#¶ ↑
discover_which_entries_are_not_symlinks
¶ ↑
This will fill up the Array @array_these_entries_are_not_symlinks.
Note that this method will NOT report anything - look at the report method instead if you require output from this class.
#¶ ↑
# File lib/rbt/utility_scripts/check_for_invalid_current_symlinks.rb, line 181 def discover_which_entries_are_not_symlinks _ = programs_directory? array_all_programs = Dir["#{_}*"].sort array_all_programs.each {|entry| _ = rds(entry+'/Current') if File.exist? _ is_it_a_symlink = File.symlink?(_) unless is_it_a_symlink @array_these_entries_are_not_symlinks << _ end end } end
Also aliased as: discover_stuff
inform_the_user_what_can_be_done_about_incorrect_entries()
click to toggle source
input?()
click to toggle source
main_array?()
click to toggle source
notify_the_user_that_everything_appears_to_be_fine()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/check_for_invalid_current_symlinks.rb, line 40 def reset super() infer_the_namespace # ======================================================================= # # === @array_these_entries_are_not_symlinks # # We collect all non-symlinks into the following Array. # ======================================================================= # @array_these_entries_are_not_symlinks = [] discover_which_entries_are_not_symlinks # Fill up our main Array first, always. end
run()
click to toggle source
set_input(i = '')
click to toggle source
show_which_entries_are_not_symlinks()
click to toggle source
#¶ ↑
show_which_entries_are_not_symlinks
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/check_for_invalid_current_symlinks.rb, line 156 def show_which_entries_are_not_symlinks unless main_array?.empty? main_array?.each {|entry| e "#{rev}Note that #{sfancy(entry.ljust(37))} is #{sfancy('NOT')}"\ " a symlink." }; e end end
Also aliased as: report