class RBT::Base

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.

#
KONSOLE
#

KONSOLE

#
NAMESPACE
#

NAMESPACE

#

Public Class Methods

make_command?() click to toggle source
#

RBT::Base.make_command?

#
# File lib/rbt/base/base.rb, line 265
def self.make_command?
  RBT.configuration?.make_command # The Configuration object has our make command.
end
new( i = nil, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/rbt/base/initialize.rb, line 23
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(
    i
  )
  # ======================================================================= #
  # Next handle blocks given.
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    when :no_colours
      disable_colours
    else
      # =================================================================== #
      # === Handle Hash given in blockform
      # =================================================================== #
      if yielded.is_a? Hash
        if yielded.has_key? :use_colours
          _ = yielded.delete :use_colours
          if _ == false
            disable_colours
          end
        end
      end
    end
  end
  run if run_already
end
registered_binaries?() click to toggle source
#

RBT::Base.registered_binaries?

Tell us where our binaries are registered.

#
# File lib/rbt/base/base.rb, line 166
def self.registered_binaries?
  RBT.all_binaries?
end

Public Instance Methods

abbreviations?() click to toggle source
#

abbreviations?

Easier getter-method over the available abbreviations.

#
# File lib/rbt/base/prototype.rb, line 544
def abbreviations?
  RBT.hash_aliases_to_the_available_programs?
end
all_available_programs?()
Alias for: available_programs?
all_binaries?() click to toggle source
#

all_binaries?

#
# File lib/rbt/base/prototype.rb, line 285
def all_binaries?
  require 'rbt/toplevel_methods/all_binaries.rb'
  RBT.all_binaries?
end
all_libraries?() click to toggle source
#

all_libraries?

#
# File lib/rbt/base/prototype.rb, line 293
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?
always_show_dependencies?() click to toggle source
#

always_show_dependencies?

If this setting is true then we will always show the dependencies on the commandline.

#
# File lib/rbt/base/base.rb, line 379
def always_show_dependencies?
  RBT.configuration?.always_show_dependencies
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/base/base.rb, line 519
def appdir_location_of?(i)
  "#{programs_dir?}#{i.capitalize}/Current"
end
append_what_into(what, into) click to toggle source
#

append_what_into

#
# File lib/rbt/base/save_file.rb, line 28
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/base/prototype.rb, line 607
def archive_type_of?(i)
  RBT.return_archive_type(i)
end
available_cookbook_files?(show_how = :show_only_name)
Alias for: cookbook_files?
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/base/available_programs.rb, line 16
def available_programs?
  RBT.available_programs?
end
base_dir?()
Alias for: temp_directory?
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/base/be_verbose.rb, line 21
def be_quiet?
  !@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/base/be_verbose.rb, line 14
def be_verbose?
  @be_verbose
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/base/prototype.rb, line 135
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
capitalize_program_names?() click to toggle source
#

capitalize_program_names?

#
# File lib/rbt/base/base.rb, line 245
def capitalize_program_names?
  RBT.configuration?.capitalize_program_names
end
Also aliased as: do_capitalize?
cat(i) click to toggle source
#

cat (cat tag)

#
# File lib/rbt/base/base.rb, line 293
def cat(i)
  if File.exist? i
    return File.readlines(i).join
  end
end
ccache_is_available?()
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/base/base.rb, line 566
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/base/prototype.rb, line 443
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/base/change_directory.rb, line 19
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
  when :be_quiet,
       :quiet,
       :silent,
       :be_silent,
       :do_not_report_anything
      be_verbose = false
  when true,
       :be_verbose
    be_verbose = true
  when :create_the_directory_if_it_does_not_exist
    FileUtils.mkdir_p(i) unless File.directory? i
  when :verbose_create_the_directory_if_it_does_not_exist,
       :ensure_that_the_directory_exists
    unless File.directory? i
      if be_verbose
        opnn; e "The directory at `#{sdir(i)}` does not exist."
        opnn; e 'We will create it 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 "Changing into the directory `#{sdir(i.to_s)}` 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/base/prototype.rb, line 777
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
cheering_person?() click to toggle source
#

cheering_person?

#
# File lib/rbt/base/prototype.rb, line 700
def cheering_person?
  '\o/'
end
Also aliased as: return_cheering_person
chmod(i) click to toggle source
#

chmod

#
# File lib/rbt/base/prototype.rb, line 369
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/base/base.rb, line 470
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'
  i = i.sub(/&type=zip$/,'').
        sub(/\.lz$/,'').
        sub(/\.gz$/,'').
        sub(/\.xz$/,'').
        sub(/\.bz2$/,'').
        sub(/\.tar$/,'').
        sub(/\.zip$/,'').
        sub(/\.js$/,'')
  return i
end
chown( file = 'test', use_this_uid_number = '1000' )
Alias for: change_permission
cliner( optional_arguments = nil, use_this_colour = nil ) { || ... } click to toggle source
#

cliner

#
# File lib/rbt/base/cliner.rb, line 17
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
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/base/colours.rb, line 203
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/base/colours.rb, line 284
def colourize_this_error(i)
  return darkgoldenrod(i) if use_colours?
  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/base/colours.rb, line 252
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_warning(i) click to toggle source
#

colourize_this_warning

#
# File lib/rbt/base/colours.rb, line 292
def colourize_this_warning(i)
  return firebrick(i) if use_colours?
  i
end
Also aliased as: colourize_for_warnings
config?() click to toggle source
#

config?

#
# File lib/rbt/base/base.rb, line 286
def config?
  RBT.configuration?
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/base/prototype.rb, line 521
def convert_env_variable(i)
  ConvertGlobalEnv[i]
end
Also aliased as: convert_global_env
convert_global_env(i)
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/base/prototype.rb, line 507
def cookbook_directory?
  RBT.cookbook_directory?
end
cookbook_files?(show_how = :show_only_name) click to toggle source
#

cookbook_files?

This method will return all available cookbook files in an Array.

Usage example:

cookbook_files?(:show_full_path)
#
# File lib/rbt/base/base.rb, line 149
def cookbook_files?(show_how = :show_only_name)
  result = Dir["#{individual_cookbooks_directory?}*yml"].sort
  case show_how
  when :show_only_name # In this case, show only the name.
    result.map! {|entry|
      File.basename(entry).gsub( File.extname(entry), '' )
    }
  when :show_full_path # In this case make no modifications.
  end
  return result
end
Also aliased as: available_cookbook_files?
cookbooks_directory()
Alias for: cookbook_directory?
cookbooks_directory?()
Alias for: cookbook_directory?
cookbooks_include_this_program?( i, optional_arguments = nil )
copy( from, to = Dir.pwd, be_verbose = false )
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/base/copy_directory.rb, line 19
def copy_directory(
    from,
    to         = return_pwd,
    be_verbose = false
  )
  case to
  when :be_verbose
    to = return_pwd
    be_verbose = true
  end
  case be_verbose
  when :be_verbose
    be_verbose = true
  end
  if be_verbose
    e "Now copying the directory `#{sdir(from)}` to `#{sdir(to)}`."
  end
  FileUtils.cp_r(from, to)
end
copy_file( from, to = Dir.pwd, be_verbose = false )
Alias for: copy_files
copy_files( from, to = Dir.pwd, be_verbose = false ) 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/base/copy_files.rb, line 18
def copy_files(
    from,
    to         = Dir.pwd,
    be_verbose = false
  )
  case be_verbose # case tag
  when :be_verbose
    be_verbose = true
  end
  case to
  when '.'
    to = Dir.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
      e "Now copying the file `#{sfile(from)}` to `#{sfile(to)}`."
    end
    FileUtils.cp(from, to)
  else
    e "Can not copy the file `#{sfile(from)}` as it "\
      "does not appear to exist."
  end
end
Also aliased as: copy_file, copy, cp
copy_recursively( what, where_to = '/usr/', be_verbose = false ) click to toggle source
#

copy_recursively

#
# File lib/rbt/base/base.rb, line 109
def copy_recursively(
    what,
    where_to   = '/usr/',
    be_verbose = false
  )
  ::RBT.copy_recursively(what, where_to, be_verbose)
end
cp( from, to = Dir.pwd, be_verbose = false )
Alias for: copy_files
create_directory( i = '/Users/Packages/', be_verbose = true, 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/base/create_directory.rb, line 19
def create_directory(
    i           = '/Users/Packages/',
    be_verbose  = true,
    permissions = :default
  )
  unless i.end_with? '/'
    i = i.dup if i.frozen?
    i << '/'
  end
  if block_given?
    yielded = yield
    case yielded
    when :be_quiet
      be_verbose = false
    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
      if be_verbose.has_key? :be_quiet
        be_verbose = be_verbose.delete(:be_quiet)
      elsif be_verbose.has_key? :verbosity
        be_verbose = be_verbose.delete(:verbosity)
      end
    end
    case be_verbose
    when :be_quiet,
         :be_silent
      be_verbose = false
    end
    unless File.directory? i
      if be_verbose
        opnn; e "Creating the directory `#{sdir(i)}` now."
      end
      RBT.create_directory(
        i, permissions, :be_quiet, :do_not_use_opn
      ) # ^^^ 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 = true, permissions = :default )
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/base/time.rb, line 115
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/base/time.rb, line 159
def dd_mmm_yyy
  current_day = Time.now.strftime('%d') # This will return a string such as "30".
  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/base/prototype.rb, line 466
def debug(i)
  cliner { ewarn(i) }
end
debug?() click to toggle source
#

debug?

#
# File lib/rbt/base/debug.rb, line 21
def debug?
  @debug
end
delete( this_target, be_verbose = false )
Alias for: remove
delete_file( i, report_the_action = false )
Alias for: remove_file
determine_appdir_prefix_from_this_input( i = nil, program_version = nil ) click to toggle source
#

determine_appdir_prefix_from_this_input

This method has to return a String, which constitutes the AppDir prefix of the target program at hand.

#
# File lib/rbt/base/base.rb, line 600
def determine_appdir_prefix_from_this_input(
    i               = nil,
    program_version = nil
  )
  return RBT.determine_appdir_prefix_from_this_input(
    i, program_version
  )
end
Also aliased as: static_appdir_prefix_of?
determine_archive_type(i) click to toggle source
#

determine_archive_type

We determine the archive type with this method, which really is a simplification.

#
# File lib/rbt/base/base.rb, line 137
def determine_archive_type(i)
  RBT.return_archive_type(i)
end
directory_expanded_cookbooks()
directory_expanded_cookbooks?() click to toggle source
#

directory_expanded_cookbooks?

#
# File lib/rbt/base/expanded_cookbooks.rb, line 48
def directory_expanded_cookbooks?
  RBT.directory_expanded_cookbooks?
end
directory_expanded_cookbooks_exists?()
directory_validation?() click to toggle source
#

directory_validation?

#
# File lib/rbt/base/base.rb, line 559
def directory_validation?
  RBT.directory_validation?
end
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/base/colours.rb, line 232
def disable_colours
  @use_colours = false
end
disable_opn()
Alias for: no_opn
display_md5sum?() click to toggle source
#

display_md5sum?

#
# File lib/rbt/base/base.rb, line 120
def display_md5sum?
  RBT.display_md5sum?
end
Also aliased as: show_md5sum?
do_capitalize?()
do_not_debug() click to toggle source
#

do_not_debug

#
# File lib/rbt/base/debug.rb, line 28
def do_not_debug
  @debug = false
end
do_not_show_names() click to toggle source
#

do_not_show_names

#
# File lib/rbt/base/base.rb, line 127
def do_not_show_names
  RBT.do_not_show_names
end
do_not_use_colours()
Alias for: disable_colours
does_include?( i, optional_arguments = nil )
does_the_cookbook_include_this_program?(i) click to toggle source
#

does_the_cookbook_include_this_program?

#
# File lib/rbt/base/base.rb, line 88
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?

#
# File lib/rbt/base/expanded_cookbooks.rb, line 20
def does_this_expanded_cookbook_file_exist_for_this_program?(i)
  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/base/base.rb, line 500
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/base/base.rb, line 509
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 = '') click to toggle source
#

e

#
# File lib/rbt/base/prototype.rb, line 95
def e(i = '')
  puts i
end
ecomment(i = '') click to toggle source
#

ecomment

#
# File lib/rbt/base/colours.rb, line 131
def ecomment(i = '')
  ::Colours.ecomment(i)
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/base/colours.rb, line 275
def ecrimson(i = '')
  e crimson(i)
end
edir(i = '') click to toggle source
#

edir

#
# File lib/rbt/base/colours.rb, line 124
def edir(i = '')
  e sdir(i)
end
editor?() click to toggle source
#

editor?

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

efancy

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

simp

#
# File lib/rbt/base/colours.rb, line 185
def eimp(i)
  e simp(i)
end
email?() click to toggle source
#

email?

#
# File lib/rbt/base/email.rb, line 14
def email?
  RBT.configuration?.email.to_s
end
enable_colours() click to toggle source
#

enable_colours

#
# File lib/rbt/base/colours.rb, line 110
def enable_colours
  @use_colours = true
end
enable_debug() click to toggle source
#

enable_debug

#
# File lib/rbt/base/debug.rb, line 14
def enable_debug
  @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/base/prototype.rb, line 674
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 = true, permissions = :default )
Alias for: create_directory
eparse(i) click to toggle source
#

