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.

#
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/cookbooks/scan_for_blfs_programs.rb, line 55
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/cookbooks/scan_for_blfs_programs.rb, line 128
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?
    opne '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?
      opne 'The program `'+sfancy(this_program)+'` is missing a blfs: entry.'
      remote_html_page = remote_blfs_page+'general/'+this_program+'.html'
      opne 'The remote BLFS page is: '+
            simp(remote_html_page)
      # =================================================================== #
      # Next, also report where it is available locally.
      # =================================================================== #
      if on_roebe?
        local_path = "#{RUBY_SRC_RBT_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
          open_in_editor(local_path)
        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/cookbooks/scan_for_blfs_programs.rb, line 114
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/cookbooks/scan_for_blfs_programs.rb, line 94
def obtain_dataset_from_the_remote_webpage
  opne 'Obtaining data from '+steelblue(REMOTE_BASE_URL)+'.'
  @dataset_from_the_remote_webpage = URI.open(REMOTE_BASE_URL).read
  # ======================================================================= #
  # The remote homepage is actuall in ISO format.
  # ======================================================================= #
  @dataset_from_the_remote_webpage.force_encoding('iso-8859-1')
  # ======================================================================= #
  # 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/cookbooks/scan_for_blfs_programs.rb, line 80
def remote_blfs_page?
  REMOTE_BASE_URL
end
remote_regex?() click to toggle source
#

remote_regex?

#
# File lib/rbt/cookbooks/scan_for_blfs_programs.rb, line 87
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/cookbooks/scan_for_blfs_programs.rb, line 121
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/cookbooks/scan_for_blfs_programs.rb, line 181
def report_how_many_remote_entries_exist
  opne '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/cookbooks/scan_for_blfs_programs.rb, line 66
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @dataset_from_the_remote_webpage
  # ======================================================================= #
  @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/cookbooks/scan_for_blfs_programs.rb, line 190
def run
  report_how_many_remote_entries_exist
  iterate_over_all_programs_missing_a_blfs_entry 
end