class RBT::Blfs

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

initialize

#
# File lib/rbt/utility_scripts/blfs.rb, line 35
def initialize(
    i           = '',
    run_already = true
  )
  register_sigint
  reset # reset() must come before the remaining methods.
  set_program(i)
  if block_given?
    yielded = yield
    case yielded
    when :no_colours,
         :disable_colours
      disable_colours
      do_not_show_opnn
      @report_result = false
    when :be_quiet_and_do_not_tamper_with_the_xorg_buffer
      @be_verbose = false
      @also_assign_the_xorg_buffer = false
    when :be_quiet
      @be_verbose = 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 115
def all_blfs_entries
  RBT.return_all_blfs_entries
end
assign_xorg_buffer(i) click to toggle source
#

assign_xorg_buffer

#
# File lib/rbt/utility_scripts/blfs.rb, line 90
def assign_xorg_buffer(i)
  XorgBuffer[i] if @also_assign_the_xorg_buffer
end
check_blfs_entry_for(i) click to toggle source
#

check_blfs_entry_for

#
# File lib/rbt/utility_scripts/blfs.rb, line 168
def check_blfs_entry_for(i)
  _ = RBT::Cookbooks::Cookbook.new(input?) { :bypass_menu }
  @blfs_homepage = _.obtain 'blfs' # Fetch the blfs entry.
  report_homepage(@blfs_homepage) # Defaults to @homepage as argument.
end
do_not_show_opnn() click to toggle source
#

do_not_show_opnn

#
# File lib/rbt/utility_scripts/blfs.rb, line 122
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 177
def homepage?
  @blfs_homepage # Store the homepage here.
end
Also aliased as: homepage, remote_url?
input?()
Alias for: program?
program?() click to toggle source
#

program?

This will yield to us which program we are searching for. In other words, this will be equal to the input the user provided to this class.

#
# File lib/rbt/utility_scripts/blfs.rb, line 108
def program?
  @program
end
Also aliased as: input?
remote_url?()
Alias for: homepage?
report_homepage( i = homepage?, also_assign_to_the_xorg_buffer = true ) click to toggle source
#

report_homepage

#
# File lib/rbt/utility_scripts/blfs.rb, line 139
def report_homepage(
    i                              = homepage?,
    also_assign_to_the_xorg_buffer = true
  )
  if i.is_a? Array
    if i.empty?
      if be_verbose?
        report_that_no_blfs_entry_exists_for_the_program
      end
    else
      assign_xorg_buffer(i)
      i.each {|entry| report_homepage(entry, false) }
    end
  else
    if i.to_s.empty? and be_verbose?
      opnn; e "No BLFS entry could be found for "\
              "the program `#{sfancy(input?)}`."
    else
      if be_verbose? and @report_result and !(i == 'blfs')
        opnn; e teal(i)
      end
      assign_xorg_buffer(i) if also_assign_to_the_xorg_buffer
    end
  end
end
report_that_no_blfs_entry_exists_for_the_program() click to toggle source
#

report_that_no_blfs_entry_exists_for_the_program

#
# File lib/rbt/utility_scripts/blfs.rb, line 129
def report_that_no_blfs_entry_exists_for_the_program
  if be_verbose?
    opnn; e 'No '+teal('BLFS entry')+' is available '\
            'for `'+slategray(program?)+'`.'
  end
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/blfs.rb, line 63
def reset
  super()
  @namespace = NAMESPACE
  @homepage = nil
  @run_in_batch_mode = false
  @also_assign_the_xorg_buffer = true
  @report_result = true
end
result?()
Alias for: result_as_string?
result_as_string?() click to toggle source
#

result_as_string?

#
# File lib/rbt/utility_scripts/blfs.rb, line 185
def result_as_string?
  _ = @blfs_homepage
  _ = _.first if _.is_a? Array
  _
end
Also aliased as: result?
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/blfs.rb, line 194
def run
  if @run_in_batch_mode # In this case, we check for all BLFS entries here.
    all_blfs_entries.each {|program_name, url|
      if url # Some entries currently may be nil, since we use grep.
        set_input(program_name)
        report_homepage(url) if @report_result
      end
    }
  else # else we check on only one entry.
    check_blfs_entry_for(input?)
  end
end
run_in_batch_mode() click to toggle source
#

run_in_batch_mode

#
# File lib/rbt/utility_scripts/blfs.rb, line 97
def run_in_batch_mode
  @run_in_batch_mode = true
end
set_input(i)
Alias for: set_program
set_program(i) click to toggle source
#

set_program

We seek this program.

#
# File lib/rbt/utility_scripts/blfs.rb, line 77
def set_program(i)
  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 i.empty?
    run_in_batch_mode
  end
  @program = i
end
Also aliased as: set_input