class RBT::CreateShellScriptContainingTheseProgramsVersions

Public Class Methods

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

RBT::CreateShellScriptContainingTheseProgramsVersions[]

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 212
def self.[](i = '')
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 24
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

add(i) click to toggle source
#

add (add tag)

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 175
def add(i)
  case i
  # ======================================================================= #
  # === :newline
  # ======================================================================= #
  when :newline
    i = "\n"
  end
  @_ << i
end
add_work_on_these_programs(i)
determine_all_programs_versions( i = @array_work_on_these_programs ) click to toggle source
#

determine_all_programs_versions

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 114
def determine_all_programs_versions(
    i = @array_work_on_these_programs
  )
  # ======================================================================= #
  # Obtain a handle to a file such as:
  #
  #   "/usr/lib/ruby/site_ruby/3.0.0/rbt/yaml/programs_version/available_programs_versions.md"
  #
  # ======================================================================= #
  _ = RBT.file_available_programs_versions
  if File.exist? _
    dataset = File.readlines(_).reject {|line| line.strip.empty? }
  end
  if is_on_roebe? and i.empty?
    opne 'Assuming that, as input, '+steelblue('--everything')+' was meant.'
    i << return_all_programs
  end
  if i.empty?
    opne 'No program was passed. Thus, as no dataset has been given,'
    opne 'no file will be created. Please supply the programs that'
    opne 'you wish to generate shell-variables for (or use '+
         steelblue('--lfs')+')'
  else
    i.flatten.compact.each {|this_program|
      selection = dataset.select {|line|
        line.start_with? "#{this_program} "
      }
      first_line = selection.first
      # ===================================================================== #
      # Next, skip entries we can not find:
      # ===================================================================== #
      next unless first_line
      # program_version = RBT.swift_return_version_of_this_program(
      #                     this_program.to_s.delete('_').to_sym
      #                   )
      program_version = first_line.split(' ')[1].to_s.strip    
      # ===================================================================== #
      # === export MY_GAWKV="gawk-5.0.1"
      #
      # But also:
      #
      #   export MY_GAWK="${MY_GAWKV}.tar.xz"
      #
      # We need to remove '+' chars, though, as these are not valid for
      # the shell.
      # ===================================================================== #
      add(
        "export #{this_program.delete('+').upcase}V=\"#{this_program.downcase}-#{program_version}\"\n"
      )
      add(
        "export #{this_program.delete('+').upcase}=\"\$\{#{this_program.upcase}V\}.tar.xz\"\n"
      )
      add :newline
    }
    save_our_findings_into_a_file
  end
end
menu( i = @commandline_arguments ) click to toggle source
#

menu (menu tag)

#
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 38
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @_
  #
  # We will store into this String.
  # ======================================================================= #
  @_ = ''.dup
  # ======================================================================= #
  # === @array_work_on_these_programs
  # ======================================================================= #
  @array_work_on_these_programs = []
end
return_all_programs() click to toggle source
#

return_all_programs

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 56
def return_all_programs
  available_programs?
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 204
def run
  menu
  determine_all_programs_versions
end
save_our_findings_into_a_file() click to toggle source
#

save_our_findings_into_a_file

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 189
def save_our_findings_into_a_file
  into = 'shell_script_containing_the_program_versions.sh'
  e "#{rev}Now storing into `#{sfile(into)}`."
  write_what_into(@_, into)
  if is_on_roebe?
    into = '/home/x/programming/ruby/src/rbt/lib/rbt/shell/'+
           File.basename(into)
    e "#{rev}Now storing into `#{sfile(into)}`."
    write_what_into(@_, into)
  end
end
set_work_on_these_programs(i) click to toggle source
#

set_work_on_these_programs

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 63
def set_work_on_these_programs(i)
  i = [i].flatten.compact # Work on an Array past that point here.
  i.each {|entry|
    unless @array_work_on_these_programs.include? entry
      @array_work_on_these_programs << entry
    end
  }
end
Also aliased as: add_work_on_these_programs
show_help() click to toggle source
#

show_help

#
# File lib/rbt/shell/create_shell_script_containing_these_program_versions.rb, line 75
def show_help
  e 'No help options are presently documented.'
end