eparse

#
# File lib/rbt/base/colours.rb, line 222
def eparse(i)
  Colours.eparse(i)
end
esystem(i) click to toggle source
#

esystem

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

#
# File lib/rbt/base/prototype.rb, line 255
def esystem(i)
  RBT.esystem(i)
end
esystem_gold(i) click to toggle source
#

esystem_gold

#
# File lib/rbt/base/base.rb, line 425
def esystem_gold(i)
  e gold(i)
  system i
end
ewarn(i = '') click to toggle source
#

ewarn

#
# File lib/rbt/base/colours.rb, line 308
def ewarn(i = '')
  e swarn(i) # <- This method will already check for use of colours.
end
exit_on_unregistered_cookbook_entries?() click to toggle source
#

exit_on_unregistered_cookbook_entries?

#
# File lib/rbt/base/base.rb, line 231
def exit_on_unregistered_cookbook_entries?
  RBT.configuration?.exit_on_unregistered_cookbook_entries
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

#
# File lib/rbt/base/exit_program.rb, line 17
def exit_program(
    symbol_exit            = :standalone,
    optional_message       = nil,
    use_this_as_exit_value = 0
  )
  e optional_message if optional_message
  if symbol_exit.to_s =~ /\d+/ # If we give a number, assume this as exit code.
     use_this_as_exit_value = symbol_exit.to_i
  end
  case symbol_exit
  when :connected,
       :chained,
       :continue
    return :break # i.e. when you run it from a shell. Return the Symbol :break.
  when :standalone, # <- Added because I like to read the symbol :standalone.
       :may_we_exit,
       :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_cookbooks_directory_exists?() 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/base/expanded_cookbooks.rb, line 60
