class RBT::CreateBashScripts

Constants

WHERE_TO
#

WHERE_TO

#

Public Class Methods

new( for_this_program = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/generate_files/create_bash_scripts.rb, line 27
def initialize(
    for_this_program = nil,
    run_already      = true
  )
  reset
  set_for_this_program(
    for_this_program
  )
  run if run_already
end

Public Instance Methods

copy_archive_shell_script() click to toggle source
#

copy_archive_shell_script

#
# File lib/rbt/generate_files/create_bash_scripts.rb, line 60
def copy_archive_shell_script
  copy '$LINUX/SHELL/SCRIPTS/extract_archive.sh', WHERE_TO
end
create_shellscript( for_this_program = @this_program ) click to toggle source
#

create_shellscript

This delegates the task to RBT::GenerateShellscript.

bl $RBT/utility_scripts/generate_shellscript.rb
#
# File lib/rbt/generate_files/create_bash_scripts.rb, line 96
def create_shellscript(
    for_this_program = @this_program
  )
  @cookbook_dataset = action(:SanitizeCookbook, for_this_program)
  _ = GenerateShellscript.new(
    @cookbook_dataset, true, false, false
  ) {{
    also_run_at_once: false
  }}
  return _.dataset+N
end
exit_program() click to toggle source
#

exit_program

#
# File lib/rbt/generate_files/create_bash_scripts.rb, line 83
def exit_program
  exit
end
notify_user(file) click to toggle source
#

notify_user

Use this method to notify the user.

#
# File lib/rbt/generate_files/create_bash_scripts.rb, line 69
def notify_user(file)
  cliner
  opne sfancy('Finished creation! The file was: '+N+'  ')+sfile(file)
  e
  opne 'If you want to cd to the directory, use this command:'
  opne sfancy('  cd ')+sdir('/System/Settings/Scripts/')
  opne 'And if you want to source this file, use this command:'
  e sfancy('  source ')+sfile(file)
  exit_program
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/generate_files/create_bash_scripts.rb, line 41
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @cookbook_dataset
  # ======================================================================= #
  @cookbook_dataset = action(:SanitizeCookbook) { :dont_run_yet }
end
run() click to toggle source
#

run

Everything is bundled here in this method.

#
# File lib/rbt/generate_files/create_bash_scripts.rb, line 113
def run
  reset
  copy_archive_shell_script
  e
  dir = system_directory?+'Settings/Scripts/'
  file = dir+'bash_programs_rc'
  cliner {
    e sfancy('Now creating a bash file. The name and file path will be:')
    e '  '+sfile(file)
  }
  create_directory(dir) unless File.exist?(dir) # create dir if it doesnt exist yet.
  remove_file(file) if File.exist? file
  string = ''.dup
  # ======================================================================= #
  # First, lets collect which programs actually are available. This will
  # be an array.
  # ======================================================================= #
  string << '# Store all available programs in an array, so that we '+N
  string << '# can use this information in our shell scripts lateron.'+N
  string << 'programs=('
  all_programs.each { |program|
    string << '  "'+program.to_s+'"'+N
  }; string << ')'+N+N
  # ======================================================================= #
  # Second, we write their info :>
  # It will lead to a lot of "c_" functions.
  #
  # Example entries start like so:
  #
  #   function c_python() {
  #
  # ======================================================================= #
  all_programs.each { |program|
    opne "Creating a shellscript for `#{sfancy(program)}` next."
    string << create_shellscript(program) # This is defined in this file here.
  }
  write_what_into(string, file)
  # ======================================================================= #
  # The following 3 lines are specific for my machine.
  # ======================================================================= #
  _ = ENV['LINUX'].to_s+'/SHELL/bash_programs_rc'
  remove_file(_) if File.exist? _
  write_what_into(string, _)
  # ======================================================================= #
  # At this point, all data has been written and we can notify the user
  # about it.
  # ======================================================================= #
  notify_user(file)
end
set_for_this_program(i) click to toggle source
#

set_for_this_program

#
# File lib/rbt/generate_files/create_bash_scripts.rb, line 53
def set_for_this_program(i)
  @this_program = i
end