Class: Roebe::Shell

Inherits:
Base show all
Includes:
Time
Defined in:
lib/roebe/shell/help/help.rb,
lib/roebe/shell/shell/menu.rb,
lib/roebe/shell/shell/misc.rb,
lib/roebe/shell/shell/reset.rb,
lib/roebe/shell/shell/shell.rb,
lib/roebe/shell/shell/core/e.rb,
lib/roebe/shell/shell/core/is.rb,
lib/roebe/shell/shell/core/add.rb,
lib/roebe/shell/shell/core/all.rb,
lib/roebe/shell/shell/core/cat.rb,
lib/roebe/shell/shell/core/cut.rb,
lib/roebe/shell/shell/core/env.rb,
lib/roebe/shell/shell/core/ftp.rb,
lib/roebe/shell/shell/core/irb.rb,
lib/roebe/shell/shell/core/irc.rb,
lib/roebe/shell/shell/core/iso.rb,
lib/roebe/shell/shell/core/log.rb,
lib/roebe/shell/shell/core/pdf.rb,
lib/roebe/shell/shell/core/pid.rb,
lib/roebe/shell/shell/core/rbt.rb,
lib/roebe/shell/shell/core/scp.rb,
lib/roebe/shell/shell/core/set.rb,
lib/roebe/shell/shell/core/tab.rb,
lib/roebe/shell/shell/core/url.rb,
lib/roebe/shell/shell/core/use.rb,
lib/roebe/shell/colours/colours.rb,
lib/roebe/shell/project/project.rb,
lib/roebe/shell/session/session.rb,
lib/roebe/shell/shell/constants.rb,
lib/roebe/shell/shell/core/call.rb,
lib/roebe/shell/shell/core/copy.rb,
lib/roebe/shell/shell/core/dump.rb,
lib/roebe/shell/shell/core/exit.rb,
lib/roebe/shell/shell/core/gems.rb,
lib/roebe/shell/shell/core/gist.rb,
lib/roebe/shell/shell/core/glob.rb,
lib/roebe/shell/shell/core/help.rb,
lib/roebe/shell/shell/core/make.rb,
lib/roebe/shell/shell/core/misc.rb,
lib/roebe/shell/shell/core/mode.rb,
lib/roebe/shell/shell/core/move.rb,
lib/roebe/shell/shell/core/open.rb,
lib/roebe/shell/shell/core/path.rb,
lib/roebe/shell/shell/core/ping.rb,
lib/roebe/shell/shell/core/play.rb,
lib/roebe/shell/shell/core/ruby.rb,
lib/roebe/shell/shell/core/save.rb,
lib/roebe/shell/shell/core/sort.rb,
lib/roebe/shell/shell/core/stat.rb,
lib/roebe/shell/shell/core/test.rb,
lib/roebe/shell/shell/core/time.rb,
lib/roebe/shell/shell/core/undo.rb,
lib/roebe/shell/shell/core/wlan.rb,
lib/roebe/shell/shell/core/yaml.rb,
lib/roebe/shell/shell/core/ascii.rb,
lib/roebe/shell/shell/core/audio.rb,
lib/roebe/shell/shell/core/chmod.rb,
lib/roebe/shell/shell/core/count.rb,
lib/roebe/shell/shell/core/debug.rb,
lib/roebe/shell/shell/core/delay.rb,
lib/roebe/shell/shell/core/email.rb,
lib/roebe/shell/shell/core/empty.rb,
lib/roebe/shell/shell/core/fetch.rb,
lib/roebe/shell/shell/core/merge.rb,
lib/roebe/shell/shell/core/mount.rb,
lib/roebe/shell/shell/core/phone.rb,
lib/roebe/shell/shell/core/popup.rb,
lib/roebe/shell/shell/core/serve.rb,
lib/roebe/shell/shell/core/sleep.rb,
lib/roebe/shell/shell/core/split.rb,
lib/roebe/shell/shell/core/start.rb,
lib/roebe/shell/shell/core/strip.rb,
lib/roebe/shell/shell/core/tasks.rb,
lib/roebe/shell/shell/core/video.rb,
lib/roebe/shell/shell/core/watch.rb,
lib/roebe/shell/shell/core/action.rb,
lib/roebe/shell/shell/core/append.rb,
lib/roebe/shell/shell/core/assign.rb,
lib/roebe/shell/shell/core/backup.rb,
lib/roebe/shell/shell/core/become.rb,
lib/roebe/shell/shell/core/buffer.rb,
lib/roebe/shell/shell/core/checks.rb,
lib/roebe/shell/shell/core/cliner.rb,
lib/roebe/shell/shell/core/cracks.rb,
lib/roebe/shell/shell/core/create.rb,
lib/roebe/shell/shell/core/editor.rb,
lib/roebe/shell/shell/core/enable.rb,
lib/roebe/shell/shell/core/ensure.rb,
lib/roebe/shell/shell/core/google.rb,
lib/roebe/shell/shell/core/images.rb,
lib/roebe/shell/shell/core/random.rb,
lib/roebe/shell/shell/core/record.rb,
lib/roebe/shell/shell/core/reload.rb,
lib/roebe/shell/shell/core/remove.rb,
lib/roebe/shell/shell/core/repair.rb,
lib/roebe/shell/shell/core/repeat.rb,
lib/roebe/shell/shell/core/replay.rb,
lib/roebe/shell/shell/core/switch.rb,
lib/roebe/shell/shell/core/toggle.rb,
lib/roebe/shell/shell/core/upcase.rb,
lib/roebe/shell/shell/core/update.rb,
lib/roebe/shell/shell/core/upload.rb,
lib/roebe/shell/shell/core/wecker.rb,
lib/roebe/shell/shell/core/whoami.rb,
lib/roebe/shell/module_methods/ftp.rb,
lib/roebe/shell/shell/core/aliases.rb,
lib/roebe/shell/shell/core/browser.rb,
lib/roebe/shell/shell/core/burning.rb,
lib/roebe/shell/shell/core/compile.rb,
lib/roebe/shell/shell/core/disable.rb,
lib/roebe/shell/shell/core/english.rb,
lib/roebe/shell/shell/core/esystem.rb,
lib/roebe/shell/shell/core/extract.rb,
lib/roebe/shell/shell/core/get_var.rb,
lib/roebe/shell/shell/core/history.rb,
lib/roebe/shell/shell/core/install.rb,
lib/roebe/shell/shell/core/jumpers.rb,
lib/roebe/shell/shell/core/protect.rb,
lib/roebe/shell/shell/core/queries.rb,
lib/roebe/shell/shell/core/replace.rb,
lib/roebe/shell/shell/core/require.rb,
lib/roebe/shell/shell/core/symlink.rb,
lib/roebe/shell/shell/core/trainer.rb,
lib/roebe/shell/shell/core/trigger.rb,
lib/roebe/shell/shell/core/unalias.rb,
lib/roebe/shell/shell/core/webrick.rb,
lib/roebe/shell/shell/core/windows.rb,
lib/roebe/shell/module_methods/misc.rb,
lib/roebe/shell/shell/core/archives.rb,
lib/roebe/shell/shell/core/collapse.rb,
lib/roebe/shell/shell/core/defaults.rb,
lib/roebe/shell/shell/core/downcase.rb,
lib/roebe/shell/shell/core/download.rb,
lib/roebe/shell/shell/core/generate.rb,
lib/roebe/shell/shell/core/hardware.rb,
lib/roebe/shell/shell/core/hostname.rb,
lib/roebe/shell/shell/core/optimize.rb,
lib/roebe/shell/shell/core/personal.rb,
lib/roebe/shell/shell/core/printing.rb,
lib/roebe/shell/shell/core/register.rb,
lib/roebe/shell/shell/core/treeview.rb,
lib/roebe/shell/colours/colour_codes.rb,
lib/roebe/shell/shell/core/arguments.rb,
lib/roebe/shell/shell/core/autostart.rb,
lib/roebe/shell/shell/core/birthdays.rb,
lib/roebe/shell/shell/core/calculate.rb,
lib/roebe/shell/shell/core/clipboard.rb,
lib/roebe/shell/shell/core/passwords.rb,
lib/roebe/shell/shell/core/pkgconfig.rb,
lib/roebe/shell/shell/core/read_file.rb,
lib/roebe/shell/shell/core/repackage.rb,
lib/roebe/shell/shell/core/translate.rb,
lib/roebe/shell/shell/core/variables.rb,
lib/roebe/shell/shell/core/screenshot.rb,
lib/roebe/shell/shell/core/conversions.rb,
lib/roebe/shell/shell/core/information.rb,
lib/roebe/shell/commandline/commandline.rb,
lib/roebe/shell/module_methods/encoding.rb,
lib/roebe/shell/shell/core/file_actions.rb,
lib/roebe/shell/shell/core/shellrc_file.rb,
lib/roebe/shell/standalone_classes/todo.rb,
lib/roebe/shell/module_methods/anmeldung.rb,
lib/roebe/shell/module_methods/main_file.rb,
lib/roebe/shell/shell/core/configuration.rb,
lib/roebe/shell/shell/core/documentation.rb,
lib/roebe/shell/help/colourized_help_line.rb,
lib/roebe/shell/module_methods/benchmarks.rb,
lib/roebe/shell/shell/core/clear_and_purge.rb,
lib/roebe/shell/shell/core/find_and_search.rb,
lib/roebe/shell/shell/core/question_answer.rb,
lib/roebe/shell/configuration/configuration.rb,
lib/roebe/shell/gui/gtk3/vte_terminal_frame.rb,
lib/roebe/shell/module_methods/startup_time.rb,
lib/roebe/shell/shell/core/change_directory.rb,
lib/roebe/shell/shell/core/get_file_listing.rb,
lib/roebe/shell/shell/core/set_file_listing.rb,
lib/roebe/shell/help/documented_help_options.rb,
lib/roebe/shell/shell/core/directory_actions.rb,
lib/roebe/shell/module_methods/home_directory.rb,
lib/roebe/shell/shellrc_parser/shellrc_parser.rb,
lib/roebe/shell/shell/core/act_filetype_specific.rb,
lib/roebe/shell/standalone_classes/time_converter.rb,
lib/roebe/shell/shell/core/escape_shell_characters.rb,
lib/roebe/shell/module_methods/available_components.rb,
lib/roebe/shell/module_methods/commandline_arguments.rb,
lib/roebe/shell/module_methods/generate_tab_completion.rb,
lib/roebe/shell/shell/core/show_display_feedback_and_report.rb,
lib/roebe/shell/shell/core/tell_us_whether_this_program_exists.rb,
lib/roebe/shell/module_methods/report_where_the_home_directory_can_be_found.rb

Overview

Roebe::Shell

Defined Under Namespace

Classes: ColourCodes, ColourizedHelpLine, Commandline, Configuration, DocumentedHelpOptions, Session, ShellrcParser, TimeConverter, Todo, VteTerminalFrame

Constant Summary collapse

ARRAY_VALID_HELP_OPTIONS =
#

Roebe::Shell::ARRAY_VALID_HELP_OPTIONS

#
%w(
  commandline_help
  --show_commandline_help
  --help
  HELP
  help
)
ARRAY_FOR_COMPLETION =
#

Roebe::Shell::ARRAY_FOR_COMPLETION

There idea for this constant here is to add some mandatory constants that can be completed via Readline. Evidently this is only useful if readline is available and used on the target computer system at hand.

#
%w(
 search
 download
 open
 help
 history 
 quit
 url
 next
 clear
).sort
RUBY_KEYWORDS =
#

Roebe::Shell::RUBY_KEYWORDS

Collect all ruby keywords here. This depends on the gem keywords.

#
::Roebe.ruby_keywords?
ROEBE_SHELL_YAML_LOG_DIRECTORY =
#

Roebe::Shell::ROEBE_SHELL_YAML_LOG_DIRECTORY

Here we store the log directory for yaml files.

#
"#{Roebe::Shell.log_directory?}yaml/"
LAST_COMMANDS =
#

Roebe::Shell::LAST_COMMANDS

Where we store our last commands.

#
"#{ROEBE_SHELL_YAML_LOG_DIRECTORY}last_commands.yml"
RUBY_ASSUMED_VERSION =
#

RUBY_ASSUMED_VERSION

This is e. g. “2.7.1”. It must come before we define the RI_DIRECTORY constant.

#
RbConfig::CONFIG['MAJOR']+'.'+
RbConfig::CONFIG['MINOR']+'.'+
RbConfig::CONFIG['TEENY']
RI_DIRECTORY =
#

Roebe::Shell::RI_DIRECTORY

Where ri stores it's docu normally.

#
"#{RbConfig::CONFIG['datarootdir']}/ri/#{RUBY_ASSUMED_VERSION}/system"
ARRAY_KEYWORD_EXCEPTIONS_FOR_ALL_AS_AN_ARGUMENT =
#

ARRAY_KEYWORD_EXCEPTIONS_FOR_ALL_AS_AN_ARGUMENT

A list of exceptions for when the argument is 'all'.

#
%w(
  play_song
  playsong
  playsongs
  play rsong
)
ARRAY_ALLOWED_MODES =
#

ARRAY_ALLOWED_MODES

#
%w(
  browser display edit play
)
AUDIO_FILE_TYPES =
#

AUDIO_FILE_TYPES

#
%w(
  .mp3
  .wav
  .ogg
  .mp4
)
ARRAY_POSSIBLE_CHMOD_VALUES =
#

ARRAY_POSSIBLE_CHMOD_VALUES

All possible chmod-values are registered here.