def expanded_cookbooks_directory_exists?
  target = directory_expanded_cookbooks?
  File.directory? target
end
expanded_directory_exists?()
fast_return_file_size_of_this_program(i) click to toggle source
#

fast_return_file_size_of_this_program

#
# File lib/rbt/base/base.rb, line 341
def fast_return_file_size_of_this_program(i)
  RBT.fast_return_file_size_of_this_program(i)
end
file_last_symlinked_program?() click to toggle source
#

file_last_symlinked_program?

#
# File lib/rbt/base/base.rb, line 689
def file_last_symlinked_program?
  RBT.file_last_symlinked_program?
end
file_predefined_installation_instructions()
file_predefined_installation_instructions?() click to toggle source
#

file_predefined_installation_instructions?

#
# File lib/rbt/base/prototype.rb, line 686
def file_predefined_installation_instructions?
  RBT.file_predefined_installation_instructions
end
file_specification_of_registered_cookbook_entries() click to toggle source
#

file_specification_of_registered_cookbook_entries

#
# File lib/rbt/base/base.rb, line 526
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/base/prototype.rb, line 457
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) # => "/Users/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rbt/lib/rbt/yaml/individual_cookbooks/poppler.yml"
#
# File lib/rbt/base/prototype.rb, line 627
def find_this_yaml_file(i = :poppler)
  i = i.to_s
  if File.exist? i
    i
  else
    RBT.return_location_of_this_yaml_file(i)
  end
end
gem_version(i) click to toggle source
#

gem_version

This method is a wrapper over Gem::Version.new()

The reason as to why this resides in a method is so that we can do some input-sanitizing, and easier rescue, if this is necessary one day.

#
# File lib/rbt/base/prototype.rb, line 237
def gem_version(i)
  i = i.to_s.delete('vr')
  begin
    if i =~ /\d+/ # Must have at the least one number.
      return Gem::Version.new(i)
    end
  rescue ArgumentError => error
    opnn; e 'An error occurred in gem_version()'
    pp error
  end
  nil # Indicate "failure" aka unable to parse this version.
end
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/base/prototype.rb, line 754
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/base/prototype.rb, line 362
def get_all_files_from(i)
  RBT.get_all_files_from(i)
end
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/base/prototype.rb, line 567
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 2017”.

#
# File lib/rbt/base/time.rb, line 30
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_files_and_directories_from( i = Dir.pwd ) click to toggle source
#

get_files_and_directories_from

#
# File lib/rbt/base/prototype.rb, line 276
def get_files_and_directories_from(
    i = Dir.pwd
  )
  RBT.get_files_and_directories_from(i)
end
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/base/prototype.rb, line 430
def go_to_base_dir(be_verbose = true)
  _ = temp_dir?
  if be_verbose
    opnn; e 'Changing to '+sdir(_)
  end
  cd(_)
end
home_dir?() click to toggle source
#

home_dir?

#
# File lib/rbt/base/prototype.rb, line 735
def home_dir?
  ENV['HOME'].to_s.dup
