class RBT::ClassesForIndividualPrograms::Gcc::ChangeLib64ToLib

Constants

DEFAULT_FILE
#

DEFAULT_FILE

This constant specifies the default that is to be used. After all the whole class here was written in order to modify that particular file anyway.

#
SEEK_THIS_SUBSTRING
#

SEEK_THIS_SUBSTRING

#

Public Class Methods

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

RBT::ClassesForIndividualPrograms::Gcc:ChangeLib64ToLib[]

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 183
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 45
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

query_whether_an_argument_has_been_given() click to toggle source
#

query_whether_an_argument_has_been_given

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 173
def query_whether_an_argument_has_been_given
  _ = first_argument?
  if _.nil? or _.nil?
    opne 'Please provide a valid file path to this class.'
  end
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 59
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = nil # <- Initial state.
end
return_the_default_regex() click to toggle source
#

return_the_default_regex

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 136
def return_the_default_regex
  Regexp.new(SEEK_THIS_SUBSTRING)
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 143
def run
  query_whether_an_argument_has_been_given
  if first_argument?
    set_modify_this_file(first_argument?)
    try_to_read_in_the_main_dataset
    if @dataset
      # =================================================================== #
      # The replacement will only work on 64-bit systems.
      # =================================================================== #
      if is_a_64bit_system?
        if @dataset.include? SEEK_THIS_SUBSTRING
          use_this_regex = return_the_default_regex
          opne 'The regex to be applied is: '+steelblue(use_this_regex)
          @dataset.gsub!(use_this_regex, 'm64=../lib')
          store_file(@dataset)
        else
          opne "The file does not contain the "\
               "substring #{steelblue(SEEK_THIS_SUBSTRING)}."
        end
      else
        opne 'Applying the regex replacing m64=../lib only works'
        opne 'for 64-bit systems.'
      end
    end
  end
end
sanitize_commandline_arguments() click to toggle source
#

sanitize_commandline_arguments

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 90
def sanitize_commandline_arguments
  commandline_arguments?.map! {|entry|
    case entry
    when 'default'
      entry = DEFAULT_FILE
    end unless File.exist?('default')
    entry
  }
end
set_commandline_arguments(i = ARGV) click to toggle source
#

set_commandline_arguments

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 71
def set_commandline_arguments(i = ARGV)
  case i
  when :default
    i = DEFAULT_FILE
  end
  i = [i].flatten.compact
  if i.empty? and is_on_roebe?
    # ===================================================================== #
    # Use a default, hardcoded file path in this event.
    # ===================================================================== #
    i << DEFAULT_FILE
  end
  internal_hash_set_commandline_arguments(i)
  sanitize_commandline_arguments
end
set_modify_this_file(i) click to toggle source
#

set_modify_this_file

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 103
def set_modify_this_file(i)
  @modify_this_file = i
end
store_file( what = @dataset, into = @modify_this_file ) click to toggle source
#

store_file

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 122
def store_file(
    what = @dataset, into = @modify_this_file
  )
  into = File.absolute_path(into)
  opne "Saving into the file:"
  e
  e "  #{sfile(into)}"
  e
  write_what_into(what, into)
end
try_to_read_in_the_main_dataset() click to toggle source
#

try_to_read_in_the_main_dataset

#
# File lib/rbt/misc/classes_for_individual_programs/change_lib64_to_lib.rb, line 110
def try_to_read_in_the_main_dataset
  _ = @modify_this_file
  if File.exist? _
    @dataset = default_readlines(_).join
  else
    opnn; no_file_exists_at(_)
  end
end