Class: RBT::LeanPrototype

Inherits:
Object
  • Object
show all
Defined in:
lib/rbt/lean_prototype/lean_prototype.rb

Overview

RBT::LeanPrototype

Direct Known Subclasses

Action, Base, Cookbooks::Aliases

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
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.

#
%w(
  Sun Mon Tue Wed Thu Fri Sat
)
ALL_COLOUR_METHODS =
#

ALL_COLOUR_METHODS

#
::Colours::HtmlColoursMethods
SILENT_REDIRECTION =
#

SILENT_REDIRECTION

This can simply be appended.

#
' > /dev/null'
ARRAY_KDE_KONSOLE_COLOURS_IN_USE =
#

ARRAY_KDE_KONSOLE_COLOURS_IN_USE

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

#
%w(
  aliceblue
  aquamarine
  blueviolet
  cadetblue
  cornflowerblue
  crimson
  cyan
  darkcyan
  darkgoldenrod
  darkgreen
  darkorchid
  darkseagreen
  darkslateblue
  darkturquoise
  deepskyblue
  dodgerblue
  firebrick
  forestgreen
  gold
  gray
  grey
  green
  hotpink
  khaki
  lightblue
  lightseagreen
  lightgoldenrodyellow
  lightgreen
  lightsalmon
  lightskyblue
  lightslategray
  lightsteelblue
  limegreen
  mediumaquamarine
  mediumorchid
  mediumpurple
  mediumseagreen
  mediumslateblue
  mediumspringgreen
  mediumturquoise
  mediumvioletred
  navajowhite
  olive
  olivedrab
  orange
  orangebrown
  orangered
  orchid
  palevioletred
  paleturquoise
  peru
  plum
  powderblue
  royalblue
  salmon
  saddlebrown
  sandybrown
  seagreen
  silver
  skyblue
  slateblue
  slategray
  springgreen
  steelblue
  rosybrown
  teal
  tomato
  turquoise
  violet
  yellow
  yellowgreen
)

Instance Method Summary collapse

Constructor Details

#initialize(i = ARGV, run_already = true, &block) ⇒ LeanPrototype

#

initialize

#


97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# 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

Instance Method Details

#a_or_an?(i) ⇒ Boolean

#

a_or_an?

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

#

Returns:

  • (Boolean)


1176
1177
1178
1179
1180
1181
1182
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1176

def a_or_an?(i)
  if i.start_with?('a','i','o','u')
    'an'
  else
    'a'
  end
end

#abbreviations?Boolean

#

abbreviations?

Easier getter-method over the available abbreviations.

#

Returns:

  • (Boolean)


1311
1312
1313
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1311

def abbreviations?
  RBT.hash_aliases_to_the_available_programs?
end

#absolute_path(i) ⇒ Object

#

absolute_path

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

#


1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1321

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 = nil, options_hash = {}, &block) ⇒ Object Also known as: actions

#

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.

#


2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2998

def action(
    action_that_is_desired = nil,
    optional_argument1     = nil, # 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

#add_to_the_commandline_arguments(i) ⇒ Object Also known as: append_to_the_commandline_arguments, append_these_options_to_the_commandline, append_to_the_commandline

#

add_to_the_commandline_arguments

Simply append to the commandline options through this method here.

#


909
910
911
912
913
914
915
916
917
918
919
920
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 909

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_binaries?Boolean

#

all_binaries?

#

Returns:

  • (Boolean)


527
528
529
530
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 527

def all_binaries?
  require 'rbt/toplevel_methods/all_binaries.rb'
  RBT.all_binaries?
end

#all_files_from(this_directory) ⇒ Object

#

all_files_from

#


1375
1376
1377
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1375

def all_files_from(this_directory)
  Dir[rds(this_directory+'/*')].select {|entry| File.file?(entry) }
end

#all_libraries?Boolean

#

all_libraries?

#

Returns:

  • (Boolean)


405
406
407
408
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 405

def all_libraries?
  require 'rbt/toplevel_methods/all_libraries.rb'
  RBT.all_libraries?
end

#allowed_cookbook_entries?(i = RBT.file_registered_cookbook_entries) ⇒ Boolean

#

allowed_cookbook_entries?

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

#

Returns:

  • (Boolean)


705
706
707
708
709
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 705

def allowed_cookbook_entries?(
    i = RBT.file_registered_cookbook_entries
  )
  YAML.load_file(i) if File.exist? i
end

#appdir_location_of?(i) ⇒ Boolean

#

appdir_location_of?

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

#

Returns:

  • (Boolean)


213
214
215
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 213

def appdir_location_of?(i)
  "#{programs_dir?}#{i.capitalize}/Current"
end

#append_onto_the_internal_hash(i) ⇒ Object Also known as: append_onto_the_main_hash

#

append_onto_the_internal_hash

#


1203
1204
1205
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1203

def append_onto_the_internal_hash(i)
  @internal_hash.update(i)
end

#append_what_into(what, into) ⇒ Object

#

append_what_into

#


1728
1729
1730
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1728

def append_what_into(what, into)
  RBT.append_what_into(what, into)
end

#archive_type_of?(i) ⇒ Boolean Also known as: return_archive_type, archive_type_of, archive_type?, determine_archive_type

#

archive_type_of?

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

#

Returns:

  • (Boolean)


1407
1408
1409
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1407

def archive_type_of?(i)
  RBT.return_archive_type(i)
end

#available_programs?Boolean Also known as: all_programs?, all_programs, all_available_programs?, available_programs, available_cookbooks?, available_cookbooks, return_available_programs, get_cookbooks

#

available_programs?

#

Returns:

  • (Boolean)


2372
2373
2374
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2372

def available_programs?
  RBT.available_programs?
end

#be_quiet?Boolean

#

be_quiet?

#

Returns:

  • (Boolean)


1925
1926
1927
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1925

def be_quiet?
  !@internal_hash[:be_verbose]
end

#be_verbose?Boolean

#

be_verbose?

#

Returns:

  • (Boolean)


1918
1919
1920
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1918

def be_verbose?
  @internal_hash[:be_verbose]
end

#begins_with_a_comment?(i) ⇒ Boolean

#

begins_with_a_comment?

#

Returns:

  • (Boolean)


3088
3089
3090
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3088

def begins_with_a_comment?(i)
  i.start_with? '#'
end

#capitalize_first_alphabetical_character(i = '/programs') ⇒ Object

#

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”.

#


2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2569

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_to_the_log_directoryObject

#

cd_to_the_log_directory

#


1424
1425
1426
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1424

def cd_to_the_log_directory
  cd log_directory?
end

#cd_to_the_temp_directory(be_verbose = :be_quiet) ⇒ Object

#

cd_to_the_temp_directory

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

#


831
832
833
834
835
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 831

def cd_to_the_temp_directory(
    be_verbose = :be_quiet
  )
  cd temp_directory?, be_verbose
end

#change_directory(i, optional_arguments = nil) ⇒ Object Also known as: chdir, change_dir, cd

#

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.

#


1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1954

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

#change_permission(file = 'test', use_this_uid_number = '1000') ⇒ Object Also known as: chown

#

change_permission (chown tag)

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

#


3107
3108
3109
3110
3111
3112
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3107

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

#cheering_person?Boolean Also known as: return_cheering_person, cheering_person, cheerful_person, cheering_ascii_person

#

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?)
#