end
host_system?() click to toggle source
#

host_system?

#
# File lib/rbt/base/base.rb, line 348
def host_system?
  RBT.determine_host_architecture
end
in_simulation?()
Alias for: run_simulation?
include?( i, optional_arguments = nil )
included?( i, optional_arguments = nil )
includes?( i, optional_arguments = nil )
includes_this_program?( i, optional_arguments = nil )
individual_cookbooks_dir?()
Alias for: cookbook_directory?
individual_cookbooks_directory?()
Alias for: cookbook_directory?
is_an_archive?(i) click to toggle source
#

is_an_archive?

#
# File lib/rbt/base/prototype.rb, line 767
def is_an_archive?(i)
  RBT.is_an_archive?(i)
end
Also aliased as: is_archive?
is_archive?(i)
Alias for: is_an_archive?
is_ccache_available?() click to toggle source
#

is_ccache_available?

This method queries as to whether ccache is available or whether it is not.

#
# File lib/rbt/base/base.rb, line 623
def is_ccache_available?
  result = true
  begin
    check_for_ccache = `ccache 2>&1`
    if check_for_ccache.include? 'command not found'
      result = false
    end
  rescue Errno::ENOENT
    # ===================================================================== #
    # This clause can happen when there is no
    # /bin/sh symlink.
    # ===================================================================== #
    check_for_ccache = false
  end
  result
end
Also aliased as: ccache_is_available?
is_file?(i) click to toggle source
#

is_file?

#
# File lib/rbt/base/prototype.rb, line 528
def is_file?(i)
  File.file? i
end
is_included?( i, optional_arguments = nil )
is_on_gobolinux?() click to toggle source
#

is_on_gobolinux?

Method to query whether the host system is using gobolinux or whether it is not.

#
# File lib/rbt/base/prototype.rb, line 340
def is_on_gobolinux?
  RBT.is_on_gobolinux?
end
is_on_roebe?()
Alias for: is_roebe?
is_on_windows?() click to toggle source
#

is_on_windows?

#
# File lib/rbt/base/base.rb, line 102
def is_on_windows?
  RBT.is_on_windows?
end
is_porg_available?() click to toggle source
#

is_porg_available?

This method is required to determine whether porg is available or not.

#
# File lib/rbt/base/base.rb, line 645
def is_porg_available?
  result = `porg 2>&1`.include? 'porg: command not found'
  return !result
end
Also aliased as: porg_is_available?
is_roebe?() click to toggle source
#

is_roebe?

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

#
# File lib/rbt/base/prototype.rb, line 329
def is_roebe?
  RBT.is_roebe?
end
Also aliased as: is_on_roebe?, on_roebe?
is_this_program_included?( i, optional_arguments = nil ) click to toggle source
#

is_this_program_included?

Use this method to query whether a program is included or whether it is not.

The second argument is, by default, nil. It can be a symbol such as :include_abbreviations, in which case we will include abbreviations.

#
# File lib/rbt/base/base.rb, line 458
def is_this_program_included?(
    i, optional_arguments = nil
  )
  RBT.is_this_program_included?(i, optional_arguments) # bl $RBT/toplevel_methods/available_programs.rb
end
is_this_program_registered?( i, optional_arguments = nil )
load_yaml(i) click to toggle source
#

load_yaml

#
# File lib/rbt/base/prototype.rb, line 311
def load_yaml(i)
  YAML.load_file(i)
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/”.

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

main_encoding?

#
# File lib/rbt/base/prototype.rb, line 112
def main_encoding?
  USE_THIS_ENCODING
end
make_command?() click to toggle source
#

make_command?

#
# File lib/rbt/base/base.rb, line 272
def make_command?
  Base.make_command?
end
make_install_command?() click to toggle source
#

make_install_command?

This is the default “make install” command for now.

#
# File lib/rbt/base/base.rb, line 304
def make_install_command?
  'make install'
end
mkdir( i = '/Users/Packages/', be_verbose = true, permissions = :default )
Alias for: create_directory
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/base/prototype.rb, line 350
def move_file(
    this_file, where_to, be_verbose = true
  )
  if be_verbose
    e 'Moving from '+sfile(this_file)+' to '+sfile(where_to)+'.'
  end
  FileUtils.mv(this_file, where_to)
end
Also aliased as: mv
mv( this_file, where_to, be_verbose = true )
Alias for: move_file
n_programs_available()
n_programs_available?() click to toggle source
#

n_programs_available?

#
# File lib/rbt/base/prototype.rb, line 269
def n_programs_available?
  RBT.n_programs_available?
end
Also aliased as: n_programs_available
new_cookbook_instance_for(name_of_the_program) click to toggle source
#

new_cookbook_instance_for

Use a slightly shorter wrapper to access class Cookbook.

#
# File lib/rbt/base/base.rb, line 398
def new_cookbook_instance_for(name_of_the_program)
  RBT::Cookbooks::Cookbook.new(name_of_the_program) { :bypass_menu_check }
end
no_directory_exists_at(i) click to toggle source
#

no_directory_exists_at

#
# File lib/rbt/base/prototype.rb, line 721
def no_directory_exists_at(i)
  e "No directory exists at `#{sdir(i)}`."
end
no_file_exists_at(i)
Alias for: no_such_file_exists
no_opn() click to toggle source
#

no_opn

#
# File lib/rbt/base/opn.rb, line 63
def no_opn
  @use_opn = false
end
Also aliased as: disable_opn
no_such_file_exists(i) click to toggle source
#

no_such_file_exists

#
# File lib/rbt/base/prototype.rb, line 714
def no_such_file_exists(i)
  e "No file called `#{sfile(i)}` appears to exist."
end
Also aliased as: no_file_exists_at
on_roebe?()
Alias for: is_roebe?
open_in_browser(i) click to toggle source
#

open_in_browser

#
# File lib/rbt/base/base.rb, line 612
def open_in_browser(i)
  require 'open_in_browser'
  OpenInBrowser[i]
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/base/editor.rb, line 18
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.
      # =================================================================== #
      i.prepend "#{RUBY_SRC_DIR_RBT_YAML}individual_cookbooks/"
    else
      i.prepend individual_cookbooks_dir?
    end
    esystem "#{editor?} #{i}"
  end
