class RBT::Cookbooks::CheckForInclusion

Constants

ARRAY_WITH_EXCEPTIONS
#

ARRAY_WITH_EXCEPTIONS

The following Array has a list of exceptions.

#
DEFAULT_FILE
#

DEFAULT_FILE

Where to store our results. A .md markdown file may seem appropriate.

#
NAMESPACE
#

NAMESPACE

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

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

Public Instance Methods

check_each_file_whether_it_is_included() click to toggle source
#

check_each_file_whether_it_is_included

Here we report only if @be_verbose is true. (3)

#
# File lib/rbt/utility_scripts/check_for_inclusion.rb, line 89
def check_each_file_whether_it_is_included
  @all_files.each { |file_long_name, file_short_name|
    unless ARRAY_WITH_EXCEPTIONS.empty?
      dirname = File.dirname(file_long_name)+'/'
      next if ARRAY_WITH_EXCEPTIONS.include?(dirname)
    end
    if file_short_name.nil?
      file_short_name = ProgramInformation.return_real_name(
        File.basename(file_long_name)
      ).downcase
      opnn; e 'Now scanning for the program `'+sfile(file_short_name)+'`.'
    end
    # ===================================================================== #
    # If it is included then everything is fine.
    # ===================================================================== #
    if is_included?(file_short_name)
      # f '`'+file_long_name+'` is included.' if @be_verbose # Be silent here.
    else # Else it is not included.
      if be_verbose?
        opnn; ewarn '`'+simp(file_long_name)+swarn('` is not included.')
      end
      @array_files_which_were_not_found << file_long_name
    end
  }
end
is_included?(i) click to toggle source
#

is_included?

Query whether the program is included or not.

#
# File lib/rbt/utility_scripts/check_for_inclusion.rb, line 120
def is_included?(i)
  i.delete!('_') if i.include? '_'
  is_included = @query.is_included?(i)
  return true if is_included
  false # default return value
end
report_to_user_which_files_are_not_included() click to toggle source
#

report_to_user_which_files_are_not_included

#
# File lib/rbt/utility_scripts/check_for_inclusion.rb, line 130
def report_to_user_which_files_are_not_included
  e sfancy('These files were not found:')
  cliner {
    @array_files_which_were_not_found.each {|entry|
      e '  '+entry
    }
  }
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/check_for_inclusion.rb, line 62
def reset
  super()
  @namespace = NAMESPACE
  @base_dir = source_directory?
  @array_files_which_were_not_found = []
  @all_files = []
  @be_verbose = true
  @query = RBT::Cookbooks::Cookbook.new { :bypass_menu_check }
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/check_for_inclusion.rb, line 168
def run # Run tag
  run_everything
end
run_everything() click to toggle source
#

run_everything

#
# File lib/rbt/utility_scripts/check_for_inclusion.rb, line 157
def run_everything
  reset                                       # (1)
  scan_for_all_files                          # (2)
  check_each_file_whether_it_is_included      # (3)
  report_to_user_which_files_are_not_included # (4)
  store_results_to_file                       # (5)
end
scan_for_all_files() click to toggle source
#

scan_for_all_files

Scan for all files and fill up the array @all_files

#
# File lib/rbt/utility_scripts/check_for_inclusion.rb, line 77
def scan_for_all_files
  _ = @base_dir+'*/**'
  opnn; e 'Scanning for all files in directory `'+sdir(_)+'` now.'
  opnn; e 'Be patient, this may take a while.'
  @all_files = Dir[_]
end
store_results_to_file( what = @array_files_which_were_not_found, where_to = DEFAULT_FILE ) click to toggle source
#

store_results_to_file

#
# File lib/rbt/utility_scripts/check_for_inclusion.rb, line 142
def store_results_to_file(
    what     = @array_files_which_were_not_found,
    where_to = DEFAULT_FILE
  )
  remove_file(where_to) # Delete the old file first, before appending into a new one.
  @array_files_which_were_not_found.each { |f|
    append_what_into(f+N, where_to)
  }
  e 'Stored into:'
  e sfancy("  #{where_to}")
end