class RBT::LeanPrototype

Constants

ALL_COLOUR_METHODS
#

ALL_COLOUR_METHODS

#
ARRAY_KDE_KONSOLE_COLOURS_IN_USE
#

ARRAY_KDE_KONSOLE_COLOURS_IN_USE

Next, we will define the KONSOLE Colours that can be used.

#
DAY_NAMES
#

DAY_NAMES

The addition of this constant was necessary due to upstream MRI ruby removing the RFC2822_DAY_NAME constant from time.rb.

#
NAMESPACE
#

NAMESPACE

#
SILENT_REDIRECTION
#

SILENT_REDIRECTION

This can simply be appended.

#

Public Class Methods

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

initialize

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 97
def initialize(
    i           = ARGV,
    run_already = true,
    &block
  )
  reset
  set_commandline_arguments(i)
  # ======================================================================= #
  # Next handle blocks given to the class.
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :no_colours
    # ===================================================================== #
    when :no_colours
      disable_colours
    else
      # =================================================================== #
      # === Handle Hash given in blockform
      # =================================================================== #
      if yielded.is_a? Hash
        # ================================================================= #
        # === :use_colours
        # ================================================================= #
        if yielded.has_key? :use_colours
          _ = yielded.delete :use_colours
          if _ == false
            disable_colours
          end
        end
      end
    end
  end
  run if run_already
end

Public Instance Methods

a_or_an?(i) click to toggle source
#

a_or_an?

For proper english titles, we can use “a” or “an”.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1257
def a_or_an?(i)
  if i.start_with?('a','i','o','u')
    'an'
  else
    'a'
  end
end
abbreviations?() click to toggle source
#

abbreviations?

Easier getter-method over the available abbreviations.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1392
def abbreviations?
  RBT.hash_aliases_to_the_available_programs?
end
absolute_path(i) click to toggle source
#

absolute_path

This method will ensure that there is a trailing ‘/’ on the returned result, if it is a directory.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1402
def absolute_path(i)
  _ = File.absolute_path(i)
  # ======================================================================= #
  # Only append if it is a directory.
  # ======================================================================= #
  if File.directory?(_) and !_.end_with?('/')
    _ = _.dup if _.frozen?
    _ << '/'
  end
  return _
end
action( action_that_is_desired = nil, optional_argument1 = ARGV, options_hash = {}, &block ) click to toggle source
#

action (action tag)

This method bundles together all “actionable components”. It thus ties options to the user in a convenient manner, without needing to remember the name of classes or where the code resides at. All the user has to know is the name of the action itself, and they are good to go.

This method is a simpler wrapper over the toplevel RBT.action() code.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3194
def action(
    action_that_is_desired = nil,
    optional_argument1     = ARGV, # This is typically the main input to this method.
    options_hash           = {},
    &block
  )
  unless ::RBT.respond_to? :action
    require 'rbt/requires/require_actions.rb'
  end
  RBT.action(
    action_that_is_desired,
    optional_argument1,
    options_hash,
    &block
  )
end
Also aliased as: actions
actions( action_that_is_desired = nil, optional_argument1 = ARGV, options_hash = {}, &block )
Alias for: action
add_to_the_commandline_arguments(i) click to toggle source
#

add_to_the_commandline_arguments

Simply append to the commandline options through this method here.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 957
def add_to_the_commandline_arguments(i)
  # ======================================================================= #
  # First check whether the input is a Hash:
  # ======================================================================= #
  if i.is_a? Hash
    if i.has_key? :commandline_arguments
      i = i.delete(:commandline_arguments)
    end
  end
  @internal_hash[:commandline_arguments] << i
  @internal_hash[:commandline_arguments].flatten!
end
all_arguments?()
all_available_programs?()
Alias for: available_programs?
all_binaries?() click to toggle source
#

all_binaries?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 441
def all_binaries?
  require 'rbt/toplevel_methods/all_binaries.rb'
  RBT.all_binaries?
end
all_files_from(this_directory) click to toggle source
#

all_files_from

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1456
def all_files_from(this_directory)
  Dir[rds(this_directory+'/*')].select {|entry| File.file?(entry) }
end
all_libraries?() click to toggle source
#

all_libraries?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 323
def all_libraries?
  require 'rbt/toplevel_methods/all_libraries.rb'
  RBT.all_libraries?
end
all_programs()
Alias for: available_programs?
all_programs?()
Alias for: available_programs?
allowed_cookbook_entries?( i = RBT.file_registered_cookbook_entries ) click to toggle source
#

allowed_cookbook_entries?

This method will load the .yml file containing all registered cookbook entries.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 753
def allowed_cookbook_entries?(
    i = RBT.file_registered_cookbook_entries
  )
  YAML.load_file(i) if File.exist? i
end
appdir_location_of?(i) click to toggle source
#

appdir_location_of?

Give an input of something like ‘foo’, this method will return a path such as ‘/Programs/Foo/Current’.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 213
def appdir_location_of?(i)
  "#{programs_dir?}#{i.capitalize}/Current"
end
appdir_prefix?()
Alias for: programs_directory?
append_onto_the_internal_hash(i) click to toggle source
#

append_onto_the_internal_hash

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1284
def append_onto_the_internal_hash(i)
  @internal_hash.update(i)
end
Also aliased as: append_onto_the_main_hash
append_onto_the_main_hash(i)
append_these_options_to_the_commandline(i)
append_to_the_commandline(i)
append_to_the_commandline_arguments(i)
append_what_into(what, into) click to toggle source
#

append_what_into

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1816
def append_what_into(what, into)
  RBT.append_what_into(what, into)
end
archive_dir?()
archive_type?(i)
Alias for: archive_type_of?
archive_type_of(i)
Alias for: archive_type_of?
archive_type_of?(i) click to toggle source
#

archive_type_of?

Determine the archive type of the given input, such as ‘.tar.xz’ and so forth.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1488
def archive_type_of?(i)
  RBT.return_archive_type(i)
end
are_we_on_gobolinux?()
Alias for: is_on_gobolinux?
are_we_on_windows?()
Alias for: is_on_windows?
arguments?()
available_cookbooks()
Alias for: available_programs?
available_cookbooks?()
Alias for: available_programs?
available_programs()
Alias for: available_programs?
available_programs?() click to toggle source
#

available_programs?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2458
def available_programs?
  RBT.available_programs?
end
base_dir_to_store_expanded_cookbooks?()
be_quiet(i = false)
Alias for: set_be_silent
be_quiet?() click to toggle source
#

be_quiet?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2011
def be_quiet?
  !@internal_hash[:be_verbose]
end
be_silent(i = false)
Alias for: set_be_silent
be_verbose(i = true)
Alias for: set_be_verbose
be_verbose=(i = true)
Alias for: set_be_verbose
be_verbose?() click to toggle source
#

be_verbose?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2004
def be_verbose?
  @internal_hash[:be_verbose]
end
begins_with_a_comment?(i) click to toggle source
#

begins_with_a_comment?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3284
def begins_with_a_comment?(i)
  i.start_with? '#'
end
capitalize_first_alphabetical_character( i = '/programs' ) click to toggle source
#

capitalize_first_alphabetical_character

This method will capitalize on the given input, but it will act on the first alphabetical character. So for example, if we input a string such as “/programs” then this method will return “/Programs”.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2655
def capitalize_first_alphabetical_character(
    i = '/programs'
  )
  new_string = ''.dup
  capitalized_already = false
  i.chars.each {|char|
    if capitalized_already
    else
      if char =~ /[a-zA-Z]/
        char.upcase!
        capitalized_already = true
      end
    end
    new_string << char
  }
  new_string
end
cd( i, optional_arguments = nil )
Alias for: change_directory
cd_to_the_log_directory() click to toggle source
#

cd_to_the_log_directory

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1505
def cd_to_the_log_directory
  cd log_directory?
end
cd_to_the_temp_directory( be_verbose = :be_quiet ) click to toggle source
#

cd_to_the_temp_directory

This will cd to the temp directory, while being quiet.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 879
def cd_to_the_temp_directory(
    be_verbose = :be_quiet
  )
  cd temp_directory?, be_verbose
end
change_dir( i, optional_arguments = nil )
Alias for: change_directory
change_directory( i, optional_arguments = nil ) { || ... } click to toggle source
#

change_directory (cd tag)

Change into the given directory.

The second argument to this method can be used to do additional tasks, such as creating the directory if it does not yet exist.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2040
def change_directory(
    i,
    optional_arguments = nil
  )
  be_verbose = false
  # ======================================================================= #
  # First, handle Symbol-keywords given as first argument.
  # ======================================================================= #
  case i
  when :log_directory
    i = log_directory?
  end
  if block_given?
    yielded = yield
    case yielded
    when :be_verbose
      be_verbose = true
    end
  end 
  # ======================================================================= #
  # Past this point, the variable `i` ought to be a String.
  # ======================================================================= #
  i = i.to_s unless i.is_a? String
  case optional_arguments
  # ======================================================================= #
  # === :be_quiet
  # ======================================================================= #
  when :be_quiet,
       :quiet,
       :silent,
       :be_silent,
       :do_not_report_anything
      be_verbose = false
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  when :be_verbose,
       true
    be_verbose = true
  # ======================================================================= #
  # === :create_the_directory_if_it_does_not_exist
  # ======================================================================= #
  when :create_the_directory_if_it_does_not_exist
    FileUtils.mkdir_p(i) unless File.directory? i
  # ======================================================================= #
  # === :verbose_create_the_directory_if_it_does_not_exist
  # ======================================================================= #
  when :verbose_create_the_directory_if_it_does_not_exist,
       :ensure_that_the_directory_exists
    unless File.directory? i
      if be_verbose
        opne "#{rev}The directory at `#{sdir(i)}#{rev}` does not exist."
        opne "#{rev}It will be created now."
      end
      FileUtils.mkdir_p(i)
    end
  end
  i = i.dup if i.frozen?
  i << '/' unless i.end_with? '/'
  i = rds(i) # Added this here as of May 2014.
  # ======================================================================= #
  # Perform the cd-action next.
  # ======================================================================= #
  if File.directory? i
    if be_verbose
      e "#{rev}Changing into the directory `#{sdir(i.to_s)}#{rev}` now."
    end
    Dir.chdir(i) if File.directory? i # This is the actual cd-action.
  end
end
Also aliased as: chdir, change_dir, cd
change_permission( file = 'test', use_this_uid_number = '1000' ) click to toggle source
#

change_permission (chown tag)

This simple method can be used to change permissions, by making use of FileUtils.chown().

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3303
def change_permission(
    file                = 'test',
    use_this_uid_number = '1000'
  )
  FileUtils.chown(use_this_uid_number, use_this_uid_number, file) # Hardcoded right now.
end
Also aliased as: chown
chdir( i, optional_arguments = nil )
Alias for: change_directory
cheerful_person()
Alias for: cheering_person?
cheering_ascii_person()
Alias for: cheering_person?
cheering_person()
Alias for: cheering_person?
cheering_person?() click to toggle source
#

cheering_person?

This is just an ASCII “person” that is presently cheering. It is meant to indicate success and/or happiness. For instance, if a compilation-run has succeeded then we may display such a cheering ASCII “person”.

I found this to be cute and neat - and it is also somewhat useful, as I tend to use the colour gold for this. Thus it is a slight visual cue, e. g.:

e steelblue('All went well!' )+gold(cheering_person?)
#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 899
def cheering_person?
  '\o/'
end
chmod(i) click to toggle source
#

chmod

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2424
def chmod(i)
  RBT.chmod(i)
end
chop_off_archive(i) click to toggle source
#

chop_off_archive

