class RBT::Cookbooks::FindMultipleVersions

Constants

ARRAY_IGNORE_THESE_DIRECTORIES
#

ARRAY_IGNORE_THESE_DIRECTORIES

These directories will be ignored.

#
LOCATION
#

LOCATION

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/find_multiple_versions.rb, line 46
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 64
def find_all_directories_with_more_than_one_program
  result = Dir["#{LOCATION}*"].select {|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 56
def reset
  super()
  infer_the_namespace
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/find_multiple_versions.rb, line 104
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 82
def seek_and_report_directories_with_more_than_one_entry
  counter = 0
  all_dirs?.each {|dir|
    _ = Dir["#{dir}*"]
    if _.size > 1
      counter += 1
      opne "(#{sfancy(counter.to_s)}) The directory at `#{sdir(dir)}"\
           "` has more than one entry."
      # =================================================================== #
      # Sort them all alphabetically before we display them next.
      # =================================================================== #
      _.sort.each {|entry|
        e crimson("  #{entry}")
      }
      e
    end
  }
end