Returns:

  • (Boolean)


851
852
853
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 851

def cheering_person?
  '\o/'
end

#chmod(i) ⇒ Object

#

chmod

#


2338
2339
2340
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2338

def chmod(i)
  RBT.chmod(i)
end

#chop_off_archive(i) ⇒ Object

#

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).

#


1880
1881
1882
1883
1884
1885
1886
1887
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1880

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

#clear_commandline_argumentsObject Also known as: clear_commandline_options

#

clear_commandline_arguments

#


3488
3489
3490
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3488

def clear_commandline_arguments
  @internal_hash[:commandline_arguments] = []
end

#cliner(optional_arguments = nil, use_this_colour = nil) ⇒ Object

#

cliner

#


998
999
1000
1001
1002
1003
1004
1005
1006
1007
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 998

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) ⇒ Object

#

coloured_and_padded_e

#


1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1509

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, &block) ⇒ Object Also known as: colourize_this_important_system_command, ecolourize_this_important_system_command, colourized_esystem_with_padding, colourized_and_padded_esystem

#

coloured_and_padded_esystem

Usage example:

coloured_and_padded_esystem('ls', true, nil, :cornflowerblue)
#


3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3342

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) ⇒ Object Also known as: colourized_esystem

#

coloured_esystem

#


1557
1558
1559
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1557

def coloured_esystem(i)
  esystem i, :fancy_colours
end

#colourize_directory_for_system_results(i) ⇒ Object

#

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.

#


2190
2191
2192
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2190

def colourize_directory_for_system_results(i)
  lightslategray(i)
end

#colourize_this_error(i) ⇒ Object

#

colourize_this_error

This method in particular attempts to colourize some errors.

#


2260
2261
2262
2263
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2260

def colourize_this_error(i)
  return darkgoldenrod(i) if use_colours?
  return i
end

#colourize_this_file_path(i, colour1 = :slateblue, colour2 = :royalblue) ⇒ Object

#

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.

#


2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2221

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) ⇒ Object Also known as: colourize_for_warnings

#

colourize_this_warning

#


2268
2269
2270
2271
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2268

def colourize_this_warning(i)
  return firebrick(i) if use_colours?
  return i
end

#commandline_arguments?Boolean Also known as: input?, arguments?, all_arguments?, commandline?, commandline_options?, commandline, commandline_args?

#

commandline_arguments?

#

Returns:

  • (Boolean)


947
948
949
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 947

def commandline_arguments?
  @internal_hash[:commandline_arguments]
end

#commandline_arguments_without_hyphens?(i = commandline_arguments? ) ⇒ Boolean Also known as: reject_entries_starting_with_hyphens, non_hyphen_arguments, non_hyphened_arguments, non_hyphened_arguments?

#

commandline_arguments_without_hyphens?

As above, but reversed.

#

Returns:

  • (Boolean)


962
963
964
965
966
967
968
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 962

def commandline_arguments_without_hyphens?(
    i = commandline_arguments?
  )
  i.select {|entry|
    entry and !entry.start_with?('--')
  }
end

#comment(i) ⇒ Object

#

comment

#


2331
2332
2333
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2331

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) ⇒ Object

#

convert_dd_mm_yyyy_to_its_long_variant

#


3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3248

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) ⇒ Object Also known as: convert_global_env, sanitize_for_environment_variable

#

convert_env_variable

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

#


2416
2417
2418
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2416

def convert_env_variable(i)
  RBT.convert_global_env(i)
end

#copy_directory(from, to = return_pwd, be_verbose = false) ⇒ Object

#

copy_directory

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

#


2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2764

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_files(from, to = return_pwd, be_verbose = false, use_namespace = true, &block) ⇒ Object Also known as: copy_file, copy, cp

#

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

Use this if you need to copy a file.

#


1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1766

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

#cpr(from, to = return_pwd) ⇒ Object

#

cpr

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

#


1704
1705
1706
1707
1708
1709
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1704

def cpr(
    from,
    to = return_pwd
  )
  FileUtils.cp_r(from, to)
end

#create_directory(i = '/Users/Packages/', be_verbose = :be_quiet, permissions = :default, &block) ⇒ Object Also known as: mkdir, mkdir_p, ensure_that_this_directory_exists, create_directory_if_it_does_not_yet_exist

#

create_directory (mkdir tag)

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

#


2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2614

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

#current_hour?Boolean Also known as: return_time

#

current_hour?

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

#

Returns:

  • (Boolean)


3241
3242
3243
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3241

def current_hour?
  ::Time.now.strftime('%H:%M:%S') # '04:21:14'
end

#dd_mmm_yyyObject

#

dd_mmm_yyy

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

#


2838
2839
2840
2841
2842
2843
2844
2845
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2838

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) ⇒ Object

#

debug

Debug functionality here.

#


2469
2470
2471
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2469

def debug(i)
  cliner { ewarn(i) }
end

#debug?Boolean

#

debug?

#

Returns:

  • (Boolean)


976
977
978
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 976

def debug?
  @internal_hash[:debug]
end

#directory_expanded_cookbooks?Boolean Also known as: directory_expanded_cookbooks, base_dir_to_store_expanded_cookbooks?, expanded_cookbooks?, expanded_cookbook_directory?

#

directory_expanded_cookbooks?

#

Returns:

  • (Boolean)


1589
1590
1591
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1589

def directory_expanded_cookbooks?
  RBT.directory_expanded_cookbooks?
end

#disable_coloursObject Also known as: do_not_use_colours, disable_colors

#

disable_colours

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

#


3556
3557
3558
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3556

def disable_colours
  @internal_hash[:use_colours] = false
end

#display_md5sum?Boolean Also known as: show_md5sum?

#

display_md5sum?

#

Returns:

  • (Boolean)


3126
3127
3128
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3126

def display_md5sum?
  RBT.display_md5sum?
end

#do_not_debugObject

#

do_not_debug

#


990
991
992
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 990

def do_not_debug
  @internal_hash[:debug] = false
end

#does_the_cookbook_include_this_program?(i) ⇒ Boolean

#

does_the_cookbook_include_this_program?

#

Returns:

  • (Boolean)


3304
3305
3306
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3304

def does_the_cookbook_include_this_program?(i)
  RBT.does_include?(i)
end

#does_this_expanded_cookbook_file_exist_for_this_program?(i) ⇒ Boolean Also known as: does_the_expanded_cookbook_file_exist_for_this_program?, expanded_cookbook_file_exists_for?

#

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.

#

Returns:

  • (Boolean)


821
822
823
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 821

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) ⇒ Boolean

#

does_this_file_exist?

#

Returns:

  • (Boolean)


258
259
260
261
262
263
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 258

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) ⇒ Boolean

#

does_this_file_exist_and_is_it_a_file?

#

Returns:

  • (Boolean)


3163
3164
3165
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3163

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? ) ⇒ Object

#

e (e tag)

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

#


3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3313

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 = '') ⇒ Object

#

eblue

#


2251
2252
2253
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2251

def eblue(i = '')
  e steelblue(i)
end

#ecomment(i = '', use_colours = use_colours? ) ⇒ Object

#

ecomment

#


2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2590

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

#ecrimson(i = '') ⇒ Object

#

ecrimson

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

#


2244
2245
2246
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2244

