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)


1256
1257
1258
1259
1260
1261
1262
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1256

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)


1391
1392
1393
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1391

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.

#


1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1401

def absolute_path(i)
  _ = File.absolute_path(i)
  # ======================================================================= #
  # Only append if it is a directory.
  # ======================================================================= #
  if File.directory?(_) and !_.end_with?('/')
    _ = _.dup if _.frozen?
    _ << '/'
  end
  return _
end

#action(action_that_is_desired = nil, optional_argument1 = ARGV, options_hash = {}, &block) ⇒ 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.

#


3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3191

def action(
    action_that_is_desired = nil,
    optional_argument1     = ARGV, # This is typically the main input to this method.
    options_hash           = {},
    &block
  )
  unless ::RBT.respond_to? :action
    require 'rbt/requires/require_actions.rb'
  end
  RBT.action(
    action_that_is_desired,
    optional_argument1,
    options_hash,
    &block
  )
end

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

#


957
958
959
960
961
962
963
964
965
966
967
968
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 957

def add_to_the_commandline_arguments(i)
  # ======================================================================= #
  # First check whether the input is a Hash:
  # ======================================================================= #
  if i.is_a? Hash
    if i.has_key? :commandline_arguments
      i = i.delete(:commandline_arguments)
    end
  end
  @internal_hash[:commandline_arguments] << i
  @internal_hash[:commandline_arguments].flatten!
end

#all_binaries?Boolean

#

all_binaries?

#

Returns:

  • (Boolean)


441
442
443
444
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 441

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

#all_files_from(this_directory) ⇒ Object

#

all_files_from

#


1455
1456
1457
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1455

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

#all_libraries?Boolean

#

all_libraries?

#

Returns:

  • (Boolean)


323
324
325
326
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 323

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)


753
754
755
756
757
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 753

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

#appdir_location_of?(i) ⇒ 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

#


1283
1284
1285
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1283

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

#append_what_into(what, into) ⇒ Object

#

append_what_into

#


1815
1816
1817
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1815

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)


1487
1488
1489
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1487

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)


2457
2458
2459
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2457

def available_programs?
  RBT.available_programs?
end

#be_quiet?Boolean

#

be_quiet?

#

Returns:

  • (Boolean)


2010
2011
2012
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2010

def be_quiet?
  !@internal_hash[:be_verbose]
end

#be_verbose?Boolean

#

be_verbose?

#

Returns:

  • (Boolean)


2003
2004
2005
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2003

def be_verbose?
  @internal_hash[:be_verbose]
end

#begins_with_a_comment?(i) ⇒ Boolean

#

begins_with_a_comment?

#

Returns:

  • (Boolean)


3281
3282
3283
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3281

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

#


2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2652

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

#


1504
1505
1506
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1504

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.

#


879
880
881
882
883
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 879

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

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

#


2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2039

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

#


3300
3301
3302
3303
3304
3305
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3300

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)


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

def cheering_person?
  '\o/'
end

#chmod(i) ⇒ Object

#

chmod

#


2423
2424
2425
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2423

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

#


1967
1968
1969
1970
1971
1972
1973
1974
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1967

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_optionsObject Also known as: clear_commandline_arguments

#

clear_commandline_options

#


623
624
625
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 623

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

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

#

cliner

#


1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1068

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

#


1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1589

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


3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3546

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

#


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

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.

#


2275
2276
2277
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2275

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.

#


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

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.

#


2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2306

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

#


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

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)


1017
1018
1019
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1017

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)


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

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

#comment(i) ⇒ Object

#

comment

#


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

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

#


3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3452

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.

#


2501
2502
2503
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2501

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.

#


2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2878

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.

#


1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1853

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.

#


1791
1792
1793
1794
1795
1796
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1791

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.

#


2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2697

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)


3445
3446
3447
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3445

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.

#


2952
2953
2954
2955
2956
2957
2958
2959
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2952

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.

#


2554
2555
2556
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2554

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

#debug?Boolean

#

debug?

#

Returns:

  • (Boolean)


1046
1047
1048
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1046

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)


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

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.

#


2802
2803
2804
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2802

def disable_colours
  @internal_hash[:use_colours] = false
end

#display_md5sum?Boolean Also known as: show_md5sum?

#

display_md5sum?

#

Returns:

  • (Boolean)


3319
3320
3321
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3319

