class RBT::Cookbooks::CheckForRemoteWebpages

Public Instance Methods

add_these_programs_were_updated(i) click to toggle source
#

add_these_programs_were_updated

#
# File lib/rbt/check_for_updates/base.rb, line 79
def add_these_programs_were_updated(i)
  @internal_hash[:array_these_programs_were_updated] << i
end
array_these_programs_were_updated?() click to toggle source
#

array_these_programs_were_updated?

#
# File lib/rbt/check_for_updates/base.rb, line 64
def array_these_programs_were_updated?
  @internal_hash[:array_these_programs_were_updated]
end
commandline_size_query_was_issued?() click to toggle source
#

commandline_size_query_was_issued?

#
# File lib/rbt/check_for_updates/base.rb, line 100
def commandline_size_query_was_issued?
  commandline_arguments?.any? {|entry|
    entry.include? 'size'
  }
end
correct_for_common_mistakes_in_program_names(i) click to toggle source
#

correct_for_common_mistakes_in_program_names

The BLFS folks, but also the slackware folks, use some wrong names.

The following ad-hoc case/when menu will correct some of these wrong names.

The correct name is the one that comes from the official tarball release. So for example, for “gtk+-3.93.0.tar.xz”, the official name is exactly “gtk+” and NOT “gtk+3”, despite the BLFS team thinking otherwise.

#
# File lib/rbt/check_for_updates/base.rb, line 126
def correct_for_common_mistakes_in_program_names(i)
  case i # case tag, sanitize tag
  when 'node.js'
    i = 'node'
  when 'openjpeg2'
    i = 'openjpeg'
  when 'gtk+3'
    i = 'gtk+'
  end
  return i
end
dataset?() click to toggle source
#

dataset?

#
# File lib/rbt/check_for_updates/base.rb, line 154
def dataset?
  @dataset
end
distrowatch_url?() click to toggle source
#

distrowatch_url?

#
# File lib/rbt/check_for_updates/base.rb, line 109
def distrowatch_url?
  'https://distrowatch.org/'
end
do_use_wget() click to toggle source
#

do_use_wget

#
# File lib/rbt/check_for_updates/base.rb, line 86
def do_use_wget
  @internal_hash[:use_wget] = true
end
ensure_download_mode_is_system_wget_from_now_on() click to toggle source
#

ensure_download_mode_is_system_wget_from_now_on

#
# File lib/rbt/check_for_updates/base.rb, line 264
def ensure_download_mode_is_system_wget_from_now_on
  @internal_hash[:use_this_download_mode] = :system_wget
end
menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
notify_the_user_that_no_downloads_have_occurred() click to toggle source
#

notify_the_user_that_no_downloads_have_occurred

#
# File lib/rbt/check_for_updates/base.rb, line 161
def notify_the_user_that_no_downloads_have_occurred
  opne "#{rev}No downloads occurred. This usually means"
  opne "that all local programs are up to date! "+
       yellow("\\o/")+rev
end
obtain_dataset_from_the_remote_webpage( url_to_the_remote_webpage = remote_webpage? ) click to toggle source
#

obtain_dataset_from_the_remote_webpage

The argument to this method can be a String such as “download.kde.org/stable/frameworks/5.102/”.

#
# File lib/rbt/check_for_updates/base.rb, line 231
def obtain_dataset_from_the_remote_webpage(
    url_to_the_remote_webpage = remote_webpage?
  )
  begin
    @dataset = URI.open(url_to_the_remote_webpage).read
  # ======================================================================= #
  # The next clause will be entered when we encountered some OpenSSL
  # related problem.
  # ======================================================================= #
  rescue OpenSSL::SSL::SSLError => error
    opne tomato('An error occurred, related to OpenSSL. Perhaps openssl')
    opne tomato('has not been installed correctly. Either way the')
    opne tomato('download mode will be changed.')
    ensure_download_mode_is_system_wget_from_now_on
    cd log_dir? # We are now in "/home/x/Temp/rbt/".
    local_file = "#{log_dir?}index.html"
    delete_file(local_file)
    esystem "wget #{url_to_the_remote_webpage}"
    @dataset = File.read(local_file)
  rescue OpenURI::HTTPError => error
    opnn; etomato('OpenURI::HTTPError was encountered. This usually happens when the')
    opne  tomato('URL is invalid (')+
          sfancy(url_to_the_remote_webpage)+
          tomato(')')
    opnn; etomato('Consider fixing the URL and trying again.')
    pp error
    exit
  end