def ecrimson(i = '')
  e crimson(i)
end

#edir(i = return_pwd) ⇒ Object

#

edir

#


2125
2126
2127
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2125

def edir(i = return_pwd)
  e sdir(i)
end

#editor?Boolean

#

editor?

#

Returns:

  • (Boolean)


3118
3119
3120
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3118

def editor?
  RBT.editor?
end

#efancy(i = '') ⇒ Object

#

efancy

#


2156
2157
2158
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2156

def efancy(i = '')
  e sfancy(i)
end

#eimp(i) ⇒ Object

#

simp

#


2179
2180
2181
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2179

def eimp(i)
  e simp(i)
end

#enable_coloursObject Also known as: do_use_colours

#

enable_colours

#


3585
3586
3587
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3585

def enable_colours
  @internal_hash[:use_colours] = true
end

#enable_debugObject

#

enable_debug

#


983
984
985
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 983

def enable_debug
  @internal_hash[:debug] = true
end

#ensure_main_encoding_for(i, use_this_encoding = USE_MAIN_ENCODING) ⇒ Object

#

ensure_main_encoding_for

The input to this method should be a String object.

#


492
493
494
495
496
497
498
499
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 492

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

#eparse(i) ⇒ Object

#

eparse

#


2313
2314
2315
2316
2317
2318
2319
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2313

def eparse(i)
  if use_colours?
    Colours.eparse(i)
  else
    e i
  end
end

#esystem(i, use_this_colour = nil) ⇒ Object

#

esystem

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

#


1566
1567
1568
1569
1570
1571
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1566

def esystem(
    i,
    use_this_colour = nil
  )
  RBT.esystem(i, use_this_colour)
end

#esystem_gold(i) ⇒ Object

#

esystem_gold

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

#


1501
1502
1503
1504
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1501

def esystem_gold(i)
  e gold(i)
  system i
end

#etomato(i) ⇒ Object

#

etomato

#


2324
2325
2326
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2324

def etomato(i)
  e tomato(i)
end

#ewarn(i = '') ⇒ Object

#

ewarn

#


2286
2287
2288
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2286

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, &block) ⇒ Object

#

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.

#


1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1833

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_cookbooks_directory_exists?(target = directory_expanded_cookbooks? ) ⇒ Boolean Also known as: expanded_directory_exists?, directory_expanded_cookbooks_exists?

#

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.

#

Returns:

  • (Boolean)


1034
1035
1036
1037
1038
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1034

def expanded_cookbooks_directory_exists?(
    target = directory_expanded_cookbooks?
  )
  return File.directory?(target)
end

#extract_this_archive(i, extract_to = return_pwd) ⇒ Object

#

extract_this_archive

#


2975
2976
2977
2978
2979
2980
2981
2982
2983
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2975

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) ⇒ Boolean

#

extract_to?

#

Returns:

  • (Boolean)


2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2888

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?Boolean

#

file_compiled_programs?

#

Returns:

  • (Boolean)


2345
2346
2347
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2345

def file_compiled_programs?
  RBT.file_compiled_programs?
end

#file_dirname_retaining_trailing_slash(i) ⇒ Object

#

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.

#


1347
1348
1349
1350
1351
1352
1353
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1347

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?Boolean Also known as: file_predefined_installation_instructions

#

file_predefined_installation_instructions?

#

Returns:

  • (Boolean)


2550
2551
2552
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2550

def file_predefined_installation_instructions?
  RBT.file_predefined_installation_instructions
end

#file_specification_of_registered_cookbook_entriesObject

#

file_specification_of_registered_cookbook_entries

#


678
679
680
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 678

def file_specification_of_registered_cookbook_entries
  ::RBT.file_specification_of_registered_cookbook_entries
end

#find_cookbook_alias_for(i) ⇒ Object

#

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”.

#


2460
2461
2462
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2460

def find_cookbook_alias_for(i)
  RBT.find_cookbook_alias_for(i)
end

#find_this_yaml_file(i = :poppler) ⇒ Object Also known as: return_yaml_file_for

#

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"
#


3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3029

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

#first_argument?Boolean Also known as: first?, first_commandline_argument?

#

first_argument?

#

Returns:

  • (Boolean)


3466
3467
3468
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3466

def first_argument?
  @internal_hash[:commandline_arguments].first
end

#first_non_hyphen_argument?(i = commandline_arguments_without_hyphens? ) ⇒ Boolean Also known as: return_first_non_hyphen_argument, first_non_hyphened_argument_from_the_commandline_arguments, first_non_hyphened_argument?

#

first_non_hyphen_argument?

#

Returns:

  • (Boolean)


927
928
929
930
931
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 927

def first_non_hyphen_argument?(
    i = commandline_arguments_without_hyphens?
  )
  i.first
end

#get_all_directories_from(here = return_pwd, return_full_path = false) ⇒ Object Also known as: get_dir_listing, get_directory_listing, get_directories_from

#

get_all_directories_from

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

#


1126
1127
1128
1129
1130
1131
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1126

def get_all_directories_from(
    here             = return_pwd,
    return_full_path = false
  )
  RBT.get_all_directories_from(here, return_full_path)
end

#get_all_files_from(i) ⇒ Object Also known as: get_files_from

#

get_all_files_from

#


1139
1140
1141
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1139

def get_all_files_from(i)
  return RBT.get_all_files_from(i)
end

#get_all_programs(from = "#{RBT.programs_directory?}*") ⇒ Object

#

get_all_programs (all programs tag)

Simply returns all programs from the $PROGRAMS directory.

#


518
519
520
521
522
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 518

def get_all_programs(
    from = "#{RBT.programs_directory?}*"
  )
  Dir[from] # The constant PROGRAMS is set in config.rb. It has a trailing / 
end

#get_dateObject

#

get_date

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

#


2805
2806
2807
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2805

def get_date
  ::RBT.get_date
end

#get_extended_dateObject

#

get_extended_date

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

#


2814
2815
2816
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2814

def get_extended_date
  ::RBT.get_extended_date
end

#get_files_and_directories_from(i = return_pwd) ⇒ Object

#

get_files_and_directories_from

#


1194
1195
1196
1197
1198
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1194

def get_files_and_directories_from(
    i = return_pwd
  )
  RBT.get_files_and_directories_from(i)
end

#go_to_base_dir(be_verbose = true) ⇒ Object Also known as: go_to_the_base_directory

#

go_to_base_dir

Simply go to the temp-directory.

#


2478
2479
2480
2481
2482
2483
2484
2485
2486
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2478

def go_to_base_dir(
    be_verbose = true
  )
  _ = temp_dir?
  if be_verbose
    opne "Changing to `#{sdir(_)}`."
  end
  cd(_)
end

#home_dir?Boolean

#

home_dir?

#

Returns:

  • (Boolean)


2393
2394
2395
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2393

def home_dir?
  rds("#{ENV['HOME']}/") # We ensure here that a trailing '/' is part of the result.
end

#host_system?Boolean Also known as: host_architecture?, host_achiteture_in_use?

#

host_system?

#

Returns:

  • (Boolean)


2364
2365
2366
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2364

def host_system?
  RBT.determine_host_architecture
end

#infer_the_namespaceObject

#

infer_the_namespace

This will assume the true namespace from the inspectable name.

#


879
880
881
882
883
884
885
886
887
888
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 879

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

