class RBT::Cookbooks::UpdateKdePlasma

Public Class Methods

[](i = '') click to toggle source
#

RBT::Cookbooks::UpdateKdePlasma[]

#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 183
def self.[](i = '')
  new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 28
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_commandline(
    i
  )
  run if run_already
end

Public Instance Methods

decide_what_to_do_next() click to toggle source
#

decide_what_to_do_next

The first variant can be invoked via:

KDE_Plasma --size
#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 82
def decide_what_to_do_next
  if commandline_size_query_was_issued?
    opne "There are #{sfancy(@scanned_results.size)} remote "\
         "KDE Plasma programs."
  else # else, enter the default "modus operandi".
    iterate_through_the_results_and_update_old_cookbooks_entries
  end
end
iterate_through_the_results_and_update_old_cookbooks_entries() click to toggle source
#

iterate_through_the_results_and_update_old_cookbooks_entries

This will go over the dataset stored in @scanned_results, to then check on the program given there.

#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 112
def iterate_through_the_results_and_update_old_cookbooks_entries
  @scanned_results.each {|this_program| # ← That variable is e. g. 'plasma-vault-5.11.0'
    name_of_the_program, program_version = ::ProgramInformation.return_array_program_name_and_program_version(this_program)
    # ===================================================================== #
    # Next, we must compare it to the local dataset.
    # ===================================================================== #
    local_dataset = new_cookbook_instance_for(name_of_the_program)
    local_program_version = local_dataset.program_version?
    if local_program_version.nil?
      e
      e tomato('nil-value for ')+
        sfancy(name_of_the_program)+
        ' - the local_program_version was nil.'
      e
    elsif program_version.nil?
      e
      e tomato('nil-value for ')+
        sfancy(name_of_the_program)+
        ' - the program_version was nil.'
      e
    end
    shall_we_download_the_program = local_program_version < program_version
    shall_we_download_the_program = true if @download_the_program_without_any_additional_checks
    if shall_we_download_the_program
      # =================================================================== #
      # In this case, we have to update.
      # =================================================================== #
      @downloaded_n_programs += 1
      opne "#{rev}There is a more recent program version "\
           "available for `#{sfancy(name_of_the_program)}`."
      full_remote_url = remote_download_url?.dup
      full_remote_url << '/' unless full_remote_url.end_with? '/'
      full_remote_url << "#{program_version}/#{this_program}.tar.xz"
      that_remote_URL_should_be_at(full_remote_url)
      colourized_result = slateblue(
        "class RBT::UpdateEntry.new(#{full_remote_url})"
      )
      opne "Now delegating towards #{colourized_result}."
      update_entry(full_remote_url)
      # =================================================================== #
      # Keep track of which programs were updated:
      # =================================================================== #
      add_these_programs_were_updated(
        remove_archive_from_the_end(
          File.basename(full_remote_url)
        )
      )
    end
  }
  if @downloaded_n_programs == 0
    notify_the_user_that_no_downloads_have_occurred
  else
    report_that_these_programs_were_updated(
      array_these_programs_were_updated?
    )
  end
end
main_url?() click to toggle source
#

main_url?

#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 61
def main_url?
  REMOTE_URL_FOR_KDE_PLASMA # ← e. g. "https://www.kde.org/info/plasma-5.13.5.php"
end
remote_download_url?() click to toggle source
#

remote_download_url?

#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 70
def remote_download_url?
  REMOTE_DOWNLOAD_URL_FOR_KDE_PLASMA # => e. g. "https://download.kde.org/stable/plasma/"
end
remote_url?()
Alias for: main_url?
remote_webpage?()
Alias for: main_url?
remote_website?()
Alias for: main_url?
reset() click to toggle source
#

reset (reset tag)

#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 42
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @download_the_program_without_any_additional_checks
  #
  # If the following instance variable is set to true then we will
  # download the remote program anyway, without any additional
  # checks.
  #
  # By default this is set to false, but for debugging I may
  # sometimes set this to true.
  # ======================================================================= #
  @download_the_program_without_any_additional_checks = false
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 173
def run
  report_the_remote_webpage
  obtain_remote_dataset
  scan_for_all_results
  decide_what_to_do_next
end
scan_for_all_results() click to toggle source
#

scan_for_all_results

#
# File lib/rbt/check_for_updates/update_kde_plasma.rb, line 94
def scan_for_all_results
  # ======================================================================= #
  # See this entry for the following regex:
  #
  #   https://rubular.com/r/KsMYvnkFWk
  #
  # ======================================================================= #
  use_this_regex =
    /<td><a href="(http:\/\/download.kde.org\/stable\/plasma\/\d{0,1}.\d{0,2}.\d{0,2}\/)?(.+)\.tar\.xz">\D.+<\/a>/
  @scanned_results = @dataset.scan(use_this_regex).flatten.compact
end