class RBT::Action::Cookbooks::Blfs

Public Class Methods

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

RBT::Action::Cookbooks::Blfs[]

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 526
def self.[](i = ARGV)
  new(i)
end
new( i = ARGV, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 36
def initialize(
    i           = ARGV,
    run_already = true,
    &block
  )
  register_sigint
  reset # reset() must come before the other methods.
  set_commandline_arguments(i)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_quiet_and_no_colours_and_do_not_tamper_with_the_xorg_buffer_and_do_not_open_in_the_browser
    # ===================================================================== #
    when :be_quiet_and_no_colours_and_do_not_tamper_with_the_xorg_buffer_and_do_not_open_in_the_browser
      set_do_not_be_verbose
      do_not_open_via_the_browser
      do_not_show_opnn
      disable_colours
      do_not_report_the_result
      do_not_make_use_of_the_xorg_buffer
    # ===================================================================== #
    # === :no_colours_be_quiet
    # ===================================================================== #
    when :no_colours_be_quiet
      disable_colours
      set_do_not_be_verbose
      do_not_show_opnn
      do_not_report_the_result
    # ===================================================================== #
    # === :be_quiet_and_no_colours_and_do_not_tamper_with_the_xorg_buffer
    # ===================================================================== #
    when :be_quiet_and_no_colours_and_do_not_tamper_with_the_xorg_buffer
      set_do_not_be_verbose
      do_not_show_opnn
      disable_colours
      do_not_report_the_result
      do_not_make_use_of_the_xorg_buffer
    # ===================================================================== #
    # === :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
      do_not_show_opnn
      do_not_report_the_result
      do_not_make_use_of_the_xorg_buffer
    # ===================================================================== #
    # === :be_quiet
    # ===================================================================== #
    when :be_quiet
      set_be_quiet
    # ===================================================================== #
    # === :no_colours
    # ===================================================================== #
    when :no_colours,
         :disable_colours
      disable_colours
    end
  end
  run if run_already
end

Public Instance Methods

all_blfs_entries() click to toggle source
#

all_blfs_entries

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 432
def all_blfs_entries
  RBT.return_all_blfs_entries
end
all_programs_with_a_registered_BLFS_entry()
Alias for: all_blfs_entries
also_assign_the_xorg_buffer?() click to toggle source
#

also_assign_the_xorg_buffer?

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 190
def also_assign_the_xorg_buffer?
  @internal_hash[:also_assign_the_xorg_buffer]
end
array_work_on_these_entries?()
blfs_homepage?()
Alias for: homepage?
check_blfs_entry_for( this_program ) click to toggle source
#

check_blfs_entry_for (check tag)

This method is normally called from within do_work_on_the_designated_programs().

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 385
def check_blfs_entry_for(
    this_program
  )
  set_blfs_homepage(nil) # Reset it here.
  set_program_name(nil)  # Reset this as well.
  _ = raw_cookbook?
  this_program = this_program.to_s.dup
  this_program.delete!('-') if this_program.include? '-'
  set_program_name(this_program) # Always keep a reference here.
  _result_of_the_search = _.try_to_find(which_program?) # This variable will normally be a Hash.
  if _.has_non_empty_BLFS_entry?
    set_blfs_homepage(_.blfs_homepage?)
    homepage = homepage? # Get a reference, for easier working with this variable.
    # report_the_program(this_program)
    if report_the_result?
      report_this_BLFS_homepage(homepage)
    end
    if homepage and !homepage.empty?
      if shall_we_open_via_the_browser? and !in_batch_mode?
        # ================================================================= #
        # Since as of January 2023, the homepage will be opened on my
        # home system whenever we report the BLFS-homepage. This will,
        # however had, NOT be the case when we run in batch-mode.
        # ================================================================= #
        open_in_browser(homepage)
      end
    end
  else
    report_that_no_blfs_entry_exists_for_the_program(this_program)
  end
  _.reset_the_internal_state # And reset RawCookbook again.
end
do_not_make_use_of_the_xorg_buffer() click to toggle source
#

do_not_make_use_of_the_xorg_buffer

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 174
def do_not_make_use_of_the_xorg_buffer
  @internal_hash[:also_assign_the_xorg_buffer] = false
end
do_not_open_in_the_browser() click to toggle source
#

do_not_open_in_the_browser

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 296
def do_not_open_in_the_browser
  @internal_hash[:open_in_browser] = false
end
Also aliased as: do_not_open_via_the_browser
do_not_open_via_the_browser()
do_not_report_the_result() click to toggle source
#

do_not_report_the_result

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 233
def do_not_report_the_result
  @internal_hash[:report_the_result] = false
end
do_not_show_opnn() click to toggle source
#

do_not_show_opnn

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 212
def do_not_show_opnn
  disable_opn
end
do_report_the_result() click to toggle source
#

do_report_the_result

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 226
def do_report_the_result
  @internal_hash[:report_the_result] = true
end
do_run_in_batch_mode() click to toggle source
#

do_run_in_batch_mode

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 289
def do_run_in_batch_mode
  @internal_hash[:run_in_batch_mode] = true
end
Also aliased as: run_in_batch_mode
do_we_run_in_batchmode?()
Alias for: run_in_batch_mode?
do_work_on_the_designated_programs( i = work_on_these_programs? ) click to toggle source
#

do_work_on_the_designated_programs

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 421
def do_work_on_the_designated_programs(
    i = work_on_these_programs?
  )
  i.each {|this_program|
    check_blfs_entry_for(this_program)
  }
end
homepage()
Alias for: homepage?
homepage?() click to toggle source
#

homepage?

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 240
def homepage?
  @internal_hash[:blfs_homepage] # Store the homepage here.
end
in_batch_mode?()
Alias for: run_in_batch_mode?
is_in_batchmode?()
Alias for: run_in_batch_mode?
menu( i = hyphened_arguments? ) click to toggle source
#

menu (menu tag)

#
open_in_browser?() click to toggle source
#

open_in_browser?

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 258
def open_in_browser?
  @internal_hash[:open_in_browser]
end
program?()
Alias for: program_name?
program_name?() click to toggle source
#

program_name?

This method will return the program we are searching for in this class.

In other words, this will be roughly equal to the input the user provided to this class, although a bit sanitized (for instance, a trailing ‘/’ is chopped off).

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 204
def program_name?
  @internal_hash[:program_name]
end
Also aliased as: program?, which_program?
raw_cookbook?() click to toggle source
#

raw_cookbook?

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 251
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? )
report_no_entry_was_found_for_this_program( i = program_name?, url2 = url2? )
report_that_no_blfs_entry_exists_for_the_program( i = program_name?, url2 = url2? ) click to toggle source
#

