class RBT::Cookbooks::UpdateLxqt

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

RBT::Cookbooks::UpdateLxqt[]

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

initialize

#
# File lib/rbt/check_for_updates/update_lxqt.rb, line 32
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:

update_lxqt --size
#
# File lib/rbt/check_for_updates/update_lxqt.rb, line 67
def decide_what_to_do_next
  if commandline_size_query_was_issued?
    opnn; e "There are #{sfancy(@scanned_results.size)} remote "\
            "LXQT components."
  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

#
# File lib/rbt/check_for_updates/update_lxqt.rb, line 79
def iterate_through_the_results_and_update_old_cookbooks_entries
  require 'rbt/cookbooks/class/class.rb'
  @scanned_results.each {|this_program| # <- That variable is the full URL to the program.
    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 < program_version
      # =================================================================== #
      # In this case, we have to update.
      # =================================================================== #
      @downloaded_n_programs += 1
      opnn; e "There is a more recent program version "\
              "available for `#{sfancy(name_of_the_program)}`."
      full_remote_url = "#{this_program}".dup
      opnn; e "That remote URL should be at: "\
              "#{sfancy(full_remote_url)}"
      colourized_result = slateblue(
        "class RBT::UpdateEntry.new(#{full_remote_url})"
      )
      opnn; e "Now delegating towards #{colourized_result}."
      RBT::UpdateEntry.new(full_remote_url) { :do_not_ftp_upload }
      # =================================================================== #
      # Keep track of which programs were updated:
      # =================================================================== #
      @array_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_lxqt.rb, line 54
def main_url?
  REMOTE_DOWNLOAD_URL_FOR_LXQT # <- e. g. 'https://downloads.lxqt.org/'
end
remote_download_url?()
Alias for: main_url?
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_lxqt.rb, line 46
def reset
  super()
  @namespace = NAMESPACE
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/check_for_updates/update_lxqt.rb, line 153
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_lxqt.rb, line 123
def scan_for_all_results
  # ======================================================================= #
  # See this entry for the following regex:
  #   https://rubular.com/r/6SYxcOqmJxK9gC
  # ======================================================================= #
  use_this_regex =
    /<a href="downloads\/([a-z-]+)\/([0-9.]+)">(.+)<\/a><br>/
  scanned_results = @dataset.scan(use_this_regex)
  # ======================================================================= #
  # Must modify it a bit still, to get the real URL.
  # ======================================================================= #
  scanned_results.map! {|inner_array| # <- May look like ["libqtxdg", "3.3.1", "libqtxdg 3.3.1"]
    first  = inner_array[0] # like: 'libqtxdg'
    second = inner_array[1] # like: '0.14.1'
    third  = inner_array[2] # like: 'libqtxdg 3.3.1'
    # ===================================================================== #
    # Assemble the full URL here, rather than at a later point.
    # ===================================================================== #
    "#{REMOTE_DOWNLOAD_BASE_URL_FOR_LXQT}"\
    "downloads/"\
    "#{first}/"\
    "#{second}/"\
    "#{third.tr(' ','-')}.tar.xz"
  }
  @scanned_results = scanned_results
end