class RBT::SymlinkIntoTheUsrBinHierarchy
Constants
- USR_BIN_DIRECTORY
#¶ ↑
USR_BIN_DIRECTORY
¶ ↑#¶ ↑
Public Class Methods
[](i = ARGV)
click to toggle source
new( symlink_these_files = nil, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/symlink_into_the_usr_bin_hierarchy.rb, line 36 def initialize( symlink_these_files = nil, run_already = true, &block ) reset set_symlink_these_files( symlink_these_files ) # ======================================================================= # # === Handle blocks given to this class next # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :force # ===================================================================== # when :force @internal_hash[:remove_the_target_file_at_the_usr_bin_hierarchy] = true else if yielded.is_a?(Hash) # ================================================================= # # === :force_symlink # ================================================================= # if yielded.has_key? :force_symlink @internal_hash[:remove_the_target_file_at_the_usr_bin_hierarchy] = yielded.delete(:force_symlink) end end end end run if run_already end
Public Instance Methods
do_work_on_these_files( i = symlink_these_files? )
click to toggle source
#¶ ↑
do_work_on_these_files
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/symlink_into_the_usr_bin_hierarchy.rb, line 117 def do_work_on_these_files( i = symlink_these_files? ) remove_the_target_file_at_the_usr_bin_hierarchy = remove_the_target_file_at_the_usr_bin_hierarchy? i.each {|this_file| # ===================================================================== # # The variable this_file may contain a file such as # /Programs/Ruby/Current/lib/libruby.so.2.5.3. # ===================================================================== # target = "#{USR_BIN_DIRECTORY}#{File.basename(this_file)}" # This may be a String such as "/usr/bin/htop" orev 'Next symlinking the file `'+sfile(this_file)+ rev+'` into `'+sfile(target)+'`.' # ===================================================================== # # Next, handle the case when the target at `target` is a directory: # ===================================================================== # if File.directory? this_file if File.directory? target # ================================================================= # # In this case the target directory already exists. # ================================================================= # Dir["#{this_file}/*"].each {|target_in_that_directory| inner_target = target+'/'+File.basename(target_in_that_directory) orev 'Symlinking '+sfile(target_in_that_directory)+ rev+' into `'+sfancy(inner_target)+rev+'` next.' symlink( target_in_that_directory, inner_target ) } return end target = this_file else if File.file?(target) and remove_the_target_file_at_the_usr_bin_hierarchy and File.file?(this_file) # This check here is necessary to find out that the file exists. delete_file(target) end end symlink(this_file, target) } end
remove_the_target_file_at_the_usr_bin_hierarchy?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/symlink_into_the_usr_bin_hierarchy.rb, line 73 def reset super() infer_the_namespace # ========================================================================= # # === :remove_the_target_file_at_the_usr_bin_hierarchy # ========================================================================= # @internal_hash[:remove_the_target_file_at_the_usr_bin_hierarchy] = false end
run()
click to toggle source
set_symlink_these_files(i = '')
click to toggle source
#¶ ↑
set_symlink_these_files
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/symlink_into_the_usr_bin_hierarchy.rb, line 92 def set_symlink_these_files(i = '') if i i = [i].flatten.compact.map {|entry| # Always have an Array past this point. if File.directory? entry # If it is a directory we'll grab all entries from it. target = ("#{entry}/*").squeeze '/' entry = Dir[target] # ← Obtain the files from that directory. end entry } i.flatten! i.compact! end @internal_hash[:symlink_these_files] = i end