class RBT::Cookbooks::CheckForInclusion

Constants

ARRAY_WITH_EXCEPTIONS
#

ARRAY_WITH_EXCEPTIONS

The following Array has a list of exceptions. If you wish to skip entries then simply add them here.

#
DEFAULT_FILE
#

DEFAULT_FILE

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

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/cookbooks/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/cookbooks/check_for_inclusion.rb, line 104
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
    file_short_name = ProgramInformation.return_real_name(
      File.basename(file_long_name)
    )
    file_short_name.downcase! if file_short_name
    e "Now #{steelblue('scanning')} for the "\
      "program `#{sfile(file_short_name)}`."
    # ===================================================================== #
    # 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?
        opnwarn '`'+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/cookbooks/check_for_inclusion.rb, line 135
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/cookbooks/check_for_inclusion.rb, line 145
def report_to_user_which_files_are_not_included
  e sfancy('These files were not found:')
  e
  cliner {
    @array_files_which_were_not_found.each {|entry|
      e steelblue("  #{entry}")
    }
  }
  e
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/cookbooks/check_for_inclusion.rb, line 62
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @base_dir
  # ======================================================================= #
  @base_dir = source_directory?
  # ======================================================================= #
  # === @array_files_which_were_not_found
  # ======================================================================= #
  @array_files_which_were_not_found = []
  # ======================================================================= #
  # === @all_files
  # ======================================================================= #
  @all_files = []
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  set_be_verbose
  # ======================================================================= #
  # === @query
  # ======================================================================= #
  @query = RBT::Cookbooks::SanitizeCookbook.new(:do_not_run_yet) { :fast }
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/cookbooks/check_for_inclusion.rb, line 185
def run
  run_everything
end
run_everything() click to toggle source
#

run_everything

#
# File lib/rbt/cookbooks/check_for_inclusion.rb, line 174
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/cookbooks/check_for_inclusion.rb, line 92
def scan_for_all_files
  _ = @base_dir+'*/**'
  opne 'Scanning for all files in directory `'+sdir(_)+'` now.'
  opne 'Be patient, this may take a while.'
  @all_files = Dir[_].sort
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/cookbooks/check_for_inclusion.rb, line 159
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