Remove the trailing part of an archive, for the most part. This isn’t very sophisticated but it “just works” for most cases (TM).

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1968
def chop_off_archive(i)
  if i.include? '#' # Chop off at '#' characters.
    i = i[0 .. (i.index('#') - 1)]
  end
  i.sub!(/\.source$/,'') if i.include? 'source'
  i.sub!(/-stable$/,'')  if i.end_with? '-stable'
  return RBT.remove_file_extension(i)
end
chown( file = 'test', use_this_uid_number = '1000' )
Alias for: change_permission
clear_commandline_arguments()
clear_commandline_options() click to toggle source
#

clear_commandline_options

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 623
def clear_commandline_options
  @internal_hash[:commandline_arguments] = []
end
Also aliased as: clear_commandline_arguments
cliner( optional_arguments = nil, use_this_colour = nil ) { || ... } click to toggle source
#

cliner

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1069
def cliner(
    optional_arguments = nil,
    use_this_colour    = nil
  )
  if block_given?
    RBT.cliner(optional_arguments, use_this_colour) { yield }
  else
    RBT.cliner(optional_arguments, use_this_colour)
  end
end
coloured_and_padded_e( i, use_colours = use_colours?, optional_arguments = nil ) click to toggle source
#

coloured_and_padded_e

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1590
def coloured_and_padded_e(
    i,
    use_colours        = use_colours?,
    optional_arguments = nil
  )
  case use_colours
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    use_colours = use_colours?
  end
  # ======================================================================= #
  # Next, modify this command if it includes "--prefix=".
  # In that event we will colourize it a bit; the prefix will
  # be colourized in another colour.
  # ======================================================================= #
  if i and i.include?('--prefix=') and use_colours
    i = i.dup
    # ===================================================================== #
    # === Colourize the prefix, in cornflowerblue().
    # ===================================================================== #
    i.sub!(/(--prefix=)(\/.+?)\s/, # See: https://rubular.com/r/Df8OzLqXGd
      '\1'+
      cornflowerblue('\2 ')+
      ::Colours.remove_escape_sequences(
        teal('')
      )
    )
  end
  case optional_arguments
  # ======================================================================= #
  # === :inner_padding
  #
  # Also use inner-padding here.
  # ======================================================================= #
  when :inner_padding
    i = i.dup
    i.prepend('  ')
  end
  e
  e i, :fancy_colours # or: teal(i)
  e
end
coloured_and_padded_esystem( i, use_colours = use_colours?, optional_arguments = :inner_padding, use_this_primary_colour = :cornflowerblue ) { || ... } click to toggle source
#

coloured_and_padded_esystem

Usage example:

coloured_and_padded_esystem('ls', true, nil, :cornflowerblue)
#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3549
def coloured_and_padded_esystem(
    i,
    use_colours             = use_colours?,
    optional_arguments      = :inner_padding,
    use_this_primary_colour = :cornflowerblue,
    &block
  )
  # ======================================================================= #
  # We need to work on a copy, as we use colours, and system() does
  # not understand ANSI escape sequences - hence the copy next.
  # ======================================================================= #
  this_command_will_be_passed_to_system_directly = i.dup
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === Handle Symbols first
    # ===================================================================== #
    if yielded.is_a? Symbol
      if ::Colours.is_this_html_colour_included?(yielded)
        use_colours = true
        use_this_primary_colour = yielded
      end
    end
  end
  case use_colours
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    use_colours = use_colours?
  end
  # ======================================================================= #
  # Next, modify this command if it includes "--prefix=".
  #
  # In that event we will colourize it a bit; the prefix will
  # be colourized in another colour.
  # ======================================================================= #
  if i and i.include?('--prefix=') and use_colours
    i = i.dup
    # ===================================================================== #
    # === Colourize the prefix, in cornflowerblue().
    # ===================================================================== #
    i.sub!(/(--prefix=)(\/.+?)\s/, # See: https://rubular.com/r/Df8OzLqXGd
      '\1'+
      send(use_this_primary_colour, '\2 ')+
      ::Colours.remove_escape_sequences(
        teal('')
      )
    )
  end
  case optional_arguments
  # ======================================================================= #
  # === :inner_padding
  #
  # Also use inner-padding here.
  # ======================================================================= #
  when :inner_padding
    i = i.dup
    i.prepend('  ')
  end
  e
  if use_colours and use_this_primary_colour.is_a?(Symbol)
    e "#{rev}#{::Colours.send(use_this_primary_colour, i)}"
  else
    e "#{rev}#{i}", :fancy_colours # or: teal(i)
  end
  e
  system(this_command_will_be_passed_to_system_directly)
end
coloured_esystem(i) click to toggle source
#

coloured_esystem

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1638
def coloured_esystem(i)
  esystem i, :fancy_colours
end
Also aliased as: colourized_esystem
colourize_directory_for_system_results(i) click to toggle source
#

colourize_directory_for_system_results

This method is to colourize directories that are given via system() or similar calls. In theory, we could use sdir(), but I wanted to have another colour.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2276
def colourize_directory_for_system_results(i)
  lightslategray(i)
end
colourize_for_warnings(i)
colourize_this_error(i) click to toggle source
#

colourize_this_error

This method in particular attempts to colourize some errors.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2346
def colourize_this_error(i)
  return darkgoldenrod(i) if use_colours?
  return i
end
colourize_this_file_path( i, colour1 = :slateblue, colour2 = :royalblue ) click to toggle source
#

colourize_this_file_path

This method will colourize a “file path”. So for example, if you have a file path such as “/opt/foo/bar.rb”, then this method will colourize the directory in one colour, and the file itself (bar.rb) in another colour.

The whole idea behind this is to be easily able to separate which part is the directory and which part is the file.

If no ‘/’ has been given then the input will be returned unmodified.

The colour for this can be controlled by the input-arguments.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2307
def colourize_this_file_path(
    i,
    colour1 = :slateblue, # ← This is the colour for the directory.
    colour2 = :royalblue  # ← This is the colour for the file.
  )
  if i.include? '/'
    if use_colours?
      dirname  = File.dirname(i)
      basename = File.basename(i)
      dirname  = send(colour1, dirname+'/')
      basename = send(colour2, basename)
      i = "#{dirname}#{basename}"
    end
  end
  i
end
colourize_this_important_system_command( i, use_colours = use_colours?, optional_arguments = :inner_padding, use_this_primary_colour = :cornflowerblue, &block )
colourize_this_warning(i) click to toggle source
#

colourize_this_warning

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2354
def colourize_this_warning(i)
  return firebrick(i) if use_colours?
  return i
end
Also aliased as: colourize_for_warnings
colourized_and_padded_esystem( i, use_colours = use_colours?, optional_arguments = :inner_padding, use_this_primary_colour = :cornflowerblue, &block )
colourized_esystem(i)
Alias for: coloured_esystem
colourized_esystem_with_padding( i, use_colours = use_colours?, optional_arguments = :inner_padding, use_this_primary_colour = :cornflowerblue, &block )
commandline()
commandline?()
commandline_args?()
commandline_arguments?() click to toggle source
#

commandline_arguments?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1018
def commandline_arguments?
  @internal_hash[:commandline_arguments]
end
commandline_arguments_containing_leading_hyphens?( i = commandline_arguments? )
commandline_arguments_with_hyphens?( i = commandline_arguments? )
commandline_arguments_with_leading_hyphens?( i = commandline_arguments? )
commandline_arguments_without_hyphens?( i = commandline_arguments? ) click to toggle source
#

commandline_arguments_without_hyphens?

As above, but reversed.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1033
def commandline_arguments_without_hyphens?(
    i = commandline_arguments?
  )
  i.select {|entry|
    entry and !entry.start_with?('--')
  }
end
commandline_options?()
comment(i) click to toggle source
#

comment

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2417
def comment(i)
  Colours.comment(i) # Delegate to class Colours for this.
end
convert_dd_mm_yyyy_to_its_long_variant( i = dd_mm_yyyy.to_s ) click to toggle source
#

convert_dd_mm_yyyy_to_its_long_variant

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3455
def convert_dd_mm_yyyy_to_its_long_variant(
    i = dd_mm_yyyy.to_s
  )
  i = i.to_s
  if i.include? '.'
    splitted = i.split('.')
    splitted[1] = return_month_based_on_this_number(splitted[1]).to_s
    splitted = splitted.join(' ')
    return splitted
  end
  return i
end
convert_env_variable(i) click to toggle source
#

convert_env_variable

This method can be used to convert a ENV variable, such as $BLA, into its corresponding “real” value.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2502
def convert_env_variable(i)
  RBT.convert_global_env(i)
end
convert_global_env(i)
cookbook_dir?()
Alias for: cookbook_directory?
cookbook_directory?() click to toggle source
#

cookbook_directory

This method will return a String such as:

/Programs/Ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rbt/yaml/individual_cookbooks/
#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1130
def cookbook_directory?
  return RBT.cookbook_directory?
end
cookbooks_dir?()
Alias for: cookbook_directory?
cookbooks_directory()
Alias for: cookbook_directory?
cookbooks_directory?()
Alias for: cookbook_directory?
copy( from, to = return_pwd, be_verbose = false, use_namespace = true, &block )
Alias for: copy_files
copy_directory( from, to = return_pwd, be_verbose = false ) click to toggle source
#

copy_directory

This method can be used to copy a directory from a certain location to the specified (second argument) target directory.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2881
def copy_directory(
    from,
    to         = return_pwd,
    be_verbose = false
  )
  case to
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  when :be_verbose
    to = return_pwd
    be_verbose = true
  end
  case be_verbose
  when :be_verbose
    be_verbose = true
  end
  if be_verbose
    e "#{rev}Now copying the directory `#{sdir(from)}#{rev}` "\
      "to `#{sdir(to)}#{rev}`."
  end
  FileUtils.cp_r(from, to)
end
copy_file( from, to = return_pwd, be_verbose = false, use_namespace = true, &block )
Alias for: copy_files
copy_files( from, to = return_pwd, be_verbose = false, use_namespace = true ) { || ... } click to toggle source
#

copy_files (copy tag, cp tag, copy file tag)

Use this if you need to copy a file.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1854
def copy_files(
    from,
    to            = return_pwd,
    be_verbose    = false,
    use_namespace = true,
    &block
  )
  # ======================================================================= #
  # === Handle blocks first
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    when :be_verbose
      be_verbose = true
    end
  end
  case be_verbose # case tag
  when :be_verbose
    be_verbose = true
  end
  case to
  when '.'
    to = return_pwd
  end
  # ======================================================================= #
  # The next method is defined in the file 'prototype.rb'.
  # ======================================================================= #
  from = sanitize_for_environment_variable(from) if from.include? '$'
  to   = sanitize_for_environment_variable(to)   if to.include? '$'
  # ======================================================================= #
  # Since as of June 2011, we will also automatically create
  # the base directory should it not yet exist.
  # ======================================================================= #
  unless File.exist? File.dirname(to)
    create_directory(File.dirname(to))
  end
  if File.exist? from
    if be_verbose
      if use_namespace
        opne "#{rev}Now copying the file `#{sfile(from)}#{rev}`"
        opne "to `#{sfile(to)}#{rev}`."
      else
        e "#{rev}Now copying the file `#{sfile(from)}#{rev}`"
        e "to `#{sfile(to)}#{rev}`."
      end
    end
    FileUtils.cp(from, to)
  else
    e "#{rev}Can not copy the file `#{sfile(from)}#{rev}` as "\
      "it does not appear to exist."
  end
end
Also aliased as: copy_file, copy, cp
cp( from, to = return_pwd, be_verbose = false, use_namespace = true, &block )
Alias for: copy_files
cpr( from, to = return_pwd ) click to toggle source
#

