class RBT::FlatpakUrlScanner

Constants

REMOTE_URL
#

REMOTE_URL

#

Public Class Methods

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

RBT::FlatpakUrlScanner[]

#
# File lib/rbt/utility_scripts/flatpak_url_scanner.rb, line 154
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/flatpak_url_scanner.rb, line 28
def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

detect_the_remote_programs() click to toggle source
#

detect_the_remote_programs

This method will detect which remote flatpaks are available. This can then be used to compare it with the local listing done through RBT.

The remote entries will appear like so:

<a href="org.videolan.VLC.flatpakref">org.videolan.VLC.flatpakref</a>        21-Aug-2019 15:24        4021
<a href="org.vim.Vim.flatpakref">org.vim.Vim.flatpakref</a>                  19-Aug-2019 15:25        4011
<a href="org.vranki.spectral.flatpakref">org.vranki.spectral.flatpakref</a>  26-Apr-2019 10:24        4026
<a href="org.wesnoth.Wesnoth.flatpakref">org.wesnoth.Wesnoth.flatpakref</a>  15-Oct-2019 22:29

So we need to grab the entries that are like “VLC” or “Vim”.

#
# File lib/rbt/utility_scripts/flatpak_url_scanner.rb, line 71
def detect_the_remote_programs
  use_this_regex = /a href="org.(.+)\.(.+)\.flatpakref">/ # See: https://rubular.com/r/a4tOp4udOXVy1T
  splitted = @dataset_from_the_remote_website.split("\n")
  splitted.select! {|entry|
    entry.include?('<a href="org.') and
    entry.include?('</a>')
  }
  scanned = splitted.join("\n").scan(
    use_this_regex
  )
  scanned = scanned.map {|a, b| b }
  report(scanned)
end
obtain_the_dataset_available_from_the_remote_website() click to toggle source
#

obtain_the_dataset_available_from_the_remote_website

#
# File lib/rbt/utility_scripts/flatpak_url_scanner.rb, line 50
def obtain_the_dataset_available_from_the_remote_website
  require 'open-uri'
  @dataset_from_the_remote_website = URI.open(REMOTE_URL).read
end
remote_url?() click to toggle source
#

remote_url?

#
# File lib/rbt/utility_scripts/flatpak_url_scanner.rb, line 88
def remote_url?
  REMOTE_URL
end
report(i) click to toggle source
#

report (report tag)

#
# File lib/rbt/utility_scripts/flatpak_url_scanner.rb, line 95
def report(i)
  e
  e "#{rev}The following programs are available at #{steelblue(remote_url?)}:"
  e
  i.each_with_index {|entry, index| index += 1
    name_of_the_program = entry.downcase.delete('-')
    result = lightgreen("  #{index.to_s.rjust(3)}) ")+
             royalblue(
               "#{name_of_the_program.ljust(22)}"
             ).dup
    if RBT.is_this_program_registered? name_of_the_program
      result << olivedrab(
        ' [is a registered program]'
      )
      # =================================================================== #
      # Next determine whether this file has a flatpak_entry or
      # whether it does not.
      # =================================================================== #
      dataset = quickly_obtain_expanded_cookbook_dataset_from(name_of_the_program)
      if dataset.nil?
        require 'rbt/requires/require_the_cookbook_class.rb'
        # ================================================================= #
        # This error here can happen if we do not yet have the expanded
        # dataset. After May 2020 this will no longer be the case, as
        # we will have at the least one expanded dataset in the home
        # directory of the gem - but for the time being, if this returns
        # nil then we will use class Cookbook to add data.
        # ================================================================= #
        dataset = action(:SanitizeCookbook, name_of_the_program) { :fast }
      end
      if dataset.has_key?('flatpak_url') and
        !dataset['flatpak_url'].empty?
      else
        if is_on_roebe?
          result << crimson(' [This entry lacks a flatpak URL.]')
          open_this_file(
            RUBY_SRC_RBT_COOKBOOKS+
            name_of_the_program+'.yml'
          )
          sleep 1
        end
      end
    end
    e result unless result.empty?
  }
  e
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/flatpak_url_scanner.rb, line 42
def reset
  super()
  infer_the_namespace
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/flatpak_url_scanner.rb, line 146
def run
  obtain_the_dataset_available_from_the_remote_website
  detect_the_remote_programs
end