class RBT::Cookbooks::FindMultipleVersions

Constants

ARRAY_IGNORE_THESE_DIRECTORIES
#

ARRAY_IGNORE_THESE_DIRECTORIES

These directories will be ignored.

#
LOCATION
#

LOCATION

#
NAMESPACE
#

NAMESPACE

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/find_multiple_versions.rb, line 50
def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Public Instance Methods

find_all_directories_with_more_than_one_program() click to toggle source
#

find_all_directories_with_more_than_one_program

#
# File lib/rbt/utility_scripts/find_multiple_versions.rb, line 68
def find_all_directories_with_more_than_one_program
  result = Dir[LOCATION+'*'].reject {|entry| !File.directory? entry}
  # ======================================================================= #
  # Next, we have to filter out entries that we do not want to have.
  # ======================================================================= #
  unless ARRAY_IGNORE_THESE_DIRECTORIES.empty?
    result.reject! {|entry|
      ARRAY_IGNORE_THESE_DIRECTORIES.include? File.basename(entry)
    }
  end
  result.sort! # Keep it sorted alphabetically.
  result.map! {|entry| (entry << '/').squeeze('/') }
  return result
end
Also aliased as: all_dirs?
reset() click to toggle source
#

reset

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

run

#
# File lib/rbt/utility_scripts/find_multiple_versions.rb, line 105
def run
  seek_and_report_directories_with_more_than_one_entry
end
seek_and_report_directories_with_more_than_one_entry() click to toggle source
#

seek_and_report_directories_with_more_than_one_entry

#
# File lib/rbt/utility_scripts/find_multiple_versions.rb, line 86
def seek_and_report_directories_with_more_than_one_entry
  counter = 0
  all_dirs?.each {|dir|
    _ = Dir["#{dir}*"]
    if _.size > 1
      counter += 1
      opnn; e '('+sfancy(counter.to_s)+') The directory at `'+sdir(dir)+
              '` has more than one entry.'
      _.each {|entry|
        e crimson("  #{entry}")
      }
      e
    end
  }
end