class RBT::SymlinkHeaders

Constants

DELETE_TARGET_HEADER_FILE_IF_IT_EXISTS
#

DELETE_TARGET_HEADER_FILE_IF_IT_EXISTS

The following constant will remove the .h file if it exists in the /usr/include/ hierarchy. Suffice to say that this may be dangerous, so you should really know what you are doing.

#
NAMESPACE
#

NAMESPACE

#
USR_INCLUDE_HIERARCHY
#

USR_INCLUDE_HIERARCHY

#

Public Class Methods

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

[]

#
# File lib/rbt/utility_scripts/symlink_headers.rb, line 255
def self.[](i = '')
  self.new(i)
end
new( program_name = ARGV, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/symlink_headers.rb, line 52
def initialize(
    program_name = ARGV,
    run_already  = true
  )
  reset
  set_program_name(program_name)
  if block_given?
    yielded = yield
    case yielded
    when :do_not_notify_if_there_were_no_header_files
      @notify_the_user_if_there_were_no_header_files = false
    when :notify_the_user_if_no_header_files_were_found
      @notify_the_user_if_there_were_no_header_files = true
    end
  end
  run if run_already
end

Public Instance Methods

consider_notifying_the_user_that_no_header_files_were_found() click to toggle source
#

consider_notifying_the_user_that_no_header_files_were_found

#
# File lib/rbt/utility_scripts/symlink_headers.rb, line 172
def consider_notifying_the_user_that_no_header_files_were_found
  if @notify_the_user_if_there_were_no_header_files
    opnn; e "No .h files were found in the target "\
            "directory `#{sdir(@target_directory)}`."
  end
end
obtain_all_header_files() click to toggle source
#

obtain_all_header_files

#
# File lib/rbt/utility_scripts/symlink_headers.rb, line 135
def obtain_all_header_files
  target = programs_dir?+program_name?+'/Current/'
  include_target = "#{target}include/"
  set_target_directory(include_target)
  target_for_header_files = include_target+'**/**.h'
  _found_headers = Dir[target_for_header_files] # <- This variable is currently not in use.
  # ======================================================================= #
  # The next variable is probably the best, as in, the most useful
  # target. We only look for one base heirarchy, not for any files
  # within that directory. Is not very sophisticated, but the simplest
  # and best variant, in my opinion.
  # ======================================================================= #
  all_targets_in_the_base_include_directory = Dir[include_target+'*']
  symlink_these_targets_into_the_usr_include_hierarchy(
    all_targets_in_the_base_include_directory
  )
end
program_name?() click to toggle source
#

program_name?

#
# File lib/rbt/utility_scripts/symlink_headers.rb, line 121
def program_name?
  @program_name
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/symlink_headers.rb, line 73
def reset
  super()
  @namespace = NAMESPACE
  @delete_target_header_file_if_it_exists = DELETE_TARGET_HEADER_FILE_IF_IT_EXISTS
  @target_directory = nil
  # ======================================================================= #
  # We may either notify the user that we did not find anything, if there
  # were no header files, or we may not. By default, the variable that
  # controls this behaviour is set to false, in order to lessen the
  # spam/verbosity of RBT.
  # However had, RBT::Compile will specifically set this variable to
  # true, since it appears to be more helpful if this is done to
  # the end user.
  # ======================================================================= #
  @notify_the_user_if_there_were_no_header_files = false
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/symlink_headers.rb, line 248
def run
  obtain_all_header_files
end
set_program_name( i = Dir.pwd ) click to toggle source
#

set_program_name

#
# File lib/rbt/utility_scripts/symlink_headers.rb, line 93
def set_program_name(
    i = Dir.pwd
  )
  i = i.first if i.is_a? Array
  i = Dir.pwd if i.nil?
  i = i.to_s.dup
  # ======================================================================= #
  # Next, if we have at the least one '/' character, we will try to infer
  # what the user wants to do. Ideally the user provides us with a
  # specific instruction but this will not always be the case so. In
  # these cases, we will have to infer something.
  # ======================================================================= #
  if i.include? '/'
    if i.include?(programs_dir?) and
       (i =~ /\d+/) # Has at the least one number.
      i = i.split('/').reject {|line| line.empty? } # This is assumed to be a String such as '/Programs/Glib/Current/'.
      i = i[1]
    else
      i = File.basename(i)
    end
  end
  i.capitalize! # Conform to my custom, semi-GoboLinux hierarchy.
  @program_name = i
end
set_target_directory(i = nil) click to toggle source
#

set_target_directory

#
# File lib/rbt/utility_scripts/symlink_headers.rb, line 128
def set_target_directory(i = nil)
  @target_directory = i
end