def display_md5sum?
  RBT.display_md5sum?
end

#do_not_debugObject

#

do_not_debug

#


1060
1061
1062
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1060

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)


3508
3509
3510
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3508

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)


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

def does_this_expanded_cookbook_file_exist_for_this_program?(i)
  return File.exist?(path_to_this_expanded_cookbooks_dataset(i))
end

#does_this_file_exist?(i, prepend_this = nil) ⇒ Boolean

#

does_this_file_exist?

#

Returns:

  • (Boolean)


244
245
246
247
248
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 244

def does_this_file_exist?(
    i, prepend_this = nil
  )
  ::RBT.does_this_file_exist?(i, prepend_this)
end

#does_this_file_exist_and_is_it_a_file?(i) ⇒ Boolean

#

does_this_file_exist_and_is_it_a_file?

#

Returns:

  • (Boolean)


3356
3357
3358
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3356

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.

#


3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3517

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

#


2336
2337
2338
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2336

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

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

#

ecomment

#


2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2673

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.

#


2329
2330
2331
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2329

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

#edir(i = return_pwd) ⇒ Object

#

edir

#


2210
2211
2212
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2210

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

#editor?Boolean

#

editor?

#

Returns:

  • (Boolean)


3311
3312
3313
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3311

def editor?
  RBT.editor?
end

#efancy(i = '') ⇒ Object

#

efancy

#


2241
2242
2243
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2241

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

#eimp(i) ⇒ Object

#

simp

#


2264
2265
2266
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2264

def eimp(i)
  e simp(i)
end

#enable_coloursObject Also known as: set_use_colours, do_use_colours

#

enable_colours

#


2791
2792
2793
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2791

def enable_colours
  @internal_hash[:use_colours] = true
end

#enable_debugObject

#

enable_debug

#


1053
1054
1055
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1053

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.

#


406
407
408
409
410
411
412
413
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 406

def ensure_main_encoding_for(
    i, use_this_encoding = USE_MAIN_ENCODING
  )
  unless i.encoding.to_s.include? use_this_encoding
    i = i.force_encoding(use_this_encoding)
  end
  return i
end

#eparse(i) ⇒ Object

#

eparse

#


2398
2399
2400
2401
2402
2403
2404
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2398

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.

#


1646
1647
1648
1649
1650
1651
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1646

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.

#


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

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

#etomato(i) ⇒ Object

#

etomato

#


2409
2410
2411
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2409

def etomato(i)
  e tomato(i)
end

#ewarn(i = '') ⇒ Object

#

ewarn

#


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

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.

#


1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1920

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)


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

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

#


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

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)


3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3081

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)


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

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.

#


1427
1428
1429
1430
1431
1432
1433
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1427

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)


2633
2634
2635
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2633

def file_predefined_installation_instructions?
  RBT.file_predefined_installation_instructions
end

#file_specification_of_registered_cookbook_entriesObject

#

file_specification_of_registered_cookbook_entries

#


726
727
728
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 726

def file_specification_of_registered_cookbook_entries
  ::RBT.file_specification_of_registered_cookbook_entries
end

#find_cookbook_alias_for(i) ⇒ 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”.

#


2545
2546
2547
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2545

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


3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3222

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)


601
602
603
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 601

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

#

Returns:

  • (Boolean)


998
999
1000
1001
1002
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 998

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.

#


1206
1207
1208
1209
1210
1211
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1206

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

#


1219
1220
1221
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1219

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.

#


432
433
434
435
436
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 432

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

#get_dateObject

#

get_date

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

#


2919
2920
2921
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2919

def get_date
  ::RBT.get_date
end

#get_extended_dateObject

#

get_extended_date

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

#


2928
2929
2930
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2928

def get_extended_date
  ::RBT.get_extended_date
end

#get_files_and_directories_from(i = return_pwd) ⇒ Object

#

get_files_and_directories_from

#


1274
1275
1276
1277
1278
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1274

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.

#


2563
2564
2565
2566
2567
2568
2569
2570
2571
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2563

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)


2478
2479
2480
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2478

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)


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

def host_system?
  RBT.determine_host_architecture
end

#infer_the_namespaceObject

#

infer_the_namespace

This will assume the true namespace from the inspectable name.

#


927
928
929
930
931
932
933
934
935
936
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 927

