class RBT::SymlinkIntoUsrLibDirectory

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

[](i = '') click to toggle source
#

[]

#
# File lib/rbt/utility_scripts/symlink_into_usr_lib_directory.rb, line 112
def self.[](i = '')
  self.new(i)
end
new( symlink_these_files = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/symlink_into_usr_lib_directory.rb, line 33
def initialize(
    symlink_these_files = nil,
    run_already         = true
  )
  reset
  set_symlink_these_files(
    symlink_these_files
  )
  run if run_already
end

Public Instance Methods

reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/symlink_into_usr_lib_directory.rb, line 47
def reset
  super()
  @namespace = NAMESPACE
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/symlink_into_usr_lib_directory.rb, line 79
def run
  @symlink_these_files.each {|this_file|
    # ===================================================================== #
    # The variable this_file may contain a file such as
    # /Programs/Ruby/Current/lib/libruby.so.2.5.3.
    # ===================================================================== #
    target = "/usr/lib/#{File.basename(this_file)}"
    opnn; e 'Next symlinking the file `'+sfile(this_file)+'` into `'+sfile(target)+'`.'
    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)
          opnn; e 'Symlinking '+sfile(target_in_that_directory)+
                  ' into `'+sfancy(inner_target)+'` next.'
          symlink(
            target_in_that_directory,
            inner_target
          )
        }
        return
      end
      target = this_file
    end
    symlink(this_file, target)
  }
end