end
opne(i) click to toggle source
#

opne (opne tag)

#
# File lib/rbt/base/base.rb, line 665
def opne(i)
  opn(namespace: @namespace) if use_opn?; e i
end
opnef(i) click to toggle source
#

opnef (opnef tag)

#
# File lib/rbt/base/base.rb, line 573
def opnef(i)
  opn(namespace: @namespace) if use_opn?; ee i
end
opnerror( i, use_this_as_namespace = @namespace ) click to toggle source
#

opnerror (opnerror tag)

#
# File lib/rbt/base/base.rb, line 580
def opnerror(
    i, use_this_as_namespace = @namespace
  )
  opn(namespace: use_this_as_namespace) if use_opn?
  stderr i
end
opnewarn(i) click to toggle source
#

opnewarn

#
# File lib/rbt/base/base.rb, line 672
def opnewarn(i)
  opne swarn(i)
end
opnn( i = @namespace, &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/base/opn.rb, line 29
def opnn(
    i = @namespace,
    &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?
output_namespace?( i = @namespace, &block )
Alias for: opnn
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 is 'htop' then this method should return 'htop.yml'.

#
# File lib/rbt/base/expanded_cookbooks.rb, line 33
def path_to_this_expanded_cookbooks_dataset(i)
  i = i.dup
  i = remove_archive_at_the_end(
    File.basename(i)
  )
  if i =~ /\d+/
    i = ProgramInformation.return_program_name(i)
  end
  i << '.yml' unless i.end_with? '.yml'
  "#{directory_expanded_cookbooks?}#{i}"
end
play_song?() click to toggle source
#

play_song?

Query over as to whether we will play a song or not, after compilation has finished.

#
# File lib/rbt/base/base.rb, line 389
def play_song?
  RBT.configuration?.play_song
end
porg_is_available?()
Alias for: is_porg_available?
predefined_installation_instructions?() click to toggle source
#

predefined_installation_instructions?

#
# File lib/rbt/base/prototype.rb, line 693
def predefined_installation_instructions? 
  RBT.predefined_installation_instructions?
end
program_dir?()
Alias for: programs_dir?
program_exists?(this_program) click to toggle source
#

program_exists?

Use this method to find out if a program exists.

Usage Example:

if program_exists? :htop
#
# File lib/rbt/base/base.rb, line 202
def program_exists?(this_program)
  does_program_exist = false # Defaults to false - the program is not installed.
  this_program = this_program.to_s.dup #. downcase # sanitize. downcase is BAD, it breaks stuff like "Esetroot"
  if this_program.include? ' ' # split it, and take the first word in this case.
    this_program = this_program.split(' ').first 
  end
  path_variable_file = "#{LINUX}YAML/path_variable.yml"
  if File.exist? path_variable_file
    array_available_paths = YAML.load_file(path_variable_file)['path'].strip.split(' ')
    array_available_paths.each {|path|
      _ = "#{path}/#{this_program}"
      does_program_exist = true if File.exist?(_)
    }
  end
  # Hack - an exception for configure:
  does_program_exist = true if this_program.include? '/configure'
  return does_program_exist
end
program_was_found?( i, optional_arguments = nil )
programs_dir?() click to toggle source
#

programs_dir?

#
# File lib/rbt/base/programs_dir.rb, line 16
def programs_dir?
  RBT.programs_dir?.dup
end
Also aliased as: programs_directory?, programs_directory?, program_dir?
programs_directory?()
Alias for: programs_dir?
project_base_dir?() click to toggle source
#

project_base_dir?

#
# File lib/rbt/base/prototype.rb, line 728
def project_base_dir?
  RBT::PROJECT_BASE_DIRECTORY
end
project_yaml_directory?() click to toggle source
#

project_yaml_directory?

This will return the path to the yaml directory.

#
# File lib/rbt/base/prototype.rb, line 870
def project_yaml_directory?
  RBT.yaml_directory?
end
Also aliased as: rbt_path?
publish_list_of_all_programs_version() click to toggle source
#

publish_list_of_all_programs_version

#
# File lib/rbt/base/ftp.rb, line 16
def publish_list_of_all_programs_version
  ::RBT.publish_list_of_all_programs_version
end
pwd?()
Alias for: return_pwd
rbt_log_dir?()
Alias for: log_directory?
rbt_log_directory?()
Alias for: log_directory?
rbt_logs?() click to toggle source
#

rbt_logs?

This method will return the path of where we store RBT-related log files.

#
# File lib/rbt/base/base.rb, line 323
def rbt_logs?
  RBT.log_directory?
end
rbt_path?()
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/base/prototype.rb, line 641
def read_file(i)
  File.read(i) if File.exist? i
end
read_file_in_default_encoding( i, use_this_encoding = ::RBT.encoding? ) click to toggle source
#

read_file_in_default_encoding

#
# File lib/rbt/base/prototype.rb, line 648
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 "Can not read file `#{i}` as it does not exist."
  end
end
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/base/prototype.rb, line 105
def readlines(i)
  File.readlines(i)
end
readlines_with_proper_encoding(i) click to toggle source
#

readlines_with_proper_encoding

File.readlines() variant with proper encoding.

#
# File lib/rbt/base/prototype.rb, line 121
def readlines_with_proper_encoding(i)
  File.readlines(
    i, encoding: main_encoding?
  )
end
recipes_dir?() click to toggle source
#

recipes_dir?

#
# File lib/rbt/base/base.rb, line 224
def recipes_dir?
  RBT.configuration?.recipes_dir
end
register_sigint( optional_message = nil, use_this_as_exit_code = 0 ) click to toggle source
#

register_sigint

#
# File lib/rbt/base/prototype.rb, line 193
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
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/base/prototype.rb, line 379
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
        opnn; e swarn('WARNING: file ')+this_target.to_s+swarn(' does not exist.')
        opnn; e 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/base/prototype.rb, line 834
def remove_archive_from_the_end(i)
  RBT.remove_archive_from_the_end(i)
end
Also aliased as: remove_archive_at_the_end, remove_file_archive_at_the_end
remove_archive_stuff_at_the_end( i, also_remove_the_basename = true )
remove_dir( this_directory, be_verbose = false )
Alias for: remove_directory
remove_directories( this_directory, be_verbose = false )
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.

#
# File lib/rbt/base/remove_directory.rb, line 19
def remove_directory(
    this_directory,
    be_verbose = false
  )
  if this_directory.is_a? Array
    this_directory.each {|entry| 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:
      # =================================================================== #
      when '/' # We will never remove '/', ever.
        e "The #{sdir('/')} directory can not be removed "\
          "via this method." # Tiny "safeguard".
      # =================================================================== #
      # RBT.temp_directory?
      # =================================================================== #
      when RBT.temp_directory?
        e "Will not remove directory `#{sdir(this_directory)}`." # Another tiny "safeguard".
      else
        if File.exist?(this_directory) and (this_directory.size > 1)
          if be_verbose
            e "Removing the directory `#{sdir(this_directory)}'` next."
          end
          FileUtils.rm_rf(this_directory) # Finally remove the directory.
        end
      end
    end
  else
    e "Unknown input: #{this_directory.class}"
  end
end
remove_double_slashes(i) click to toggle source
#

remove_double_slashes (rds tag)

Replace // with / in a given string.

#
# File lib/rbt/base/prototype.rb, line 165
def remove_double_slashes(i)
  i.squeeze '/'
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/base/remove_file.rb, line 29
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/base/prototype.rb, line 791
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_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/base/prototype.rb, line 156
def remove_newlines(i)
  i.delete("\n")
end
remove_these_directories( this_directory, be_verbose = false )
Alias for: remove_directory
remove_these_files( i, report_the_action = false )
Alias for: remove_file
remove_this_directory( this_directory, be_verbose = false )
Alias for: remove_directory
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/base/base.rb, line 66
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/base/prototype.rb, line 222
def rename(old_name, new_name)
  if File.exist? old_name
    File.rename(old_name, new_name)
  end
end
repackage( i, use_this_for_the_opnn_namespace = 'RBT::UpdateEntry' ) click to toggle source
#

repackage

This method will repackage an archive format such as .tar.gz into .tar.xz.

#
# File lib/rbt/base/base.rb, line 536
def repackage(
    i, use_this_for_the_opnn_namespace = 'RBT::UpdateEntry'
  )
  begin
    require 'repackage'
    if File.exist? i
      opnn(
        namespace_to_use: use_this_for_the_opnn_namespace
      )
      e "Trying to repackage `#{sfile(i)}` next:"
      Repackage.new(i) { :run_already }
    else
      # Not sure whether we should report to the user or not.
    end
  rescue LoadError
    e 'The gem called "repackage" is not available - please install it'
    e "in order to repackage the archive at hand here (`#{sfile(i)}`)."
  end
end
Also aliased as: repackage_this
repackage_this( i, use_this_for_the_opnn_namespace = 'RBT::UpdateEntry' )
Alias for: repackage
report_n_programs() click to toggle source
#

report_n_programs

Usage example for the report functionality of this method:

report_n_programs
#
# File lib/rbt/base/base.rb, line 183
def report_n_programs
  consider_reporting_how_many_programs_are_registered
end
report_pwd() click to toggle source
#

report_pwd

#
# File lib/rbt/base/return_pwd.rb, line 26
def report_pwd
  e "The current directory is at `#{sdir_return_pwd}`."
end
report_to_developers( this_email = RBT.configuration?.email ) click to toggle source
#

report_to_developers

Feedback information to the user so that he can report useful information to the project lead.

#
# File lib/rbt/base/base.rb, line 408
def report_to_developers(
    this_email = RBT.configuration?.email
  )
  opnn; ewarn 'To report to the developer(s) of RBT, use this '\
              'email address:'
  opnn; e
  opnn; efancy '  '+this_email
  opnn; e
  opnn; ewarn 'You can also use this URL:'
  opnn; e
  opnn; efancy "  #{RBT_HOMEPAGE_URL}"
  opnn; e
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/rbt/base/reset.rb, line 18
def reset
  @use_colours = RBT.use_colours? # Use the default value for RBT.
  @be_verbose = true
  @run_simulation = RBT.configuration?.run_simulation # Whether we run in simulation mode or not.
  @use_opn = true
  @debug = RBT.shall_we_debug?
  @namespace = { namespace: NAMESPACE }
end
return_all_archives_from_this_directory(i) click to toggle source
#

return_all_archives_from_this_directory

#
# File lib/rbt/base/prototype.rb, line 707
def return_all_archives_from_this_directory(i)
  RBT.return_all_archives_from_this_directory(i)
end
return_archive_type(i)
Alias for: archive_type_of?
return_available_programs()
Alias for: available_programs?
return_cheering_person()
Alias for: cheering_person?
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/base/time.rb, line 139
def return_current_hour_minutes_second
  Time.now.strftime '%H:%M:%S' # => "16:08:40"
end
return_current_pwd()
Alias for: return_pwd
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/base/time.rb, line 149
def return_date
  ::RBT.return_date
end
Also aliased as: return_current_date, dd_mm_yyyy
return_day_of_the_month_based_on_utc() click to toggle source
#

return_day_of_the_month_based_on_utc

#
# File lib/rbt/base/time.rb, line 57
def return_day_of_the_month_based_on_utc
  return_utc.day.to_s
end
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/base/time.rb, line 39
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/base/time.rb, line 71
def return_hours_minutes_seconds_based_on_utc
  _ = return_utc
  _.strftime('%H:%M:%S') 
end
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/base/prototype.rb, line 665
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/base/time.rb, line 105
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/base/time.rb, line 95
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/base/opn.rb, line 47
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/base/base.rb, line 679
def return_program_information(i)
  if i.include? '-'
    i = ProgramInformation.return_real_short_name(i)
  end
  i
end
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/base/prototype.rb, line 554
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.

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

return_pwd

#
# File lib/rbt/base/return_pwd.rb, line 33
def return_pwd
  RBT.return_pwd
end
Also aliased as: return_current_pwd, pwd?, get_pwd
return_time()
Alias for: current_hour?
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/base/time.rb, line 21
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/base/time.rb, line 83
def return_utc_time_in_a_format_similar_to_slackware
  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.

#
# File lib/rbt/base/time.rb, line 48
def return_weekday_based_on_utc
  _ = return_utc
  wday = _.wday
  Time::RFC2822_DAY_NAME[wday]
end
return_year_based_on_utc() click to toggle source
#

return_year_based_on_utc

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

rev

#
# File lib/rbt/base/colours.rb, line 192
def rev
  ::Colours.rev
end
rpn(i, optional_padding = ' ')
Alias for: return_program_name
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/base/run.rb, line 14
def run
end
run_ldconfig?() click to toggle source
#

run_ldconfig?

#
# File lib/rbt/base/base.rb, line 238
def run_ldconfig?
  RBT.configuration?.run_ldconfig
end
Also aliased as: use_ldconfig?
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/base/prototype.rb, line 495
def run_simulation=(i = false)
  @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/base/prototype.rb, line 482
def run_simulation?
  @run_simulation
end
Also aliased as: run_simulation, in_simulation?
sanitize_for_environment_variable(i) click to toggle source
#

sanitize_for_environment_variable

#
# File lib/rbt/base/prototype.rb, line 215
def sanitize_for_environment_variable(i)
  RBT.convert_global_env(i)
end
Also aliased as: convert_global_env
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/base/colours.rb, line 146
def sdir(i = '')
  return ::Colours.sdir(i) if use_colours?
  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/base/return_pwd.rb, line 19
def sdir_return_pwd
  sdir(return_pwd)
end
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/base/be_verbose.rb, line 47
def set_be_silent(i = false) # false because we assign to @be_verbose
  @be_verbose = i
end
Also aliased as: be_silent, be_quiet
set_be_verbose(i = true) click to toggle source
#

set_be_verbose

By default we will be verbose.

#
# File lib/rbt/base/be_verbose.rb, line 30
def set_be_verbose(i = true)
  @be_verbose = i
end
Also aliased as: be_verbose, be_verbose=
set_input(i) click to toggle source
#

set_input

#
# File lib/rbt/base/initialize.rb, line 16
def set_input(i)
  @input = i
end
set_source_dir( i = return_pwd, be_verbose = false )
set_source_directory( i = return_pwd, be_verbose = false ) click to toggle source
#

set_source_directory

Set the source dir to ANY new location. Defaults to Dir.pwd.

Example to test it this method:

ry mantis --source_dir=/Depot/j
#
# File lib/rbt/base/base.rb, line 438
def set_source_directory(
    i          = return_pwd,
    be_verbose = false
  )
  i << '/' unless i.end_with? '/'
  RBT.set_source_directory(i)
  if be_verbose?
    e "Setting source directory to `#{sdir(i)}` next." 
  end
end
Also aliased as: set_source_dir
set_use_opn(i) click to toggle source
#

set_use_opn

#
# File lib/rbt/base/opn.rb, line 70
def set_use_opn(i)
  @use_opn = i
end
set_xorg_buffer(i) click to toggle source
#

set_xorg_buffer

#
# File lib/rbt/base/base.rb, line 490
def set_xorg_buffer(i)
  begin
    require 'xorg_buffer'
  rescue LoadError; end
  XorgBuffer.set_xorg_buffer(i)
end
sfancy(i = '') click to toggle source
#

sfancy

#
# File lib/rbt/base/colours.rb, line 169
def sfancy(i = '')
  return ::Colours.sfancy(i) if use_colours?
  i
end
sfile(i = '') click to toggle source
#

sfile

#
# File lib/rbt/base/colours.rb, line 154
def sfile(i = '')
  return ::Colours.sfile(i) if use_colours?
  i
end
show_md5sum?()
Alias for: display_md5sum?
show_opnn?()
Alias for: use_opn?
show_overview_over_available_utility_scripts() click to toggle source
#

show_overview_over_available_utility_scripts

#
# File lib/rbt/base/base.rb, line 173
def show_overview_over_available_utility_scripts
  RBT.show_overview_over_available_utility_scripts
end
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/base/prototype.rb, line 262
def silently_create_this_directory_if_it_does_not_yet_exist(i)
  create_directory(i, :be_quiet)
end
simp(i = '') click to toggle source
#

simp

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

source_base_directory?

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

ssym

#
# File lib/rbt/base/colours.rb, line 177
def ssym(i)
  return Colours.ssym(i) if use_colours?
  i
end
static_appdir_prefix_of?( i = nil, program_version = nil )
stderr( i = '', use_puts_or_print = :puts ) click to toggle source
#

stderr

#
# File lib/rbt/base/prototype.rb, line 742
def stderr(
    i = '', use_puts_or_print = :puts
  )
  RBT.stderr(i, use_puts_or_print)
end
store_into_this_directory?() click to toggle source
#

store_into_this_directory?

#
# File lib/rbt/base/base.rb, line 355
def store_into_this_directory?
  RBT.store_into_this_directory?
end
Also aliased as: store_where?
store_what_into( what, into, permissions_to_use = '755' )
Alias for: write_what_into
store_where?()
swarn(i = '') click to toggle source
#

swarn

#
# File lib/rbt/base/colours.rb, line 300
def swarn(i = '')
  return Colours.swarn(i) if use_colours?
  i
end
sysbin_directory?() click to toggle source
#

sysbin_directory?

#
# File lib/rbt/base/prototype.rb, line 912
def sysbin_directory?
  RBT.sysbin_directory?
end
sysetc_directory?() click to toggle source
#

sysetc_directory?

#
# File lib/rbt/base/prototype.rb, line 940
def sysetc_directory?
  RBT.sysetc_directory?
end
sysinclude_directory?() click to toggle source
#

sysinclude_directory?

#
# File lib/rbt/base/prototype.rb, line 919
def sysinclude_directory?
  RBT.sysinclude_directory?
end
syslib_directory?() click to toggle source
#

syslib_directory?

#
# File lib/rbt/base/prototype.rb, line 926
def syslib_directory?
  RBT.syslib_directory?
end
sysshare_directory?() click to toggle source
#

sysshare_directory?

#
# File lib/rbt/base/prototype.rb, line 933
def sysshare_directory?
  RBT.sysshare_directory?
end
system_directory?() click to toggle source
#

system_directory?

#
# File lib/rbt/base/prototype.rb, line 897
def system_directory?
  RBT.system_directory?
end
system_tags?() click to toggle source
#

system_tags?

#
# File lib/rbt/base/base.rb, line 590
def system_tags?
  RBT.system_tags?
end
temp_dir?()
Alias for: temp_directory?
temp_directory?() click to toggle source
#

temp_directory?

#
# File lib/rbt/base/prototype.rb, line 888
def temp_directory?
  RBT.temp_directory?
end
Also aliased as: temp_dir?, log_dir?, base_dir?
to_bool(i) click to toggle source
#

to_bool

#
# File lib/rbt/base/base.rb, line 95
def to_bool(i)
  RBT.to_bool(i)
end
to_camelcase(i) click to toggle source
#

to_camelcase

#
# File lib/rbt/base/prototype.rb, line 208
def to_camelcase(i)
  i.split('_').map { |_| _.capitalize }.join
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/base/time.rb, line 124
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/base/prototype.rb, line 175
def touch(
    i,
    be_verbose = false
  )
  case be_verbose
  when :be_verbose
    be_verbose = true
  end
  if be_verbose
    e "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
unicode_cliner(a = :default, b = :default, &block) click to toggle source
#

unicode_cliner

#
# File lib/rbt/base/prototype.rb, line 816
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/base/prototype.rb, line 823
def unicode_middle_cliner(a = :default, b = :default)
  ::RBT.unicode_cliner(a, b) { :unicode_middle_horizontal_bar }
end
upload_list_of_all_programs_version() click to toggle source
#

upload_list_of_all_programs_version

#
# File lib/rbt/base/ftp.rb, line 23
def upload_list_of_all_programs_version
  ::RBT.upload_list_of_all_programs_version
end
use_ccache?() click to toggle source
#

use_ccache?

Whether we will make use of ccache or whether we don't, by default.

#
# File lib/rbt/base/base.rb, line 313
def use_ccache?
  RBT.configuration?.use_ccache
end
use_colours=(i = true) click to toggle source
#

use_colours=

#
# File lib/rbt/base/colours.rb, line 117
def use_colours=(i = true)
  @use_colours = i
end
use_colours?() click to toggle source
#

use_colours?

Query whether we may use colours or not.

#
# File lib/rbt/base/colours.rb, line 103
def use_colours?
  @use_colours
end
Also aliased as: we_may_use_colours?
use_ldconfig?()
Alias for: run_ldconfig?
use_mrxvt?() click to toggle source
#

use_mrxvt?

#
# File lib/rbt/base/base.rb, line 362
def use_mrxvt?
  RBT.configuration?.use_mrxvt
end
use_opn=(i = true) click to toggle source
#

use_opn=

#
# File lib/rbt/base/opn.rb, line 77
def use_opn=(i = true)
  @use_opn = i
end
use_opn?() click to toggle source
#

use_opn?

#
# File lib/rbt/base/opn.rb, line 17
def use_opn?
  @use_opn
end
Also aliased as: show_opnn?
use_porg?() click to toggle source
#

use_porg?

Whether we will use porg for installation or whether we will not.

Most users probably do not need/want this, so this is mostly for my home system, but also those users who may wish to use porg.

#
# File lib/rbt/base/base.rb, line 658
def use_porg?
  RBT.configuration?.use_porg
end
use_stow?() click to toggle source
#

use_stow?

#
# File lib/rbt/base/base.rb, line 279
def use_stow?
  RBT.configuration?.use_stow
end
use_tags?() click to toggle source
#

use_tags?

#
# File lib/rbt/base/base.rb, line 369
def use_tags?
  RBT.configuration?.use_tags
end
use_yaml_database_for_tags?() click to toggle source
#

use_yaml_database_for_tags?

#
# File lib/rbt/base/base.rb, line 190
def use_yaml_database_for_tags?
  RBT.use_yaml_database_for_tags?
end
verbose_truth(i) click to toggle source
#

verbose_truth

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

#
# File lib/rbt/base/prototype.rb, line 303
def verbose_truth(i)
  RBT.verbose_truth(i)
end
Also aliased as: vt, verbose_truth?
verbose_truth?(i)
Alias for: verbose_truth
vt(i)
Alias for: verbose_truth
warn_and_exit(input, exit_mode = true) click to toggle source
#

warn_and_exit

This method will exit from the scripts.

You should be careful when using this, because in some situations we do not actually want to exit completely - for example when we chain-compile something.

#
# File lib/rbt/base/base.rb, line 258
def warn_and_exit(input, exit_mode = true)
  warn(input, exit_mode)
end
Also aliased as: warn_then_exit
warn_then_exit(input, exit_mode = true)
Alias for: warn_and_exit
we_may_use_colours?()
Alias for: use_colours?
word_wrap( this_text, n_characters_limit = 78 ) 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/base/prototype.rb, line 590
def word_wrap(
    this_text, n_characters_limit = 78
  )
  if this_text.respond_to? :encoding
    unless this_text.encoding.to_s.include? main_encoding?
      this_text = ensure_main_encoding_for(this_text)
    end
    this_text.gsub(/(.{1,#{n_characters_limit}})(\s+|$)/, "\\1\n")
  end
end
wrap_at( i, n_characters = :default ) click to toggle source
#

wrap_at

#
# File lib/rbt/base/base.rb, line 330
def wrap_at(
    i,
    n_characters = :default
  )
  RBT.wrap_at(i, n_characters)
end
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/base/save_file.rb, line 16
def write_what_into(
    what, into, permissions_to_use = '755'
  )
  RBT.write_what_into(what, into, permissions_to_use)
end