#internal_hash?Boolean Also known as: ihash, ihash?, internal_hash, return_default_internal_hash

#

internal_hash?

#

Returns:

  • (Boolean)


1440
1441
1442
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1440

def internal_hash?
  @internal_hash
end

#internal_hash_set_commandline_arguments(i = ARGV) ⇒ Object Also known as: set_commandline_arguments, set_input, set_commandline

#

internal_hash_set_commandline_arguments

This method will set the commandline arguments.

#


3437
3438
3439
3440
3441
3442
3443
3444
3445
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3437

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_an_archive?(i) ⇒ Boolean Also known as: is_archive?, is_this_an_archive?

#

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”.

#

Returns:

  • (Boolean)


1895
1896
1897
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1895

def is_an_archive?(i)
  return RBT.is_an_archive?(i)
end

#is_directory?(i) ⇒ Boolean

#

is_directory?

#

Returns:

  • (Boolean)


1253
1254
1255
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1253

def is_directory?(i)
  File.directory? i
end

#is_file?(i) ⇒ Boolean

#

is_file?

#

Returns:

  • (Boolean)


1167
1168
1169
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1167

def is_file?(i)
  File.file? i
end

#is_github_url?(i = url1? ) ⇒ Boolean Also known as: is_a_github_url?

#

is_github_url?

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

#

Returns:

  • (Boolean)


506
507
508
509
510
511
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 506

def is_github_url?(
    i = url1?
  )
  i and (i.start_with?('https://github.com/') or
         i.start_with?('http://github.com/'))
end

#is_make_available?(path = query_path? ) ⇒ Boolean

#

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.

#

Returns:

  • (Boolean)


717
718
719
720
721
722
723
724
725
726
727
728
729
730
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 717

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?Boolean

#

is_meson_installed?

#

Returns:

  • (Boolean)


3421
3422
3423
3424
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3421

def is_meson_installed?
  _ = `meson 2>&1`
  !_.include?('meson: command not found')
end

#is_on_gobolinux?Boolean Also known as: are_we_on_gobolinux?

#

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.

#

Returns:

  • (Boolean)


2405
2406
2407
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2405

def is_on_gobolinux?
  RBT.is_on_gobolinux?
end

#is_on_windows?Boolean Also known as: are_we_on_windows?

#

is_on_windows?

#

Returns:

  • (Boolean)


3624
3625
3626
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3624

def is_on_windows?
  RBT.is_on_windows?
end

#is_roebe?Boolean Also known as: is_on_roebe?, on_roebe?

#

is_roebe?

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

#

Returns:

  • (Boolean)


795
796
797
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 795

def is_roebe?
  RBT.is_roebe?
end

#is_superuser?Boolean

#

is_superuser?

#

Returns:

  • (Boolean)


1417
1418
1419
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1417

def is_superuser?
  Process.uid == 0
end

#is_symlink?(i) ⇒ Boolean

#
#

Returns:

  • (Boolean)


465
466
467
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 465

def is_symlink?(i)
  File.symlink?(i)
end

#is_this_a_header?(i) ⇒ Boolean

#

is_this_a_header?

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

#

Returns:

  • (Boolean)


249
250
251
252
253
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 249

def is_this_a_header?(
    i
  )
  i.strip.end_with?('.h')
end

#is_this_a_library?(i) ⇒ Boolean

#

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.

#

Returns:

  • (Boolean)


367
368
369
370
371
372
373
374
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 367

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_program_included?(i) ⇒ Boolean Also known as: included?, includes?, program_was_found?, include?, is_included?, includes_this_program?, is_this_program_registered?, is_the_program_included?, does_include?, is_this_program_part_of_the_RBT_project?

#

is_this_program_included?

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

#

Returns:

  • (Boolean)


3288
3289
3290
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3288

def is_this_program_included?(i)
  available_programs?.include?(i)
end

#iso_encoding?Boolean

#

iso_encoding?

#

Returns:

  • (Boolean)


1153
1154
1155
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1153

def iso_encoding?
  ENCODING_ISO
end

#load_dataset_from_this_expanded_cookbook(i, &block) ⇒ Object Also known as: return_dataset_from_expanded_cookbook, return_dataset_from_this_expanded_cookbook, quickly_obtain_expanded_cookbook_dataset_from

#

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.

#


383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 383

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) ⇒ Object

#

load_yaml

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

#


416
417
418
419
420
421
422
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 416

def load_yaml(i)
  begin
    YAML.load_file(i)
  rescue Psych::SyntaxError => error
    pp error
  end
end

#load_yaml_file_from_the_cookbook_directory_for_this_program(i) ⇒ Object

#

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.

#


450
451
452
453
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 450

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_directory?Boolean Also known as: rbt_temp_directory?, log_dir?, rbt_log_dir, rbt_log_dir?, rbt_log_directory?, rbt_temp_dir?, rbt_logs?

#

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?.

#

Returns:

  • (Boolean)


2912
2913
2914
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2912

def log_directory?
  RBT.log_directory?
end

#main_encoding?Boolean

#

main_encoding?

#

Returns:

  • (Boolean)


656
657
658
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 656

def main_encoding?
  USE_THIS_ENCODING
end

#meson_build_file_exists?(at_this_location = return_pwd, use_build_directory = false) ⇒ Boolean Also known as: meson_file_exists?

#

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.

#

Returns:

  • (Boolean)


747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 747

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

#months?Boolean

#

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.

#

Returns:

  • (Boolean)


2796
2797
2798
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2796

def months?
  Date::MONTHNAMES.compact
end

#move_file(this_file, where_to, be_verbose = true) ⇒ Object Also known as: mv, rename_file, rename_directory

#

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().

#


688
689
690
691
692
693
694
695
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 688

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

#n_programs_are_available?Boolean

#

n_programs_are_available?

#

Returns:

  • (Boolean)


2386
2387
2388
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2386

def n_programs_are_available?
  available_programs?.size
end

#n_programs_available?Boolean Also known as: n_programs_available

#

n_programs_available?

#

Returns:

  • (Boolean)


473
474
475
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 473

def n_programs_available?
  RBT.n_programs_available?
end

#namespace?Boolean

#

namespace?

#

Returns:

  • (Boolean)


893
894
895
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 893

def namespace?
  @internal_hash[:namespace]
end

#no_directory_exists_at(i) ⇒ Object

#

no_directory_exists_at

#


2436
2437
2438
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2436

def no_directory_exists_at(i)
  e "#{rev}No directory exists at `#{sdir(i)}#{rev}`."
end

#no_directory_was_found_at(to) ⇒ Object

#

no_directory_was_found_at

#


3506
3507
3508
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3506

def no_directory_was_found_at(to)
  orev "No directory was found at `#{sdir(to)}#{rev}`."
end

#no_opnObject Also known as: disable_opn

#

no_opn

#


1613
1614
1615
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1613

def no_opn
  @internal_hash[:use_opn] = false
end

#no_such_file_exists(i, be_verbose = true, &block) ⇒ Object Also known as: no_file_exists_at

#

no_such_file_exists

#


2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2514

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

#open_in_browser(i = nil) ⇒ Object

#

open_in_browser

#


3170
3171
3172
3173
3174
3175
3176
3177
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3170

def open_in_browser(i = nil)
  if i
    begin
      require 'open'
      Open.in_browser(i)
    rescue LoadError; end
  end