cpr

This method can be used to recursively copy to a target directory.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1792
def cpr(
    from,
    to = return_pwd
  )
  FileUtils.cp_r(from, to)
end
create_directory( i = '/Users/Packages/', be_verbose = :be_quiet, permissions = :default ) { || ... } click to toggle source
#

create_directory (mkdir tag)

Consistently use this when you want to create a directory for the RBT-Project.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2700
def create_directory(
    i           = '/Users/Packages/',
    be_verbose  = :be_quiet,
    permissions = :default,
    &block
  )
  yielded = nil # Will be filled up if a block is given.
  unless i.end_with? '/'
    i = i.dup if i.frozen?
    i << '/'
  end
  # ========================================================================= #
  # === Handle blocks next
  # ========================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_quiet
    # ===================================================================== #
    when :be_quiet
      be_verbose = false
    # ===================================================================== #
    # === :be_verbose
    # ===================================================================== #
    when :be_verbose
      be_verbose = true
    end
  end
  unless File.directory? i
    if be_verbose.is_a? Hash
      # =================================================================== #
      # We have to handle other keys first, in particular the permissions
      # key:
      # =================================================================== #
      if be_verbose.has_key? :permissions
        permissions = be_verbose.delete(:permissions)
      end
      # =================================================================== #
      # === :be_quiet
      # =================================================================== #
      if be_verbose.has_key? :be_quiet
        be_verbose = be_verbose.delete(:be_quiet)
      # =================================================================== #
      # === :verbosity
      # =================================================================== #
      elsif be_verbose.has_key? :verbosity
        be_verbose = be_verbose.delete(:verbosity)
      end
    end
    case be_verbose
    # ===================================================================== #
    # === :be_quiet
    # ===================================================================== #
    when :be_quiet,
         :be_silent
      be_verbose = false
    end
    unless File.directory? i
      if be_verbose
        opne "#{rev}Creating the directory `#{sdir(i)}#{rev}` now."
      end
      RBT.create_directory(
        i,
        permissions,
        :be_quiet,
        :do_not_use_opn
      ) { yielded } # ^^^ We are already verbose above, and handle opn on
        # our own.
    end
  end
end
create_directory_if_it_does_not_yet_exist( i = '/Users/Packages/', be_verbose = :be_quiet, permissions = :default, &block )
Alias for: create_directory
create_file( i, be_verbose = false )
Alias for: touch
current_hour?() click to toggle source
#

current_hour?

Consistently use this method whenever you wish to return the current hour.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3448
def current_hour?
  ::Time.now.strftime('%H:%M:%S') # '04:21:14'
end
Also aliased as: return_time
dd_mm_yyyy()
Alias for: return_date
dd_mmm_yyy() click to toggle source
#

dd_mmm_yyy

This method-format is specifically the default for cookbook-files.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2955
def dd_mmm_yyy
  current_day = ::Time.now.strftime('%d') # This will return a string such as "30".
  return current_day+
         ' '+
         Date::MONTHNAMES[Date.today.month][0,3].capitalize+
         ' '+
         ::Time.now.strftime('%Y')
end
debug(i) click to toggle source
#

debug

Debug functionality here.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2555
def debug(i)
  cliner { ewarn(i) }
end
debug?() click to toggle source
#

debug?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1047
def debug?
  @internal_hash[:debug]
end
default_read( i, use_this_encoding = ::RBT.encoding? )
default_readlines( i, use_this_encoding = main_encoding? )
delete( this_target, be_verbose = false )
Alias for: remove
delete_file( i, report_the_action = false )
Alias for: remove_file
determine_archive_type(i)
Alias for: archive_type_of?
directory_expanded_cookbooks()
directory_expanded_cookbooks?() click to toggle source
#

directory_expanded_cookbooks?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1670
def directory_expanded_cookbooks?
  RBT.directory_expanded_cookbooks?
end
directory_expanded_cookbooks_exists?( target = directory_expanded_cookbooks? )
disable_colors()
Alias for: disable_colours
disable_colours() click to toggle source
#

disable_colours

Use this method if you wish to disable colours. Invoke it only when you really do wish to disable the colours.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2805
def disable_colours
  @internal_hash[:use_colours] = false
end
disable_opn()
Alias for: no_opn
display_md5sum?() click to toggle source
#

display_md5sum?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3322
def display_md5sum?
  RBT.display_md5sum?
end
Also aliased as: show_md5sum?
do_not_be_verbose(i = false)
Alias for: set_be_silent
do_not_debug() click to toggle source
#

do_not_debug

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1061
def do_not_debug
  @internal_hash[:debug] = false
end
do_not_use_colours()
Alias for: disable_colours
do_use_colours()
Alias for: enable_colours
do_use_opn(i = true)
Alias for: set_use_opn
does_include?(i)
does_the_cookbook_include_this_program?(i) click to toggle source
#

does_the_cookbook_include_this_program?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3511
def does_the_cookbook_include_this_program?(i)
  RBT.does_include?(i)
end
does_the_expanded_cookbook_file_exist_for_this_program?(i)
does_this_expanded_cookbook_file_exist_for_this_program?(i) click to toggle source
#

does_this_expanded_cookbook_file_exist_for_this_program?

This method can be used to determine whether an expanded cookbook dataset exists for a given program at hand.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 869
def does_this_expanded_cookbook_file_exist_for_this_program?(i)
  return File.exist?(path_to_this_expanded_cookbooks_dataset(i))
end
does_this_file_exist?( i, prepend_this = nil ) click to toggle source
#

does_this_file_exist?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 244
def does_this_file_exist?(
    i, prepend_this = nil
  )
  ::RBT.does_this_file_exist?(i, prepend_this)
end
does_this_file_exist_and_is_it_a_file?(i) click to toggle source
#

does_this_file_exist_and_is_it_a_file?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3359
def does_this_file_exist_and_is_it_a_file?(i)
  ::RBT.does_this_file_exist_and_is_it_a_file?(i)
end
e( i = '', optional_colours = nil, use_colours = use_colours? ) click to toggle source
#

e (e tag)

The second argument can be a Symbol such as :fancy_colours.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3520
def e(
    i                = '',
    optional_colours = nil,
    use_colours      = use_colours?
  )
  if use_colours
    case optional_colours
    # =================================================================== #
    # === :fancy_colours
    # =================================================================== #
    when :fancy_colours
      optional_colours = :mediumslateblue
    else
      puts i
    end
    puts "#{::Colours.send(optional_colours, i)}#{rev}" if optional_colours
  else
    puts i
  end
end
eblue(i = '') click to toggle source
#

eblue

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2337
def eblue(i = '')
  e steelblue(i)
end
ecolourize_this_important_system_command( i, use_colours = use_colours?, optional_arguments = :inner_padding, use_this_primary_colour = :cornflowerblue, &block )
ecomment( i = '', use_colours = use_colours? ) click to toggle source
#

ecomment

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2676
def ecomment(
    i           = '',
    use_colours = use_colours?
  )
  if use_colours
    ::Colours.ecomment(i)
  else
    e i
  end
end
ecrimson(i = '') click to toggle source
#

ecrimson

This is mostly for debug-related output, e. g. colourize something via the colour red (or rather, crimson) quickly.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2330
def ecrimson(i = '')
  e crimson(i)
end
edir(i = return_pwd) click to toggle source
#

edir

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2211
def edir(i = return_pwd)
  e sdir(i)
end
editor?() click to toggle source
#

editor?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3314
def editor?
  RBT.editor?
end
efancy(i = '') click to toggle source
#

efancy

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2242
def efancy(i = '')
  e sfancy(i)
end
eimp(i) click to toggle source
#

simp

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2265
def eimp(i)
  e simp(i)
end
enable_colours() click to toggle source
#

enable_colours

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2794
def enable_colours
  @internal_hash[:use_colours] = true
end
Also aliased as: set_use_colours, do_use_colours
enable_debug() click to toggle source
#

enable_debug

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1054
def enable_debug
  @internal_hash[:debug] = true
end
ensure_main_encoding_for( i, use_this_encoding = USE_MAIN_ENCODING ) click to toggle source
#

ensure_main_encoding_for

The input to this method should be a String object.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 406
def ensure_main_encoding_for(
    i, use_this_encoding = USE_MAIN_ENCODING
  )
  unless i.encoding.to_s.include? use_this_encoding
    i = i.force_encoding(use_this_encoding)
  end
  return i
end
ensure_that_this_directory_exists( i = '/Users/Packages/', be_verbose = :be_quiet, permissions = :default, &block )
Alias for: create_directory
eparse(i) click to toggle source
#

eparse

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2399
def eparse(i)
  if use_colours?
    Colours.eparse(i)
  else
    e i
  end
end
esystem( i, use_this_colour = nil ) click to toggle source
#

esystem

Combine system() with output of the command.at hand.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1647
def esystem(
    i,
    use_this_colour = nil
  )
  RBT.esystem(i, use_this_colour)
end
esystem_gold(i) click to toggle source
#

esystem_gold

A variant for esystem(), via the gold colour on the commandline.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1582
def esystem_gold(i)
  e gold(i)
  system i
end
etc_dir?()
Alias for: sysetc_directory?
etomato(i) click to toggle source
#

etomato

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2410
def etomato(i)
  e tomato(i)
end
ewarn(i = '') click to toggle source
#

ewarn

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2372
def ewarn(i = '')
  e swarn(i) # ← This method will already check for use of colours.
end
exit_program( symbol_exit = :standalone, optional_message = nil, use_this_as_exit_value = 0 ) { || ... } click to toggle source
#

exit_program (exit tag)

This is a wrapper to exit, that is, to exit a program. Either we just exit; or we return the special symbol :break

A few Symbols may be passed as block to this method, indicating special behaviour. For instance, the Symbol :exit_no_matter_what shall indicate that this method ought to exit at all times, no matter what.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1921
def exit_program(
    symbol_exit            = :standalone,
    optional_message       = nil,
    use_this_as_exit_value = 0,
    &block
  )
  e optional_message if optional_message
  # ======================================================================= #
  # If we give a number, assume this to be the exit code which we will
  # use for exiting there.
  # ======================================================================= #
  if symbol_exit.to_s =~ /\d+/
    use_this_as_exit_value = symbol_exit.to_i
  end
  if block_given?
    symbol_exit = yield # This variable may now be a Symbol, such as: :exit_no_matter_what
  end
  case symbol_exit
  # ======================================================================= #
  # === :connected
  # ======================================================================= #
  when :connected,
       :chained,
       :continue
    return :break # i.e. when you run it from a shell. Return the Symbol :break.
  # ======================================================================= #
  # === :standalone
  # ======================================================================= #
  when :standalone, # ← Added because I like to read the symbol :standalone.
       :may_we_exit,
       :exit_no_matter_what,
       :default,
       'default',
       'def',
       true
    exit(use_this_as_exit_value)
  else # this is the default, just like with :standalone too
    exit(use_this_as_exit_value)
  end
end
expanded_cookbook_directory?()
expanded_cookbook_file_exists_for?(i)
expanded_cookbooks?()
expanded_cookbooks_directory_exists?( target = directory_expanded_cookbooks? ) click to toggle source
#

expanded_cookbooks_directory_exists?

This method will try and check to see if the expanded-cookbooks directory exists. If this directory exists then this method will return true; otherwise this method will return false.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1115
def expanded_cookbooks_directory_exists?(
    target = directory_expanded_cookbooks?
  )
  return File.directory?(target)
end
expanded_directory_exists?( target = directory_expanded_cookbooks? )
extract_this_archive( i, extract_to = return_pwd ) click to toggle source
#