#
%w(
  000
  111 110 101 100 011 010 001
  333
  444 400
  555
  644 655
  777 775 757 755 744 741 714 711 700
)
ARRAY_POSSIBLE_INSTALL_ACTIONS =
#

ARRAY_POSSIBLE_INSTALL_ACTIONS

List which install actions are allowed in the following Array.

PLEASE KEEP THIS ARRAY ALWAYS UP-TO-DATE!

#
%w( 
  default
  wlan
  grub
  mp3directcut
  starter_pack
  nvidia
  flash
  windows
  pdf
  debian_package
)
ARRAY_WAYS_TO_EXIT =
#

ARRAY_WAYS_TO_EXIT

The following Array keeps track how to exit from the Diamond Shell.

#
%w(
  q   exit quit break bye
  out exi  rdia eit   exti 
  rda toq  ra   da    cq
  eq  w    qq   qu    aus
  ende
)
ARRAY_REGISTERED_ENTRIES_FOR_GENERATE =
#

ARRAY_REGISTERED_ENTRIES_FOR_GENERATE

#
%w(
  xorg
  www_colours
  images
  keys
  feedback
  inputrc
  spreadsheet
)
ARRAY_AVAILABLE_OPTIONS_FOR_GENERATE =
#

ARRAY_AVAILABLE_OPTIONS_FOR_GENERATE

Next, we gather all options available for generate.

#
%w(
  xorg
  rcfiles
  www_colours
  image
  keys
  feedback
  inputrc
  spreadsheet
  aliases
)
ARRAY_AVAILABLE_DISPLAY_OPTIONS =
#

ARRAY_AVAILABLE_DISPLAY_OPTIONS

#
%w(
  hardware_information
  contacts
  ram
  video_resolution
  host_information
).sort
ARRAY_RUBY_CORE_CONSTANTS =
#

ARRAY_RUBY_CORE_CONSTANTS

As of ruby 2.4, Bignum is no longer a part of ruby.

#
[
  String,
  Hash,
  Array,
  BasicObject,
  Object,
  Module,
  Class,
  Numeric,
  Integer,
  Float,
  Fiber,
  Dir,
  File,
  Encoding,
  Enumerator
]
ARRAY_COMMANDS_FOR_THE_ROEBE_SHELL_HISTORY =
#

ARRAY_COMMANDS_FOR_THE_ROEBE_SHELL_HISTORY

#
%w(
  show_logfile_for_history
  show_history
  showhistory
  handle_history
  history?
  history
  commands?
  use_command_at_history_position
  hh
  hist
  h?
  h
  history_file?
  hist?
)
HELP_OPTIONS =
#

Roebe::Shell::HELP_OPTIONS

Which help options are valid? Typically these are help, h and ? and a few more. They will be defined in the following Array.

#
%w(
  HELP
  ?
  h
  help
  help?
  elp
  hel
  he
  h?
  hep
  show_help_options
  --help hlep
  helpoptions?
  help_options?
  hoptions?
  hopt?
  hop?
)
FILE_HOME_DIR =
#

Roebe::Shell::FILE_HOME_DIR

This is a yaml file but normally it does not exist, on purpose. The user may enable this through a commandline switch.

If this constant is ported then we also have to modify the file called 'home_directory.rb'.

#
"#{::Roebe::Shell.project_base_directory?}configuration/home_dir.yml"
LOCALHOST =
#

Roebe::Shell::LOCALHOST

The localhost has which URLs?

#
'http://localhost/'
SITELIBDIR =
#

Roebe::Shell::SITELIBDIR

The Ruby sitelib directory.

#
RbConfig::CONFIG['sitelibdir']
MSG_PROVIDE_ONE_ARGUMENT =
#

Roebe::Shell::MSG_PROVIDE_ONE_ARGUMENT

#
'Please provide at least one argument.'
WINDOWS_HOMEDIR =
#

Roebe::Shell::WINDOWS_HOMEDIR

This might also be USERPROFILE variable.

#
"#{ENV['HOMEDRIVE']}/"
LEFT_ARROW_KEY_AND_ALT_KEY =
#

Roebe::Shell::LEFT_ARROW_KEY_AND_ALT_KEY

#
"\e[1;3D\n"
TOP_ARROW_KEY_AND_ALT_KEY =
#

Roebe::Shell::TOP_ARROW_KEY_AND_ALT_KEY

#
"\e[1;3A\n"
RIGHT_ARROW_KEY_AND_ALT_KEY =
#

Roebe::Shell::RIGHT_ARROW_KEY_AND_ALT_KEY

#
"\e[1;3C\n"
BOTTOM_ARROW_KEY_AND_ALT_KEY =
#

BOTTOM_ARROW_KEY_AND_ALT

#
"\e[1;3B\n"
ARRAY_ARROW_KEYS =
#

Roebe::Shell::ARRAY_ARROW_KEYS

Collect the arrow-keys into an Array.

#
[
  LEFT_ARROW_KEY_AND_ALT_KEY,
  TOP_ARROW_KEY_AND_ALT_KEY,
  RIGHT_ARROW_KEY_AND_ALT_KEY,
  BOTTOM_ARROW_KEY_AND_ALT_KEY
]
ARRAY_REQUIRE_THESE_PROJECT_INTERNAL_FILES =
#

ARRAY_REQUIRE_THESE_PROJECT_INTERNAL_FILES

Unsure whether we will retain this Array in the long run.

#
%w(
  act_filetype_specific
  action
  add
  aliases
  all
  append
  archives
  ascii
  audio
  autostart
  backup
  become
  browser
  buffer
  calculate
  initialize
  cat
  call
  change_directory
  checks
  chmod
  clear_and_purge
  cliner
  collapse
  compile
  conversions
  count
  copy
  cracks
  create
  cut
  defaults
  delay
  disable
  documentation
  downcase
  download
  dump
  e
  editor
  email
  empty
  enable
  ensure
  esystem
  exit
  extract
  feedback
  file_actions
  find_and_search
  ftp
  generate
  get_var
  hardware
  help
  history
  hostname
  information
  install
  irb
  irc
  iso
  jumpers
  merge
  misc
  mode
  move
  mount
  open
  optimize
  passwords
  pdf
  personal
  pid
  ping
  play
  pkgconfig
  protect
  queries
  question_answer
  random
  record
  repackage
  repair
  replay
  require
  rbt
  ruby
  save
  screenshot
  serve
  set
  show_display_and_report
  split
  stat
  strip
  switch
  tab
  time
  toggle
  treeview
  upcase
  update
  upload
  url
  use
  video
  wecker
  whoami
  windows
  wlan
  yaml
)
FILE_IGNORE_THESE_LAST_COMMANDS =
#

Roebe::Shell::FILE_IGNORE_THESE_LAST_COMMANDS

This constant may expand to a value such as:

/home/Programs/Ruby/2.7.1/lib/ruby/site_ruby/2.7.0/roebe/shell/yaml/ignore_these_last_commands.yml
#
"#{Roebe::Shell.yaml_directory?}ignore_these_last_commands.yml"
ROEBE_SHELL_BUFFER_FILE =
#

ROEBE_SHELL_BUFFER_FILE

#
"#{Roebe::Shell.yaml_directory?}configuration/buffer.yml"
ROEBE_SHELL_DOC_DIRECTORY =
#

Roebe::Shell::ROEBE_SHELL_DOC_DIRECTORY

#
"#{HOME_OF_THE_USER_CALLED_X}programming/ruby/src/roebe/doc/"
ROEBE_SHELL_TODO_FILE =
#

Roebe::Shell::ROEBE_SHELL_TODO_FILE

#
"#{ROEBE_SHELL_DOC_DIRECTORY}todo/roebe_shell_todo.md"
CURRENT_DAY =
#

CURRENT_DAY

#
_[0].to_s
CURRENT_MONTH =
#

CURRENT_MONTH

#
_[1].to_s
CURRENT_YEAR =
#

CURRENT_YEAR

#
_[2].to_s
CURRENT_DATE =
#

CURRENT_DATE

#
::Time.now.strftime('%d.%m.%Y')
HASH_CONTAINING_THE_HELP_OPTIONS =
#

Roebe::Shell::HASH_CONTAINING_THE_HELP_OPTIONS

This is stored in a separate Hash so that we can access this content from Roebe::Shell embedded in a gtk-widget too.

To show this via the commandline do:

dia --help
#
{
  '--benchmarks'                 => 'show some benchmarks while starting '\
                                    'the Roebe::Shell',
  '--extract'                    => "extract something with aid of the Roebe::Shell,\n"\
                                    "such as in: `roebeshell --extract=foo.tar.xz`",
  '--enable-roebe'               => "will enable home-system support. This will enable "\
                                    "all features.\n",
  '--generate-tab-completion'    => 'generate the tab-completable shortcuts '\
                                    'for the Roebe::Shell',
  '--help'                       => 'show this menu here',
  '--home-dir?'                  => 'show where the Roebe::Shell '\
                                    'assumes the home\ndirectory to be',
  '--home-dir=(new_value)'       => "permanently set a new home directory, such as via:\n"\
                                    "  roebeshell --home-dir=/opt/shell/\n",
  '--no-colours'                 => 'do not use colours',
  '--no-startup'                 => "skip the startup() method invocation, thus "\
                                    "loading a bit\n"\
                                    "faster, but missing out on extra-functionality "\
                                    "as well\n",
  '--norc'                       => 'do not load the configuration file on startup',
  '--noreadline'                 => 'do not make use of the ruby readline module',
  '--nohistory'                  => 'do not make use of history',
  '--run-method'                 => 'invoke a specific method in the Roebe::Shell',
  '--silent-startup'             => "do a rather quiet startup of the "\
                                    "Roebe::Shell, which means \n"\
                                    "that we won't report too much information",
  '--time'                       => 'simply show the current time '\
                                    '(in HH:MM:SS format); a convenience flag mostly',
  '--yaml-directory?'            => "query the path to the local yaml-directory "\
                                    "for\nthe Roebe::Shell",
  '--silent-start'               => "do a silent start, e. g. suppress all output\n"\
                                    "until the shell is running",
  '--version'                    => 'show the version of the Roebe::Shell, then exit'
}
FILE_ROEBE_SHELL_HELP =
#

Roebe::Shell::FILE_ROEBE_SHELL_HELP

This constant will point to a location such as:

/home/Programs/Ruby/2.7.1/lib/ruby/site_ruby/2.7.0/roebe/shell/help/help.rb
#
"#{::Roebe::Shell.project_base_directory?}help/help.rb"
DIRECTORY_FOR_THE_CONFIGURATION_FILES =
#

DIRECTORY_FOR_THE_CONFIGURATION_FILES

#
"#{Roebe::Shell.yaml_directory?}configuration/"
LAST_DOWNLOADED_FILE =
#

Roebe::Shell::LAST_DOWNLOADED_FILE

We store into this file here.

#
"#{Roebe::Shell.yaml_directory?}last_downloaded_file.yml"
FILE_APPOINTMENT_DATES =
#

Roebe::Shell::FILE_APPOINTMENT_DATES

#
"#{::Roebe::HOME_OF_THE_USER_CALLED_X}misc/yaml/appointment_dates.yml"
LOCATION_APPOINTMENT_DATES =

LOCATION_APPOINTMENT_DATES

FILE_APPOINTMENT_DATES
FILE_DEFAULT_APPS =
#

FILE_DEFAULT_APPS

#
"#{Roebe::Shell.yaml_directory?}default_apps.yml"
HELLO_WORLD =
#

HELLO_WORLD

#
'Hello world!'
FILE_NOTIFICATIONS =
#

Roebe::Shell::FILE_NOTIFICATIONS

#
'NOTIFICATIONS.md'
IGNORE_THESE_LAST_COMMANDS =
[]
TV_CHANNELS =
{}
ARRAY_ABBREVIATIONS_FOR_THE_SILENT_START =
#

Roebe::Shell::ARRAY_ABBREVIATIONS_FOR_THE_SILENT_START

#
%w(
  --silent-startup
  --silent
  --silentstartup
  --besilent
  --quiet
  --bequiet
  --silent-start
  SILEN
  quiet_start
  QUIET
)
FILE_FIRST_TIME_RUN =
#

Roebe::Shell::FILE_FIRST_TIME_RUN

#
"#{log_directory?}roebe_shell_has_been_started_at_the_least_once.md"
ARRAY_VALID_VERSION_OPTIONS =
#

Roebe::Shell::ARRAY_VALID_VERSION_OPTIONS

#
%w(
  --version?
  --version
  -version
  version
  ver
  v
)
ARRAY_ABBREVIATIONS_FOR_DISABLING_THE_HISTORY =
#

Roebe::Shell::ARRAY_ABBREVIATIONS_FOR_DISABLING_THE_HISTORY

#
%w(
    --no-history
    no-history
    nohistory
    nhistory
    --nohistory
    disablehistory
    --disable-history
)
NAMESPACE =
#

Roebe::Shell::NAMESPACE

The general namespace for the Roebe::Shell.

#
inspect
RUBY_OS =
#

Roebe::Shell::RUBY_OS

Very conveniently, Gem carries this information. It will return a String such as “linux”.

#
Gem::Platform.local.os
CONVERT_COMMANDS =
#

Roebe::Shell::CONVERT_COMMANDS

These are the actions we can use to convert formats such as .mp3 into .wav and so forth.

#
%w(
  convert_to
  convertto
  convert
  conv
)
LONG_FILE_SIZE =
#

Roebe::Shell::LONG_FILE_SIZE

