class 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

#
Calls superclass method
# File lib/cookbooks/utility_scripts/check_for_inclusion.rb, line 51
def initialize(run_already = true)
  super()
  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/cookbooks/utility_scripts/check_for_inclusion.rb, line 84
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/cookbooks/utility_scripts/check_for_inclusion.rb, line 115
def is_included?(i)
  i.delete!('_') if i.include? '_'
  @query[i]
  is_included = @query.is_included?
  return true if is_included
  false # default return value
end
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Base#opnn
# File lib/cookbooks/utility_scripts/check_for_inclusion.rb, line 153
def opnn
  super(NAMESPACE)
end
report_to_user_which_files_are_not_included() click to toggle source
#

#report_to_user_which_files_are_not_included

#
# File lib/cookbooks/utility_scripts/check_for_inclusion.rb, line 126
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

#
# File lib/cookbooks/utility_scripts/check_for_inclusion.rb, line 59
def reset
  @base_dir = SOURCE_DIR
  @array_files_which_were_not_found = []
  @all_files = []
  @be_verbose = true
  @query = Cookbooks::Cookbook.new
end
run() click to toggle source
#

run

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

#run_everything

#
# File lib/cookbooks/utility_scripts/check_for_inclusion.rb, line 160
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/cookbooks/utility_scripts/check_for_inclusion.rb, line 72
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/cookbooks/utility_scripts/check_for_inclusion.rb, line 138
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('  '+DEFAULT_FILE)
end