report_that_no_blfs_entry_exists_for_the_program

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 329
def report_that_no_blfs_entry_exists_for_the_program(
    i    = program_name?,
    url2 = url2?
  )
  if be_verbose?
    if i and !i.empty? and !run_in_batch_mode?
      opne "#{rev}No #{teal('BLFS entry')} #{rev}is available "\
           "for `#{slategray(File.basename(i).delete_suffix('.yml'))}#{rev}`."
      if url2
        e
        opne "However had, as it may often be the case that you would like"
        opne "#{rev}to see any useful URL, the main download page "\
             "(#{steelblue('url2')}#{rev}) will be"
        opne "shown next:"
        e
        e "  #{steelblue(url2)}"
        e
      end
    end
  end
end
report_the_program( this_program = program_name? ) click to toggle source
#

report_the_program

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 303
def report_the_program(
    this_program = program_name?
  )
  opne lightblue(this_program)
end
report_the_result?() click to toggle source
#

report_the_result?

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 219
def report_the_result?
  @internal_hash[:report_the_result]
end
report_this_BLFS_homepage( i = blfs_homepage?, also_assign_to_the_xorg_buffer = also_assign_the_xorg_buffer? ) click to toggle source
#

report_this_BLFS_homepage

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 354
def report_this_BLFS_homepage(
    i                              = blfs_homepage?, # Defaults to @internal_hash[:blfs_homepage] as argument.
    also_assign_to_the_xorg_buffer = also_assign_the_xorg_buffer?
  )
  i = i.first if i.is_a? Array
  if be_verbose? and report_the_result?
    if run_in_batch_mode?
      e "#{lightgreen(program_name?)} #{orange(right_arrow?)} #{steelblue(i)}"
    else
      opnn { :no_trailing }
      e
      e
      e "#{rev}Opening"
      e
      e "  #{sfancy(homepage)}#{rev}"
      e
      e "#{rev}in the browser next."
    end
  end
  e
  if also_assign_to_the_xorg_buffer
    set_xorg_buffer(i)
  end
end
Also aliased as: report_homepage
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Action#reset
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 104
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === :report_the_result
  # ======================================================================= #
  do_report_the_result
  # ======================================================================= #
  # === :work_on_these_programs
  #
  # This variable will be an Array of programs that will be
  # compiled/installed.
  # ======================================================================= #
  @internal_hash[:work_on_these_programs] = []
  # ======================================================================= #
  # === :program_name
  #
  # This variable must be nil initially.
  # ======================================================================= #
  @internal_hash[:program_name] = nil
  # ======================================================================= #
  # === :also_assign_the_xorg_buffer
  # ======================================================================= #
  @internal_hash[:also_assign_the_xorg_buffer] = true
  # ======================================================================= #
  # === :open_in_browser
  #
  # If this variable is true then this class will attempt to open
  # ======================================================================= #
  @internal_hash[:open_in_browser] = true
  # ======================================================================= #
  # === :blfs_homepage
  #
  # This variable will keep a reference towards the BLFS homepage of
  # the corresponding program at hand.
  # ======================================================================= #
  @internal_hash[:blfs_homepage] = nil
  # ======================================================================= #
  # === :raw_cookbook
  #
  # We need an instance of raw-cookbooks, in order to find not only
  # the BLFS entry, but also make use of url1 and url2.
  # ======================================================================= #
  @internal_hash[:raw_cookbook] = action(:raw_cookbook) { :be_quiet_if_the_file_was_not_found }
  # ======================================================================= #
  # === :run_in_batch_mode
  #
  # If this is true then we will report all entries registered in the
  # RBT project.
  # ======================================================================= #
  @internal_hash[:run_in_batch_mode] = false