extract_this_archive

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3171
def extract_this_archive(
    i,
    extract_to = return_pwd
  )
  if File.exist?(i)
    try_to_require_the_extracter_gem
    action(:extract, i, to: extract_to)
  end
end
extract_to?( optional_argument = nil ) click to toggle source
#

extract_to?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3084
def extract_to?(
    optional_argument = nil
  )
  #result = "#{temp_directory?}"
  result = "#{log_directory?}"
  if optional_argument
    result = result.dup
    _ = remove_archive_from_the_end(
          File.basename(optional_argument)
        )
    _ = return_program_name(_)
    result << _
  end
  return rds("#{result}/")
end
file_compiled_programs?() click to toggle source
#

file_compiled_programs?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2431
def file_compiled_programs?
  RBT.file_compiled_programs?
end
file_dirname_retaining_trailing_slash(i) click to toggle source
#

file_dirname_retaining_trailing_slash

This method will invoke File.dirname(), but it will ensure that the last character of the result returned will be a ‘/’, if the given input also ended with a ‘/’ token.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1428
def file_dirname_retaining_trailing_slash(i)
  if i.end_with?('/')
    return "#{File.dirname(i)}/"
  else
    return File.dirname(i)
  end
end
file_predefined_installation_instructions()
file_predefined_installation_instructions?() click to toggle source
#

file_predefined_installation_instructions?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2636
def file_predefined_installation_instructions?
  RBT.file_predefined_installation_instructions
end
file_read( i, use_this_encoding = ::RBT.encoding? )
file_specification_of_registered_cookbook_entries() click to toggle source
#

file_specification_of_registered_cookbook_entries

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 726
def file_specification_of_registered_cookbook_entries
  ::RBT.file_specification_of_registered_cookbook_entries
end
find_cookbook_alias_for(i) click to toggle source
#

find_cookbook_alias_for

This method depends on the Cookbooks gem.

It allows us to find the registered alias for a given program, and thus acts as an “input-sanitizer”.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2546
def find_cookbook_alias_for(i)
  RBT.find_cookbook_alias_for(i)
end
find_this_yaml_file(i = :poppler) click to toggle source
#

find_this_yaml_file

This method can be used to find a proper yaml file.

We will delegate to Cookbooks for this though.

We will return the absolute path to the .yml file in question.

Usage example:

find_this_yaml_file(:poppler) # => "/home/x/programming/ruby/src/rbt/lib/rbt/yaml/individual_cookbooks/poppler.yml"
#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3225
def find_this_yaml_file(i = :poppler)
  i = i.to_s
  # ======================================================================= #
  # The next check has to be explicit for File.file? as well, because
  # a local directory with that name may exist, which we would not
  # want to have.
  # ======================================================================= #
  if File.exist?(i) and File.file?(i)
    i
  else
    RBT.return_location_of_this_yaml_file(i)
  end
end
Also aliased as: return_yaml_file_for
first?()
Alias for: first_argument?
first_argument?() click to toggle source
#

first_argument?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 601
def first_argument?
  @internal_hash[:commandline_arguments].first
end
first_commandline_argument?()
Alias for: first_argument?
first_non_hyphen_argument?( i = commandline_arguments_without_hyphens? ) click to toggle source
#

first_non_hyphen_argument?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 998
def first_non_hyphen_argument?(
    i = commandline_arguments_without_hyphens?
  )
  i.first
end
first_non_hyphened_argument?( i = commandline_arguments_without_hyphens? )
first_non_hyphened_argument_from_the_commandline_arguments( i = commandline_arguments_without_hyphens? )
get_all_directories_from( here = return_pwd, return_full_path = false ) click to toggle source
#

get_all_directories_from

This method can be used to obtain all directories from the given (first) input argument.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1207
def get_all_directories_from(
    here             = return_pwd,
    return_full_path = false
  )
  RBT.get_all_directories_from(here, return_full_path)
end
Also aliased as: get_dir_listing, get_directory_listing, get_directories_from, get_dir_listing
get_all_files_from(i) click to toggle source
#

get_all_files_from

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1220
def get_all_files_from(i)
  return RBT.get_all_files_from(i)