The constant LONG_FILE_SIZE tells us when to cut down file size.

#
50
DEFAULT_PROMPT =
#

Roebe::Shell::DEFAULT_PROMPT

We default to display the current working directory as our prompt.

#
'PWD'
REALVIDS =
#

Roebe::Shell::REALVIDS

This constant is only useful on my home directory.

#
'/home/x/video/Realvids/'
REALLIFE_KARTEN =
#

Roebe::Shell::REALLIFE_KARTEN

#
"#{ENV['IMG']}/KARTEN/"
REALLIFE_KARTEN_WIEN =
#

Roebe::Shell::REALLIFE_KARTEN_WIEN

#
"#{REALLIFE_KARTEN}WIEN/"
REALLIFE_KARTEN_GERMANY =
#

Roebe::Shell::REALLIFE_KARTEN_GERMANY

#
"#{REALLIFE_KARTEN}DEUTSCHLAND/"
ARRAY_VALID_NO_CONFIGURATION_OPTIONS =
#

ARRAY_VALID_NO_CONFIGURATION_OPTIONS

#
%w(
  --norc
  --noconfig
  --no-config
  -noconfig
  -norc
  noconfig
  norc
)
STARTUP_MESSAGE =
#

Roebe::Shell::STARTUP_MESSAGE

#
'Ready to accept commands now.'
PROC_MODULES =
#

Roebe::Shell::PROC_MODULES

#
'/proc/modules'
DEFAULT_PROMPT_TO_USE =
#

Roebe::Shell::DEFAULT_PROMPT_TO_USE

#
'> '
MY_VIDEO =
#

Roebe::Shell::MY_VIDEO

#
"#{HOME_OF_THE_USER_CALLED_X}video/"
LPAD =
#

LPAD

#
"  #{Colours::CYAN}"
FILE_HELP_MENU =
#

FILE_HELP_MENU

The constant defined here depends on a method, defined in the file 'programs_directory.rb'.