def infer_the_namespace
  _ = inspect.to_s.delete('<')
  if _.include? ' '
    _ = _.split(' ').first.delete('#')
    if _.include? ':'
      _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::')
    end
  end
  set_the_namespace(_) # And assign it here.
end

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

#

internal_hash?

#

Returns:

  • (Boolean)


1520
1521
1522
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1520

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.

#


572
573
574
575
576
577
578
579
580
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 572

def internal_hash_set_commandline_arguments(
    i = ARGV
  )
  i = [i].flatten.compact
  if @internal_hash.nil?
    reset_the_internal_hash # Trying this since as of 10.06.2023.
  end
  @internal_hash[:commandline_arguments] = i
end

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


1982
1983
1984
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1982

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

#is_directory?(i) ⇒ Boolean

#

is_directory?

#

Returns:

  • (Boolean)


1333
1334
1335
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1333

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

#is_file?(i) ⇒ Boolean

#

is_file?

#

Returns:

  • (Boolean)


1247
1248
1249
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1247

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)


420
421
422
423
424
425
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 420

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

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


765
766
767
768
769
770
771
772
773
774
775
776
777
778
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 765

def is_make_available?(
    path = query_path?
  )
  is_make_available = false # By default it is assumed that make is NOT available.
  if path.include? ':'
    check_these_directories = path.split(':')
    check_these_directories.each {|dir|
      if File.exist?("#{dir}/make")
        is_make_available = true # Yup, make is available.
      end
    }
  end
  return is_make_available
end

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


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

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)


704
705
706
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 704

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)


843
844
845
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 843

def is_roebe?
  RBT.is_roebe?
end

#is_superuser?Boolean

#

is_superuser?

#

Returns:

  • (Boolean)


1497
1498
1499
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1497

def is_superuser?
  Process.uid == 0
end

#is_symlink?(i) ⇒ Boolean

#
#

Returns:

  • (Boolean)


379
380
381
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 379

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)


237
238
239
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 237

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

#is_this_a_library?(i) ⇒ 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)


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

def is_this_a_library?(i)
  (
    i.strip.end_with?('.so') or
    i.strip.end_with?('.a')  or
    i.strip.end_with?('.o')  or
    i.strip.include?('.so.') # <- For e. g. "libfoo.so.1.2.3"
  )
end

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


3492
3493
3494
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3492

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

#iso_encoding?Boolean

#

iso_encoding?

#

Returns:

  • (Boolean)


1233
1234
1235
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1233

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.

#


301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 301

def load_dataset_from_this_expanded_cookbook(
    i, &block
  )
  i = i.to_s unless i.is_a? String # We need Strings.
  if File.file?(i)
    use_this_file = i.dup
  else
    use_this_file = path_to_this_expanded_cookbooks_dataset(i)
  end
  if File.exist? use_this_file
    load_yaml(use_this_file) # Load the .yml file here, if it exists.
  else
    no_file_exists_at(use_this_file, &block)
    return nil
  end
end

#load_yaml(i) ⇒ Object

#

load_yaml

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

#


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

def load_yaml(i)
  YAML.load_file(i)
end

#load_yaml_file_from_the_cookbook_directory_for_this_program(i) ⇒ 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.

#


364
365
366
367
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 364

def load_yaml_file_from_the_cookbook_directory_for_this_program(i)
  target_file = "#{RBT.cookbook_directory?}#{i}.yml"
  load_yaml(target_file)
end

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


3105
3106
3107
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3105

def log_directory?
  RBT.log_directory?
end

#main_encoding?Boolean

#

main_encoding?

#

Returns:

  • (Boolean)


697
698
699
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 697

def main_encoding?
  USE_THIS_ENCODING
end

#meson_build_file_exists?(at_this_location = return_pwd, use_build_directory = false) ⇒ 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)


795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 795

def meson_build_file_exists?(
    at_this_location    = return_pwd,
    use_build_directory = false
  )
  case at_this_location
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    at_this_location = return_pwd
  end
  if File.exist?(at_this_location) and File.file?(at_this_location)
    return true
  else
    # ===================================================================== #
    # Next check whether we do use a build directory or whether we do not.
    # ===================================================================== #
    if use_build_directory
      # =================================================================== #
      # Check the directory below the one given next:
      # =================================================================== #
      target_file = File.absolute_path("#{at_this_location}../meson.build")
      check_for_this_file = target_file
    else
      check_for_this_file = "#{at_this_location}meson.build"
    end
    return File.exist?(check_for_this_file) # Perform the check here.
  end