end

#open_in_editor(i) ⇒ Object Also known as: open_this_file

#

open_in_editor

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

#


3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3135

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

#opncomment(i = '') ⇒ Object

#

opncomment

#


1684
1685
1686
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1684

def opncomment(i = '')
  opnn; ecomment i
end

#opne(i = nil, use_opn = use_opn? ) ⇒ Object

#

opne (opne tag)

#


3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3571

def opne(
    i       = nil,
    use_opn = use_opn?
  )
  opn(
    namespace:   namespace?,
    use_colours: use_colours?
  ) if use_opn
  e i if i
end

#opnef(i) ⇒ Object

#

opnef (opnef tag)

#


3182
3183
3184
3185
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3182

def opnef(i)
  opn(namespace: namespace?) if use_opn?
  ee i
end

#opnerev(i = nil, use_opn = use_opn? ) ⇒ Object Also known as: orev

#

opnerev

#


3190
3191
3192
3193
3194
3195
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3190

def opnerev(
    i       = nil,
    use_opn = use_opn?
  )
  opne "#{rev}#{i}", use_opn
end

#opnerror(i, use_this_as_namespace = namespace? ) ⇒ Object

#

opnerror (opnerror tag)

This will combine opn() with stderr-output.

#


1578
1579
1580
1581
1582
1583
1584
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1578

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) ⇒ Object

#

opnesystem

#


1638
1639
1640
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1638

def opnesystem(i)
  opnn; esystem i
end

#opnewarn(i) ⇒ Object Also known as: opnwarn, owarn

#

opnewarn

#


1669
1670
1671
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1669

def opnewarn(i)
  opne swarn(i)
end

#opnfancy(i = '') ⇒ Object

#

opnfancy

#


1677
1678
1679
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1677

def opnfancy(i = '')
  opne sfancy(i)
end

#opnn(i = namespace?, , use_opn = use_opn?, , &block) ⇒ Object Also known as: output_namespace?

#

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.

#


1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1650

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

#otomato(i = '') ⇒ Object

#

otomato

#


3706
3707
3708
3709
3710
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3706

def otomato(
    i = ''
  )
  opne "#{tomato(i)}"
end

#packages_directory?Boolean

#

packages_directory?

#

Returns:

  • (Boolean)


1023
1024
1025
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1023

def packages_directory?
  return ::RBT.packages_directory?
end

#path_to_this_expanded_cookbooks_dataset(i) ⇒ Object Also known as: return_file_to_the_expanded_cookbooks_dataset

#

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’.

#


2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2715

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?Boolean

#

pkgconfig_directory?

#

Returns:

  • (Boolean)


1187
1188
1189
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1187

def pkgconfig_directory?
  return "#{syslib_dir?}pkgconfig/"
end

#populate_the_internal_hash_with_default_valuesObject

#

populate_the_internal_hash_with_default_values

#


151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# 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?Boolean

#

predefined_installation_instructions?

#

Returns:

  • (Boolean)


2557
2558
2559
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2557

def predefined_installation_instructions? 
  RBT.predefined_installation_instructions?
end

#prepend_this_commandline_argument(i) ⇒ Object

#

prepend_this_commandline_argument

#


3452
3453
3454
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3452

def prepend_this_commandline_argument(i)
  @internal_hash[:commandline_arguments].prepend(i)
end

#program_version_of?(i) ⇒ Boolean Also known as: return_progam_information_version?

#

program_version_of?

#

Returns:

  • (Boolean)


3541
3542
3543
3544
3545
3546
3547
3548
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3541

def program_version_of?(i)
  if Object.const_defined? :ProgramInformation
    if i.include?('-') or (i =~ /\d+/)
      return ProgramInformation.return_program_version(i)
    end
  end
  return i
end

#project_base_directory?Boolean Also known as: project_base_dir?

#

project_base_directory?

#

Returns:

  • (Boolean)


2933
2934
2935
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2933

def project_base_directory?
  RBT.project_base_directory?
end

#project_yaml_directory?Boolean Also known as: rbt_path?, project_yaml_dir?, yaml_dir?, yaml_directory?

#

project_yaml_directory?

This will return the path to the yaml directory.

#

Returns:

  • (Boolean)


782
783
784
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 782

def project_yaml_directory?
  RBT.yaml_directory?
end

#query_path?Boolean

#

query_path?

Query the $PATH variable, from within ENV.

#

Returns:

  • (Boolean)


3071
3072
3073
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3071

def query_path?
  ENV['PATH'].dup # .dup-ing it is better in the long run.
end

#rarrow?Boolean Also known as: rarrow

#

rarrow?

#

Returns:

  • (Boolean)


227
228
229
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 227

def rarrow?
  cadetblue(string_right_arrow?)
end

#read_file(i) ⇒ Object Also known as: read_this_file

#

read_file (read tag)

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

#


2870
2871
2872
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2870

def read_file(i)
  File.read(i) if File.exist? i
end

#read_file_in_default_encoding(i, use_this_encoding = ::RBT.encoding?) ⇒ Object Also known as: default_read, file_read, read_read

#

read_file_in_default_encoding

#


1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1358

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

#read_file_with_default_encoding(i) ⇒ Object

#

read_file_with_default_encoding

#


2877
2878
2879
2880
2881
2882
2883
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2877

def read_file_with_default_encoding(i)
  if File.exist? i
    File.read(i, encoding: 'UTF-8')
  else
    return i
  end
end

#readlines(i) ⇒ Object

#

readlines

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

#


1477
1478
1479
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1477

def readlines(i)
  File.readlines(i)
end

#readlines_with_proper_encoding(i, use_this_encoding = main_encoding? ) ⇒ Object Also known as: default_readlines, proper_readlines

#

readlines_with_proper_encoding

File.readlines() variant with proper encoding.

#


1486
1487
1488
1489
1490
1491
1492
1493
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1486

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) ⇒ Object

#

register_sigint

#


803
804
805
806
807
808
809
810
811
812
813
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 803

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?Boolean

#

registered_cookbook_entries?

#

Returns:

  • (Boolean)


663
664
665
666
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 663

def registered_cookbook_entries?
  require 'rbt/constants/constants.rb'
  RBT.registered_cookbook_entries?
end

#remove(this_target, be_verbose = false) ⇒ Object

#

remove (remove tag)

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

#


1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1065

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

#remove_archive_from_the_end(i) ⇒ Object Also known as: remove_archive_at_the_end, remove_file_archive_at_the_end, remove_archive_stuff_from_the_end, remove_file_extension_from

#

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).

#


2540
2541
2542
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2540

def remove_archive_from_the_end(i)
  RBT.remove_archive_from_the_end(i)
end

#remove_comments_from_each_line(i) ⇒ Object

#

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.

#


431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 431

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_directory(this_directory, be_verbose = false, &block) ⇒ Object Also known as: remove_dir, remove_these_directories, remove_directories, remove_this_directory

#

remove_directory

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

Note that ‘/’ is always protected though.

#


3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3635

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
  # ======================================================================== #
  # === Handle Arrays next
  # ======================================================================== #
  if this_directory.is_a? Array
    this_directory.each {|entry| # Recursive call here.
      remove_directory(entry, be_verbose)
    }
  # ======================================================================== #
  # === Handle Strings next
  # ======================================================================== #
  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
      # ==================================================================== #
      # === Safeguard /
      #
      # / can never be removed through this method here - at the least
      # this is our intent here.
      # ==================================================================== #
      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) ⇒ Object Also known as: rds