end
Also aliased as: get_files_from
get_all_programs( from = " click to toggle source
#

get_all_programs (all programs tag)

Simply returns all programs from the $PROGRAMS directory.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 432
def get_all_programs(
    from = "#{RBT.programs_directory?}*"
  )
  Dir[from] # The constant PROGRAMS is set in config.rb. It has a trailing /
end
get_cookbooks()
Alias for: available_programs?
get_date() click to toggle source
#

get_date

This method will return a String such as “21 Sep 2023”.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2922
def get_date
  ::RBT.get_date
end
get_dir_listing( here = return_pwd, return_full_path = false )
get_directories_from( here = return_pwd, return_full_path = false )
get_directory_listing( here = return_pwd, return_full_path = false )
get_extended_date() click to toggle source
#

get_extended_date

This method will return a String such as “21 September 2023”.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2931
def get_extended_date
  ::RBT.get_extended_date
end
get_files_and_directories_from( i = return_pwd ) click to toggle source
#

get_files_and_directories_from

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1275
def get_files_and_directories_from(
    i = return_pwd
  )
  RBT.get_files_and_directories_from(i)
end
get_files_from(i)
Alias for: get_all_files_from
get_pwd()
Alias for: return_pwd
go_to_base_dir( be_verbose = true ) click to toggle source
#

go_to_base_dir

Simply go to the temp-directory.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2564
def go_to_base_dir(
    be_verbose = true
  )
  _ = temp_dir?
  if be_verbose
    opne "Changing to `#{sdir(_)}`."
  end
  cd(_)
end
Also aliased as: go_to_the_base_directory
go_to_the_base_directory( be_verbose = true )
Alias for: go_to_base_dir
hh_mm_ss()
home_dir?() click to toggle source
#

home_dir?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2479
def home_dir?
  rds("#{ENV['HOME']}/") # We ensure here that a trailing '/' is part of the result.
end
host_achiteture_in_use?()
Alias for: host_system?
host_architecture?()
Alias for: host_system?
host_system?() click to toggle source
#

host_system?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2450
def host_system?
  RBT.determine_host_architecture
end
hyphen_arguments( i = commandline_arguments? )
hyphen_commandline_arguments?( i = commandline_arguments? )
hyphened_arguments?( i = commandline_arguments? )
ihash()
Alias for: internal_hash?
ihash?()
Alias for: internal_hash?
in_simulation?()
Alias for: run_simulation?
include?(i)
include_dir?()
included?(i)
includes?(i)
includes_this_program?(i)
individual_cookbooks_dir?()
Alias for: cookbook_directory?
individual_cookbooks_directory?()
Alias for: cookbook_directory?
infer_the_namespace() click to toggle source
#

infer_the_namespace

This will assume the true namespace from the inspectable name.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 927
def infer_the_namespace
  _ = inspect.to_s.delete('<')
  if _.include? ' '
    _ = _.split(' ').first.delete('#')
    if _.include? ':'
      _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::')
    end
  end
  set_the_namespace(_) # And assign it here.
end
input?()
internal_hash()
Alias for: internal_hash?
internal_hash?() click to toggle source
#

internal_hash?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1521
def internal_hash?
  @internal_hash
end
internal_hash_set_commandline_arguments( i = ARGV ) click to toggle source
#

internal_hash_set_commandline_arguments

This method will set the commandline arguments.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 572
def internal_hash_set_commandline_arguments(
    i = ARGV
  )
  i = [i].flatten.compact
  if @internal_hash.nil?
    reset_the_internal_hash # Trying this since as of 10.06.2023.
  end
  @internal_hash[:commandline_arguments] = i
end
is_a_github_url?( i = url1? )
Alias for: is_github_url?
is_an_archive?(i) click to toggle source
#

is_an_archive?

Query-method to determine whether the given input is assumed to be an archive. An archive is something like “foobar-1.0.tar.xz”.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1983
def is_an_archive?(i)
  return RBT.is_an_archive?(i)
end
Also aliased as: is_archive?, is_this_an_archive?
is_archive?(i)
Alias for: is_an_archive?
is_directory?(i) click to toggle source
#

is_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1334
def is_directory?(i)
  File.directory? i
end
is_file?(i) click to toggle source
#

is_file?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1248
def is_file?(i)
  File.file? i
end
is_github_url?( i = url1? ) click to toggle source
#

is_github_url?

This method will return true if the main url (url1) is a github url.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 420
def is_github_url?(
    i = url1?
  )
  i and (i.start_with?('https://github.com/') or
         i.start_with?('http://github.com/'))
end
Also aliased as: is_a_github_url?
is_included?(i)
is_make_available?( path = query_path? ) click to toggle source
#

is_make_available?

This method will attempt to find out whether make is available. It will do so by checking on the available path of the host ruby.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 765
def is_make_available?(
    path = query_path?
  )
  is_make_available = false # By default it is assumed that make is NOT available.
  if path.include? ':'
    check_these_directories = path.split(':')
    check_these_directories.each {|dir|
      if File.exist?("#{dir}/make")
        is_make_available = true # Yup, make is available.
      end
    }
  end
  return is_make_available
end
is_meson_installed?() click to toggle source
#

is_meson_installed?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3628
def is_meson_installed?
  _ = `meson 2>&1`
  !_.include?('meson: command not found')
end
is_on_gobolinux?() click to toggle source
#

is_on_gobolinux?

The method is_on_gobolinux? can be used to query whether the host system is using GoboLinux (a linux distribution) or whether it is not.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2491
def is_on_gobolinux?
  RBT.is_on_gobolinux?
end
Also aliased as: are_we_on_gobolinux?
is_on_roebe?()
Alias for: is_roebe?
is_on_windows?() click to toggle source
#

is_on_windows?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 704
def is_on_windows?
  RBT.is_on_windows?
end
Also aliased as: are_we_on_windows?
is_roebe?() click to toggle source
#

is_roebe?

If we are on our local computer, or on another computer.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 843
def is_roebe?
  RBT.is_roebe?
end
Also aliased as: is_on_roebe?, on_roebe?
is_superuser?() click to toggle source
#

is_superuser?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1498
def is_superuser?
  Process.uid == 0
end
is_the_program_included?(i)
is_this_a_header?(i) click to toggle source
#

is_this_a_header?

This method determines whether the given input argument could be considered to be a header-file.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 237
def is_this_a_header?(i)
  i.strip.end_with?('.h')
end
is_this_a_library?(i) click to toggle source
#

is_this_a_library?

This method will check whether the given input is assumed to be a library or whether it is not. If the input ends with .so or .a then this is considered to be a library, by this method.

The check inside of the method body will ensure this.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 285
def is_this_a_library?(i)
  (
    i.strip.end_with?('.so') or
    i.strip.end_with?('.a')  or
    i.strip.end_with?('.o')  or
    i.strip.include?('.so.') # <- For e. g. "libfoo.so.1.2.3"
  )
end
is_this_an_archive?(i)
Alias for: is_an_archive?
is_this_program_included?(i) click to toggle source
#

is_this_program_included?

This method will return a Boolean value (true or false).

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3495
def is_this_program_included?(i)
  available_programs?.include?(i)
end
is_this_program_part_of_the_RBT_project?(i)
is_this_program_registered?(i)
iso_encoding?() click to toggle source
#

iso_encoding?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1234
def iso_encoding?
  ENCODING_ISO
end
lib_dir?()
Alias for: syslib_directory?
load_dataset_from_this_expanded_cookbook( i, &block ) click to toggle source
#

load_dataset_from_this_expanded_cookbook

This method will attempt to load the dataset from an expanded cookbook dataset. In order for this to work, the file must exist locally.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 301
def load_dataset_from_this_expanded_cookbook(
    i, &block
  )
  i = i.to_s unless i.is_a? String # We need Strings.
  if File.file?(i)
    use_this_file = i.dup
  else
    use_this_file = path_to_this_expanded_cookbooks_dataset(i)
  end
  if File.exist? use_this_file
    load_yaml(use_this_file) # Load the .yml file here, if it exists.
  else
    no_file_exists_at(use_this_file, &block)
    return nil
  end
end
load_yaml(i) click to toggle source
#

load_yaml

This is a slightly slimpler alternative to load .yml files for the RBT project.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 334
def load_yaml(i)
  YAML.load_file(i)
end
load_yaml_file_from_the_cookbook_directory_for_this_program(i) click to toggle source
#

load_yaml_file_from_the_cookbook_directory_for_this_program

This method can be used to load the specific .yml file from the cookbook directory.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 364
def load_yaml_file_from_the_cookbook_directory_for_this_program(i)
  target_file = "#{RBT.cookbook_directory?}#{i}.yml"
  load_yaml(target_file)
end
log_dir?()
Alias for: log_directory?
log_directory?() click to toggle source
#

log_directory?

This will return a String such as “/Depot/Temp/rbt/”.

Several aliases exist to this method, such as the commonly used variant called log_dir?.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3108
def log_directory?
  RBT.log_directory?
end
main_encoding?() click to toggle source
#

main_encoding?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 697
def main_encoding?
  USE_THIS_ENCODING
end
meson_build_file_exists?( at_this_location = return_pwd, use_build_directory = false ) click to toggle source
#

meson_build_file_exists?

When we check for the file called “meson.build”, we must also keep in mind that we may use a build directory. This is the reason why the following code uses a variable.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 795
def meson_build_file_exists?(
    at_this_location    = return_pwd,
    use_build_directory = false
  )
  case at_this_location
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    at_this_location = return_pwd
  end
  if File.exist?(at_this_location) and File.file?(at_this_location)
    return true
  else
    # ===================================================================== #
    # Next check whether we do use a build directory or whether we do not.
    # ===================================================================== #
    if use_build_directory
      # =================================================================== #
      # Check the directory below the one given next:
      # =================================================================== #
      target_file = File.absolute_path("#{at_this_location}../meson.build")
      check_for_this_file = target_file
    else
      check_for_this_file = "#{at_this_location}meson.build"
    end
    return File.exist?(check_for_this_file) # Perform the check here.
  end
end
Also aliased as: meson_file_exists?
meson_file_exists?( at_this_location = return_pwd, use_build_directory = false )
mkdir( i = '/Users/Packages/', be_verbose = :be_quiet, permissions = :default, &block )
Alias for: create_directory
mkdir_p( i = '/Users/Packages/', be_verbose = :be_quiet, permissions = :default, &block )
Alias for: create_directory
months?() click to toggle source
#

months?

This method will simply return all months in a given year, via their english names, such as ‘May’, ‘April’.

This will be returned as an Array.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2913
def months?
  Date::MONTHNAMES.compact
end
move_file( this_file, where_to, be_verbose = true ) click to toggle source
#

move_file (move tag, mv tag)

Move a file via this method here. Use this consistently whenever you move a file. Could also be done via File.mv().

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 736
def move_file(
    this_file, where_to, be_verbose = true
  )
  if be_verbose
    e "#{rev}Moving from #{sfile(this_file)} to #{sfile(where_to)}."
  end
  FileUtils.mv(this_file, where_to)
end
Also aliased as: mv, rename_file, rename_directory
mv( this_file, where_to, be_verbose = true )
Alias for: move_file
n_programs_are_available?() click to toggle source
#

n_programs_are_available?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2472
def n_programs_are_available?
  available_programs?.size
end
n_programs_available()
n_programs_available?() click to toggle source
#

n_programs_available?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 387
def n_programs_available?
  RBT.n_programs_available?
end
Also aliased as: n_programs_available
namespace?() click to toggle source
#

namespace?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 941
def namespace?
  @internal_hash[:namespace]
end
no_directory_exists_at(i) click to toggle source
#

no_directory_exists_at

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2522
def no_directory_exists_at(i)
  e "#{rev}No directory exists at `#{sdir(i)}#{rev}`."
end
no_file_exists_at( i, be_verbose = true, &block )
Alias for: no_such_file_exists
no_opn() click to toggle source
#

no_opn

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1694
def no_opn
  @internal_hash[:use_opn] = false
end
Also aliased as: disable_opn
no_such_file_exists( i, be_verbose = true ) { || ... } click to toggle source
#

no_such_file_exists

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2600
def no_such_file_exists(
    i,
    be_verbose = true,
    &block
  )
  if block_given?
    yielded = yield
    case yielded
    when :be_quiet
      be_verbose = false
    end
  end
  if be_verbose
    e "#{rev}#{tomato('No file called `')}"\
      "#{sfile(i)}#{rev}"\
      "#{tomato('` appears to exist.')}"
  end
end
Also aliased as: no_file_exists_at
non_hyphen_arguments( i = commandline_arguments? )
non_hyphened_arguments( i = commandline_arguments? )
non_hyphened_arguments?( i = commandline_arguments? )
on_roebe?()
Alias for: is_roebe?
open_in_browser(i = nil) click to toggle source
#

open_in_browser

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3366
def open_in_browser(i = nil)
  if i
    begin
      require 'open'
      Open.in_browser(i)
    rescue LoadError; end
  end
end
open_in_editor(i) click to toggle source
#

open_in_editor

This will open a cookbook .yml file in the editor.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3331
def open_in_editor(i)
  if i.is_a? Array
    i.each {|entry| open_in_editor(entry) }
  else
    i = i.to_s.dup
    unless i.end_with? '.yml'
      i << '.yml'
    end
    if is_on_roebe?
      # =================================================================== #
      # On my home system.
      # =================================================================== #
      unless i.start_with?(RUBY_SRC_RBT_COOKBOOKS) or
             i.include?('/')
        i.prepend RUBY_SRC_RBT_COOKBOOKS
      end
    else
      unless i.include? individual_cookbooks_dir?
        i.prepend(individual_cookbooks_dir?)
      end
    end
    esystem "#{editor?} #{i}"
  end
end
Also aliased as: open_this_file
open_this_file(i)
Alias for: open_in_editor
opncomment(i = '') click to toggle source
#

opncomment

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1772
def opncomment(i = '')
  opnn; ecomment i
end
opne( i = nil, use_opn = use_opn? ) click to toggle source
#

opne (opne tag)

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3386
def opne(
    i       = nil,
    use_opn = use_opn?
  )
  opn(namespace: namespace?) if use_opn
  e i if i
end
opnef(i) click to toggle source
#

opnef (opnef tag)

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3378
def opnef(i)
  opn(namespace: namespace?) if use_opn?
  ee i
end
opnerev( i = nil, use_opn = use_opn? ) click to toggle source
#

opnerev

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3397
def opnerev(
    i       = nil,
    use_opn = use_opn?
  )
  opne "#{rev}#{i}", use_opn
end
Also aliased as: orev
opnerror( i, use_this_as_namespace = namespace? ) click to toggle source
#

opnerror (opnerror tag)

This will combine opn() with stderr-output.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1659
def opnerror(
    i,
    use_this_as_namespace = namespace?
  )
  opn(namespace: use_this_as_namespace) if use_opn?
  stderr i # Use standard-error output.
end
opnesystem(i) click to toggle source
#

opnesystem

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1726
def opnesystem(i)
  opnn; esystem i
end
opnewarn(i) click to toggle source
#

opnewarn

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1757
def opnewarn(i)
  opne swarn(i)
end
Also aliased as: opnwarn, owarn
opnfancy(i = '') click to toggle source
#

opnfancy

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1765
def opnfancy(i = '')
  opne sfancy(i)
end
opnn( i = namespace?, use_opn = use_opn?, &block ) click to toggle source
#

opnn (opnn tag)

The abbreviation “opn” stands for “output program name”. This also describes the major functionality of this method - we will try to display the name of the program that generates a particular output, so that the user can understand which component may have went wrong.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1738
def opnn(
    i       = namespace?,
    use_opn = use_opn?,
    &block
  )
  if use_opn
    if i.is_a? String
      i = {
        namespace:   i,
        use_colours: use_colours?
      }
    end
    RBT.opnn(i, &block) # ← Let that method handle this.
  end
end
Also aliased as: output_namespace?
opnwarn(i)
Alias for: opnewarn
orev( i = nil, use_opn = use_opn? )
Alias for: opnerev
original_stdout()
Alias for: silent_redirection?
original_stdout?()
Alias for: silent_redirection?
output_namespace?( i = namespace?, use_opn = use_opn?, &block )
Alias for: opnn
owarn(i)
Alias for: opnewarn
packages_directory?() click to toggle source
#

packages_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1104
def packages_directory?
  return ::RBT.packages_directory?
end
path_to_this_expanded_cookbooks_dataset(i) click to toggle source
#

path_to_this_expanded_cookbooks_dataset

This method shall attempt to return the full path to the expanded cookbooks directory dataset of a given program.

For example, if the input to this method is ‘htop’ then this method should return ‘htop.yml’, or rather, ‘/home/Temp/rbt/expanded_cookbooks/htop.yml’.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2820
def path_to_this_expanded_cookbooks_dataset(i)
  i = i.to_s.dup
  i = remove_archive_at_the_end(
    File.basename(i)
  )
  # ======================================================================= #
  # The next check leads to problems for input such as "0install.yml".
  # Unfortunately I did not explain why I added the following line,
  # so I have removed it on 13.09.2019 again.
  #
  # If it is to be re-added, it has to be explained why it is there;
  # and if not, then it is suggested to remove the code eventually.
  # ======================================================================= #
  # if i =~ /\d+/
  #   i = ProgramInformation.return_program_name(i)
  # end
  # ======================================================================= #
  i << '.yml' unless i.end_with? '.yml'
  "#{directory_expanded_cookbooks?}#{i}"
end
pkgconfig_directory?() click to toggle source
#

pkgconfig_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1268
def pkgconfig_directory?
  return "#{syslib_dir?}pkgconfig/"
end
populate_the_internal_hash_with_default_values() click to toggle source
#

populate_the_internal_hash_with_default_values

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 151
def populate_the_internal_hash_with_default_values
  # ======================================================================= #
  # === :namespace
  #
  # We must initialize this variable here so that subclasses can make
  # use of it from the very beginning.
  # ======================================================================= #
  set_the_namespace(
    { namespace: NAMESPACE }
  )
  # ======================================================================= #
  # === :commandline_arguments
  # ======================================================================= #
  @internal_hash[:commandline_arguments] = []
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  @internal_hash[:be_verbose] = true
  # ======================================================================= #
  # === :use_colours
  # ======================================================================= #
  @internal_hash[:use_colours] = RBT.use_colours? # Use the default value for RBT.
  # ======================================================================= #
  # === :run_simulation
  #
  # This variable will determine whether we run in simulation mode or not.
  # ======================================================================= #
  @internal_hash[:run_simulation] = RBT.configuration?.run_simulation
  # ======================================================================= #
  # === :use_opn
  # ======================================================================= #
  @internal_hash[:use_opn] = true
  # ======================================================================= #
  # === :debug
  # ======================================================================= #
  @internal_hash[:debug] = RBT.shall_we_debug?
end
predefined_installation_instructions?() click to toggle source
#

predefined_installation_instructions?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2643
def predefined_installation_instructions? 
  RBT.predefined_installation_instructions?
end
prepend_this_commandline_argument(i) click to toggle source
#

prepend_this_commandline_argument

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 587
def prepend_this_commandline_argument(i)
  @internal_hash[:commandline_arguments].prepend(i)
end
program_dir?()
Alias for: programs_directory?
program_directory?()
Alias for: programs_directory?
program_version_of?(i) click to toggle source
#

program_version_of?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2855
def program_version_of?(i)
  if Object.const_defined? :ProgramInformation
    if i.include?('-')
      return ProgramInformation.return_program_version(i)
    end
  end
  return i
end
program_was_found?(i)
programs_dir?()
Alias for: programs_directory?
programs_directory?() click to toggle source
#

programs_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2844
def programs_directory?
  RBT.programs_directory?.dup
end
Also aliased as: appdir_prefix?, program_directory?, programs_dir?, programs_directory?, program_dir?
project_base_dir?()
project_base_directory?() click to toggle source
#

project_base_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3129
def project_base_directory?
  RBT.project_base_directory?
end
Also aliased as: project_base_dir?
project_yaml_dir?()
project_yaml_directory?() click to toggle source
#

project_yaml_directory?

This will return the path to the yaml directory.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 830
def project_yaml_directory?
  RBT.yaml_directory?
end
proper_readlines( i, use_this_encoding = main_encoding? )
pwd?()
Alias for: return_pwd
query_path?() click to toggle source
#

query_path?

Query the $PATH variable, from within ENV.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3267
def query_path?
  ENV['PATH'].dup # .dup-ing it is better in the long run.
end
quickly_obtain_expanded_cookbook_dataset_from( i, &block )
rarrow()
Alias for: rarrow?
rarrow?() click to toggle source
#

rarrow?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 227
def rarrow?
  cadetblue(string_right_arrow?)
end
Also aliased as: rarrow
rbt_log_dir()
Alias for: log_directory?
rbt_log_dir?()
Alias for: log_directory?
rbt_log_directory?()
Alias for: log_directory?
rbt_logs?()
Alias for: log_directory?
rbt_path?()
rbt_temp_dir?()
Alias for: log_directory?
rbt_temp_directory?()
Alias for: log_directory?
rds(i)
read_file(i) click to toggle source
#

read_file (read tag)

Use this method whenever you want to read in a file.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3054
def read_file(i)
  File.read(i) if File.exist? i
end
Also aliased as: read_this_file
read_file_in_default_encoding( i, use_this_encoding = ::RBT.encoding? ) click to toggle source
#

read_file_in_default_encoding

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1439
def read_file_in_default_encoding(
    i, use_this_encoding = ::RBT.encoding?
  )
  if File.exist? i
    File.read(
      i, encoding: use_this_encoding
    )
  else
    e "#{rev}Can not read file `#{i}` as it does not exist."
  end
end
Also aliased as: default_read, file_read, read_read
read_file_with_default_encoding(i) click to toggle source
#

read_file_with_default_encoding

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3061
def read_file_with_default_encoding(i)
  if File.exist? i
    File.read(i, encoding: 'UTF-8')
  else
    return i
  end
end
read_read( i, use_this_encoding = ::RBT.encoding? )
read_this_file(i)
Alias for: read_file
readlines(i) click to toggle source
#

readlines

This is added in the event that we may wish to use a special encoding, by default, one day.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1558
def readlines(i)
  File.readlines(i)
end
readlines_with_proper_encoding( i, use_this_encoding = main_encoding? ) click to toggle source
#

readlines_with_proper_encoding

File.readlines() variant with proper encoding.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1567
def readlines_with_proper_encoding(
    i,
    use_this_encoding = main_encoding?
  )
  File.readlines(
    i, encoding: use_this_encoding
  )
end
register_sigint( optional_message = nil, use_this_as_exit_code = 0 ) click to toggle source
#

register_sigint

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 851
def register_sigint(
    optional_message      = nil,
    use_this_as_exit_code = 0
  )
  Signal.trap('SIGINT') {
    if optional_message
      e optional_message
    end
    exit(use_this_as_exit_code)
  }
end
registered_cookbook_entries?() click to toggle source
#

registered_cookbook_entries?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 711
def registered_cookbook_entries?
  require 'rbt/constants/constants.rb'
  RBT.registered_cookbook_entries?
end
reject_entries_starting_with_hyphens( i = commandline_arguments? )
remove( this_target, be_verbose = false ) click to toggle source
#

remove (remove tag)

General remove entry-method. If you wish to delete a file or a directory or a symlink, use this method.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1146
def remove(
    this_target,
    be_verbose = false
  )
  if this_target.is_a? Array
    this_target.each {|entry| remove(entry, be_verbose) }
  else
    # ===================================================================== #
    # The next check requires a rescue clause, because the file may no
    # longer exist.
    # ===================================================================== #
    begin
      type = File.ftype(this_target)
    rescue Errno::ENOENT
      type = 'missing_entry'
    end
    if File.exist? this_target
      case type # case tag
      # =================================================================== #
      # === remove_symlink
      # =================================================================== #
      when 'link','missing_entry' # This entry is for symlinks.
        remove_symlink(this_target)
      # =================================================================== #
      # === remove_file
      # =================================================================== #
      when 'file'
        remove_file(this_target, be_verbose)
      # =================================================================== #
      # === remove_directory
      # =================================================================== #
      when 'directory'
        remove_directory(this_target)
      else # This else clause will not be entered, I think.
        ewarn "Not removing `#{simp(this)}` as \"#{simp(type)}\" is "\
              "not registered."
      end
    else
      if be_verbose
        opne swarn('WARNING: file ')+
             this_target.to_s+
             swarn(' does not exist.')
        opne swarn('Thus, it can not be removed.')
      end
    end
  end
end
Also aliased as: delete
remove_archive_at_the_end( i, also_remove_the_basename = true )
remove_archive_from_the_end(i) click to toggle source
#

remove_archive_from_the_end

This method will remove the “archive part” of the given input, such as by removing “.tar.xz” from the given input argument (which ought to be a String).

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2626
def remove_archive_from_the_end(i)
  RBT.remove_archive_from_the_end(i)
end
remove_archive_stuff_at_the_end( i, also_remove_the_basename = true )
remove_archive_stuff_from_the_end(i)
remove_comments_from_each_line(i) click to toggle source
#

remove_comments_from_each_line

This method will remove each comment from a given line. Assume multiline input that will have trailing “ # foobar” comments which will be removed.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 345
def remove_comments_from_each_line(i)
  if i.include? ' # '
    i = i.split(N).map {|line|
      if line.include? ' # '
        line = line[0 .. (line.index('#') - 1)]
        line.strip!
      end
      line
    }.join(N)
  end
  i
end
remove_dir( this_directory, be_verbose = false, &block )
Alias for: remove_directory
remove_directories( this_directory, be_verbose = false, &block )
Alias for: remove_directory
remove_directory( this_directory, be_verbose = false ) { || ... } click to toggle source
#

remove_directory

Consistently use this method in order to remove one or more directories.

Note that ‘/’ is always protected though.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2989
def remove_directory(
    this_directory,
    be_verbose = false,
    &block
  )
  # ======================================================================= #
  # Handle blocks given to this method next:
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_verbose
    # ===================================================================== #
    when :be_verbose
      be_verbose = true
    end
  end
  if this_directory.is_a? Array
    this_directory.each {|entry| # Recursive call here.
      remove_directory(entry, be_verbose)
    }
  elsif this_directory.is_a? String
    case be_verbose
    when :be_verbose
      be_verbose = true
    end
    this_directory = rds(this_directory).strip # Don't want double slashes in it.
    if File.directory? this_directory
      case this_directory # case tag
      # =================================================================== #
      # / can never be removed through this method here - at the least
      # this is our intent.
      # =================================================================== #
      when '/' # We will never remove '/', ever.
        e "#{rev}The #{sdir('/')} #{rev}directory can not be removed "\
          "via this method." # Tiny "safeguard".
      # =================================================================== #
      # RBT.temp_directory?
      # =================================================================== #
      when RBT.temp_directory?
        e "#{rev}Will not remove directory `#{sdir(this_directory)}#{rev}`." # Another tiny "safeguard".
      else
        if File.exist?(this_directory) and (this_directory.size > 1)
          if be_verbose
            e "#{rev}Removing the directory `#{sdir(this_directory)}#{rev}` "\
              "next."
          end
          FileUtils.rm_rf(this_directory) # Finally remove the directory.
        end
      end
    end
  else
    e "#{rev}Unknown input: #{this_directory.class}#{rev}"
  end
end
remove_double_slashes(i) click to toggle source
#

remove_double_slashes (rds tag)

Replace // with / in a given string.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1534
def remove_double_slashes(i)
  return RBT.rds(i)
end
Also aliased as: rds
remove_extension( i, also_remove_the_basename = true )
remove_file( i, report_the_action = false ) click to toggle source
#

remove_file (remove tag)

Use this method whenever you wish to remove a file.

The first input argument to this method shall be the file that we wish to remove. This means the “file path”, so the path to the file has to be provided, such as “/opt/foobar.md”. An Array can also be given, which will lead to batch-removal of the given files at hand.

The second input argument to this method, called ‘report_the_action`, determines whether we will be verbose or whether we will not be verbose. Verbose here means that we will notify the user what we are doing or about to do; not verbose means that we will be silent when we remove the target file.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1836
def remove_file(
    i, report_the_action = false
  )
  if i.is_a? Array
    i.each {|entry| remove_file(entry, report_the_action) }
  else
    RBT.remove_file(i, report_the_action)
  end
end
Also aliased as: delete_file, delete, remove_files, remove_these_files
remove_file_archive_at_the_end(i)
remove_file_extension( i, also_remove_the_basename = true ) click to toggle source
#

remove_file_extension

This method will try to remove anything we declare to be an improper file extension. We do this by delegating towards class RemoveFileSuffix, an external dependency.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1295
def remove_file_extension(
    i, also_remove_the_basename = true
  )
  case also_remove_the_basename
  when :do_not_strip_anything
    also_remove_the_basename = false
  end
  if also_remove_the_basename
    i = File.basename(i)
  end
  if    i.end_with? '.src'
    i[-4,4] = ''
  elsif i.end_with? '-src'
    i[-4,4] = ''
  end
  i = remove_unnecessary_data_from_url(i.to_s.dup)
  remove_archive_from_the_end(i)
end
remove_file_extension_from(i)
remove_file_suffix( i, also_remove_the_basename = true )
remove_files( i, report_the_action = false )
Alias for: remove_file
remove_newlines(i) click to toggle source
#

remove_newlines

Get rid of the newlines.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3293
def remove_newlines(i)
  i.delete("\n")
end
remove_parens(i) click to toggle source
#

remove_parens

This method will turn something like (‘FOO’) into ‘FOO’

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1343
def remove_parens(i)
  i.delete('()')
end
remove_suffix_from_the_end( i, also_remove_the_basename = true )
remove_these_directories( this_directory, be_verbose = false, &block )
Alias for: remove_directory
remove_these_files( i, report_the_action = false )
Alias for: remove_file
remove_this_commandline_argument( i, from = commandline_arguments? ) click to toggle source
#

remove_this_commandline_argument

This method can be used to remove a specific argument from the commandline arguments.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 612
def remove_this_commandline_argument(
    i, from = commandline_arguments?
  )
  from.reject! {|line|
    line =~ /#{Regexp.quote(i)}/
  }
end
remove_this_directory( this_directory, be_verbose = false, &block )
Alias for: remove_directory
remove_this_entry_from_the_commandline_arguments(i) click to toggle source
#

remove_this_entry_from_the_commandline_arguments

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1009
def remove_this_entry_from_the_commandline_arguments(i)
  commandline_arguments?.reject! {|entry|
    entry == i
  }
end
remove_trailing_ANSII_escape_code(i) click to toggle source
#

remove_trailing_ANSII_escape_code

This method can be used if you need to get rid of trailing ANSII escape sequences from a given String.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2389
def remove_trailing_ANSII_escape_code(i)
  if use_colours?
    i = ::Colours.remove_trailing_ANSII_escape_code(i)
  end
  i
end
remove_unnecessary_data_from_url(i) click to toggle source
#

remove_unnecessary_data_from_url

This method removes some meaningless information that can be found in some URLs.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 532
def remove_unnecessary_data_from_url(i)
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  i = File.basename(i)
  i.gsub(/download\?file=/,'').
    sub(/\/download$/,'').
    sub(/\?download$/,'').
    gsub(/-fullsrc/,'').
    gsub(/-source/,'').
    gsub(/\?use_mirror=dfn/,'').
    gsub(/\.src/,'').
    gsub(/-src/,'')
    # .gsub(/_/,'-') # This here may be controversial, hence it
                     # was disabled as of June 2010.
    # i = remove_file_extension(i)
    # ^^^ We can not do the above, because program_full_name
    # must include the archive.
end
rename(old_name, new_name) click to toggle source
#

rename

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2584
def rename(old_name, new_name)
  if File.exist? old_name
    begin
      File.rename(old_name, new_name)
    rescue Errno::ENOTEMPTY
      e 'old_name was: '+old_name
      e 'new_name was: '+new_name
      e 'Either directory was not empty.'
      exit
    end
  end
end
rename_directory( this_file, where_to, be_verbose = true )
Alias for: move_file
rename_file( this_file, where_to, be_verbose = true )
Alias for: move_file
report_pwd() click to toggle source
#

report_pwd

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 272
def report_pwd
  e "#{rev}The current directory is `#{sdir_return_pwd}#{rev}`."
end
Also aliased as: verbose_report_pwd
require_the_rbt_aliases() click to toggle source
#

require_the_rbt_aliases

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 690
def require_the_rbt_aliases
  require 'rbt/aliases/aliases.rb'
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 138
def reset
  # ======================================================================= #
  # === @internal_hash
  #
  # This definition for the internal Hash *must* come first.
  # ======================================================================= #
  @internal_hash = {}
  populate_the_internal_hash_with_default_values
end
reset_the_internal_hash() click to toggle source
#

reset_the_internal_hash

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 192
def reset_the_internal_hash
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  @internal_hash = {}
end
return_all_archives_from_this_directory(i) click to toggle source
#

return_all_archives_from_this_directory

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1241
def return_all_archives_from_this_directory(i)
  RBT.return_all_archives_from_this_directory(i)
end
return_appdir_prefix(i) click to toggle source
#

return_appdir_prefix

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 203
def return_appdir_prefix(i)
  return RBT.return_appdir_prefix(i)
end
Also aliased as: return_appdir_prefix_for
return_appdir_prefix_for(i)
return_archive_type(i)
Alias for: archive_type_of?
return_arguments_with_leading_hyphens( i = commandline_arguments? )
return_available_programs()
Alias for: available_programs?
return_cheering_person()
Alias for: cheering_person?
return_commandline_arguments_with_hyphens( i = commandline_arguments? )
return_commandline_arguments_with_leading_hyphens( i = commandline_arguments? ) click to toggle source
#

return_commandline_arguments_with_leading_hyphens

This will select all commandline-arguments with leading ‘–’ characters.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 978
def return_commandline_arguments_with_leading_hyphens(
    i = commandline_arguments?
  )
  i.select {|entry|
    entry and entry.start_with?('--')
  }
end
return_current_date()
Alias for: return_date
return_current_hour_minutes_second() click to toggle source
#

return_current_hour_minutes_second

This method will return the current time, in HH::MM::SS format.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3257
def return_current_hour_minutes_second
  ::Time.now.strftime '%H:%M:%S' # => "16:08:40"
end
Also aliased as: ss_mm_hh, hh_mm_ss
return_current_pwd()
Alias for: return_pwd
return_current_time()
Alias for: return_date
return_dataset_from_expanded_cookbook( i, &block )
return_dataset_from_this_expanded_cookbook( i, &block )
return_date() click to toggle source
#

return_date

This method wil return a date (a day), such as “21.09.2017” or “03.06.2018” - in other words, the dd.mm.yyyy format.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3484
def return_date
  RBT.return_date
end
return_day_of_the_month_based_on_utc() click to toggle source
#

return_day_of_the_month_based_on_utc

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3416
def return_day_of_the_month_based_on_utc
  return_utc.day.to_s
end
return_default_internal_hash()
Alias for: internal_hash?
return_entries_with_leading_hyphens( i = commandline_arguments? )
return_file_to_the_expanded_cookbooks_dataset(i)
return_first_non_hyphen_argument( i = commandline_arguments_without_hyphens? )
return_full_time() click to toggle source
#

return_full_time

This method will return a String such as ‘21.09.2017, 03:03:09’.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3409
def return_full_time
  "#{return_date}, #{return_current_hour_minutes_second}"
end
return_hours_minutes_seconds_based_on_utc() click to toggle source
#

return_hours_minutes_seconds_based_on_utc

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3430
def return_hours_minutes_seconds_based_on_utc
  _ = return_utc
  _.strftime('%H:%M:%S') 
end
return_hyphened_commandline_arguments( i = commandline_arguments? )
return_location_to_this_programs_yaml_file(i) click to toggle source
#

return_location_to_this_programs_yaml_file

Easier access-method to determine where the yaml file may be.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 397
def return_location_to_this_programs_yaml_file(i)
  RBT.return_location_to_this_programs_yaml_file(i)
end
return_month_based_on_this_number(i) click to toggle source
#

return_month_based_on_this_number

The input to this method should be an Integer, for the month, such as 1,2,3 and so forth.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3474
def return_month_based_on_this_number(i)
  Date::MONTHNAMES[i.to_i]
end
return_month_based_on_utc() click to toggle source
#

return_month_based_on_utc

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3438
def return_month_based_on_utc
  Date::MONTHNAMES[return_utc.month]
end
return_opnn( i = nil ) click to toggle source
#

return_opnn

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1701
def return_opnn(
    i = nil
  )
  hash = {
    namespace: namespace?, be_verbose: false
  }
  if i
    if i.is_a? String
      i = { namespace: i }
    end
    hash.update(i)
  end
  opnn(hash)
end
return_program_full_name_from_url(i)
return_program_information(i) click to toggle source
#

return_program_information

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3072
def return_program_information(i)
  if Object.const_defined? :ProgramInformation
    if i.include?('-')
      i = ProgramInformation.return_real_short_name(i)
    end
  end
  return i
end
Also aliased as: return_program_name
return_program_name( i, optional_padding = ' ' ) click to toggle source
#

return_program_name

This will always return the proper program name. If you need to modify that name, you must do so on your own.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1377
def return_program_name(
    i, optional_padding = ' '
  )
  _ = ''.dup
  if REPORT_SPECIFIC_PROGRAM_NAME
    _ << "#{File.basename(i)}:#{optional_padding}"
  end
  return _
end
Also aliased as: rpn
return_program_name_for_gobolinux_systems(i) click to toggle source
#

return_program_name_for_gobolinux_systems

This method should ideally return the program name for GoboLinux systems. Right now it does not work, largely because I have not found out a reliable way to determine the program name on GoboLinux-like systems.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2515
def return_program_name_for_gobolinux_systems(i)
  return i
end
return_pwd() click to toggle source
#

return_pwd

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 253
def return_pwd
  RBT.return_pwd
end
Also aliased as: return_current_pwd, pwd?, get_pwd
return_time()
Alias for: current_hour?
return_unicode_warning_symbol_or_empty_string() click to toggle source
#

return_unicode_warning_symbol_or_empty_string

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2438
def return_unicode_warning_symbol_or_empty_string
  if Object.const_defined?(:Roebe) and Roebe.respond_to?(:unicode_warning_symbol)
    Roebe.unicode_warning_symbol
  else
    ''
  end
end
return_utc() click to toggle source
#

return_utc

This method will return a Time object that is in UTC format, such as “2018-12-28 14:09:26 UTC”.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3277
def return_utc
  ::Time.now.getutc
end
return_utc_time_in_a_format_similar_to_slackware() click to toggle source
#

return_utc_time_in_a_format_similar_to_slackware

Slackware changelog uses a format such as this one here, in a UTC format:

Thu Sep 21 01:23:24 UTC 2017
#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2973
def return_utc_time_in_a_format_similar_to_slackware
  return "#{return_weekday_based_on_utc.to_s} "\
         "#{return_month_based_on_utc.to_s} "\
         "#{return_day_of_the_month_based_on_utc} "\
         "#{return_hours_minutes_seconds_based_on_utc}"\
         " UTC "\
         "#{return_year_based_on_utc}"
end
return_weekday_based_on_utc() click to toggle source
#

return_weekday_based_on_utc

This will return e. g. ‘Mon’ or ‘Fri’ or something like that.

It depends on the constant RFC2822_DAY_NAME.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3246
def return_weekday_based_on_utc
  _ = return_utc
  wday = _.wday
  return DAY_NAMES[wday]
end
return_yaml_file_for(i = :poppler)
Alias for: find_this_yaml_file
return_year_based_on_utc() click to toggle source
#

return_year_based_on_utc

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3423
def return_year_based_on_utc
  return_utc.year.to_s
end
rev() click to toggle source
#

rev (rev tag)

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2379
def rev
  ::RBT.rev(use_colours?)
end
right_arrow?()
Alias for: string_right_arrow?
rpn( i, optional_padding = ' ' )
Alias for: return_program_name
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3636
def run
end
run_simulation()
Alias for: run_simulation?
run_simulation=(i = false) click to toggle source
#

run_simulation

Setter method for the ivar @run_simulation.

This way we can run in simulation mode. That way, we won’t do any modifications, we will only assume that certain things be done.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2534
def run_simulation=(i = false)
  @internal_hash[:run_simulation] = i
end
run_simulation?() click to toggle source
#

run_simulation?

This method will tell us whether we shall we run in simulation mode or whether we shall not. The default is false, as in, we will not run in simulation mode.

The simulation mode is required to tell the user what we would do, without actually doing any of these changes. It is a “dry run”, a test run.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 562
def run_simulation?
  @internal_hash[:run_simulation]
end
Also aliased as: run_simulation, in_simulation?
sanitize_for_environment_variable(i)
sanitized_without_extension( i, also_remove_the_basename = true )
save_file( what, into, permissions_to_use = '755' )
Alias for: write_what_into
save_what_into( what, into, permissions_to_use = '755' )
Alias for: write_what_into
save_what_to( what, into, permissions_to_use = '755' )
Alias for: write_what_into
sdir(i = '') click to toggle source
#

sdir

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2226
def sdir(i = '')
  return ::RBT.sdir(i) if use_colours?
  return i
end
sdir_return_pwd() click to toggle source
#

sdir_return_pwd

This method will simply colourize the returned String from the method return_pwd().

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 265
def sdir_return_pwd
  sdir(return_pwd)
end
set_be_quiet(i = false)
Alias for: set_be_silent
set_be_silent(i = false) click to toggle source
#

set_be_silent

Set whether we will be verbose or whether we will not.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1993
def set_be_silent(i = false) # false because we assign to @internal_hash[:be_verbose]
  @internal_hash[:be_verbose] = i
end
set_be_verbose(i = true) click to toggle source
#

set_be_verbose

By default we will be verbose.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2020
def set_be_verbose(i = true)
  @internal_hash[:be_verbose] = i
end
Also aliased as: be_verbose, be_verbose=
set_commandline( i = ARGV )
set_commandline_arguments( i = ARGV )
set_do_not_be_verbose(i = false)
Alias for: set_be_silent
set_first_commandline_argument(i) click to toggle source
#

set_first_commandline_argument

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 594
def set_first_commandline_argument(i)
  @internal_hash[:commandline_arguments][0] = i
end
set_input( i = ARGV )
set_namespace(i) click to toggle source
#

set_namespace

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 948
def set_namespace(i)
  @internal_hash[:namespace] = i
end
Also aliased as: set_the_namespace
set_the_namespace(i)
Alias for: set_namespace
set_use_colours()
Alias for: enable_colours
set_use_opn(i = true) click to toggle source
#

set_use_opn

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1680
def set_use_opn(i = true) # Must remain true by default.
  @internal_hash[:use_opn] = i
end
Also aliased as: do_use_opn
set_xorg_buffer(i) click to toggle source
#

set_xorg_buffer

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 719
def set_xorg_buffer(i)
  ::RBT.set_xorg_buffer(i)
end
sfancy(i = '') click to toggle source
#

sfancy

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2249
def sfancy(i = '')
  return ::RBT.sfancy(i) if use_colours?
  return i
end
sfile(i = '') click to toggle source
#

sfile

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2234
def sfile(i = '')
  return ::RBT.sfile(i) if use_colours?
  return i
end
share_dir?()
Alias for: sysshare_directory?
show_md5sum?()
Alias for: display_md5sum?
show_opnn?()
Alias for: use_opn?
silent_redirection?() click to toggle source
#

silent_redirection?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 783
def silent_redirection?
  @internal_hash[:silent_redirection]
end
Also aliased as: original_stdout, original_stdout?
silently_create_this_directory_if_it_does_not_yet_exist(i) click to toggle source
#

silently_create_this_directory_if_it_does_not_yet_exist

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2690
def silently_create_this_directory_if_it_does_not_yet_exist(i)
  create_directory(i, :be_quiet)
end
simp(i = '', use_colours = use_colours?) click to toggle source
#

simp

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2218
def simp(i = '', use_colours = use_colours?)
  return ::RBT.simp(i) if use_colours
  return i
end
Also aliased as: simportant
simportant(i = '', use_colours = use_colours?)
Alias for: simp
source_base_directory?() click to toggle source
#

source_base_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2867
def source_base_directory?
  RBT.source_base_directory?
end
source_dir?()
source_directory()
source_directory?()
src_dir?()
ss_mm_hh()
ssym(i) click to toggle source
#

ssym

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2257
def ssym(i)
  return RBT.ssym(i) if use_colours?
  i
end
stderr( i = '', use_puts_or_print = :puts ) click to toggle source
#

stderr

This method is used specifically to indicate errors to the user.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2781
def stderr(
    i                 = '',
    use_puts_or_print = :puts
  )
  if use_colours?
    i = orangered(i)
  end
  RBT.stderr(i, use_puts_or_print)
end
store_into_this_directory?() click to toggle source
#

store_into_this_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1512
def store_into_this_directory?
  _ = RBT.store_into_this_directory?
  ensure_that_this_directory_exists(_) # Make sure that the directory exists.
  return _
end
Also aliased as: store_where?
store_what_into( what, into, permissions_to_use = '755' )
Alias for: write_what_into
store_where?()
string_right_arrow?() click to toggle source
#

string_right_arrow?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 220
def string_right_arrow?
  '→'
end
Also aliased as: right_arrow?
swarn( i = '', use_colours = use_colours? ) click to toggle source
#

swarn

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2362
def swarn(
    i = '', use_colours = use_colours?
  )
  return ::RBT.swarn(i) if use_colours
  return i
end
sysbin_directory?() click to toggle source
#

sysbin_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3143
def sysbin_directory?
  RBT.sysbin_directory?
end
Also aliased as: usr_bin?
sysetc_directory?() click to toggle source
#

sysetc_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1197
def sysetc_directory?
  RBT.sysetc_directory?
end
Also aliased as: etc_dir?
sysinclude_directory?() click to toggle source
#

sysinclude_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3157
def sysinclude_directory?
  RBT.sysinclude_directory?
end
Also aliased as: include_dir?
syslib_directory?() click to toggle source
#

syslib_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3164
def syslib_directory?
  RBT.syslib_directory?
end
Also aliased as: lib_dir?
sysshare_directory?() click to toggle source
#

sysshare_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3150
def sysshare_directory?
  RBT.sysshare_directory?
end
Also aliased as: share_dir?
system_directory?() click to toggle source
#

system_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3136
def system_directory?
  RBT.system_directory?
end
temp?()
Alias for: temp_directory?
temp_dir?()
Alias for: temp_directory?
temp_directory?() click to toggle source
#

temp_directory?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 3121
def temp_directory?
  RBT.temp_directory?
end
Also aliased as: temp_dir?, temp?
to_bool(i) click to toggle source
#

to_bool

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1417
def to_bool(i)
  RBT.to_bool(i)
end
Also aliased as: to_boolean
to_boolean(i)
Alias for: to_bool
to_camelcase(i) click to toggle source
#

to_camelcase

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2577
def to_camelcase(i)
  i.split('_').map { |_| _.capitalize }.join
end
to_iso_encoding(i) click to toggle source
#

to_iso_encoding

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1227
def to_iso_encoding(i)
  i.force_encoding(ENCODING_ISO)
end
to_unicode(i) click to toggle source
#

to_unicode

This method will “convert” into the Unicode-encoding.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 911
def to_unicode(i)
  i.force_encoding(ENCODING_UTF)
end
today?( display_in_long_format = true ) click to toggle source
#

today?

This method will return a String such as “21 September 2017”.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2940
def today?(
    display_in_long_format = true
  )
  if display_in_long_format # This is the default.
    Time.now.strftime('%d %B %Y') # => "28 December 2018"
  else
    Time.now.strftime('%d.%m.%Y') # => "28.12.2018"
  end
end
touch( i, be_verbose = false ) click to toggle source
#

touch (touch tag)

Use this unified method whenever you wish to create a new file, like the UNIX “touch” command.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1466
def touch(
    i,
    be_verbose = false
  )
  case be_verbose
  when :be_verbose
    be_verbose = true
  end
  if be_verbose
    e "#{rev}Next creating the file `#{sfile(i)}`."
  end
  FileUtils.touch(i)
end
Also aliased as: create_file, touch_file
touch_file( i, be_verbose = false )
Alias for: touch
try_to_require_beautiful_url() click to toggle source
#

try_to_require_beautiful_url

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 666
def try_to_require_beautiful_url
  begin
    require 'beautiful_url'
  rescue LoadError; end
end
try_to_require_the_environment_information_gem() click to toggle source
#

try_to_require_the_environment_information_gem

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 657
def try_to_require_the_environment_information_gem
  begin
    require 'environment_information'
  rescue LoadError; end
end
try_to_require_the_extracter_gem() click to toggle source
#

try_to_require_the_extracter_gem

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 630
def try_to_require_the_extracter_gem
  begin
    require 'extracter'
  rescue LoadError; end
end
try_to_require_the_open_gem() click to toggle source
#

try_to_require_the_open_gem

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 648
def try_to_require_the_open_gem
  begin
    require 'open'
  rescue LoadError; end
end
try_to_require_the_xorg_buffer() click to toggle source
#

try_to_require_the_xorg_buffer

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 675
def try_to_require_the_xorg_buffer
  begin
    require 'xorg_buffer' # or: require 'xorg_buffer/module'
  rescue LoadError
    if RUBY_PLATFORM.include?('linux') and
      is_on_roebe?
      puts 'The gem called `xorg_buffer` is unavailable. '\
           'Consider installing it.'
    end
  end
end
try_to_require_wget() click to toggle source
#

try_to_require_wget

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 639
def try_to_require_wget
  begin
    require 'wget'
  rescue LoadError; end
end
try_to_return_a_special_compile_component(i) click to toggle source
#

try_to_return_a_special_compile_component

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 372
def try_to_return_a_special_compile_component(i)
  action(:try_to_return_a_special_compile_component, i)
end
unicode_cliner( a = :default, b = :default, &block ) click to toggle source
#

unicode_cliner

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1083
def unicode_cliner(
    a = :default,
    b = :default,
    &block
  )
  ::RBT.unicode_cliner(a, b, &block)
end
unicode_middle_cliner( a = :default, b = :default ) click to toggle source
#

unicode_middle_cliner

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1094
def unicode_middle_cliner(
    a = :default,
    b = :default
  )
  ::RBT.unicode_cliner(a, b) { :unicode_middle_horizontal_bar }
end
use_colours=(i = true) click to toggle source
#

use_colours=

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2204
def use_colours=(i = true)
  @internal_hash[:use_colours] = i
end
use_colours?() click to toggle source
#

use_colours?

Query whether we may use colours or not.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 2197
def use_colours?
  @internal_hash[:use_colours]
end
Also aliased as: we_may_use_colours?
use_opn=(i = true) click to toggle source
#

use_opn=

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1687
def use_opn=(i = true)
  @internal_hash[:use_opn] = i
end
use_opn?() click to toggle source
#

use_opn?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1719
def use_opn?
  @internal_hash[:use_opn]
end
Also aliased as: show_opnn?
usr_bin?()
Alias for: sysbin_directory?
utf_encoding?() click to toggle source
#

utf_encoding?

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 918
def utf_encoding?
  ENCODING_UTF
end
verbose_report_pwd()
Alias for: report_pwd
verbose_truth(i, optional_arguments = nil) click to toggle source
#

verbose_truth

This will give us back “yes” or “no”, in String form.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1326
def verbose_truth(i, optional_arguments = nil)
  RBT.verbose_truth(i, optional_arguments)
end
Also aliased as: vt, verbose_truth?
verbose_truth?(i, optional_arguments = nil)
Alias for: verbose_truth
vt(i, optional_arguments = nil)
Alias for: verbose_truth
we_may_use_colours?()
Alias for: use_colours?
word_wrap( this_text, n_characters_limit = :default ) click to toggle source
#

word_wrap

The first argument is the text that will be reformatted.

The second argument is at which position we will wrap it.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1545
def word_wrap(
    this_text,
    n_characters_limit = :default # This should be equal to 78.
  )
  ::RBT.wrap_at(this_text, n_characters_limit)
end
Also aliased as: wrap_at
wrap_at( this_text, n_characters_limit = :default )
Alias for: word_wrap
write_what_into( what, into, permissions_to_use = '755' ) click to toggle source
#

write_what_into

Delegate towards the SaveFile functionality here.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1804
def write_what_into(
    what, into, permissions_to_use = '755'
  )
  RBT.write_what_into(what, into, permissions_to_use)
end
write_what_into_via_unicode( what, into, permissions_to_use = '755' ) click to toggle source
#

write_what_into_via_unicode

Delegate towards the SaveFile functionality here.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1781
def write_what_into_via_unicode(
    what, into, permissions_to_use = '755'
  )
  RBT.write_what_into_via_unicode(what, into, permissions_to_use)
end
yaml_dir?()
yaml_directory?()
yes_or_no( i, optional_instructions = nil ) click to toggle source
#

yes_or_no

Return ‘Yes.’ or ‘No.’ through this method here.

#
# File lib/rbt/lean_prototype/lean_prototype.rb, line 1352
def yes_or_no(
    i, optional_instructions = nil
  )
  case i
  when true,'true'
    i = 'Yes.'
  when false,'false'
    i = 'No.'
  end
  case optional_instructions
  # ======================================================================= #
  # === :minimalistic
  # ======================================================================= #
  when :minimalistic
    i = i.downcase.delete('.') if i
  end
  return i
end