class RBT::Cookbooks::ScanForBlfsPrograms

Constants

ALSO_GIVE_HELP_FOR_MODIFYING_THESE_ENTRIES
#

ALSO_GIVE_HELP_FOR_MODIFYING_THESE_ENTRIES

#
ALSO_REMOVE_NUMBERS_FROM_REMOTE_PROGRAM_NAMES
#

ALSO_REMOVE_NUMBERS_FROM_REMOTE_PROGRAM_NAMES

If the following constant is set, then we will remove all numbers from the given input.

#
NAMESPACE
#

NAMESPACE

#
OPEN_IN_EDITOR
#

OPEN_IN_EDITOR

#
REGEX_FOR_PROGRAMS_REGISTERED_AT_THE_REMOTE_BLFS_WEBPAGE
#

REGEX_FOR_PROGRAMS_REGISTERED_AT_THE_REMOTE_BLFS_WEBPAGE

#
REMOTE_BASE_URL
#

REMOTE_BASE_URL

#

Public Class Methods

new( optional_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 60
def initialize(
    optional_arguments = ARGV,
    run_already        = true
  )
  reset
  run if run_already
end

Public Instance Methods

iterate_over_all_programs_missing_a_blfs_entry() click to toggle source
#

iterate_over_all_programs_missing_a_blfs_entry

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 122
def iterate_over_all_programs_missing_a_blfs_entry
  # ======================================================================= #
  # First, build up our Array that has the programs registered which
  # also have a remote BLFS page.
  # ======================================================================= #
  array_these_local_programs_do_not_have_a_blfs_entry = []
  @programs_missing_a_blfs_entry.each {|this_program|
    if ALSO_REMOVE_NUMBERS_FROM_REMOTE_PROGRAM_NAMES
      if this_program =~ /\d+/
        this_program = remove_all_numbers_from(this_program)
      end
    end
    if @remotely_available_programs.include? this_program
      array_these_local_programs_do_not_have_a_blfs_entry << this_program
    end
  }
  if array_these_local_programs_do_not_have_a_blfs_entry.empty?
    opnn; e 'All remote programs have already been registered '\
            'locally. This is '+gold('good')+'! \\o/' 
  else
    array_these_local_programs_do_not_have_a_blfs_entry.each {|this_program|
      remote_blfs_page = remote_blfs_page?
      opnn; e 'The program `'+sfancy(this_program)+'` is missing a blfs: entry.'
      remote_html_page = remote_blfs_page+'general/'+this_program+'.html'
      opnn; e 'The remote BLFS page is: '+
               simp(remote_html_page)
      # =================================================================== #
      # Next, also report where it is available locally.
      # =================================================================== #
      if on_roebe?
        local_path = ROEBE_PATH_TO_COOKBOOKS+
                     'yaml/individual_cookbooks/'+this_program+'.yml'
      else
        local_path = return_location_to_this_programs_yaml_file(this_program)
      end
      if ALSO_GIVE_HELP_FOR_MODIFYING_THESE_ENTRIES
        e
        e '  bl '+sfile(local_path)
        e '  '+simp(remote_html_page)
        if OPEN_IN_EDITOR and is_on_roebe?
          e
          e 'Opening in the editor as well, after a delay of 0.8 seconds.'
          sleep 0.8
          cmd = editor?+' '+local_path
          e cmd
          system cmd
        end
        e
      end
    }
  end
end
obtain_all_programs_that_miss_a_blfs_entry() click to toggle source
#

obtain_all_programs_that_miss_a_blfs_entry

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 108
def obtain_all_programs_that_miss_a_blfs_entry
  @programs_missing_a_blfs_entry = RBT.return_array_of_programs_without_a_blfs_entry
end
obtain_dataset_from_the_remote_webpage() click to toggle source
#

obtain_dataset_from_the_remote_webpage

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 96
def obtain_dataset_from_the_remote_webpage
  @dataset_from_the_remote_webpage = open(REMOTE_BASE_URL).read
  # ======================================================================= #
  # The next variable will contain all programs that are available
  # at the BLFS webpage.
  # ======================================================================= #
  @remotely_available_programs = @dataset_from_the_remote_webpage.scan(/#{remote_regex?}/).flatten
end
remote_blfs_page?() click to toggle source
#

remote_blfs_page?

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 82
def remote_blfs_page?
  REMOTE_BASE_URL
end
remote_regex?() click to toggle source
#

remote_regex?

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 89
def remote_regex?
  REGEX_FOR_PROGRAMS_REGISTERED_AT_THE_REMOTE_BLFS_WEBPAGE
end
remove_all_numbers_from(i) click to toggle source
#

remove_all_numbers_from

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 115
def remove_all_numbers_from(i)
  i.gsub(/\d/,'')
end
report_how_many_remote_entries_exist() click to toggle source
#

report_how_many_remote_entries_exist

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 178
def report_how_many_remote_entries_exist
  opnn; e 'The remote BLFS webpage has at the least '+
           simp(@remotely_available_programs.size.to_s)+' programs registered.'
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 71
def reset
  super()
  @namespace = NAMESPACE
  @dataset_from_the_remote_webpage = nil
  obtain_all_programs_that_miss_a_blfs_entry
  obtain_dataset_from_the_remote_webpage
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/scan_for_blfs_programs.rb, line 186
def run
  report_how_many_remote_entries_exist
  iterate_over_all_programs_missing_a_blfs_entry 
end