#

remove_double_slashes (rds tag)

Replace // with / in a given string.

#


1453
1454
1455
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1453

def remove_double_slashes(i)
  return RBT.rds(i)
end

#remove_file(i, report_the_action = false) ⇒ Object Also known as: delete, delete_file, remove_files, remove_these_files

#

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.

#


1748
1749
1750
1751
1752
1753
1754
1755
1756
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1748

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

#remove_newlines(i) ⇒ Object

#

remove_newlines

Get rid of the newlines.

#


3097
3098
3099
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3097

def remove_newlines(i)
  i.delete("\n")
end

#remove_parens(i) ⇒ Object

#

remove_parens

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

#


1262
1263
1264
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1262

def remove_parens(i)
  i.delete('()')
end
#

This method can be used to selectively remove a symlink.

#


537
538
539
540
541
542
543
544
545
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 537

def remove_symlink(i)
  if i.is_a? Array
    i.each {|entry| remove_symlink(entry) }
  else
    if File.symlink?(i) # Check whether we have a symlink here.
      File.delete(i)
    end
  end
end

#remove_the_first_commandline_argumentObject

#

remove_the_first_commandline_argument

#


3495
3496
3497
3498
3499
3500
3501
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3495

def remove_the_first_commandline_argument
  if @internal_hash[:commandline_arguments] and
     @internal_hash[:commandline_arguments][0]
    @internal_hash[:commandline_arguments][0] = nil # Get rid of the first element here.
    @internal_hash[:commandline_arguments].compact!
  end
end

#remove_this_commandline_argument(i, from = commandline_arguments? ) ⇒ Object

#

remove_this_commandline_argument

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

#


3477
3478
3479
3480
3481
3482
3483
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3477

def remove_this_commandline_argument(
    i, from = commandline_arguments?
  )
  from.reject! {|line|
    line =~ /#{Regexp.quote(i)}/
  }
end

#remove_this_entry_from_the_commandline_arguments(i) ⇒ Object

#

remove_this_entry_from_the_commandline_arguments

#


938
939
940
941
942
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 938

def remove_this_entry_from_the_commandline_arguments(i)
  commandline_arguments?.reject! {|entry|
    entry == i
  }
end

#remove_trailing_ANSII_escape_code(i) ⇒ Object

#

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.

#


2303
2304
2305
2306
2307
2308
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2303

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) ⇒ Object Also known as: return_program_full_name_from_url

#

remove_unnecessary_data_from_url

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

#


618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 618

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) ⇒ Object

#

rename

#


2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2498

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

#report_pwdObject Also known as: verbose_report_pwd

#

report_pwd

#


354
355
356
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 354

def report_pwd
  e "#{rev}The current directory is `#{sdir_return_pwd}#{rev}`."
end

#require_the_rbt_aliasesObject

#

require_the_rbt_aliases

#


328
329
330
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 328

def require_the_rbt_aliases
  require 'rbt/aliases/aliases.rb'
end

#resetObject

#

reset (reset tag)

#


138
139
140
141
142
143
144
145
146
# 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_hashObject

#

reset_the_internal_hash

#


192
193
194
195
196
197
# 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) ⇒ Object

#

return_all_archives_from_this_directory

#


1160
1161
1162
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1160

def return_all_archives_from_this_directory(i)
  RBT.return_all_archives_from_this_directory(i)
end

#return_appdir_prefix(i) ⇒ Object Also known as: return_appdir_prefix_for

#

return_appdir_prefix

#


203
204
205
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 203

def return_appdir_prefix(i)
  return RBT.return_appdir_prefix(i)
end

#return_commandline_arguments_with_leading_hyphens(i = commandline_arguments? ) ⇒ Object Also known as: commandline_arguments_containing_leading_hyphens?, commandline_arguments_with_leading_hyphens?, commandline_arguments_with_hyphens?, return_arguments_with_leading_hyphens, return_commandline_arguments_with_hyphens, return_entries_with_leading_hyphens, hyphen_commandline_arguments?, return_hyphened_commandline_arguments, hyphened_arguments?, hyphen_arguments

#

return_commandline_arguments_with_leading_hyphens

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

#


3602
3603
3604
3605
3606
3607
3608
3609
3610
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3602

def return_commandline_arguments_with_leading_hyphens(
    i = commandline_arguments?
  )
  i.select {|entry|
    entry and
    entry.respond_to?(:start_with?) and
    entry.start_with?('--')
  }
end

#return_current_hour_minutes_secondObject Also known as: ss_mm_hh, hh_mm_ss

#

return_current_hour_minutes_second

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

#


3061
3062
3063
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3061

def return_current_hour_minutes_second
  ::Time.now.strftime '%H:%M:%S' # => "16:08:40"
end

#return_dateObject Also known as: return_current_date, return_current_time, dd_mm_yyyy

#

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.

#


3277
3278
3279
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3277

def return_date
  RBT.return_date
end

#return_day_of_the_month_based_on_utcObject

#

return_day_of_the_month_based_on_utc

#


3209
3210
3211
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3209

def return_day_of_the_month_based_on_utc
  return_utc.day.to_s
end

#return_full_timeObject

#

return_full_time

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

#


3202
3203
3204
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3202

def return_full_time
  "#{return_date}, #{return_current_hour_minutes_second}"
end

#return_hours_minutes_seconds_based_on_utcObject

#

return_hours_minutes_seconds_based_on_utc

#


3223
3224
3225
3226
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3223

def return_hours_minutes_seconds_based_on_utc
  _ = return_utc
  _.strftime('%H:%M:%S') 
end

#return_location_to_this_programs_yaml_file(i) ⇒ Object

#

return_location_to_this_programs_yaml_file

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

#


483
484
485
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 483

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) ⇒ Object

#

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.

#


3267
3268
3269
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3267

def return_month_based_on_this_number(i)
  Date::MONTHNAMES[i.to_i]
end

#return_month_based_on_utcObject

#

return_month_based_on_utc

#


3231
3232
3233
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3231

def return_month_based_on_utc
  Date::MONTHNAMES[return_utc.month]
end

#return_opnn(i = nil) ⇒ Object

#

return_opnn

#


1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1620

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_name(i) ⇒ Object Also known as: return_program_information, return_program_information_short_name?, return_program_information_short_name

#

return_program_name

This variant will eliminate all ‘-’ from the given input.

#


1296
1297
1298
1299
1300
1301
1302
1303
1304
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1296

def return_program_name(
    i, optional_padding = ' '
  )
  _ = ''.dup
  if REPORT_SPECIFIC_PROGRAM_NAME
    _ << "#{File.basename(i)}:#{optional_padding}"
  end
  return _
end

#return_program_name_for_gobolinux_systems(i) ⇒ Object

#

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.

#


2429
2430
2431
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2429

def return_program_name_for_gobolinux_systems(i)
  return i
end

#return_program_name_via_program_information(i) ⇒ Object

#

return_program_name_via_program_information

This variant will retain ‘-’ characters from the given input at hand.

#


3529
3530
3531
3532
3533
3534
3535
3536
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3529