end

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


2910
2911
2912
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2910

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

#


736
737
738
739
740
741
742
743
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 736

def move_file(
    this_file, where_to, be_verbose = true
  )
  if be_verbose
    e "#{rev}Moving from #{sfile(this_file)} to #{sfile(where_to)}."
  end
  FileUtils.mv(this_file, where_to)
end

#n_programs_are_available?Boolean

#

n_programs_are_available?

#

Returns:

  • (Boolean)


2471
2472
2473
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2471

def n_programs_are_available?
  available_programs?.size
end

#n_programs_available?Boolean Also known as: n_programs_available

#

n_programs_available?

#

Returns:

  • (Boolean)


387
388
389
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 387

def n_programs_available?
  RBT.n_programs_available?
end

#namespace?Boolean

#

namespace?

#

Returns:

  • (Boolean)


941
942
943
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 941

def namespace?
  @internal_hash[:namespace]
end

#no_directory_exists_at(i) ⇒ Object

#

no_directory_exists_at

#


2521
2522
2523
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2521

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

#no_opnObject Also known as: disable_opn

#

no_opn

#


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

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

#


2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2599

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}No file called `#{sfile(i)}#{rev}` appears to exist."
  end
end

#open_in_browser(i = nil) ⇒ Object

#

open_in_browser

#


3363
3364
3365
3366
3367
3368
3369
3370
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3363

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.

#


3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3328

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

#


1771
1772
1773
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1771

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

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

#

opne (opne tag)

#


3383
3384
3385
3386
3387
3388
3389
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3383

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

#opnef(i) ⇒ Object

#

opnef (opnef tag)

#


3375
3376
3377
3378
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3375

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

#


3394
3395
3396
3397
3398
3399
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3394

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.

#


1658
1659
1660
1661
1662
1663
1664
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1658

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

#


1725
1726
1727
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1725

def opnesystem(i)
  opnn; esystem i
end

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

#

opnewarn

#


1756
1757
1758
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1756

def opnewarn(i)
  opne swarn(i)
end

#opnfancy(i = '') ⇒ Object

#

opnfancy

#


1764
1765
1766
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1764

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.

#


1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1737

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

#packages_directory?Boolean

#

packages_directory?

#

Returns:

  • (Boolean)


1103
1104
1105
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1103

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

#


2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2817

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)


1267
1268
1269
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1267

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)


2640
2641
2642
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2640

def predefined_installation_instructions? 
  RBT.predefined_installation_instructions?
end

#prepend_this_commandline_argument(i) ⇒ Object

#

prepend_this_commandline_argument

#


587
588
589
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 587

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

#program_version_of?(i) ⇒ Boolean

#

program_version_of?

#

Returns:

  • (Boolean)


2852
2853
2854
2855
2856
2857
2858
2859
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2852

def program_version_of?(i)
  if Object.const_defined? :ProgramInformation
    if i.include?('-')
      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)


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

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)


830
831
832
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 830

def project_yaml_directory?
  RBT.yaml_directory?
end

#query_path?Boolean

#

query_path?

Query the $PATH variable, from within ENV.

#

Returns:

  • (Boolean)


3264
3265
3266
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3264

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.

#


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

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

#


1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1438

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

#


3058
3059
3060
3061
3062
3063
3064
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3058

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.

#


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

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.

#


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

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

#


851
852
853
854
855
856
857
858
859
860
861
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 851

def register_sigint(
    optional_message      = nil,
    use_this_as_exit_code = 0
  )
  Signal.trap('SIGINT') {
    if optional_message
      e optional_message
    end
    exit(use_this_as_exit_code)
  }
end

#registered_cookbook_entries?Boolean

#

registered_cookbook_entries?

#

Returns:

  • (Boolean)


711
712
713
714
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 711

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.

#


1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1145

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

#


2623
2624
2625
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2623

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.

#


345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 345

def remove_comments_from_each_line(i)
  if i.include? ' # '
    i = i.split(N).map {|line|
      if line.include? ' # '
        line = line[0 .. (line.index('#') - 1)]
        line.strip!
      end
      line
    }.join(N)
  end
  i
end

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

#


2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2986

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

#remove_double_slashes(i) ⇒ Object Also known as: rds

#

remove_double_slashes (rds tag)