end
Also aliased as: obtain_remote_dataset
obtain_remote_dataset( url_to_the_remote_webpage = remote_webpage? )
report_that_these_programs_were_updated(array) click to toggle source
#

report_that_these_programs_were_updated

#
# File lib/rbt/check_for_updates/base.rb, line 141
def report_that_these_programs_were_updated(array)
  unless array.empty?
    opne "#{rev}The following #{simp(array.size.to_s)} "\
         "#{rev}programs were updated:"
    array.each {|this_program|
      e "  #{sfancy(this_program)}"
    }
  end
end
report_the_remote_webpage( i = remote_webpage? ) click to toggle source
#

report_the_remote_webpage

Standard method to report the remote webpage in use.

#
# File lib/rbt/check_for_updates/base.rb, line 214
def report_the_remote_webpage(
    i = remote_webpage?
  )
  opne grey('Attempting to obtain data from the following ')+
       lightblue('remote URL')+
       (':')
  e
  e "  #{steelblue(i)}"
  e
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/check_for_updates/base.rb, line 30
def reset
  super()
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  @internal_hash = {}
  # ======================================================================= #
  # === :use_wget
  # ======================================================================= #
  @internal_hash[:use_wget] = false
  # ======================================================================= #
  # === :use_this_download_mode
  # ======================================================================= #
  @internal_hash[:use_this_download_mode] = :ruby_wrapper_over_wget
  # ======================================================================= #
  # === :array_these_programs_were_updated
  #
  # The next Array can keep track of which programs were updated.
  # ======================================================================= #
  @internal_hash[:array_these_programs_were_updated] = []
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = nil # ← This variable will store the downloaded-dataset (from open-uri).
  # ======================================================================= #
  # === @downloaded_n_programs
  # ======================================================================= #
  @downloaded_n_programs = 0 # ← Keeps track of how many programs were batch-downloaded.
  do_use_colours
end
return_local_version_of_this_program(i) click to toggle source
#

return_local_version_of_this_program

#
# File lib/rbt/check_for_updates/base.rb, line 170
def return_local_version_of_this_program(i)
  action(:SanitizeCookbook, i) { :fast }.program_version?
end
show_help() click to toggle source
#

show_help

#
# File lib/rbt/check_for_updates/base.rb, line 202
def show_help
  e
  e "#{rev}  The option #{steelblue('--use-wget')}"\
    " can be used to force the use of system wget."
  e
end
that_remote_URL_should_be_at(full_remote_url) click to toggle source
#

that_remote_URL_should_be_at

#
# File lib/rbt/check_for_updates/base.rb, line 71
def that_remote_URL_should_be_at(full_remote_url)
  opne "#{rev}That remote URL should be at: "\
       "#{sfancy(full_remote_url)}#{rev}"
end
update_entry(full_remote_url) click to toggle source
#

update_entry

#
# File lib/rbt/check_for_updates/base.rb, line 271
def update_entry(full_remote_url)
  require 'rbt/requires/require_class_update_entry.rb'
  RBT::UpdateEntry.new(full_remote_url) {{
    do_not_ftp_upload: true,
    download_mode:     @internal_hash[:use_this_download_mode]     
  }}
end
use_wget?() click to toggle source
#

use_wget?

#
# File lib/rbt/check_for_updates/base.rb, line 93
def use_wget?
  @internal_hash[:use_wget]
end