def return_program_name_via_program_information(
    i
  )
  if Object.const_defined?(:ProgramInformation)
    i = ProgramInformation.long_program_name?(i)
  end
  return i
end

#return_pwdObject Also known as: return_current_pwd, pwd?, get_pwd

#

return_pwd

#


335
336
337
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 335

def return_pwd
  RBT.return_pwd
end

#return_unicode_warning_symbol_or_empty_stringObject

#

return_unicode_warning_symbol_or_empty_string

#


2352
2353
2354
2355
2356
2357
2358
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2352

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_utcObject

#

return_utc

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

#


3081
3082
3083
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3081

def return_utc
  ::Time.now.getutc
end

#return_utc_time_in_a_format_similar_to_slackwareObject

#

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
#


2856
2857
2858
2859
2860
2861
2862
2863
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2856

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_utcObject

#

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.

#


3050
3051
3052
3053
3054
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3050

def return_weekday_based_on_utc
  _ = return_utc
  wday = _.wday
  return DAY_NAMES[wday]
end

#return_year_based_on_utcObject

#

return_year_based_on_utc

#


3216
3217
3218
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3216

def return_year_based_on_utc
  return_utc.year.to_s
end

#revObject

#

rev (rev tag)

#


2293
2294
2295
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2293

def rev
  ::RBT.rev(use_colours?)
end

#rpnObject

#

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.

#

rpn



1304
1305
1306
1307
1308
1309
1310
1311
1312
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1304

def return_program_name(
    i, optional_padding = ' '
  )
  _ = ''.dup
  if REPORT_SPECIFIC_PROGRAM_NAME
    _ << "#{File.basename(i)}:#{optional_padding}"
  end
  return _
end

#runObject

#

run (run tag)

#


3429
3430
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3429

def run
end

#run_simulation=(i = false) ⇒ Object

#

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.

#


2448
2449
2450
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2448

def run_simulation=(i = false)
  @internal_hash[:run_simulation] = i
end

#run_simulation?Boolean Also known as: run_simulation, in_simulation?

#

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.

#

Returns:

  • (Boolean)


648
649
650
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 648

def run_simulation?
  @internal_hash[:run_simulation]
end

#sdir(i = '') ⇒ Object

#

sdir

#


2140
2141
2142
2143
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2140

def sdir(i = '')
  return ::RBT.sdir(i) if use_colours?
  return i
end

#sdir_return_pwdObject

#

sdir_return_pwd

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

#


347
348
349
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 347

def sdir_return_pwd
  sdir(return_pwd)
end

#set_be_silent(i = false) ⇒ Object Also known as: be_silent, be_quiet, set_be_quiet, do_not_be_verbose, set_do_not_be_verbose

#

set_be_silent

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

#


1905
1906
1907
1908
1909
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1905

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) ⇒ Object Also known as: be_verbose, be_verbose=

#

set_be_verbose

By default we will be verbose.

#


1934
1935
1936
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1934

def set_be_verbose(i = true)
  @internal_hash[:be_verbose] = i
end

#set_first_commandline_argument(i) ⇒ Object

#

set_first_commandline_argument

#


3459
3460
3461
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3459

def set_first_commandline_argument(i)
  @internal_hash[:commandline_arguments][0] = i
end

#set_namespace(i) ⇒ Object Also known as: set_the_namespace

#

set_namespace

#


900
901
902
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 900

def set_namespace(i)
  @internal_hash[:namespace] = i
end

#set_use_colours(i = true) ⇒ Object

#

set_use_colours

#


3592
3593
3594
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3592

def set_use_colours(i = true)
  @internal_hash[:use_colours] = i
end

#set_use_opn(i = true) ⇒ Object Also known as: do_use_opn

#

set_use_opn

#


1599
1600
1601
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1599

def set_use_opn(i = true) # Must remain true by default.
  @internal_hash[:use_opn] = i
end

#set_xorg_buffer(i) ⇒ Object

#

set_xorg_buffer

#


671
672
673
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 671

def set_xorg_buffer(i)
  ::RBT.set_xorg_buffer(i)
end

#sfancy(i = '') ⇒ Object

#

sfancy

#


2163
2164
2165
2166
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2163

def sfancy(i = '')
  return ::RBT.sfancy(i) if use_colours?
  return i
end

#sfile(i = '') ⇒ Object

#

sfile

#


2148
2149
2150
2151
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2148

def sfile(i = '')
  return ::RBT.sfile(i) if use_colours?
  return i
end

#silent_redirection?Boolean Also known as: original_stdout, original_stdout?

#

silent_redirection?

#

Returns:

  • (Boolean)


735
736
737
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 735

def silent_redirection?
  @internal_hash[:silent_redirection]
end

#silently_create_this_directory_if_it_does_not_yet_exist(i) ⇒ Object

#

silently_create_this_directory_if_it_does_not_yet_exist

#


2604
2605
2606
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2604

def silently_create_this_directory_if_it_does_not_yet_exist(i)
  create_directory(i, :be_quiet)
end

#simp(i = '', use_colours = use_colours?) ) ⇒ Object Also known as: simportant

#

simp

#


2132
2133
2134
2135
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2132

def simp(i = '', use_colours = use_colours?)
  return ::RBT.simp(i) if use_colours
  return i
end

#source_base_directory?Boolean Also known as: archive_dir?, source_directory?, source_directory, source_dir?, src_dir?

#

source_base_directory?

#

Returns:

  • (Boolean)


2750
2751
2752
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2750

def source_base_directory?
  RBT.source_base_directory?
end

#ssym(i) ⇒ Object

#

ssym

#


2171
2172
2173
2174
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2171

def ssym(i)
  return RBT.ssym(i) if use_colours?
  i
end

#stderr(i = '', use_puts_or_print = :puts) ⇒ Object

#

stderr

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

#


2695
2696
2697
2698
2699
2700
2701
2702
2703
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2695

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?Boolean Also known as: store_where?

#

store_into_this_directory?

#

Returns:

  • (Boolean)


1431
1432
1433
1434
1435
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1431

def store_into_this_directory?
  _ = RBT.store_into_this_directory?
  ensure_that_this_directory_exists(_) # Make sure that the directory exists.
  return _
end

#string_right_arrow?Boolean Also known as: right_arrow?

#

string_right_arrow?

#

Returns:

  • (Boolean)


220
221
222
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 220

def string_right_arrow?
  ''
end

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

#

swarn

#


2276
2277
2278
2279
2280
2281
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2276

def swarn(
    i = '', use_colours = use_colours?
  )
  return ::RBT.swarn(i) if use_colours
  return i
end
#

symlink (symlink tag)

Wrapper to symlinking something.

The first argument should be the existing target.

The second argument shall be the name of the new location.

Since as of November 2019, the following syntax is supported as well:

symlink(
     from: @target_directory+'lib64',
     to:   @target_directory+'lib'
   )
#


565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 565

def symlink(
    existing,
    new_location = nil,
    be_verbose   = true,
    use_colours  = RBT.use_colours? # Here we need colours/colours.rb
  )
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ====================================================================== #
    # === :be_quiet
    # ====================================================================== #
    when :be_quiet
      be_verbose = false
    end
  end
  # ======================================================================= #
  # === Handle Hashes next
  # ======================================================================= #
  if existing.is_a? Hash
    # ====================================================================== #
    # === :to
    # ====================================================================== #
    if existing.has_key?(:to) and new_location.nil?
      new_location = existing.delete(:to)
    end
    # ====================================================================== #
    # === :from
    # ====================================================================== #
    if existing.has_key?(:from)
      existing = existing.delete(:from)
    end
  end
  ::RBT.symlink(
    existing,
    new_location,
    be_verbose,
    use_colours
  )