Replace // with / in a given string.

#


1533
1534
1535
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1533

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.

#


1835
1836
1837
1838
1839
1840
1841
1842
1843
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1835

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.

#


3290
3291
3292
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3290

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

#remove_parens(i) ⇒ Object

#

remove_parens

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

#


1342
1343
1344
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1342

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

This method can be used to selectively remove a symlink.

#


451
452
453
454
455
456
457
458
459
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 451

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

#


612
613
614
615
616
617
618
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 612

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

#remove_this_entry_from_the_commandline_arguments(i) ⇒ Object

#

remove_this_entry_from_the_commandline_arguments

#


1008
1009
1010
1011
1012
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1008

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.

#


2388
2389
2390
2391
2392
2393
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2388

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.

#


532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 532

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

#rename(old_name, new_name) ⇒ Object

#

rename

#


2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2583

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

#


272
273
274
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 272

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

#require_the_rbt_aliasesObject

#

require_the_rbt_aliases

#


690
691
692
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 690

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

#


1240
1241
1242
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1240

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, hyphen_arguments, hyphened_arguments?

#

return_commandline_arguments_with_leading_hyphens

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

#


978
979
980
981
982
983
984
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 978

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

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

#


3254
3255
3256
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3254

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.

#


3481
3482
3483
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3481

def return_date
  RBT.return_date
end

#return_day_of_the_month_based_on_utcObject

#

return_day_of_the_month_based_on_utc

#


3413
3414
3415
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3413

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

#


3406
3407
3408
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3406

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

#


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

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.

#


397
398
399
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 397

def return_location_to_this_programs_yaml_file(i)
  RBT.return_location_to_this_programs_yaml_file(i)
end

#return_month_based_on_this_number(i) ⇒ 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.

#


3471
3472
3473
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3471

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

#return_month_based_on_utcObject

#

return_month_based_on_utc

#


3435
3436
3437
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3435

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

#return_opnn(i = nil) ⇒ Object

#

return_opnn

#


1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1700

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_information(i) ⇒ Object Also known as: return_program_name

#

return_program_information

#


3069
3070
3071
3072
3073
3074
3075
3076
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3069

def return_program_information(i)
  if Object.const_defined? :ProgramInformation
    if i.include?('-')
      i = ProgramInformation.return_real_short_name(i)
    end
  end
  return i
end

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

#


2514
2515
2516
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2514

def return_program_name_for_gobolinux_systems(i)
  return i
end

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

#

return_pwd

#


253
254
255
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 253

def return_pwd
  RBT.return_pwd
end

#return_unicode_warning_symbol_or_empty_stringObject

#

return_unicode_warning_symbol_or_empty_string

#


2437
2438
2439
2440
2441
2442
2443
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2437

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

#


3274
3275
3276
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3274

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
#


2970
2971
2972
2973
2974
2975
2976
2977
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2970

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.

#


3243
3244
3245
3246
3247
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3243

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

#


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

def return_year_based_on_utc
  return_utc.year.to_s
end

#revObject

#

rev (rev tag)

#


2378
2379
2380
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2378

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

#runObject

#

run (run tag)

#


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

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.

#


2533
2534
2535
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2533

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)


562
563
564
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 562

def run_simulation?
  @internal_hash[:run_simulation]
end

#sdir(i = '') ⇒ Object

#

sdir

#


2225
2226
2227
2228
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2225

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

#


265
266
267
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 265

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.

#


1992
1993
1994
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1992

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.

#


2019
2020
2021
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2019

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

#set_first_commandline_argument(i) ⇒ Object

#

set_first_commandline_argument

#


594
595
596
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 594

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

#


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

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

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

#

set_use_opn

#


1679
1680
1681
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1679

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

#


719
720
721
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 719

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

#sfancy(i = '') ⇒ Object

#

sfancy

#


2248
2249
2250
2251
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2248

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

#sfile(i = '') ⇒ Object

#

sfile

#


2233
2234
2235
2236
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2233

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)


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

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

#


2687
2688
2689
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2687

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

#


2217
2218
2219
2220
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2217

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)


2864
2865
2866
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2864

def source_base_directory?
  RBT.source_base_directory?
end

#ssym(i) ⇒ Object

#

ssym

#


2256
2257
2258
2259
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2256

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.

#


2778
2779
2780
2781
2782
2783
2784
2785
2786
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2778

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)