#
'

  |{| to start using the clipboard-buffer

  # ======================================================================= #
  # === a tag
  # ======================================================================= #
  |add_user|              <name> to add a user
  |add_program|           <name> to add a program

  # ======================================================================= #
  # === b tag
  # ======================================================================= #
  |backup|                to backup your data
  |bioshell|              to start the BioShell subpart.

  # ======================================================================= #
  # === c tag
  # ======================================================================= #
  |collapse|              to toggle collapse mode
  |cal?|                  to display the calendar
  |calc|                  to calculate stuff
  |cd_burn|               to burn a cd
  |clock|                 to display a simple ASCII Clock
  |compile|               to compile a single program [Example: compile php]. Use compile ? to get help
  |contacts|              to display some contacts
  |create_large_file|     <FILE_NAME> to create a large file (Current size defaults to 200 MB)
  |create_zip|            to create a .zip archive
  |cure|                  to repair your system

  # ======================================================================= #
  # === d tag
  # ======================================================================= #
  |defaults|              to revert to shell-defaults again
  |default_action|        to do your preformed action
  |description|           <name> to get the description of a program from cookbook.yml
  |downcase|              to downcase all files in the current directory.
  |download|              <name> to download files (just like wget)
  |dvd_burn|              to burn a dvd

  # ======================================================================= #
  # === e tag
  # ======================================================================= #
  |english|               to ask an english word
  |exit|                  to exit the Roebe::Shell
  |extract|               <file> to extract a package, no matter its format

  # ======================================================================= #
  # === f tag
  # ======================================================================= #
  |fetch_form|            to fetch the first HTML formular
  |find|                  <something>, as in [find all pdf]
  |ftp|                   to ftp upload something
  |755|                   555, 644 and so forth to chmod your files (change permission and access level)

  # ======================================================================= #
  # === g tag, g tig
  # ======================================================================= #
  |generate_feedback|     to feedback help about programs, ie: gfeedback games
  |gtk|                   to enter the GTK shell (which provides gtk apps)
  |generate_random_image| <name> to generate a random image with some text
  |grabc|                 to grab a colour (delay: 1 second)
  |gist|                  to gist a file to gisthub (this requires that you did set the credentials first)

  # ======================================================================= #
  # === i tag
  # ======================================================================= #
  |include_program?|      <name> to query whether a program exists in our "database"
  |install_grub|          to install grub
  |install_nvidia|        to install nvidia
  |irb|                   to start irb
  |irc_log|               to append to QUOTES file (IRC Quotes)

  # ======================================================================= #
  # === k tag
  # ======================================================================= #
  |keyboard|              to set your keyboard, i.e. to another layout
  |keywords?|             to show the ruby keywords

  # ======================================================================= #
  # === l tag
  # ======================================================================= #
  |log_dir?|              to show where the log directory is at

  # ======================================================================= #
  # === m tag, m tig
  # ======================================================================= #
  |make_iso|              to generate an .iso file
  |merge|                 to merge different files together
  |mount_cd|              to mount a CDROM
  |move|                  to move/rename a file, directory or symlink
  |methods_in?|           to find all ruby-methods in a specific file, using "def" as the keyword

  # ======================================================================= #
  # === n tag, n tig
  # ======================================================================= #
  |new_tab|               to open a new tab in konsole

  # ======================================================================= #
  # === o tag, o tig
  # ======================================================================= #
  |open_in_background|    <name> to specifically open a program in the background /test/this

  # ======================================================================= #
  # === p tag, p tig
  # ======================================================================= #
  |php2ruby|              to convert php files to ruby code
  |program_exist?|        to query whether a given (usually binary) program exists on this system
  |popup|                 <your message> to give a visual notification on the computer and show a popup window
  |play|                  <file> to play a multimedia (audio or video) file, defaulting to mplayer (configuration value: video_player).

  # ======================================================================= #
  # === r tag, r tig
  # ======================================================================= #
  |ram?|                  to display the available RAM on your machine.
  |remove comment|        <FOO.mp3> to remove a id3 comment tag from a .mp3 file.
  |repackage|             to repackage an archive.
  |rcompile|              to compile multiple programs, example: rcompile ruby to compile addons for ruby
  |rdate|                 to set a different date and time, as in rdate 07.DEC.2007 16:12:44
  |repackage|             to repackage a file, ie: "repackage foobar-1.0.tar.gz" will become foobar-1.0.tar.bz2
  |rf|                    to open a local or remote page as in "rf map"
  |rskelmaker|            to generate ruby skeleton directory (for a ruby project)
  |rsong|                 to start playing random songs
  |rhosts|                to append to /etc/hosts
  |rm_user|               <name> to remove a user
  |rshack|                <name> to upload an image file to Imageshack

  # ======================================================================= #
  # === s tag
  # ======================================================================= #
  |screenshot|            or just |shot| to make a screenshot of your current desktop.
  |scp|                   for remote copying of some files (uses some keywords)
  |set_background|        to change to a new background.
  |show_task|             to show some tasks (things todo or to read).
  |slogan?|               to get the last slogan.
  |symlink|               to symlink programs under the '+Roebe.programs_directory?+' hierarchy
  |system_checker|        check the system.
  |show-docu|             to show the documentation of a ruby method.
  |show-method|           to show the source of a ruby method.
  |$|                     to show the source of a ruby method (this is just an alias to the above ^^^).

  # ======================================================================= #
  # === t tag, t tig
  # ======================================================================= #
  |title|                 <name> to set name of the konsole tab
  |tinyurl|               <url> to turn a "normal" url to a shorter tinyurl
  |touch|                 to create a file
  |totarbz2/totarxz|      <dir> to create a .tar.bz2 / .tar.xz archive
  |to_ascii|              <image_file_or_files> to convert an image to ASCII characters.
  |toggle|                to toggle various Roebe::Shell specific settings [Example: toggle user-input]    
  |translate|             to translate from english to german and translate ? to get help on it
  |tree_view|             to list all the trees on your system

  # ======================================================================= #
  # === u tag, u tig
  # ======================================================================= #
  |unalias|               <name> to unset an alias [Example: unalias pwdj]
  |url|                   <name> to get the URL of a program [Example: url php]
  |users?|                to display users on your system

  # ======================================================================= #
  # === w tag, w tig
  # ======================================================================= #
  |webserve|              <directory> to use Webrick as a HTTP server such as Apache httpd

  # ======================================================================= #
  # === q tag
  # ======================================================================= #
  |quiz|                  to make a little quiz
  |quit|                  to exit from the shell (aliases such as "q" or "exit" work also)

ROEBE_SUBSECTION

  Now my personal stuff:

  |bindings|              to enter interactive C-Bindings section
  |aatranslate|           to translate aminoacids
  |classic|               to play all my classic songs
  |wien?|                 to show the map of vienna

'
DEFAULT_CHMOD_VALUE =
#

Roebe::Shell::DEFAULT_CHMOD_VALUE

#
'755'
USE_THIS_EMAIL =
'[email protected]'
DEFAULT_EDITOR =
#

DEFAULT_EDITOR

#
:bluefish
URL_AUDIO_STREAM =
#

Roebe::Shell::URL_AUDIO_STREAM

#
'https://yp.shoutcast.com/sbin/tunein-station.pls?id=164231'
GENERATE_N_IMAGES =
#

Roebe::Shell::GENERATE_N_IMAGES

This constant is used in the method generate_image().

#
12
RC_FILES =
#

RC_FILES

All RC_FILES are bundled here.

#
%w(
  aliases_rc
  basic_directory_layoutrc
  cd_aliases_rc
  cflags_rc
  colours_rc
  compile_rc
  computer_hardware_rc
  display_settings_rc
  emails_rc
  file_information_rc
  german_umlaute_rc
  gnome_rc
  http_status_codes_rc
  interrupts_rc
  kde_rc
  kernel_rc
  ls_colours_rc
  network_rc
  path_variable_rc
  pkgconfig_rc
  programs_aliases_rc
  roeberia_settings_rc
  system_rc
  system_settings_rc
  video_rc
)
ARRAY_VALID_BENCHMARK_OPTIONS =
#

ARRAY_VALID_BENCHMARK_OPTIONS

#
%w(
  --show_startup_times
  --startup_times
  --speed
  --speedtests
  --debug
  --benchmark
  --benchmarks
  --use-benchmarks
  --use_benchmarks
  --use-benchmark
  --use_benchmark
  --bench
  BENCHMARK
  SHOW_STARTUP_TIMES
)

Constants inherited from Base

Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Time

dd_mm_yyyy, get_current_month, #get_current_month, hh_mm_ss, #return_current_year, return_current_year, show_time

Methods inherited from Base

#append_this_onto_that_file, #be_silent, #be_verbose?, #beautiful_url, #bold_blue, #burlywood, #call_next, #chdir, #cheerful_guy, #convert_global_env, #cornflowerblue, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkslateblue, #deeppink, #ecomment, #editor_to_use?, #efancy, #eimp, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esystem_colourized, #ewarn, #firebrick, #get_current_day, #get_current_month, #get_german_name_for_this_weekday, #gold, #grey, #hh_mm_ss, #home_directory_of_user_x?, #is_a_file?, #is_an_image_file?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_symlink?, #is_this_a_ruby_file?, #iso_encoding?, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lime, #localhost_to_data, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumspringgreen, #mediumturquoise, #n_days_in_this_month, #no_file_exists_at, #olivedrab, #opne, #opnn, #orange, #orchid, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #rename_kde_konsole_tab, #replace_localhost_with_data, #return_all_directories_from_this_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #sfile, #simp, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #teal, #to_camelcase, #tomato, #verbose_truth, #weekday?, #write_what_into, #yellow

Methods included from Base::CommandlineArguments

#clear_commandline_arguments, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #return_commandline_arguments_with_leading_hyphens, #set_commandline_arguments

Constructor Details

#initialize(commandline_arguments = ARGV, run_already = true, &block) ⇒ Shell

#

initialize

#

1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
# File 'lib/roebe/shell/shell/shell.rb', line 1067

def initialize(
    commandline_arguments = ARGV,
    run_already           = true,
    &block
  )
  register_custom_sigint
  reset
  # ======================================================================= #
  # Register the commandline arguments next:
  # ======================================================================= #
  ::Roebe::Shell.set_commandline_arguments(
    commandline_arguments
  )
  set_commandline_arguments(
    commandline_arguments
  )
  # ======================================================================= #
  # The following check also ensures that symbol-instructions such as
  # :do_not_run_main_loop will be honoured. This may be revisited at
  # a later time, but for now it will remain as it is. (If a problem
  # is encountered, it will be mentioned here.)
  # ======================================================================= #
  if commandline_arguments.to_s.include?('dont') or
     commandline_arguments.to_s.include?('do_not')
    commandline_arguments = nil
    run_already = false
  end
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_quiet
    # ===================================================================== #
    when :be_quiet,
         :be_silent
      be_quiet
    # ===================================================================== #
    # === :do_not_enter_the_main_loop
    # ===================================================================== #
    when :do_not_enter_the_main_loop
      run_already = false
      # =================================================================== #
      # We will still run startup() actions, though.
      # =================================================================== #
      startup
    else
      # =================================================================== #
      # Next handle Hashes
      # =================================================================== #
      if yielded.is_a? Hash
        # ================================================================= #
        # === :be_quiet
        #
        # We must use ! because "yes, be quiet" is opposite to "yes,
        # be verbose", as implied by the setter-method set_be_verbose().
        # ================================================================= #
        if yielded.has_key? :be_quiet
          set_be_verbose(!yielded[:be_quiet])
        end
        # ================================================================= #
        # === :enable_debug
        # ================================================================= #
        if yielded.has_key? :enable_debug
          Roebe::Shell.set_debug(yielded[:enable_debug])
        end
        # ================================================================= #
        # === :use_history
        # ================================================================= #
        if yielded.has_key? :use_history
          set_use_history(yielded[:use_history])
        end
        # ================================================================= #
        # === :enable_readline
        # ================================================================= #
        if yielded.has_key? :enable_readline
          set_use_readline(yielded[:enable_readline])
        end
        # ================================================================= #
        # === :use_configuration
        # ================================================================= #
        if yielded.has_key? :use_configuration
          set_use_configuration(yielded[:use_configuration])
        end
        # ================================================================= #
        # === :use_colours
        # ================================================================= #
        if yielded.has_key? :use_colours
          if yielded[:use_colours] == false
            disable_colours(true, :be_quiet)
          end
        end
        # ================================================================= #
        # === :skip_startup
        # ================================================================= #
        if yielded.has_key? :skip_startup
          set_skip_startup(yielded[:skip_startup])
        end
        # ================================================================= #
        # === :is_roebe
        # ================================================================= #
        if yielded.has_key? :is_roebe
          set_is_roebe(yielded[:is_roebe])
        end
        # ================================================================= #
        # === :assign_to_this_file
        # ================================================================= #
        if yielded.has_key? :assign_to_this_file
          set_this_file(yielded[:assign_to_this_file])
        end
        # ================================================================= #
        # === :run_this_method
        #
        # This will run the method, if found, then exit the shell.
        # ================================================================= #
        if yielded.has_key? :run_this_method
          be_quiet
          try_to_invoke_this_method(yielded[:run_this_method], true)
          exit_shell
        end
      end
    end
  end
  case run_already
  # ======================================================================= #
  # === :do_not_run_yet
  # ======================================================================= #
  when :do_not_run_yet
    run_already = false
  end
  run if run_already
end

Class Method Details

.append_to_the_array_roebe_shell_case_options(i) ⇒ Object

#

Roebe::Shell.append_to_the_array_roebe_shell_case_options

#

189
190
191
192
193
194
195
196
# File 'lib/roebe/shell/shell/shell.rb', line 189

def self.append_to_the_array_roebe_shell_case_options(i)
  @array_roebe_shell_case_options << i
  # ======================================================================= #
  # And always sanitize it afterwards.
  # ======================================================================= #
  @array_roebe_shell_case_options.flatten!
  @array_roebe_shell_case_options.compact!
end

.array_documented_help_optionsObject

#

Roebe::Shell.array_documented_help_options

#

241
242
243
# File 'lib/roebe/shell/help/documented_help_options.rb', line 241

def self.array_documented_help_options
  Roebe::Shell::DocumentedHelpOptions.array_documented_help_options
end

.array_help_optionsObject

#

Roebe::Shell.array_help_options

#

449
450
451
# File 'lib/roebe/shell/shell/shell.rb', line 449

def self.array_help_options
  HELP_OPTIONS
end

.array_roebe_shell_case_optionsObject

#

Roebe::Shell.array_roebe_shell_case_options

#

182
183
184
# File 'lib/roebe/shell/shell/shell.rb', line 182

def self.array_roebe_shell_case_options
  @array_roebe_shell_case_options
end

.available_components?Boolean

#

Roebe::Shell.available_components

#

Returns:

  • (Boolean)

26
27
28
# File 'lib/roebe/shell/module_methods/available_components.rb', line 26

def self.available_components?
  @available_components
end

.check_upcoming_exams=(i) ⇒ Object

#

Roebe::Shell.check_upcoming_exams=

#

26
27
28
# File 'lib/roebe/shell/module_methods/anmeldung.rb', line 26

def self.check_upcoming_exams=(i)
  @check_upcoming_exams = to_bool(i)
end

.check_upcoming_exams?Boolean

#

Roebe::Shell.check_upcoming_exams?

#

Returns:

  • (Boolean)

40
41
42
# File 'lib/roebe/shell/module_methods/anmeldung.rb', line 40

def self.check_upcoming_exams?
  @check_upcoming_exams
end

.commandline_arguments?Boolean

#

Roebe::Shell.commandline_arguments?

#

Returns:

  • (Boolean)

31
32
33
# File 'lib/roebe/shell/module_methods/commandline_arguments.rb', line 31

def self.commandline_arguments?
  @commandline_arguments
end

.config_directory?Boolean

#

Roebe::Shell.config_directory?

This would output a directory such as:

/home/Programs/Ruby/2.7.1/lib/ruby/site_ruby/2.7.0/roebe/shell/yaml/configuration/
#

Returns:

  • (Boolean)

154
155
156
# File 'lib/roebe/shell/configuration/configuration.rb', line 154

def self.config_directory?
  "#{::Roebe::Shell.yaml_directory?}configuration/"
end

.configuration?Boolean

#

Roebe::Shell.configuration?

Class method via the @configuration variable.

#

Returns:

  • (Boolean)

119
120
121
# File 'lib/roebe/shell/configuration/configuration.rb', line 119

def self.configuration?
  @configuration
end

.contains_a_valid_help_option?(i) ⇒ Boolean

#

Roebe::Shell.contains_a_valid_help_option?

This method will return true or false. False by default, and true if the given input will contain any argument.

#

Returns:

  • (Boolean)

91
92
93
94
95
96
97
98
99
# File 'lib/roebe/shell/help/help.rb', line 91

def self.contains_a_valid_help_option?(i)
  return_value = false
  if i.is_a? Array
    if i.any? {|entry| Roebe::Shell.valid_help_options.include?(entry) }
      return_value = true
    end
  end
  return return_value
end

.create_manual(use_this_object = nil) ⇒ Object

#

Roebe::Shell.create_manual

This method can be used to create a .pdf manual.

You can pass an object-instance to this method if you want to.

#

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/roebe/shell/module_methods/misc.rb', line 64

def self.create_manual(
    use_this_object = nil # <- This can be a new instance of the Roebe::Shell class.
  )
  require 'prawn'
  # ======================================================================= #
  # Checking whether the user has Prawn installed.
  # ======================================================================= #
  if Object.const_defined? :Prawn
    if use_this_object
      if use_this_object.is_a?(Hash) and
         use_this_object.has_key?(:use_this_object)
        _ = use_this_object.delete :use_this_object
      else # Else direct assignment.
        _ = use_this_object
      end
    else
      _ = Roebe::Shell.new(:do_not_run_main_loop)
    end
     = _.sanitize_url(:diamond_logo).location? # Must come very early.
    diatutorial_page  = _.pretty_url(:diatutorial).result
    # ===================================================================== #
    # diatutorial_page can be an Array. But we need a String.
    # ===================================================================== #
    if diatutorial_page.is_a? Array
      diatutorial_page = diatutorial_page.first
    end
    this_page = _.replace_data_with_localhost(diatutorial_page)
    this_page = this_page.first if this_page.is_a? Array
    # ===================================================================== #
    # The variable this_page will hold the link towards our tutorial.
    # ===================================================================== #
    _.serve_local_page(this_page)
    # ===================================================================== #
    # First, we will tell the user where to store.
    # ===================================================================== #
    store_where = _.log_dir?+'diamondshell_manual_'+_.return_date+'.pdf'
    _.remove(store_where) if File.exist? store_where
    cliner {
      e 'We will store the manual for the DiamondShell at:'
      e '  '+sfile(store_where)
    }
    html_manual = _.log_dir?+'ROEBE_SHELL_TUTORIAL.html'
    _.remove_html(html_manual) if File.exist? html_manual
    if _._.empty? # This is @_.
      _._ = _.serve(:diacgi, false) # false for "don't be verbose". bl $DIA/base/serve.rb
      _._ = _.remove_html(html_manual) # This should assign to @_
    end
    pdf = Prawn::Document.new(page_size: 'A4')
    pdf.font 'Times-Roman'
    pdf.font_size(15) # General font size. 
    pdf.text 'Roebe::Shell Manual'
    pdf.fill_color '#000000' # This is the black colour.
    pdf.move_down 25
    pdf.indent(5) {
      pdf.text(
        'The Roebe::Shell Manual',
        size: 32,
        fill_color: 'red'
      )
    }
    pdf.start_new_page 
    pdf.move_down 25
    pdf.image(, width: 48, height: 48)
    pdf.move_down 15
    _.usher.reset # Store into usher. For this to work, @_ must be assigned.
    # ===================================================================== #
    # Note that @_ would refer to something like:
    #
    #   /root/roebe_shell/DIAMOND_SHELL_TUTORIAL.html
    #
    # ===================================================================== #
    if File.exist? _._
      e 'Now reading in the file `'+sfile(_._)+'`.'
      _._ = File.read(_._)
    else
      e swarn('No file at ')+sfile(_._)+swarn(' exists.')
    end
    html_content = _._.split(N) if _._.is_a? String
    html_content.each {|line|
      if line.include? '<body' # We seek for the <body> tag.
        e 'We found a <body> tag.'
        _.usher.open
      end
      _.usher << "#{line}#{N}" # Try to append.
    }
    array = _.usher.array
    array = array.map { |entry|
      WebObject.remove_html(entry).strip
    }.reject(&:empty?)
    array.each {|line|
      line << N if line.include? '<br'
      unless line.empty?
        pdf.indent(1) { pdf.text(line) }
      end
    }
    _.delete(store_where) if File.exist? store_where # Get rid of old .pdf file.
    # ===================================================================== #
    # Next we will store the .pdf file finally.
    # ===================================================================== #
    pdf.render_file(store_where) # Render it now.
    opn namespace: NAMESPACE
    e 'We will store at'
    opn namespace: NAMESPACE
    e "  `#{sfile(store_where)}`"
    e
    opn namespace: NAMESPACE
    e 'You could open this in a pdf viewer next, if you would '\
      'like to. Just do:'
    opn namespace: NAMESPACE
    e '   open THIS_FILE'
    _.assign_file(store_where)
  else # Prawn is unavailable.
    opn namespace: NAMESPACE
    e 'Prawn is not available. Please install it first.'
  end
end

.debug?Boolean

#

Roebe::Shell.debug?

#

Returns:

  • (Boolean)

103
104
105
106
107
108
109
# File 'lib/roebe/shell/shell/core/debug.rb', line 103

def self.debug?
  if configuration? and configuration?.respond_to?(:debug)
    configuration?.debug
  else
    false
  end
end

.disable_anmeldungObject

#

Roebe::Shell.disable_anmeldung

This method can be used to disable checking for “anmeldungen” and exams. Permanently so - from the commandline as well.

#

58
59
60
61
62
63
64
65
# File 'lib/roebe/shell/module_methods/anmeldung.rb', line 58

def self.disable_anmeldung
  disable_check_for_upcoming_exams
  into = ::Roebe::Shell.file_check_upcoming_exams
  if File.exist? into
    what = 'false'
    ::Roebe.write_what_into(what, into)
  end
end

.disable_check_for_upcoming_examsObject

#

Roebe::Shell.disable_check_for_upcoming_exams

#

33
34
35
# File 'lib/roebe/shell/module_methods/anmeldung.rb', line 33

def self.disable_check_for_upcoming_exams
  @check_upcoming_exams = false
end

.disable_coloursObject

#

Roebe::Shell.disable_colours

#

48
49
50
51
52
53
# File 'lib/roebe/shell/colours/colours.rb', line 48

def self.disable_colours
  if block_given? and (yield == :be_verbose)
    e 'Disabling colours.'
  end
  @use_colours = false
end

.disable_readline_is_availableObject

#

Roebe::Shell.disable_readline_is_available

#

64
65
66
# File 'lib/roebe/shell/shell/misc.rb', line 64

def self.disable_readline_is_available
  @readline_is_available = false
end

.do_not_use_configurationObject

#

Roebe::Shell.do_not_use_configuration

#

110
111
112
# File 'lib/roebe/shell/configuration/configuration.rb', line 110

def self.do_not_use_configuration
  self.use_configuration_file = false
end

.do_use_benchmark_while_loadingObject

#

Roebe::Shell.do_use_benchmark_while_loading

This method will enable using the benchmark while loading.

#

66
67
68
# File 'lib/roebe/shell/module_methods/benchmarks.rb', line 66

def self.do_use_benchmark_while_loading
  @use_benchmark_while_loading = true
end

.do_we_use_readline?Boolean

#

Roebe::Shell.do_we_use_readline?

#

Returns:

  • (Boolean)

228
229
230
231
# File 'lib/roebe/shell/shell/misc.rb', line 228

def self.do_we_use_readline?
  puts 'Will readline be used: '+
       ::Roebe.verbose_truth(readline_is_available?).to_s
end

.e(i = '') ⇒ Object

#

Roebe::Shell.e

#

41
42
43
# File 'lib/roebe/shell/colours/colours.rb', line 41

def self.e(i = '')
  puts i
end

.ecap(i) ⇒ Object

#

Roebe::Shell.ecap

This is like e() but we will capitalize the first character passed.

#

1173
1174
1175
1176
1177
# File 'lib/roebe/shell/shell/core/show_display_feedback_and_report.rb', line 1173

def self.ecap(i)
  i = i.dup if i.frozen?
  i[0,1] = i[0,1].upcase # Upcase it here.
  e i # And then we can delegate to e().
end

.ecomment(i = '') ⇒ Object

#

Roebe::Shell.ecomment

#

34
35
36
# File 'lib/roebe/shell/help/help.rb', line 34

def self.ecomment(i = '')
  ::Roebe.ecomment(i)
end

.efancy(i = '', use_colours = true) ⇒ Object

#

Roebe::Shell.efancy

#

116
117
118
119
120
121
# File 'lib/roebe/shell/colours/colours.rb', line 116

def self.efancy(
    i           = '',
    use_colours = true
  )
  puts sfancy(i, use_colours)
end

.enable_check_for_upcoming_examsObject

#

Roebe::Shell.enable_check_for_upcoming_exams

#

47
48
49
# File 'lib/roebe/shell/module_methods/anmeldung.rb', line 47

def self.enable_check_for_upcoming_exams
  @check_upcoming_exams = true
end

.enable_coloursObject

#

Roebe::Shell.enable_colours

#

58
59
60
61
62
63
# File 'lib/roebe/shell/colours/colours.rb', line 58

def self.enable_colours
  if block_given? and (yield == :be_verbose)
    e 'Enabling colours.'
  end
  @use_colours = true
end

.enable_debugObject

#

Roebe::Shell.enable_debug

#

121
122
123
# File 'lib/roebe/shell/shell/core/debug.rb', line 121

def self.enable_debug
  configuration?.debug = true
end

.enable_readline_is_availableObject

#

Roebe::Shell.enable_readline_is_available

#

57
58
59
# File 'lib/roebe/shell/shell/misc.rb', line 57

def self.enable_readline_is_available
  @readline_is_available = true
end

.ensure_that_ftp_is_initializedObject

#

Roebe::Shell.ensure_that_ftp_is_initialized

This will call initialize_ftp() unless we already were connected.

#

50
51
52
# File 'lib/roebe/shell/module_methods/ftp.rb', line 50

def self.ensure_that_ftp_is_initialized
  initialize_ftp unless ftp?
end

.entries_from_path?Boolean

#

Roebe::Shell.entries_from_path?

#

Returns:

  • (Boolean)

109
110
111
# File 'lib/roebe/shell/shell/core/path.rb', line 109

def self.entries_from_path?
  ::Roebe.env?['PATH']
end

.entries_from_path_as_arrayObject

#

Roebe::Shell.entries_from_path_as_array

#

89
90
91
92
93
94
95
# File 'lib/roebe/shell/shell/core/path.rb', line 89

def self.entries_from_path_as_array
  _ = ::Roebe.env?['PATH']
  if _ and _.include?(':')
    _ = _.split(':')
  end
  [_].flatten.compact
end

.ewarn(i = '', use_colours = use_colours? ) ⇒ Object

#

Roebe::Shell.ewarn

#

136
137
138
139
140
141
142
143
144
145
# File 'lib/roebe/shell/colours/colours.rb', line 136

def self.ewarn(
    i           = '',
    use_colours = use_colours?
  )
  if use_colours
    ::Colours.ewarn(i)
  else
    e i
  end
end

.exceptions_keep_numbersObject

#

Roebe::Shell.exceptions_keep_numbers

Reader method over @array_exceptions_keep_numbers.

#

576
577
578
# File 'lib/roebe/shell/shell/shell.rb', line 576

def self.exceptions_keep_numbers
  @array_exceptions_keep_numbers
end

.external_requiresObject

#

Roebe::Shell.external_requires

This method will show which external requires are used.

#

1754
1755
1756
1757
1758
# File 'lib/roebe/shell/shell/shell.rb', line 1754

def self.external_requires
  file_lazy_load_these_components = ::Roebe.project_base_directory?+
                                    'shell/yaml/lazy_load_these_components.yml'
  YAML.load_file(file_lazy_load_these_components).sort
end

.file_check_upcoming_examsObject

#

Roebe::Shell.file_check_upcoming_exams

#

771
772
773
# File 'lib/roebe/shell/shell/shell.rb', line 771

def self.file_check_upcoming_exams
  "#{Roebe::Shell.yaml_directory?}configuration/check_upcoming_exams.yml"
end

.file_shellrcObject

#

Roebe::Shell.file_shellrc

Return the location towards the shellrc file.

#

834
835
836
# File 'lib/roebe/shell/shell/shell.rb', line 834

def self.file_shellrc
  "#{log_directory?}shellrc"
end

.file_video_collection(i = FILE_VIDEO_COLLECTION) ⇒ Object

#

MultimediaParadise.file_video_collection

This method will simply return where the yaml file is kept.

#

1057
1058
1059
1060
1061
# File 'lib/roebe/shell/shell/shell.rb', line 1057

def self.file_video_collection(
    i = FILE_VIDEO_COLLECTION
  )
  i
end

.ftp?Boolean

#

Roebe::Shell.ftp?

#

Returns:

  • (Boolean)

34
35
36
# File 'lib/roebe/shell/module_methods/ftp.rb', line 34

def self.ftp?
  @ftp
end

.generate_pdf_tutorial_then_upload_itObject

#

Roebe::Shell.generate_pdf_tutorial_then_upload_it

You can use this method to simply generate a new .pdf file, then upload it anyway.

#

364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/roebe/shell/shell/core/generate.rb', line 364

def self.generate_pdf_tutorial_then_upload_it
  unless File.directory? '/home/Temp/lighty/'
    FileUtils.mkdir_p '/home/Temp/lighty/'
  end if ::Roebe.is_on_roebe?
  url = 'http://localhost/programming/ruby/src/roebe/doc/roebe_shell_tutorial.cgi?pdf'
  OpenURI.send(:open, url)
  # ======================================================================= #
  # ^^^ This will have generated the .pdf.
  # ======================================================================= #
  # Hardcoded for now where the .pdf will reside.
  # ======================================================================= #
  # pdf_location = '/Depot/Temp/lighty/DIAMOND_SHELL_TUTORIAL.pdf'
  #
  # Not needed though because this is already done by the next line.
  # ======================================================================= #
  ftp = FtpParadise.new(:shevy, :dont_run_yet)
  ftp.
  ftp.upload_this_binary_file(::Roebe::Shell.path_to_local_pdf_tutorial)
  e 'Finished uploading!'
end

.generate_tab_completion(use_this_directory_as_log_directory = ::Roebe.log_dir?, &block) ⇒ Object

#

Roebe::Shell.generate_tab_completion

Use this method to generate the tab completion for the Roebe::Shell component.

This refers to a shell file for bash, primarily, but it should also be possible to generate completion files for the zsh shell.

On my home system the method will generate a new file into:

/home/Temp/roebe/completion_for_roebe_shell.sh

To invoke this, do:

generate tab
#

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/roebe/shell/module_methods/generate_tab_completion.rb', line 39

def self.generate_tab_completion(
    use_this_directory_as_log_directory = ::Roebe.log_dir?,
    &block
  )
  if Object.const_defined? :GenerateShellCompletion
    # ======================================================================= #
    # bl $RSRC/generate_shell_completion/lib/generate_shell_completion/generate_shell_completion.rb
    # ======================================================================= #
    _ = GenerateShellCompletion.new(nil, :dont_run_yet)
    # ======================================================================= #
    # The listing of completable-commands for the Roebe::Shell.
    # ======================================================================= #
    array = %w(

      --help
      --norc
      --extract
      --version
      --nocolours
      --nohistory
      --run-method

    )
    # Append the keys from the following hash:
    array << ::Roebe::Shell::HASH_CONTAINING_THE_HELP_OPTIONS.keys.sort
    array.flatten
    store_there = "#{use_this_directory_as_log_directory}"\
                  "completion_for_roebe_shell.sh" # Where to store that file.
    if block_given?
      yielded = yield
      if yielded.is_a? Hash
        # ================================================================= #
        # === :store_where
        # ================================================================= #
        if yielded.has_key? :store_where
          store_there = yielded[:store_where]
        end
      end
    end
    array = array + array.map {|entry| entry.delete('-') }
    _.append_files_from_the_current_directory
    _.set_name_of_the_shell_function('roebe_shell_completion')
    _.set_dataset(array)
    _.set_aliases('dia,rdia,rda') # Use three aliases for this.
    _.store_here = store_there
    _.run
  else
    e "GenerateShellCompletion is not available. Consider "\
      "installing it if you wish to generate the file "\
      "#{sfile(File.basename(store_there))}."
  end
end

.hash_help_optionsObject

#

Roebe::Shell.hash_help_options

We return the documented help options here.

This will be the Array defined lateron.

#

403
404
405
# File 'lib/roebe/shell/shell/core/help.rb', line 403

def self.hash_help_options
  @hash_help_options
end

.home_dir?Boolean

#

Roebe::Shell.home_dir?

Query method for the @home_dir variable.

The @home_dir variable will denote where the user's home directory resides at.

On my home system, this may return this path:

/root/shell/

For other users they may want to have it defined elsewhere.

#

Returns:

  • (Boolean)

42
43
44
# File 'lib/roebe/shell/module_methods/home_directory.rb', line 42

def self.home_dir?
  @home_directory
end

.individual_cookbooks_directory?Boolean

#

Roebe::Shell.individual_cookbooks_directory?

#

Returns:

  • (Boolean)

1021
1022
1023
1024
1025
1026
1027
1028
1029
# File 'lib/roebe/shell/shell/shell.rb', line 1021

def self.individual_cookbooks_directory?
  if Object.const_defined?(:RBT) and
     RBT.respond_to?(:individual_cookbooks_directory?)
    _ = RBT.individual_cookbooks_directory?
  else
    _ = ENV['COOKBOOK_DIRECTORY'].to_s+'/cookbooks/'
  end
  _
end

.initialize_ftp_object(use_this_host = 'SHEVY') ⇒ Object

#

Roebe::Shell.initialize_ftp_object

The first (optional) argument tells us which remote host we will use.

#

59
60
61
62
63
# File 'lib/roebe/shell/module_methods/ftp.rb', line 59

def self.initialize_ftp_object(use_this_host = 'SHEVY')
  set_ftp(
    FtpParadise::Connection.new(use_this_host, false)
  )
end

.is_on_kde_konsole?Boolean

#

Roebe::Shell.is_on_kde_konsole?

#

Returns:

  • (Boolean)

52
53
54
# File 'lib/roebe/shell/module_methods/misc.rb', line 52

def self.is_on_kde_konsole?
  Object.const_defined? :Colours # This should be equivalent to KDE Konsole colours.
end

.load_help_filesObject

#

Roebe::Shell.load_help_files

This method will load up all Roebe::Shell-specific helpfiles. They will reside in the help/ subdirectory.

#

27
28
29
30
31
32
# File 'lib/roebe/shell/module_methods/misc.rb', line 27

def self.load_help_files
  standalone_files = Dir["#{project_base_directory?}help/*.rb"]
  standalone_files.each {|file|
    require file
  }
end

.load_standalone_classes_filesObject

#

Roebe::Shell.load_standalone_classes_files

On my home system this may yield a path such as:

/usr/lib/ruby/site_ruby/3.1.0/roebe/shell/standalone_classes/*.rb
#

42
43
44
45
46
47
# File 'lib/roebe/shell/module_methods/misc.rb', line 42

def self.load_standalone_classes_files
  standalone_files = Dir["#{project_base_directory?}standalone_classes/*.rb"]
  standalone_files.each {|file|
    require file
  }
end

.main_encoding?Boolean

#

Roebe::Shell.main_encoding?

Query back which encoding we will use. This will always be a String.

#

Returns:

  • (Boolean)

28
29
30
# File 'lib/roebe/shell/module_methods/encoding.rb', line 28

def self.main_encoding?
  @encoding.to_s
end

.main_file?Boolean

#

Roebe::Shell.main_file?

#

Returns:

  • (Boolean)

30
31
32
# File 'lib/roebe/shell/module_methods/main_file.rb', line 30

def self.main_file?
  @main_file
end

.missing_gems?Boolean

#

Roebe::Shell.missing_gems?

Tell us which gems are missing upon require-time. This will allow us to install such a missing gem.

#

Returns:

  • (Boolean)

26
27
28
# File 'lib/roebe/shell/shell/core/gems.rb', line 26

def self.missing_gems?
  @missing_gems
end

.parse_help_line(line) ⇒ Object

#

Roebe::Shell.parse_help_line

Will return an Array with two members - the first one being the command in question, the second one being the content.

#

363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/roebe/shell/shell/core/help.rb', line 363

def self.parse_help_line(line)
  # ======================================================================= #
  # This regex should work:
  #   http://rubular.com/r/wTfaoomvkq
  # ======================================================================= #
  regex_to_use = /(\|.+?\|)(.+)/ # This regex is non-greedy.
  command = '' # This is the command itself.
  content = '' # This is the content of the command.
  line    =~ regex_to_use
  command = $1.to_s.dup.delete('|').strip
  content = $2.to_s.dup.strip # Here we can not delete '|' as there may be internal || in use.
  result = [command, content]
  return result
end

.permanently_set_home_dir(what = ::Roebe::Shell.home_dir?, into = FILE_HOME_DIR) ⇒ Object

#

Roebe::Shell.permanently_set_home_dir

This method will also modify the yaml file.

#

985
986
987
988
989
990
991
992
993
994
995
996
# File 'lib/roebe/shell/shell/shell.rb', line 985

def self.permanently_set_home_dir(
    what = ::Roebe::Shell.home_dir?,
    into = FILE_HOME_DIR
  )
  unless what.end_with? '/' # Ensure a trailing '/'.
    what = what.dup if what.frozen?
    what << '/'
  end
  puts "Designating #{::Roebe.sdir(what)} as the current home directory."
  puts "Saving into the file `#{::Roebe.sfile(into)}`."
  ::Roebe.write_what_into(what, into)
end

.pid_file?Boolean

#

Roebe::Shell.pid_file?

#

Returns:

  • (Boolean)

1034
1035
1036
# File 'lib/roebe/shell/shell/shell.rb', line 1034

def self.pid_file?
  "#{log_directory?}pid.yml"
end

.populate_inbuilt_hash_help_optionsObject

#

Roebe::Shell.populate_inbuilt_hash_help_options

This is the method that will populate the various '?' help options.

The '?' help options give the user some extra feedback about the individual subcommands of the Roebe::Shell.

#

339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/roebe/shell/shell/core/help.rb', line 339

def self.populate_inbuilt_hash_help_options
  Roebe::Shell.empty_hash_help_options # Always clear it before populating it anew.
  # ======================================================================= #
  # We split up the individual help-menu entries:
  # ======================================================================= #
  help_options = Roebe::Shell.return_sanitized_help_menu(:return_array)
  help_options.each {|line|
    if line.include? '|'
      command, content = Roebe::Shell.parse_help_line(line)
      # =================================================================== #
      # Next, we will always redefine the Hash with that option.
      # This allows us to query which entries exist.
      # =================================================================== #
      Roebe::Shell.hash_help_options['?'+command] = content.to_s.dup
    end
  }
end

.preferred_encoding?Boolean

#

Roebe::Shell.preferred_encoding?

The class-method preferred_encoding? expects the configuration object to yield to it the information which encoding is to be preferred.

If the configuration object is unavailable, we will default to the main_encoding instead.

#

Returns:

  • (Boolean)

75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/roebe/shell/module_methods/encoding.rb', line 75

def self.preferred_encoding?
  if ::Roebe::Shell.config? and
     ::Roebe::Shell.config?.respond_to?(:preferred_encoding)
    ::Roebe::Shell.config?.preferred_encoding
  else
    # ===================================================================== #
    # Else we default to tme encoding, via querying
    # Roebe::Shell.main_encoding?.
    # ===================================================================== #
    ::Roebe::Shell.main_encoding?
  end
end

.project_base_directory?Boolean

#

Roebe::Shell.project_base_directory?

The base directory of the project is returned by this method.

No constant is used anymore since as of August 2020.

#

Returns:

  • (Boolean)

24
25
26
# File 'lib/roebe/shell/project/project.rb', line 24

def self.project_base_directory?
  "#{Roebe.project_base_dir?}shell/"
end

.readline_is_available?Boolean

#

Roebe::Shell.readline_is_available?

Query-method as to whether readline is available or whether it is not.

#

Returns:

  • (Boolean)

50
51
52
# File 'lib/roebe/shell/shell/misc.rb', line 50

def self.readline_is_available?
  @readline_is_available
end

.register_this_component(name, is_it_available) ⇒ Object

#

Roebe::Shell.register_this_component

#

33
34
35
36
37
# File 'lib/roebe/shell/module_methods/available_components.rb', line 33

def self.register_this_component(
    name, is_it_available
  )
  @available_components[name] = is_it_available
end

.register_this_missing_gem(file) ⇒ Object

#

Roebe::Shell.register_this_missing_gem

#

33
34
35
# File 'lib/roebe/shell/shell/core/gems.rb', line 33

def self.register_this_missing_gem(file)
  @missing_gems << file
end

.registered_case_optionsObject

#

Roebe::Shell.registered_case_options

Return all available slots from the DiamondShell menu.

#

203
204
205
# File 'lib/roebe/shell/shell/shell.rb', line 203

def self.registered_case_options
  @array_roebe_shell_case_options
end

.report_where_the_home_directory_can_be_found(home_dir = home_dir? ) ⇒ Object

#

Roebe::Shell.report_where_the_home_directory_can_be_found

To invoke this method from the commandline, try:

rdia --home-dir?
#

23
24
25
26
27
28
29
# File 'lib/roebe/shell/module_methods/report_where_the_home_directory_can_be_found.rb', line 23

def self.report_where_the_home_directory_can_be_found(
    home_dir = home_dir?
  )
  puts "#{::Colours.rev}The #{::Colours.steelblue('home directory')} "\
       "for the Roebe::Shell interface can be found "\
       "at `#{::Colours.sdir(home_dir)}`."
end

.require_this_via_a_thread(i) ⇒ Object

#

Roebe::Shell.require_this_via_a_thread

Require a component via Thread.new.

#

50
51
52
53
54
# File 'lib/roebe/shell/shell/core/require.rb', line 50

def self.require_this_via_a_thread(i)
  Thread.new {
    require i
  }
end

.reset_help_optionsObject

#

Roebe::Shell.reset_help_options

#

311
312
313
# File 'lib/roebe/shell/shell/core/help.rb', line 311

def self.reset_help_options
  ::Roebe::Shell.set_hash_help_options
end

.return_help_menuObject

#

Roebe::Shell.return_help_menu

This method will simply return the FILE_HELP_MENU constant, without any sanitizing.

#

437
438
439
# File 'lib/roebe/shell/shell/core/help.rb', line 437

def self.return_help_menu
  FILE_HELP_MENU # bl diamond_shell/help/help_menu.rb
end

.return_missing_componentsObject

#

Roebe::Shell.return_missing_components

#

49
50
51
52
53
54
# File 'lib/roebe/shell/module_methods/available_components.rb', line 49

def self.return_missing_components
  _ = Roebe::Shell.available_components?.select {|key, value|
    value == :is_not_available
  }
  return _
end

.return_pwdObject

#

Roebe::Shell.return_pwd

#

17
18
19
# File 'lib/roebe/shell/module_methods/misc.rb', line 17

def self.return_pwd
  rds("#{Dir.pwd}/")
end

.return_sanitized_help_menu(return_array_or_string = :string) ⇒ Object

#

Roebe::Shell.return_sanitized_help_menu

#

411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/roebe/shell/shell/core/help.rb', line 411

def self.return_sanitized_help_menu(return_array_or_string = :string)
  _ = return_help_menu # Grab a raw copy of the help-menu first.
  _.strip!
  # ======================================================================= #
  # _ is still a String at this point. We now look for whether we
  # are on Roebe.
  # ======================================================================= #
  if _.include?('ROEBE') and !Roebe.on_roebe?
    _ = _[0.._.index(/ROEBE_SUBSECTION/)-1]
  end
  _ = _.split(N).map(&:strip)
  _.reject! {|entry| entry.start_with? '#' } # Get rid of comments.
  case return_array_or_string
  when :string, :return_string
    _.join(N) # We must return a String.
  when :array,  :return_array
    _
  end
end

.run(optional_commandline_arguments = ARGV, run_already = true) ⇒ Object

#

Roebe::Shell.run

This method can be used to instantiate a new Roebe::Shell instance.

Add more ways to instantiate a new Roebe::Shell object. This is mostly done for more convenience and flexibility.

An alias called [] exists, invokable via Roebe::Shell[].

#

375
376
377
378
379
380
381
382
383
# File 'lib/roebe/shell/commandline/commandline.rb', line 375

def self.run(
    optional_commandline_arguments = ARGV,
    run_already                    = true
  )
  Roebe::Shell::Commandline.new(
    optional_commandline_arguments,
    run_already
  )
end

.set_commandline_arguments(i = ARGV) ⇒ Object

#

Roebe::Shell.set_commandline_arguments

We keep track of the commandline arguments through this @ivar.

#

24
25
26
# File 'lib/roebe/shell/module_methods/commandline_arguments.rb', line 24

def self.set_commandline_arguments(i = ARGV)
  @commandline_arguments = [i].flatten.compact
end

.set_configuration(i = nil) ⇒ Object

#

Roebe::Shell.set_configuration

#

126
127
128
# File 'lib/roebe/shell/configuration/configuration.rb', line 126

def self.set_configuration(i = nil)
  @configuration = i # This variable will hold the configuration of the Roebe::Shell project.
end

.set_debug(i = true) ⇒ Object

#

Roebe::Shell.set_debug

#

114
115
116
# File 'lib/roebe/shell/shell/core/debug.rb', line 114

def self.set_debug(i = true)
  configuration?.debug = i
end

.set_encoding(i = :default) ⇒ Object

#

Roebe::Shell.set_encoding

You can set to another encoding if you want to, through the method called Roebe::Shell.set_encoding() here.

The method will default to UTF-8 encoding since as of July 2019.

#

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/roebe/shell/module_methods/encoding.rb', line 40

def self.set_encoding(
    i = :default
  )
  case i.to_s # case tag
  # ======================================================================= #
  # === default
  #
  # This will be the default encoding.
  # ======================================================================= #
  when 'default',
       'utf'
    i = ENCODING_UTF
  # ======================================================================= #
  # === iso
  # ======================================================================= #
  when 'iso'
    i = ENCODING_ISO
  # ======================================================================= #
  # === binary
  # ======================================================================= #
  when 'binary'
    i = ENCODING_BIT
  end
  @encoding = i
end

.set_ftp(i) ⇒ Object

#

Roebe::Shell.set_ftp

#

41
42
43
# File 'lib/roebe/shell/module_methods/ftp.rb', line 41

def self.set_ftp(i)
  @ftp = i
end

.set_hash_help_options(i = {}) ⇒ Object

#

Roebe::Shell.set_hash_help_options

#

390
391
392
# File 'lib/roebe/shell/shell/core/help.rb', line 390

def self.set_hash_help_options(i = {})
  @hash_help_options = {}
end

.set_home_directory(i = HOME_DIR) ⇒ Object

#

Roebe::Shell.set_home_directory

This method can be used to designate another home directory to use.

It will be valid for the current session - if you want to permanently set a new home directory then use the class-method Roebe::Shell.permanently_set_home_dir instead.

#

58
59
60
61
62
63
64
65
# File 'lib/roebe/shell/module_methods/home_directory.rb', line 58

def self.set_home_directory(
    i = HOME_DIR
  )
  i = i.dup if i.frozen?
  i << '/' unless i.end_with? '/'
  i = ::Roebe.rds(i)
  @home_directory = i
end

.set_main_file(i) ⇒ Object

#

Roebe::Shell.set_main_file

#

37
38
39
# File 'lib/roebe/shell/module_methods/main_file.rb', line 37

def self.set_main_file(i)
  @main_file = i
end

.set_startup_time_at(i = Time.now) ⇒ Object

#

Roebe::Shell.set_startup_time_at

This method can be used to time how long it takes to load the whole Roebe::Shell. Note that we will always register the startup-time if we load from the file diamond_shell/dia.

#

21
22
23
24
25
# File 'lib/roebe/shell/module_methods/startup_time.rb', line 21

def self.set_startup_time_at(
    i = Time.now
  )
  @startup_time_at = i
end

.set_this_file(i) ⇒ Object

#

Roebe::Shell.set_this_file

#

24
25
26
# File 'lib/roebe/shell/shell/core/assign.rb', line 24

def self.set_this_file(i)
  @this_file = i
end

.set_use_colours(i) ⇒ Object

#

Roebe::Shell.set_use_colours

#

68
69
70
71
72
73
# File 'lib/roebe/shell/colours/colours.rb', line 68

def self.set_use_colours(i)
  if i.is_a? String
    i = turn_into_boolean_value(i)
  end
  @use_colours = i
end

.sfancy(i = '', use_colours = use_colours? ) ⇒ Object

#

Roebe::Shell.sfancy

#

102
103
104
105
106
107
108
109
110
111
# File 'lib/roebe/shell/colours/colours.rb', line 102

def self.sfancy(
    i           = '',
    use_colours = use_colours?
  )
  if use_colours
    ::Colours.sfancy(i)
  else
    return i.to_s
  end
end

.show_help(n_ljust = 28, use_this_colour_for_cliner = :royalblue) ⇒ Object

#

Roebe::Shell.show_help (commandline tag)

This method shows the commandline options that are available and supported.

The first argument to this method, called `n_ljust`, can be used to pad the left side towards the right. This means that the higher that number, the more left-padded the left side will appear.

Options include commandline flags such as –nohistory or -no-colours.

To use this functionality, do:

rda --show-commandline-help
#

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/roebe/shell/help/help.rb', line 56

def self.show_help(
    n_ljust                    = 28,
    use_this_colour_for_cliner = :royalblue
  )
  print ::Colours.rev
  e
  ::Roebe.cliner(:default, :default, use_this_colour_for_cliner)
  # ======================================================================= #
  # Next, append the help options stored in the main Hash.
  # ======================================================================= #
  colourized_separator_token = Colours.royalblue('#')
  HASH_CONTAINING_THE_HELP_OPTIONS.each_pair {|key, value|
    if value.include? N
      splitted = value.split(N)
      e "  #{::Colours.steelblue(key.ljust(n_ljust))} "\
        "#{colourized_separator_token} #{::Colours.mediumseagreen(splitted[0])}"
      splitted[1 .. -1].each {|inner_value|
        e "  #{''.ljust(n_ljust)} #{colourized_separator_token} "\
          "#{::Colours.mediumseagreen(inner_value)}"
      }
    else
      e "  #{::Colours.steelblue(key.ljust(n_ljust))} "\
        "#{colourized_separator_token} #{::Colours.mediumseagreen(value)}"
    end
  }
  ::Roebe.cliner(:default, :default, use_this_colour_for_cliner)
  e
end

.simp(i = '', use_colours = @use_colours) ⇒ Object

#

Roebe::Shell.simp

#

150
151
152
153
154
155
156
157
158
159
# File 'lib/roebe/shell/colours/colours.rb', line 150

def self.simp(
    i           = '',
    use_colours = @use_colours
  )
  if use_colours
    ::Colours.simp(i)
  else
    i
  end
end

.startup_time_at?Boolean

#

Roebe::Shell.startup_time_at?

#

Returns:

  • (Boolean)

30
31
32
# File 'lib/roebe/shell/module_methods/startup_time.rb', line 30

def self.startup_time_at?
  @startup_time_at
end

.swarn(i = '', use_colours = use_colours? ) ⇒ Object

#

Roebe::Shell.swarn

#

78
79
80
81
82
83
84
85
86
87
# File 'lib/roebe/shell/colours/colours.rb', line 78

def self.swarn(
    i           = '',
    use_colours = use_colours?
  )
  if use_colours
    ::Colours.firebrick(i)
  else
    i.to_s
  end
end

.test_colours(use_colours = use_colours? ) ⇒ Object

#

Roebe::Shell.test_colours

This method can be used to find out whether we have colours enabled or disabled.

#

303
304
305
306
307
308
309
310
311
# File 'lib/roebe/shell/colours/colours.rb', line 303

def self.test_colours(
    use_colours = use_colours?
  )
  if use_colours
    efancy 'This should be colourized.'
  else
    efancy 'This should not be colourized.'
  end
end

.test_this_input(i) ⇒ Object

Roebe::Shell.test_this_input

We will register this class-method here, but I am not entirely sure whether it is still needed or not.

#

19
20
21
# File 'lib/roebe/shell/shell/core/test.rb', line 19

def self.test_this_input(i)
  check_against_menu(i)
end

.this_file?Boolean

#

Roebe::Shell.this_file?

Query method over @this_file.

#

Returns:

  • (Boolean)

33
34
35
# File 'lib/roebe/shell/shell/core/assign.rb', line 33

def self.this_file?
  @this_file
end

.update_entries_from_path(i) ⇒ Object

#

Roebe::Shell.update_entries_from_path

Provide a new path listing here.

#

102
103
104
# File 'lib/roebe/shell/shell/core/path.rb', line 102

def self.update_entries_from_path(i)
  ::Roebe.env?['PATH'] = i
end

.upload(i, ftp_mode_to_use = :ascii, do_try_to_login = true) ⇒ Object

#

Roebe::Shell.upload

Use this class-method to upload something to my remote FTP site.

We use the FtpLibrary from project FtpParadise for this.

#

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/roebe/shell/shell/core/upload.rb', line 20

def self.upload(
    i, # We will upload this here.
    ftp_mode_to_use = :ascii, # The default ftp-mode will be ascii.
     = true
  )
  ftp_mode_to_use = :ascii if ftp_mode_to_use == :default
  if  == :do_not_try_to_login
     = false
  end
  if i.is_a? Array
    i.each {|entry| upload(entry) }
  else
    i = i.to_s # We require a String from this point forward - no Symbols.
    original_input = i.dup
    case i
    # ===================================================================== #
    # === Upload my aliases
    # ===================================================================== #
    when 'aliases' # Here we upload the various aliases.
      base_dir =
        '/home/x/programming/ruby/src/rcfiles/lib/rcfiles/yaml/'
      i = %w( aliases.yml cd_aliases.yml programs_aliases.yml ).map {|entry|
        base_dir+entry
      }
    # ===================================================================== #
    # === Upload the Roebe::Shell tutorial.
    #
    # This is no longer really in use since as of 2022.
    # ===================================================================== #
    when 'tutorial' # upload :tutorial
      serve_local_page 'programming/ruby/src/roebe/doc/roebe_shell_tutorial.cgi?pdf'
      i = LOCAL_PDF_DOCUMENTATION
      ftp_mode_to_use = :binary # Must be binary as it is a .pdf file.
    # ===================================================================== #
    # === Upload zeugnisse
    # ===================================================================== #
    when 'zeugnisse'
      Studium::PublishMyExams[]; i = nil
    # ===================================================================== #
    # === Upload the main file
    # ===================================================================== #
    when 'MAIN_FILE',
         'MAINFILE',
         'MFILE',
         'this_file?'
      i = ::Roebe::Shell.this_file?
    # ===================================================================== #
    # === configuration
    # ===================================================================== #
    when 'configuration'
      i = make_gem('$RUBY_SRC/configuration/').to_s
    # ===================================================================== #
    # === pruefung
    # ===================================================================== #
    when 'pruefungsfragen','pr','pruefung'
      i = '/home/x/studium/pruefungs_fragen.rb'
      ftp_mode_to_use = :binary
    end unless File.exist?(i)
    if i.is_a? Array
      if original_input == 'aliases' # Also upload the rc-files.
        ::Roebe::Shell.ensure_that_ftp_is_initialized
        ::Roebe::Shell.ftp?. :shevy, :mode_to_use => ftp_mode_to_use
        ::Roebe::Shell.ftp?.cd('AUTOGENERATED')
        %w( aliases_rc cd_aliases_rc programs_aliases_rc ).map {|entry|
          '/AUTOGENERATED/'+entry
        }.each {|file|
          upload(file, :default, :do_not_try_to_login)
          e
        }
        ::Roebe::Shell.ftp?.cd('..') # And go down again here.
      end
      i.each {|entry| upload(entry, :default) }
    else # We want to upload an individual file here.
      i = convert_global_env(i) if i.include? '$'
      if File.exist? i
        ::Roebe::Shell.initialize_ftp unless defined? ::Roebe::Shell.ftp?
        if 
          ::Roebe::Shell.ftp?. :shevy, mode_to_use: ftp_mode_to_use
        end
        if ::Roebe::Shell.is_image_file?(i)
          ::Roebe::Shell.ftp?.mode_to_use = :binary
        end
        if ::Roebe::Shell.use_konsole?
          size = '(Size: '+::Colours.turquoise(File.size(i).to_s)+' kb)'
        else
          size = '(Size: '+File.size(i).to_s+' kb)'
        end
        e 'Next uploading `'+sfile(i)+'` '+size+
          ' to `'+sfancy(::Roebe::Shell.ftp?.host?)+'`.'
        if ftp_mode_to_use == :binary
          ::Roebe::Shell.ftp?.upload_binary(i)
        else
          ::Roebe::Shell.ftp?.upload(i)
        end
      else
        ewarn "Could not find a file or directory "\
              "called `#{simp(i)}`."
      end
    end if i # This check because "zeugnisse" sets to nil again.
  end
end

.use_benchmark_while_loading?Boolean

#

Roebe::Shell.use_benchmark_while_loading?

#

Returns:

  • (Boolean)

57
58
59
# File 'lib/roebe/shell/module_methods/benchmarks.rb', line 57

def self.use_benchmark_while_loading?
  @use_benchmark_while_loading
end

.use_configuration_file=(i) ⇒ Object

#

Roebe::Shell.use_configuration_file?

#

142
143
144
# File 'lib/roebe/shell/configuration/configuration.rb', line 142

def self.use_configuration_file=(i)
  @use_configuration_file = i
end

.use_configuration_file?Boolean

#

Roebe::Shell.use_configuration_file?

Query whether we will use the roebe-shell configuration file.

#

Returns:

  • (Boolean)

135
136
137
# File 'lib/roebe/shell/configuration/configuration.rb', line 135

def self.use_configuration_file?
  @use_configuration_file
end

.use_konsole_colours?Boolean

#

Roebe::Shell.use_konsole_colours?

Query whether we want to use konsole_colours or not. This can be toggled in the configuration for the Diamond Shell.

#

Returns:

  • (Boolean)

228
229
230
231
232
233
234
# File 'lib/roebe/shell/colours/colours.rb', line 228

def self.use_konsole_colours?
  if config? and config?.respond_to?(:use_konsole_colours)
    config?.use_konsole_colours
  else
    false
  end
end

.valid_benchmark_optionsObject

#

Roebe::Shell.valid_benchmark_options

This class-method will return all valid and registered benchmark options. This is important for the commandline variant, so that we can invoke the diashell via a –benchmark switch.

#

50
51
52
# File 'lib/roebe/shell/module_methods/benchmarks.rb', line 50

def self.valid_benchmark_options
  ARRAY_VALID_BENCHMARK_OPTIONS
end

.valid_help_optionsObject

#

Roebe::Shell.valid_help_options

#

210
211
212
# File 'lib/roebe/shell/shell/shell.rb', line 210

def self.valid_help_options
  ARRAY_VALID_HELP_OPTIONS
end

.valid_no_configuration_optionsObject

#

Roebe::Shell.valid_no_configuration_options

#

65
66
67
# File 'lib/roebe/shell/configuration/configuration.rb', line 65

def self.valid_no_configuration_options
  ARRAY_VALID_NO_CONFIGURATION_OPTIONS
end

.yaml_directory?Boolean

#

Roebe::Shell.yaml_directory?

#

Returns:

  • (Boolean)

31
32
33
# File 'lib/roebe/shell/project/project.rb', line 31

def self.yaml_directory?
  "#{project_base_directory?}yaml/"
end

Instance Method Details

#_Object

#

_

Attr reader over the @_ dump variable.

#

1186
1187
1188
# File 'lib/roebe/shell/shell/core/misc.rb', line 1186

def _
  @_
end

#_=(i) ⇒ Object

#

_=

#

1193
1194
1195
# File 'lib/roebe/shell/shell/core/misc.rb', line 1193

def _=(i)
  @_ = i
end

#act_filetype_specific(i) ⇒ Object

#

act_filetype_specific

This method should be used whenever you want to access a file in a “file-type specific manner”. For example, an archive such as .zip should be extracted (typically), whereas a ruby .gem file should be installed via a corresponding command.

This is just an assumption, though - for example, a ruby .gem file could also be extracted too by default. This method has to choose one option among more than one, so it may not always yield the “correct” option.

#

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/roebe/shell/shell/core/act_filetype_specific.rb', line 28

def act_filetype_specific(i)
  if i.is_a? Array
    i.each {|entry| act_filetype_specific(entry) }
  else
    if is_archive? i
      if i =~ /\.gem$/ # Install gems here.
        install_this_gem(i)
        return
      else
        extract(i) # Extract archives here.
      end
    end
    file_type = i.split('.').last
    case file_type
    # ===================================================================== #
    # === cgi
    # ===================================================================== #
    when 'cgi',
         'html',
         'png' # for now, png will be opened in the browser as well.
      open_in_browser_tab(i)
    # ===================================================================== #
    # === msixbundle
    #
    # This is for microsoft .msixbundle files. They are installed via
    # powershell.
    # ===================================================================== #
    when 'msixbundle'
      esystem 'Add-AppxPackage '+i
    # ===================================================================== #
    # === avi
    # ===================================================================== #
    when 'avi',
         'flv',
         'ogg',
         /mp(.)*/
      play_multimedia_file(i)
    # ===================================================================== #
    # === pdf
    # ===================================================================== #
    when 'pdf',
         'xdpf',
         'xpdf'
      open_pdf(i)
    # ===================================================================== #
    # === ppt
    # ===================================================================== #
    when 'ppt',
         'odp',
         'pptx',
         'ppx'
      esystem 'libreoffice '+file_name
    else
      # =================================================================== #
      # Handle the situation when we wish to debug next:
      # =================================================================== #
      if config?.debug
        e 'In act_filetype_specific(), line: '+__LINE__.to_s
        ewarn file_type
      end
      # =================================================================== #
      # If this is a directory, we will enter it.
      # =================================================================== #
      if File.directory? i
        cd(i)
      else
        # ================================================================= #
        # Act on mode in use next - possible modes are display,
        # browser and edit:
        # ================================================================= #
        case config?.default_file_action.to_s
        # ================================================================= #
        # === display
        # ================================================================= #
        when 'display'
          cat(i)
        # ================================================================= #
        # === browser
        # ================================================================= #
        when 'browser'
          open_in_browser(i)
        # ================================================================= #
        # === edit
        # ================================================================= #
        when 'edit'
          if is_image_file?(i)
            e 'Currently, editing an image does not make sense.'
            e 'We thus overrule it and display the image in the '\
              'browser instead.'
            open_in_browser(i)
          else
            open_in_editor(i)
          end
        end
      end
    end
  end
end

#action_check_for_isos(_ = '/Depot/ISOs/', be_verbose = be_verbose? ) ⇒ Object Also known as: check_for_isos

#

action_check_for_isos

We use this method to check whether we have any .iso file, in the directory /Depot/ISOs/.

In case we have, we will notify the user about these files on startup.

We will, however had, only check that directory - subdirectories will NOT be checked.

#

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/roebe/shell/shell/core/iso.rb', line 33

def action_check_for_isos(
    _          = '/Depot/ISOs/',
    be_verbose = be_verbose?
  )
  # ======================================================================= #
  # Only continue if the Directory /Depot/ISOs exists.
  # ======================================================================= #
  if Dir.exist?(_) and check_for_iso_files?
    # ===================================================================== #
    # If that directory is empty, we don't have to do anthing at all.
    # ===================================================================== #
    if Dir.empty?(_)
    else
      # =================================================================== #
      # Only continue if the Directory is not empty. So the next step
      # is to select all .iso files in that directory.
      # =================================================================== #
      all_isos = get_files_from(_).select {|file|
        file.include? '.iso'
      }
      # =================================================================== #
      # Since as of 23.12.2011, we scan for the content 'bootable' and
      # use the external command called `file`.
      #
      # Since March 2013 we just search for 'boot' string, as some .iso
      # files may not have the full 'bootable' string here.
      # =================================================================== #
      if program_exists? 'file' # Use file here.
        all_isos.reject! {|entry|
          result = `file #{entry}`
          !result.include?('boot')
        }
      end
      if all_isos.empty?
      else
        all_isos = all_isos.sort # Sort it first.
        if be_verbose
          e "#{rev}The following #{seagreen('.iso')} files were found:"
          e
          total_filesize_of_all_isos = 0
          all_isos.each {|this_iso_file|
            e "    #{steelblue(this_iso_file)}"
            total_filesize_of_all_isos += File.size?(this_iso_file)
          }
          total_filesize_of_all_isos = 
            ((total_filesize_of_all_isos.to_f / 1024.0) / 1024.04).round(0)
          e
          if all_isos.size == 1
            e sfancy(all_isos.size.to_s)+" iso file was found "+
              "in #{sdir(_)}, with a total filesize "+
              "of #{sfancy(total_filesize_of_all_isos)} MB:"
          else
            e sfancy(all_isos.size.to_s)+" iso files were found "+
              "in #{sdir(_)}, with a total filesize "+
              "of #{sfancy(total_filesize_of_all_isos)} MB:"
          end
          # ================================================================= #
          # In the past, assign_file() was used, but I noticed that
          # this isn't quite that useful, so it was disabled again.
          # ================================================================= #
          proper_english = 'it' 
          proper_english = 'them' if all_isos.size > 1
          e 'Consider '+sfancy('burning')+' (or '+sfancy('removing')+
            ') '+proper_english+'.'
        end
      end
      # =================================================================== #
      # Next, we will check for non .iso files.
      # =================================================================== #
      non_iso_files = get_all_files_from(
        _, :ignore_subdirectories
      ) # bl $DIA/base/get_file_listing.rb
      # =================================================================== #
      # This may still include subdirectories, which we will ignore,
      # thus the following reject.
      # =================================================================== #
      non_iso_files.reject! {|entry| File.directory? entry }
      non_iso_files.reject! {|entry|
        (File.extname(entry) == '.iso') or
        (File.extname(entry) == '.md') # .md files are also ignored, since November 2018.
      }
      unless non_iso_files.empty? # Ok, we found non-iso files here.
        if be_verbose
          cliner('=')
          e 'We found some '+swarn('non .iso files')+' in '+sdir(_)+' - namely'
          e '('+sfancy(non_iso_files.join(', '))+').'+N
          e 'It is preferred if only .iso files are stored in that directory.'
          cliner('=')
          e
        end
      end
    end
  end
end

#add(i) ⇒ Object

#

add (add tag)

Gather all add-related methods here.

#

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/roebe/shell/shell/core/add.rb', line 77

def add(i)
  if i.is_a? Array
    if i.first == 'user'
       add(i.join(' ').strip)
    else
      i.each {|entry| add(entry) }
    end
  else
    i = i.to_s.strip
    i = i.gsub(/to/,'').strip # Get rid of "to".
    case i
    # ===================================================================== #
    # === jumpers
    # ===================================================================== #
    when 'jumpers','jumper','setpoint'
      create_setpoint
    # ===================================================================== #
    # === user
    # ===================================================================== #
    when /^user/
      add_user(i)
    # ===================================================================== #
    # === favourites
    # ===================================================================== #
    when /favourites/ # This entry also handles include? 'favourites'
      add_to_favourites(i)
    # ===================================================================== #
    # === group
    # ===================================================================== #
    when 'group'
      add_group
    # ===================================================================== #
    # === recipe
    # ===================================================================== #
    when 'recipe'
      interactive_recipe_creation
    end
  end
end

#add_favourite_audio(i) ⇒ Object

#

add_favourite_audio

This will add entries into the file:

env?['AUDIO']+'/YAML/current_favourites.yml'
#

329
330
331
332
333
334
335
336
337
338
# File 'lib/roebe/shell/shell/core/audio.rb', line 329

def add_favourite_audio(i)
  if i.is_a? Array
    i.each {|entry| add_favourite_audio(entry) }
  else
    this_file = env?['AUDIO']+'/YAML/current_favourites.yml'
    _ = N+'- '+i
    e 'Now appending `'+simp(_)+'` to '+sfile(this_file)+'.'
    append_what_to(_, this_file)
  end
end

#add_group(this_group = nil) ⇒ Object

#

add_group

Add a group via this method. We will use the command “groupadd” for this task.

Usage example:

add_group nobody
#

57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/roebe/shell/shell/core/add.rb', line 57

def add_group(
    this_group = nil
  )
  if this_group
    if this_group.is_a? Array
      this_group.each {|entry| add_group(entry) }
    else
      _ = "groupadd #{this_group}" 
      e
      esystem _
      e
    end
  end
end

#add_personal_help_sectionObject

#

add_personal_help_section

This method hooks in some stuff for my personal settings.

#

275
276
277
278
# File 'lib/roebe/shell/shell/core/help.rb', line 275

def add_personal_help_section
  register_these_help_options ''
  register_this_help_option
end

#add_require(i) ⇒ Object

#

add_require

This method will be verbose by default.

It will add a new gem to the list of gems that will be loaded upon startup.

#

177
178
179
180
181
182
183
184
# File 'lib/roebe/shell/shell/core/add.rb', line 177

def add_require(i)
  if i.is_a? Array
    i.each {|entry| add_require(entry) }
  else
    e "Now adding the gem called #{simp(i)} to the list of startup files."
    add_this_entry_to_the_yaml_file_containing_custom_requires(i)
  end
end

#add_to_favourites(i) ⇒ Object

#

add_to_favourites

Use this method to add to the favourites file.

#

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/roebe/shell/shell/core/add.rb', line 21

def add_to_favourites(i)
  require 'multimedia_paradise'
  i = i.first if i.is_a? Array
  if i.include? 'favourites'
    i.gsub!(/favourites/,'')
    i.strip!
  end
  i = "\n#{i}"
  # ======================================================================= #
  # Query whether the input is to be considered an audio file.
  # ======================================================================= #
  if is_audio_file? i
    if File.exist? where_to
      i = i.dup if i.frozen?
      i.prepend(' - ') 
      MultimediaParadise.add_this_song_to_the_playlist(i)
    else
      ewarn "Can not append to #{sfile(where_to)} because it "\
            "does not exist."
    end
  else # Ok, it is not an audio file.
    e "It is not an audio file. Thus we won't add it."
  end
end

#add_to_path(i, be_verbose = false) ⇒ Object

#

add_to_path

#

116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/roebe/shell/shell/core/path.rb', line 116

def add_to_path(
    i, be_verbose = false
  )
  if i.is_a? Array
    i = i.join(':')
  end
  if be_verbose == :be_verbose
    e "Now adding #{col(i)} to the PATH setting."
  end
  old_values = env?['PATH']
  Roebe::Shell.update_entries_from_path(
    (old_values+':'+i).squeeze(':')
  )
end

#add_to_the_playlist(i) ⇒ Object

#

add_to_the_playlist

Use this method to add to the audio playlist.

#

29
30
31
32
33
34
# File 'lib/roebe/shell/shell/core/audio.rb', line 29

def add_to_the_playlist(i)
  begin
    require 'multimedia_paradise/audio/playlist/playlist.rb'
  rescue LoadError; end
   MultimediaParadise::Playlist.add(i)
end

#add_user(this_user = nil) ⇒ Object

#

add_user

This method adds a user to the system.

#

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/roebe/shell/shell/core/add.rb', line 122

def add_user(
    this_user = nil
  )
  if this_user
    if this_user.is_a? Array
      this_user.each {|entry| add_user(entry) }
    else # At this point we assume that this will be a String.
      if this_user.include? 'user '
        this_user.gsub!(/^user /,'')
      end
      case this_user
      # =================================================================== #
      # === lighty
      # =================================================================== #
      when 'lighty'
        if is_on_roebe?
          add_group(:nobody)
          do_add_this_user(this_user)
        else
          do_add_this_user(this_user)
        end
      when *HELP_OPTIONS
        e '|args|Arguments|_| for this method:'
        e
        e '  (1) |fa|<this_user>|_|: Give the name of this user.'
        e
      else
        # ================================================================= #
        # This is the action that will add the user in question.
        # ================================================================= #
        do_add_this_user(this_user)
      end
    end
  else # else this is when input is nil.
    e 'Please provide a name for the user to be added.'
  end
end

#aliases?Boolean

#

aliases?

#

Returns:

  • (Boolean)

75
76
77
# File 'lib/roebe/shell/shell/core/aliases.rb', line 75

def aliases?
  return @internal_hash[:aliases]
end

#all(i = nil) ⇒ Object

#

all

#

47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/roebe/shell/shell/core/all.rb', line 47

def all(
    i = nil
  )
  _ = get_all_files
  if i.is_a? Array
    unless i.empty?
      # In this case, we will apply a filter.
      _.select! {|entry| entry.end_with? i.first }
    end
  end
  e 'Assigning all files in this directory to the '\
    'variable '+sfancy('@_')+'.'
  @_ = _
end

#all_arguments?Boolean Also known as: all_arguments, a?, a, arguments?

#

all_arguments?

#

Returns:

  • (Boolean)

293
294
295
# File 'lib/roebe/shell/shell/core/arguments.rb', line 293

def all_arguments?
  @internal_hash[:all_arguments]
end

#all_files(from_where = :pwd) ⇒ Object Also known as: get_all_files

#

all_files

Use this method to obtain all files from a given directory.

#

90
91
92
# File 'lib/roebe/shell/shell/core/get_file_listing.rb', line 90

def all_files(from_where = :pwd)
  get_file_listing(from_where).reject {|entry| ! File.file? entry } # Reject non-files here.
end

#all_images(of_this_directory = get_pwd) ⇒ Object

#

all_images

Retrieve all images of this directory with this method here.

We will also automatically assign to the ivar @_.

By default we will use the current directory.

#

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/roebe/shell/shell/core/all.rb', line 25

def all_images(
    of_this_directory = get_pwd
  )
  of_this_directory = of_this_directory.to_s.dup # In case it is tainted.
  of_this_directory << '/*' unless of_this_directory.end_with? '/*'
  of_this_directory = rds(of_this_directory)
  if of_this_directory.include? '$'
    of_this_directory = convert_global_env(of_this_directory)
  end
  the_files = get_files_from(
    of_this_directory,
    :obtain_from_subdirectories
  )
  @_ = the_files.select {|file| # true for "include subdirs".
    is_image_file?(file)
  }
  return @_
end

#all_songs(i = env?['MY_SONGS']) ⇒ Object Also known as: get_all_songs, all_audio_files, return_all_audio_files

#

all_songs

Obtain all songs, by calling into get_files_from().

#

256
257
258
259
260
# File 'lib/roebe/shell/shell/core/audio.rb', line 256

def all_songs(
    i = env?['MY_SONGS']
  )
  return get_files_from(i, true)
end

#analyse_the_user_input(_ = user_input? ) ⇒ Object Also known as: process_user_input

#

analyse_the_user_input

This method in particular has to set the arguments from the user input.

#

2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
# File 'lib/roebe/shell/shell/shell.rb', line 2102

def analyse_the_user_input(
    _ = user_input?
  )
  # ======================================================================= #
  # Next we must split the arguments up.
  # ======================================================================= #
  if _ and _.include? ' '
    splitted = _.split(' ')
    set_all_arguments(
      splitted[1 .. -1]
    )
    user_input = splitted.first
    set_user_input(user_input)
    # ===================================================================== #
    # If the arguments include a '# ' then pass them into the
    # following clause again. Note that 
    # ===================================================================== #
    if _.include? '# '
      set_all_arguments(
        return_user_input_without_trailing_comments
      )
    end
    return user_input # We need to return this here, so it can be used in the second loop.
  end
  return _
end

#anyone_has_a_birthday?(optional_n_days = 14) ⇒ Boolean Also known as: check_whether_anyone_has_a_birthday

#

anyone_has_a_birthday?

We check here if anyone has a birthday, within the coming 14 days.

Right now this solution is not 100% perfect because we do not include older dates.

Usage example:

bday 120

bl $RUBY_MISC/birthday_notifications.rb
#

Returns:

  • (Boolean)

27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/roebe/shell/shell/core/birthdays.rb', line 27

def anyone_has_a_birthday?(
    optional_n_days = 14
  )
  require 'roebe/classes/birthday_notifications.rb'
  if optional_n_days.is_a? Array
    optional_n_days = optional_n_days.first
  end
  optional_n_days = 10 if optional_n_days.nil?
  optional_n_days = 10 if optional_n_days.to_s.empty?
  _ = ::Roebe::BirthdayNotifications.new(nil, :do_not_run_yet) # false so we do not run already
  _.set_n_days optional_n_days # One week by default.
  #_.report_when_nothing_was_found
  _.run # true for "be silent".
end

#append_file(what, into) ⇒ Object Also known as: append_onto_this_file

#

append_file

#

109
110
111
# File 'lib/roebe/shell/shell/core/append.rb', line 109

def append_file(what, into)
  ::Roebe.append_file(what, into)
end

#append_this_to_the_arguments(i) ⇒ Object

#

append_this_to_the_arguments

Note that this method will NOT do any additional processing.

#

26
27
28
29
# File 'lib/roebe/shell/shell/core/arguments.rb', line 26

def append_this_to_the_arguments(i)
  all_arguments? << i
  all_arguments.flatten!
end

#append_this_to_the_last_result(i) ⇒ Object

#

append_this_to_the_last_result

#

18
19
20
# File 'lib/roebe/shell/shell/core/append.rb', line 18

def append_this_to_the_last_result(i)
  @internal_hash[:last_result] << "#{i