end

#sysbin_directory?Boolean Also known as: usr_bin?

#

sysbin_directory?

#

Returns:

  • (Boolean)


2947
2948
2949
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2947

def sysbin_directory?
  RBT.sysbin_directory?
end

#sysetc_directory?Boolean Also known as: etc_dir?

#

sysetc_directory?

#

Returns:

  • (Boolean)


1116
1117
1118
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1116

def sysetc_directory?
  RBT.sysetc_directory?
end

#sysinclude_directory?Boolean Also known as: include_dir?

#

sysinclude_directory?

#

Returns:

  • (Boolean)


2961
2962
2963
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2961

def sysinclude_directory?
  RBT.sysinclude_directory?
end

#syslib_directory?Boolean Also known as: lib_dir?

#

syslib_directory?

#

Returns:

  • (Boolean)


2968
2969
2970
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2968

def syslib_directory?
  RBT.syslib_directory?
end

#sysshare_directory?Boolean Also known as: share_dir?

#

sysshare_directory?

#

Returns:

  • (Boolean)


2954
2955
2956
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2954

def sysshare_directory?
  RBT.sysshare_directory?
end

#system_directory?Boolean

#

system_directory?

#

Returns:

  • (Boolean)


2940
2941
2942
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2940

def system_directory?
  RBT.system_directory?
end

#temp_directory?Boolean Also known as: temp_dir?, temp?

#

temp_directory?

#

Returns:

  • (Boolean)


2925
2926
2927
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2925

def temp_directory?
  RBT.temp_directory?
end

#to_bool(i) ⇒ Object Also known as: to_boolean

#

to_bool

#


1336
1337
1338
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1336

def to_bool(i)
  RBT.to_bool(i)
end

#to_camelcase(i) ⇒ Object

#

to_camelcase

#


2491
2492
2493
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2491

def to_camelcase(i)
  i.split('_').map { |_| _.capitalize }.join
end

#to_iso_encoding(i) ⇒ Object

#

to_iso_encoding

#


1146
1147
1148
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1146

def to_iso_encoding(i)
  i.force_encoding(ENCODING_ISO)
end

#to_unicode(i) ⇒ Object

#

to_unicode

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

#


863
864
865
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 863

def to_unicode(i)
  i.force_encoding(ENCODING_UTF)
end

#today?(display_in_long_format = true) ⇒ Boolean

#

today?

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

#

Returns:

  • (Boolean)


2823
2824
2825
2826
2827
2828
2829
2830
2831
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2823

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) ⇒ Object Also known as: create_file, touch_file

#

touch (touch tag)

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

#


1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1385

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

#try_to_require_beautiful_urlObject

#

try_to_require_beautiful_url

#


304
305
306
307
308
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 304

def try_to_require_beautiful_url
  begin
    require 'beautiful_url'
  rescue LoadError; end
end

#try_to_require_the_environment_information_gemObject

#

try_to_require_the_environment_information_gem

#


295
296
297
298
299
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 295

def try_to_require_the_environment_information_gem
  begin
    require 'environment_information'
  rescue LoadError; end
end

#try_to_require_the_extracter_gemObject

#

try_to_require_the_extracter_gem

#


268
269
270
271
272
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 268

def try_to_require_the_extracter_gem
  begin
    require 'extracter'
  rescue LoadError; end
end

#try_to_require_the_open_gemObject

#

try_to_require_the_open_gem

#


286
287
288
289
290
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 286

def try_to_require_the_open_gem
  begin
    require 'open'
  rescue LoadError; end
end

#try_to_require_the_xorg_bufferObject

#

try_to_require_the_xorg_buffer

#


313
314
315
316
317
318
319
320
321
322
323
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 313

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_wgetObject

#

try_to_require_wget

#


277
278
279
280
281
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 277

def try_to_require_wget
  begin
    require 'wget'
  rescue LoadError; end
end

#try_to_return_a_special_compile_component(i) ⇒ Object

#

try_to_return_a_special_compile_component

#


458
459
460
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 458

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) ⇒ Object

#

unicode_cliner

#


1012
1013
1014
1015
1016
1017
1018
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1012

def unicode_cliner(
    a = :default,
    b = :default,
    &block
  )
  ::RBT.unicode_cliner(a, b, &block)
end

#unicode_middle_cliner(a = :default, b = :default) ⇒ Object Also known as: new_cliner

#

unicode_middle_cliner

#


234
235
236
237
238
239
240
241
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 234

def unicode_middle_cliner(
    a = :default,
    b = :default
  )
  ::RBT.unicode_cliner(a, b) {
    :unicode_middle_horizontal_bar
  }
end

#use_colours=(i = true) ⇒ Object

#

use_colours=

#


2118
2119
2120
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2118

def use_colours=(i = true)
  @internal_hash[:use_colours] = i
end

#use_colours?Boolean Also known as: we_may_use_colours?

#

use_colours?

Query whether we may use colours or not.

#

Returns:

  • (Boolean)


2111
2112
2113
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2111

def use_colours?
  @internal_hash[:use_colours]
end

#use_opn=(i = true) ⇒ Object

#

use_opn=

#


1606
1607
1608
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1606

def use_opn=(i = true)
  @internal_hash[:use_opn] = i
end

#use_opn?Boolean Also known as: show_opnn?

#

use_opn?

#

Returns:

  • (Boolean)


3564
3565
3566
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3564

def use_opn?
  @internal_hash[:use_opn]
end

#utf_encoding?Boolean

#

utf_encoding?

#

Returns:

  • (Boolean)


870
871
872
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 870

def utf_encoding?
  ENCODING_UTF
end

#verbose_truth(i, optional_arguments = nil) ⇒ Object Also known as: vt, verbose_truth?

#

verbose_truth

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

#


1245
1246
1247
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1245

def verbose_truth(i, optional_arguments = nil)
  RBT.verbose_truth(i, optional_arguments)
end

#word_wrap(this_text, n_characters_limit = :default) ⇒ Object Also known as: wrap_at

#

word_wrap

The first argument is the text that will be reformatted.

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

#


1464
1465
1466
1467
1468
1469
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1464

def word_wrap(
    this_text,
    n_characters_limit = :default # This should be equal to 78.
  )
  ::RBT.wrap_at(this_text, n_characters_limit)
end

#write_what_into(what, into, permissions_to_use = '755') ⇒ Object Also known as: save_file, save_what_into, store_what_into, save_what_to

#

write_what_into

Delegate towards the SaveFile functionality here.

#


1716
1717
1718
1719
1720
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1716

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') ⇒ Object

#

write_what_into_via_unicode

Delegate towards the SaveFile functionality here.

#


1693
1694
1695
1696
1697
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1693

def write_what_into_via_unicode(
    what, into, permissions_to_use = '755'
  )
  RBT.write_what_into_via_unicode(what, into, permissions_to_use)
end

#yes_or_no(i, optional_instructions = nil) ⇒ Object

#

yes_or_no

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

#


1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1271

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