1511
1512
1513
1514
1515
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1511

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

#


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

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


479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 479

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)


3140
3141
3142
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3140

def sysbin_directory?
  RBT.sysbin_directory?
end

#sysetc_directory?Boolean Also known as: etc_dir?

#

sysetc_directory?

#

Returns:

  • (Boolean)


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

def sysetc_directory?
  RBT.sysetc_directory?
end

#sysinclude_directory?Boolean Also known as: include_dir?

#

sysinclude_directory?

#

Returns:

  • (Boolean)


3154
3155
3156
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3154

def sysinclude_directory?
  RBT.sysinclude_directory?
end

#syslib_directory?Boolean Also known as: lib_dir?

#

syslib_directory?

#

Returns:

  • (Boolean)


3161
3162
3163
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3161

def syslib_directory?
  RBT.syslib_directory?
end

#sysshare_directory?Boolean Also known as: share_dir?

#

sysshare_directory?

#

Returns:

  • (Boolean)


3147
3148
3149
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3147

def sysshare_directory?
  RBT.sysshare_directory?
end

#system_directory?Boolean

#

system_directory?

#

Returns:

  • (Boolean)


3133
3134
3135
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3133

def system_directory?
  RBT.system_directory?
end

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

#

temp_directory?

#

Returns:

  • (Boolean)


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

def temp_directory?
  RBT.temp_directory?
end

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

#

to_bool

#


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

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

#to_camelcase(i) ⇒ Object

#

to_camelcase

#


2576
2577
2578
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2576

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

#to_iso_encoding(i) ⇒ Object

#

to_iso_encoding

#


1226
1227
1228
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1226

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.

#


911
912
913
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 911

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

#today?(display_in_long_format = true) ⇒ Boolean

#

today?

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

#

Returns:

  • (Boolean)


2937
2938
2939
2940
2941
2942
2943
2944
2945
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2937

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.

#


1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1465

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

#


666
667
668
669
670
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 666

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

#try_to_require_the_environment_information_gemObject

#

try_to_require_the_environment_information_gem

#


657
658
659
660
661
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 657

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

#try_to_require_the_extracter_gemObject

#

try_to_require_the_extracter_gem

#


630
631
632
633
634
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 630

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

#try_to_require_the_open_gemObject

#

try_to_require_the_open_gem

#


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

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

#try_to_require_the_xorg_bufferObject

#

try_to_require_the_xorg_buffer

#


675
676
677
678
679
680
681
682
683
684
685
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 675

def try_to_require_the_xorg_buffer
  begin
    require 'xorg_buffer' # or: require 'xorg_buffer/module'
  rescue LoadError
    if RUBY_PLATFORM.include?('linux') and
      is_on_roebe?
      puts 'The gem called `xorg_buffer` is unavailable. '\
           'Consider installing it.'
    end
  end
end

#try_to_require_wgetObject

#

try_to_require_wget

#


639
640
641
642
643
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 639

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

#try_to_return_a_special_compile_component(i) ⇒ Object

#

try_to_return_a_special_compile_component

#


372
373
374
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 372

def try_to_return_a_special_compile_component(i)
  action(:try_to_return_a_special_compile_component, i)
end

#unicode_cliner(a = :default, b = :default, &block) ⇒ Object

#

unicode_cliner

#


1082
1083
1084
1085
1086
1087
1088
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1082

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

#unicode_middle_cliner(a = :default, b = :default) ⇒ Object

#

unicode_middle_cliner

#


1093
1094
1095
1096
1097
1098
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1093

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=

#


2203
2204
2205
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2203

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)


2196
2197
2198
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2196

def use_colours?
  @internal_hash[:use_colours]
end

#use_opn=(i = true) ⇒ Object

#

use_opn=

#


1686
1687
1688
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1686

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

#use_opn?Boolean Also known as: show_opnn?

#

use_opn?

#

Returns:

  • (Boolean)


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

def use_opn?
  @internal_hash[:use_opn]
end

#utf_encoding?Boolean

#

utf_encoding?

#

Returns:

  • (Boolean)


918
919
920
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 918

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.

#


1325
1326
1327
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1325

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.

#


1544
1545
1546
1547
1548
1549
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1544

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.

#


1803
1804
1805
1806
1807
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1803

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.

#


1780
1781
1782
1783
1784
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1780

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.

#


1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1351

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