class RBT::Blfs

Public Class Methods

new( i = ARGV, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/blfs.rb, line 27
def initialize(
    i           = ARGV,
    run_already = true
  )
  register_sigint
  reset # reset() must come before the other methods.
  set_commandline_arguments(i)
  # ======================================================================= #
  # === Handle blocks
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    when :no_colours,
         :disable_colours
      disable_colours
      do_not_show_opnn
      @report_result = false
    # ===================================================================== #
    # === :be_quiet_and_do_not_tamper_with_the_xorg_buffer
    # ===================================================================== #
    when :be_quiet_and_do_not_tamper_with_the_xorg_buffer
      set_do_not_be_verbose
      @also_assign_the_xorg_buffer = false
    # ===================================================================== #
    # === :be_quiet
    # ===================================================================== #
    when :be_quiet
      set_be_quiet
    # ===================================================================== #
    # === :no_colours_be_quiet
    # ===================================================================== #
    when :no_colours_be_quiet
      set_do_not_be_verbose
      disable_colours
      do_not_show_opnn
      @report_result = false
    end
  end
  run if run_already
end

Public Instance Methods

all_blfs_entries() click to toggle source
#

all_blfs_entries

#
# File lib/rbt/utility_scripts/blfs.rb, line 144
def all_blfs_entries
  RBT.return_all_blfs_entries
end
check_blfs_entry_for( i, raw_cookbook = raw_cookbook? ) click to toggle source
#

check_blfs_entry_for

#
# File lib/rbt/utility_scripts/blfs.rb, line 161
def check_blfs_entry_for(
    i, raw_cookbook = raw_cookbook?
  )
  i = i.to_s.dup
  i.delete!('-') if i.include? '-'
  set_program(i)
  raw_cookbook.unfreeze
  _ = raw_cookbook.find(program?)
  if _ # Some entries may be nil, if we use grep.
    use_this_key = 'blfs'
    # ===================================================================== #
    # Work on Symbols next, if the dataset makes use of them:
    # ===================================================================== #
    if _.has_key? use_this_key.to_sym
      use_this_key = use_this_key.to_sym
    end
    if _.has_key? use_this_key
      blfs_entry = _[use_this_key] # Fetch the blfs entry here.
      blfs_entry = blfs_entry.first if blfs_entry.is_a? Array
      @blfs_homepage = blfs_entry
      if @report_result and be_verbose? and !(i == 'blfs')
        report_homepage(@blfs_homepage) # Defaults to @homepage as argument.
        # ================================================================= #
        # Since as of January 2023, the homepage will be opened on my
        # home system.
        # ================================================================= #
        if is_on_roebe?
          open_in_browser(@blfs_homepage)
        end
      end
    else
      report_that_no_blfs_entry_exists_for_the_program if be_verbose?
    end
  else
    report_that_no_blfs_entry_exists_for_the_program if be_verbose?
  end
end
do_not_show_opnn() click to toggle source
#

do_not_show_opnn

#
# File lib/rbt/utility_scripts/blfs.rb, line 124
def do_not_show_opnn
  disable_opn
end
homepage()
Alias for: homepage?
homepage?() click to toggle source
#

homepage?

#
# File lib/rbt/utility_scripts/blfs.rb, line 151
def homepage?
  @blfs_homepage # Store the homepage here.
end
program?() click to toggle source
#

program?

This will yield to us which program we are searching for in this class.

In other words, this will be equal to the input the user provided to this class.

#
# File lib/rbt/utility_scripts/blfs.rb, line 137
def program?
  @program
end
raw_cookbook?() click to toggle source
#

raw_cookbook?

#
# File lib/rbt/utility_scripts/blfs.rb, line 110
def raw_cookbook?
  @internal_hash[:raw_cookbook]
end
remote_url?()
Alias for: homepage?
report_homepage( i = @blfs_homepage, also_assign_to_the_xorg_buffer = @also_assign_the_xorg_buffer ) click to toggle source
#

report_homepage

#
# File lib/rbt/utility_scripts/blfs.rb, line 231
def report_homepage(
    i                              = @blfs_homepage, # Defaults to @blfs_homepage as argument.
    also_assign_to_the_xorg_buffer = @also_assign_the_xorg_buffer
  )
  e
  e "  #{steelblue(i)}"
  e
  if also_assign_to_the_xorg_buffer
    set_xorg_buffer(i)
  end
end
report_that_no_blfs_entry_exists_for_the_program( i = program? ) click to toggle source
#

report_that_no_blfs_entry_exists_for_the_program

#
# File lib/rbt/utility_scripts/blfs.rb, line 262
def report_that_no_blfs_entry_exists_for_the_program(
    i = program?
  )
  if be_verbose?
    opne "No #{teal('BLFS entry')} is available "\
         "for `#{slategray(File.basename(i).sub(/\.yml$/,''))}`."
    e
    opne "However had, as it may often be the case that you would like"
    opne "to see any useful URL, the main download page "\
         "(#{steelblue('url2')}) will be"
    opne "shown next:"
    e
    e "  #{steelblue(url2?)}"
    e
  end
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/blfs.rb, line 72
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === :raw_cookbook
  # ======================================================================= #
  @internal_hash[:raw_cookbook] = RBT.raw_cookbook { :be_quiet_if_the_file_was_not_found }
  # ======================================================================= #
  # === @blfs_homepage
  #
  # This variable will keep a reference towards the BLFS homepage.
  # ======================================================================= #
  @blfs_homepage = nil
  # ======================================================================= #
  # === @array_work_on_these_entries
  #
  # This class will always work on these entries.
  # ======================================================================= #
  @array_work_on_these_entries = []
  # ======================================================================= #
  # === @run_in_batch_mode
  #
  # If this is true then we will report all entries.
  # ======================================================================= #
  @run_in_batch_mode = false
  # ======================================================================= #
  # === @also_assign_the_xorg_buffer
  # ======================================================================= #
  @also_assign_the_xorg_buffer = true
  # ======================================================================= #
  # === @report_result
  # ======================================================================= #
  @report_result = true
end
result?()
Alias for: homepage?
result_as_string?()
Alias for: homepage?
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/blfs.rb, line 289
def run
  if @run_in_batch_mode
    @array_work_on_these_entries << return_available_programs
  else
    # ===================================================================== #
    # Else put in the commandline-arguments.
    # ===================================================================== #
    @array_work_on_these_entries << all_arguments?
  end
  sanitize_the_array_work_on_these_entries # This will also use .flatten! and .compact!
  unless @array_work_on_these_entries.empty?
    @array_work_on_these_entries.each {|this_entry|
      check_blfs_entry_for(this_entry)
    }
  end
end
run_in_batch_mode() click to toggle source
#

run_in_batch_mode

#
# File lib/rbt/utility_scripts/blfs.rb, line 117
def run_in_batch_mode
  @run_in_batch_mode = true
end
sanitize_the_array_work_on_these_entries() click to toggle source
#

sanitize_the_array_work_on_these_entries

#
# File lib/rbt/utility_scripts/blfs.rb, line 246
def sanitize_the_array_work_on_these_entries
  @array_work_on_these_entries.flatten!
  @array_work_on_these_entries.map! {|entry|
    case entry
    when :run_everything
      entry = return_available_programs
    end
    entry
  }
  @array_work_on_these_entries.flatten!
  @array_work_on_these_entries.compact!
end
set_input(i = first_argument?)
Alias for: set_program
set_program(i = first_argument?) click to toggle source
#

set_program

We seek this program through the method here. The method will also handle aliases since as of June 2020.

#
# File lib/rbt/utility_scripts/blfs.rb, line 205
def set_program(i = first_argument?)
  i = i.first if i.is_a? Array
  i = i.to_s.dup.downcase # Downcase since as of Sep 2017.
  i = i[0, i.index('.')] if i.include? '.'
  if RBT.is_included?(i, false)
    # In this case all is fine.
  elsif RBT.is_included?(i, true)
    old_name = i.dup
    # ===================================================================== #
    # It is an alias, so find the real name.
    # ===================================================================== #
    i = RBT.find_cookbook_alias_for(i)
    opne 'This name ('+forestgreen(old_name)+
         ') was not found, but a replacement name ('+
         steelblue(i)+')'
    opne 'was found and will be used next.'
  end
  if i.empty?
    run_in_batch_mode
  end
  @program = i
end
Also aliased as: set_input
url2?() click to toggle source
#

url2?

#
# File lib/rbt/utility_scripts/blfs.rb, line 282
def url2?
  return raw_cookbook?.dataset['url2']
end