end
result?()
Alias for: homepage?
result_as_string?()
Alias for: homepage?
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 501
def run
  # ======================================================================= #
  # By default all non-hyphened commandline arguments will constitute
  # the array of programs this class will operate on. Note that
  # --batch will overrule this anyway, if provided on the commandline.
  # ======================================================================= #
  _ = non_hyphened_arguments?
  # ======================================================================= #
  # Next we enter menu():
  # ======================================================================= #
  menu
  if do_we_run_in_batchmode?
    _ = all_programs_with_a_registered_BLFS_entry
  end
  if _.empty? and !is_in_batchmode?
    opne "#{rev}Please supply at the least one argument to this class."
  else
    set_work_on_these_programs(_)
    do_work_on_the_designated_programs
  end
end
run_in_batch_mode()
run_in_batch_mode?() click to toggle source
#

run_in_batch_mode?

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 181
def run_in_batch_mode?
  @internal_hash[:run_in_batch_mode]
end
sanitize_this_program_name(i) click to toggle source
#

sanitize_this_program_name

This method will sanitize the program-name a little bit.

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 162
def sanitize_this_program_name(i)
  i = i.first if i.is_a? Array
  i = i.dup if i.frozen?
  i = i.to_s.dup.downcase # Downcase the input since as of September 2017.
  i = i[0, i.index('.')] if i.include? '.'
  i.chop! if i.end_with? '/'
  return i
end
set_array_work_on_these_entries( i = non_hyphened_arguments? )
set_blfs_homepage(i)
Alias for: set_homepage
set_homepage(i) click to toggle source
#

set_homepage

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 312
def set_homepage(i)
  if i and i.is_a? Array
    i = i.first
  end
  @internal_hash[:blfs_homepage] = i
end
Also aliased as: set_blfs_homepage
set_input( i = first_argument? )
Alias for: set_program_name
set_program( i = first_argument? )
Alias for: set_program_name
set_program_name( i = first_argument? ) click to toggle source
#

set_program_name

We seek this program through the method here.

The method will also handle aliases since as of June 2020.

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 469
def set_program_name(
    i = first_argument?
  )
  if i
    i = sanitize_this_program_name(i)
    if RBT.is_included?(i, false)
      # ===================================================================== #
      # In this case all is fine. We'll assign the program-name past this
      # clause.
      # ===================================================================== #
    elsif RBT.is_included?(i, true)
      old_name = i.dup
      # ===================================================================== #
      # === Handle aliases next
      #
      # It is an alias, so find the real name.
      # ===================================================================== #
      i = RBT.find_cookbook_alias_for(i)
      opne "#{rev}This name (#{forestgreen(old_name)}"\
           "#{rev}) was not found, but a replacement name ("\
           "#{steelblue(i)}#{rev})"
      opne "#{rev}was found and will subsequently be used instead."
      e
    end
  end
  @internal_hash[:program_name] = i
end
Also aliased as: set_program, set_input
set_seek_these_programs( i = non_hyphened_arguments? )
set_seek_this_program( i = non_hyphened_arguments? )
set_seek_this_program_name( i = non_hyphened_arguments? )
set_work_on_these_programs( i = non_hyphened_arguments? ) click to toggle source
#

set_work_on_these_programs

This will actually assign to an Array. The method is not allowed to modify the content of this Array.

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 268
def set_work_on_these_programs(
    i = non_hyphened_arguments?
  )
  i = [i].flatten.compact
  @internal_hash[:work_on_these_programs] = i
end
shall_we_open_via_the_browser?()
Alias for: open_in_browser?
url2?() click to toggle source
#

url2?

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 322
def url2?
  return raw_cookbook?.url2?
end
which_program?()
Alias for: program_name?
work_on_these_programs?() click to toggle source
#

work_on_these_programs?

#
# File lib/rbt/actions/individual_actions/cookbooks/blfs/blfs.rb, line 281
def work_on_these_programs?
  @internal_hash[:work_on_these_programs]
end
work_on_which_entries?()