class RBT::CheckForDuplicateBinaries

Constants

DEFAULT_TARGET_DIRECTORY
#

DEFAULT_TARGET_DIRECTORY

#

Public Class Methods

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

[]

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

initialize

#
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 36
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(commandline_arguments)
  menu
  run if run_already
end

Public Instance Methods

check_on_the_files_of_the_target_directory() click to toggle source
#

check_on_the_files_of_the_target_directory

#
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 102
def check_on_the_files_of_the_target_directory
  all_binaries = RBT.all_binaries?
  array_all_binaries = RBT.registered_binaries?
  entries = Dir[target_dir?+'*']
  entries.each {|this_file|
    result = sfile(this_file.ljust(32))
    if array_all_binaries.include?(File.basename(this_file))
      program_name = all_binaries[File.basename(this_file)]
      e result+' is part of the program `'+
        saddlebrown(program_name)+'`.'
      # =================================================================== #
      # Next, we will also check whether there is a duplicate.
      # =================================================================== #
      target_for_binary_duplicate = programs_directory?+
                                    program_name.capitalize+'/'+
                                    'Current/bin/'+program_name
      if File.exist?(target_for_binary_duplicate)
        e (' ' * 31)+
          crimson('This appears to be a duplicate entry, for the file at')
        e (' ' * 31)+
          crimson('`')+sfancy(target_for_binary_duplicate)+crimson('` exists.')
      end
    end
  }
end
menu( i = @commandline_arguments ) click to toggle source
#

menu (menu tag)

#
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 56
def reset
  super()
  use_default_target_directory # Set the default here.
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 162
def run
  check_on_the_files_of_the_target_directory
end
set_commandline_arguments(i) click to toggle source
#

set_commandline_arguments

#
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 49
def set_commandline_arguments(i)
  @commandline_arguments = [i].flatten.compact
end
set_dir( i = DEFAULT_TARGET_DIRECTORY )
set_directory( i = DEFAULT_TARGET_DIRECTORY )
set_pwd_as_directory() click to toggle source
#

set_pwd_as_directory

#
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 88
def set_pwd_as_directory
  set_target_directory(Dir.pwd)
end
set_target_directory( i = DEFAULT_TARGET_DIRECTORY ) click to toggle source
#

set_target_directory

#
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 64
def set_target_directory(
    i = DEFAULT_TARGET_DIRECTORY
  )
  i = i.join(' ').strip if i.is_a? Array
  case i
  when nil, ''
    i = DEFAULT_TARGET_DIRECTORY
  end
  i = i.dup if i.frozen?
  i << '/' unless i.end_with? '/'
  @target_directory = i
end
Also aliased as: set_directory, set_dir
target_dir?()
Alias for: target_directory?
target_directory?() click to toggle source
#

target_directory?

#
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 95
def target_directory?
  @target_directory
end
Also aliased as: target_dir?
use_default_target_directory() click to toggle source
#

use_default_target_directory

#
# File lib/rbt/utility_scripts/check_for_duplicate_binaries.rb, line 81
def use_default_target_directory
  set_target_directory(DEFAULT_TARGET_DIRECTORY)
end