class Cookbooks::Base

Constants

KONSOLE
#

KONSOLE

#

Public Class Methods

registered_binaries?() click to toggle source
#

::registered_binaries?

Tell us where our binaries are registered.

#
# File lib/cookbooks/base/base.rb, line 61
def self.registered_binaries?
  Cookbooks.all_binaries?
end

Public Instance Methods

CookbookDirectory?() click to toggle source
#

CookbookDirectory?

The name is not pretty, but we use it for now. Perhaps at a later time we will change it to “cookbook_directory?” or something like that, but presently (Jan 2018) this conflicts with an alias. We may have to get rid of the alias, and also change all the code that uses that alias.

#
# File lib/cookbooks/base/prototype.rb, line 525
def CookbookDirectory?
  temp_directory?+'CookbookDirectory/'
end
all_available_programs?()
Alias for: available_programs?
all_binaries?() click to toggle source
#

all_binaries?

#
# File lib/cookbooks/base/prototype.rb, line 371
def all_binaries?
  ::Cookbooks.all_binaries?
end
all_libraries?() click to toggle source
#

all_libraries?

#
# File lib/cookbooks/base/prototype.rb, line 378
def all_libraries?
  ::Cookbooks.all_libraries?
end
append_what_into(what, into) click to toggle source
#

#append_what_into

#
# File lib/cookbooks/base/base.rb, line 52
def append_what_into(what, into)
  Cookbooks::SaveFile.append_what_into(what, into)
end
archive_dir?()
Alias for: source_directory?
available_cookbook_files?(show_how = :show_only_name)
Alias for: cookbook_files?
available_cookbooks()
Alias for: available_programs?
available_cookbooks?()
Alias for: available_programs?
available_programs()
Alias for: available_programs?
available_programs?() click to toggle source
#

#available_programs

Feedback which programs are available, in sorted Array form.

#
# File lib/cookbooks/base/base.rb, line 42
def available_programs?
  Cookbooks.available_cookbooks?
end
be_quiet(i = false)
Alias for: set_be_silent
be_silent(i = false)
Alias for: set_be_silent
be_verbose(i = true)
Alias for: set_be_verbose
be_verbose=(i) click to toggle source
#

#be_verbose=

#
# File lib/cookbooks/base/prototype.rb, line 269
def be_verbose=(i)
  @be_verbose = i
end
be_verbose?() click to toggle source
#

#be_verbose?

#
# File lib/cookbooks/base/prototype.rb, line 292
def be_verbose?
  @be_verbose
end
cadetblue(i) click to toggle source
#

cadetblue

#
# File lib/cookbooks/base/colours.rb, line 308
def cadetblue(i)
  return KONSOLE.cadetblue(i) if use_colours?
  i
end
cd(i, be_verbose = true)
Alias for: change_directory
change_directory(i, be_verbose = true) click to toggle source
#

#change_directory

Use this to change directory.

#
# File lib/cookbooks/base/prototype.rb, line 427
def change_directory(i, be_verbose = true)
  case be_verbose
  when :be_quiet
    be_verbose = false
  end
  if be_verbose
    e 'Changing into the directory `'+sdir(i.to_s)+'` now.'
  end
  FileUtils.cd(i)
end
Also aliased as: cd
chop_off_archive(i) click to toggle source
#

#chop_off_archive

Remove the trailing part of an archive. This isn't very sophisticated but it “just works” (TM).

#
# File lib/cookbooks/base/prototype.rb, line 238
def chop_off_archive(i)
  if i.include? '#' # Chop off at '#' characters.
    i = i[0..(i.index('#')-1)]
  end
  i.sub!(/\.source$/,'') if i.include? 'source'
  i.sub!(/-stable$/,'')  if i.end_with? '-stable'
  i = i.sub(/&type=zip$/,'').
        sub(/\.lz$/,'').
        sub(/\.gz$/,'').
        sub(/\.xz$/,'').
        sub(/\.bz2$/,'').
        sub(/\.tar$/,'').
        sub(/\.zip$/,'').
        sub(/\.js$/,'')
  return i
end
cliner( i = '=', use_this_colour = nil ) { || ... } click to toggle source
#

cliner

#
# File lib/cookbooks/base/cliner.rb, line 14
def cliner(
    i = '=',
    use_this_colour = nil
  )
  result = ''.dup
  append = ''.dup
  if use_colours?
    if use_this_colour
      if i.is_a? Symbol
        use_this_colour = Colours::Konsole.send(i)
      end
      result << use_this_colour
      append << Colours.rev
    end
  end
  if i.is_a? Symbol
    i = '=' # Restore to the default here.
  end
  result << (i * 80)
  result << append unless append.empty?
  puts result
  if block_given?
    yield
    cliner('=', use_this_colour)
  end
end
cookbook_directory?()
cookbook_files?(show_how = :show_only_name) click to toggle source
#

cookbook_files?

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

Usage example:

cookbook_files?(:show_full_path)
#
# File lib/cookbooks/base/prototype.rb, line 220
def cookbook_files?(show_how = :show_only_name)
  result = Dir[individual_cookbooks_directory?+'*yml'].sort
  case show_how
  when :show_only_name # In this case, show only the name.
    result.map! {|entry|
      File.basename(entry).gsub( File.extname(entry), '' )
    }
  when :show_full_path # In this case make no modifications.
  end
  return result
end
Also aliased as: available_cookbook_files?
cookbooks_directory?()
copy_file(file, where_to) click to toggle source
#

#copy_file (copy file, cp tag, copy tag)

Use this method to copy a file.

#
# File lib/cookbooks/base/prototype.rb, line 117
def copy_file(file, where_to)
  FileUtils.cp(file, where_to)
end
Also aliased as: cp
cornflowerblue(i) click to toggle source
#

cornflowerblue

#
# File lib/cookbooks/base/colours.rb, line 252
def cornflowerblue(i)
  return KONSOLE.cornflowerblue(i) if use_colours?
  i
end
cp(file, where_to)
Alias for: copy_file
create_directory(i) click to toggle source
#

#create_directory

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

#
# File lib/cookbooks/base/prototype.rb, line 77
def create_directory(i)
  unless File.directory? i
    opnn; e 'Creating directory `'+sdir(i)+'` now.'
    FileUtils.mkdir_p(i)
  end
end
create_file( i, be_verbose = false )
Alias for: touch
crimson(i) click to toggle source
#

crimson

#
# File lib/cookbooks/base/colours.rb, line 100
def crimson(i)
  return KONSOLE.crimson(i) if use_colours?
  i
end
cyan(i) click to toggle source
#

cyan

#
# File lib/cookbooks/base/colours.rb, line 180
def cyan(i)
  return KONSOLE.cyan(i) if use_colours?
  i
end
darkseagreen(i) click to toggle source
#

darkseagreen

#
# File lib/cookbooks/base/colours.rb, line 244
def darkseagreen(i)
  return KONSOLE.darkseagreen(i) if use_colours?
  i
end
darkslateblue(i) click to toggle source
#

darkslateblue

#
# File lib/cookbooks/base/colours.rb, line 228
def darkslateblue(i)
  return KONSOLE.darkslateblue(i) if use_colours?
  i
end
debug?() click to toggle source
#

debug?

#
# File lib/cookbooks/base/debug.rb, line 18
def debug?
  @debug
end
deepskyblue(i) click to toggle source
#

deepskyblue

#
# File lib/cookbooks/base/colours.rb, line 300
def deepskyblue(i)
  return KONSOLE.deepskyblue(i) if use_colours?
  i
end
delete(i)
Alias for: remove_file
delete_file(i)
Alias for: remove_file
determine_archive_type(i) click to toggle source
#

#determine_archive_type

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

#
# File lib/cookbooks/base/prototype.rb, line 198
def determine_archive_type(i)
  _ = ''
  if    i.include? '.tar.xz'
    _ = '.tar.xz'
  elsif i.include? '.tar.gz'
    _ = '.tar.gz'
  elsif i.include? '.tar.bz2'
    _ = '.tar.bz2'
  else # else use the extension name.
    _ = File.extname(i)
  end
  return _
end
disable_colours() click to toggle source
#

#disable_colours

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

#
# File lib/cookbooks/base/colours.rb, line 38
def disable_colours
  ::Cookbooks.disable_colours
end
Also aliased as: do_not_use_colours
display_md5sum?() click to toggle source
#

display_md5sum?

#
# File lib/cookbooks/base/prototype.rb, line 357
def display_md5sum?
  ::Cookbooks.display_md5sum?
end
Also aliased as: show_md5sum?
do_not_debug() click to toggle source
#

#do_not_debug

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

#do_not_show_names

#
# File lib/cookbooks/base/prototype.rb, line 364
def do_not_show_names
  ::Cookbooks.do_not_show_names
end
do_not_use_colours()
Alias for: disable_colours
e(i = '') click to toggle source
#

e

#
# File lib/cookbooks/base/prototype.rb, line 163
def e(i = '')
  Cookbooks.e(i)
end
ecomment(i = '') click to toggle source
#

ecomment

#
# File lib/cookbooks/base/colours.rb, line 61
def ecomment(i = '')
  ::Colours.ecomment(i)
end
edir(i = '') click to toggle source
#

edir

#
# File lib/cookbooks/base/colours.rb, line 54
def edir(i = '')
  e sdir(i)
end
enable_colours() click to toggle source
#

#enable_colours

#
# File lib/cookbooks/base/colours.rb, line 28
def enable_colours
  ::Cookbooks.enable_colours
end
enable_debug() click to toggle source
#

#enable_debug

#
# File lib/cookbooks/base/debug.rb, line 11
def enable_debug
  @debug = true
end
ensure_main_encoding_for(i) click to toggle source
#

#ensure_main_encoding_for

The input to this method should be a String object.

#
# File lib/cookbooks/base/prototype.rb, line 473
def ensure_main_encoding_for(i)
  unless i.encoding.to_s.include? USE_MAIN_ENCODING
    i = i.force_encoding(USE_MAIN_ENCODING)
  end
  return i
end
ensure_that_this_directory_exists(i)
Alias for: create_directory
esystem(i) click to toggle source
#

esystem

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

#
# File lib/cookbooks/base/prototype.rb, line 408
def esystem(i)
  e i
  system i
end
ewarn(i = '') click to toggle source
#

ewarn

#
# File lib/cookbooks/base/colours.rb, line 372
def ewarn(i = '')
  e swarn(i)
end
expanded_cookbooks_directory_exists?() click to toggle source
#

expanded_cookbooks_directory_exists?

This method will try if the expanded-cookbooks directory exists, and false otherwise.

#
# File lib/cookbooks/base/prototype.rb, line 512
def expanded_cookbooks_directory_exists?
  File.directory? temp_directory?+'CookbookDirectory/expanded_cookbooks/'
end
fast_return_file_size_of_this_program(i) click to toggle source
#

#fast_return_file_size_of_this_program

#
# File lib/cookbooks/base/base.rb, line 126
def fast_return_file_size_of_this_program(i)
  ::Cookbooks.fast_return_file_size_of_this_program(i)
end
firebrick(i) click to toggle source
#

firebrick

#
# File lib/cookbooks/base/colours.rb, line 116
def firebrick(i)
  return KONSOLE.firebrick(i) if use_colours?
  i
end
gem_version(i) click to toggle source
#

#gem_version

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

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

#
# File lib/cookbooks/base/base.rb, line 110
def gem_version(i)
  i = i.to_s.delete('vr')
  begin
    if i =~ /\d+/ # Must have at the least one number.
      return Gem::Version.new(i)
    end
  rescue ArgumentError => error
    opnn; e 'An error occurred in gem_version()'
    pp error
  end
  nil # Indicate "failure" aka unable to parse this version.
end
get_date() click to toggle source
#

#get_date

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

#
# File lib/cookbooks/base/time.rb, line 35
def get_date
  ::Cookbooks.get_date
end
grey(i) click to toggle source
#

grey

#
# File lib/cookbooks/base/colours.rb, line 196
def grey(i)
  return KONSOLE.grey(i) if use_colours?
  i
end
include?(i)
included?(i)
includes?(i)
includes_this_program?(i)
individual_cookbooks_dir?()
individual_cookbooks_directory?() click to toggle source
#

individual_cookbooks_directory?

Pointer towards the local individual_cookbooks_directory/ directory.

#
# File lib/cookbooks/base/prototype.rb, line 492
def individual_cookbooks_directory? 
  ::Cookbooks.individual_cookbooks_directory?
end
is_included?(i)
is_on_roebe?()
Alias for: on_roebe?
is_this_program_included?(i) click to toggle source
#

is_this_program_included?

#
# File lib/cookbooks/base/base.rb, line 92
def is_this_program_included?(i)
  ::Cookbooks.program_is_included?(i)
end
lightblue(i) click to toggle source
#

lightblue

#
# File lib/cookbooks/base/colours.rb, line 124
def lightblue(i)
  return KONSOLE.lightblue(i) if use_colours?
  i
end
lightgreen(i = '') click to toggle source
#

lightgreen

#
# File lib/cookbooks/base/colours.rb, line 348
def lightgreen(i = '')
  return KONSOLE.lightgreen(i) if use_colours?
  i
end
lightslategray(i) click to toggle source
#

lightslategray

#
# File lib/cookbooks/base/colours.rb, line 220
def lightslategray(i)
  return KONSOLE.lightslategray(i) if use_colours?
  i
end
limegreen(i) click to toggle source
#

limegreen

#
# File lib/cookbooks/base/colours.rb, line 236
def limegreen(i)
  return KONSOLE.limegreen(i) if use_colours?
  i
end
log_dir?()
Alias for: temp_directory?
main_encoding?() click to toggle source
#

main_encoding?

#
# File lib/cookbooks/base/prototype.rb, line 483
def main_encoding?
  USE_THIS_ENCODING
end
mediumorchid(i) click to toggle source
#

mediumorchid

#
# File lib/cookbooks/base/colours.rb, line 268
def mediumorchid(i)
  return KONSOLE.mediumorchid(i) if use_colours?
  i
end
mediumpurple(i = '') click to toggle source
#

mediumpurple

#
# File lib/cookbooks/base/colours.rb, line 332
def mediumpurple(i = '')
  return KONSOLE.mediumpurple(i) if use_colours?
  i
end
mediumseagreen(i) click to toggle source
#

mediumseagreen

#
# File lib/cookbooks/base/colours.rb, line 204
def mediumseagreen(i)
  return KONSOLE.mediumseagreen(i) if use_colours?
  i
end
mediumslateblue(i) click to toggle source
#

mediumslateblue

#
# File lib/cookbooks/base/colours.rb, line 260
def mediumslateblue(i)
  return KONSOLE.mediumslateblue(i) if use_colours?
  i
end
mediumspringgreen(i) click to toggle source
#

mediumspringgreen

#
# File lib/cookbooks/base/colours.rb, line 156
def mediumspringgreen(i)
  return KONSOLE.mediumspringgreen(i) if use_colours?
  i
end
mediumturquoise(i) click to toggle source
#

mediumturquoise

#
# File lib/cookbooks/base/colours.rb, line 284
def mediumturquoise(i)
  return KONSOLE.mediumturquoise(i) if use_colours?
  i
end
mkdir(i)
Alias for: create_directory
move_file(old, new) click to toggle source
#

#move_file (mv file)

#
# File lib/cookbooks/base/prototype.rb, line 124
def move_file(old, new)
  e 'Moving from '+sfile(old)+' to '+sfile(new)+'.'
  FileUtils.mv(old, new)
end
olivedrab(i) click to toggle source
#

olivedrab

#
# File lib/cookbooks/base/colours.rb, line 212
def olivedrab(i)
  return KONSOLE.olivedrab(i) if use_colours?
  i
end
on_roebe?() click to toggle source
#

on_roebe?

#
# File lib/cookbooks/base/prototype.rb, line 276
def on_roebe?
  ::Cookbooks.on_roebe?
end
Also aliased as: is_on_roebe?
opnn(namespace = NAMESPACE) click to toggle source
#

opnn

#
# File lib/cookbooks/base/prototype.rb, line 258
def opnn(namespace = NAMESPACE)
  if namespace.is_a? String
    namespace = namespace.delete('.')
    namespace = { namespace: namespace }
  end
  Opn.opn(namespace)
end
orange(i = '') click to toggle source
#

orange

#
# File lib/cookbooks/base/colours.rb, line 316
def orange(i = '')
  return KONSOLE.orange(i) if use_colours?
  i
end
plum(i) click to toggle source
#

plum

#
# File lib/cookbooks/base/colours.rb, line 108
def plum(i)
  return KONSOLE.plum(i) if use_colours?
  i
end
powderblue(i) click to toggle source
#

powderblue

#
# File lib/cookbooks/base/colours.rb, line 164
def powderblue(i)
  return KONSOLE.powderblue(i) if use_colours?
  i
end
program_was_found?(i)
programs_dir?() click to toggle source
#

programs_dir?

#
# File lib/cookbooks/base/prototype.rb, line 392
def programs_dir?
  ::Cookbooks.programs_directory?.dup
end
Also aliased as: programs_directory?
programs_directory?()
Alias for: programs_dir?
project_yaml_directory?() click to toggle source
#

project_yaml_directory?

#
# File lib/cookbooks/base/prototype.rb, line 385
def project_yaml_directory?
  ::Cookbooks::PROJECT_YAML_DIRECTORY
end
publish_list_of_all_programs_version() click to toggle source
#

#publish_list_of_all_programs_version

#
# File lib/cookbooks/base/ftp.rb, line 14
def publish_list_of_all_programs_version
  ::Cookbooks.publish_list_of_all_programs_version
end
rds(i)
read_file(i) click to toggle source
#

#read_file

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

#
# File lib/cookbooks/base/prototype.rb, line 108
def read_file(i)
  File.read(i)
end
register_sigint( optional_message = nil, use_this_as_exit_code = 0 ) click to toggle source
#

#register_sigint

#
# File lib/cookbooks/base/prototype.rb, line 59
def register_sigint(
    optional_message      = nil,
    use_this_as_exit_code = 0
  )
  Signal.trap('SIGINT') {
    if optional_message
      e optional_message
    end
    exit(use_this_as_exit_code)
  }
end
remove_double_slashes(i) click to toggle source
#

#remove_double_slashes (rds tag)

Replace // with / in a given string.

#
# File lib/cookbooks/base/prototype.rb, line 99
def remove_double_slashes(i)
  i.squeeze '/'
end
Also aliased as: rds
remove_extension(i, also_remove_the_basename = true)
remove_file(i) click to toggle source
#

#remove_file (remove tag)

Use this method whenever you wish to remove a file.

#
# File lib/cookbooks/base/prototype.rb, line 134
def remove_file(i)
  if File.exist? i
    File.delete(i) if File.file? i
  end
end
Also aliased as: delete_file, delete
remove_file_extension(i, also_remove_the_basename = true) click to toggle source
#

#remove_file_extension

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

#
# File lib/cookbooks/base/prototype.rb, line 336
def remove_file_extension(i, also_remove_the_basename = true)
  case also_remove_the_basename
  when :do_not_strip_anything
    also_remove_the_basename = false
  end
  if also_remove_the_basename
    i = File.basename(i)
  end
  if    i.end_with? '.src'
    i[-4,4] = ''
  elsif i.end_with? '-src'
    i[-4,4] = ''
  end
  i = remove_unnecessary_data_from_url(i.to_s.dup)
  ::Cookbooks.remove_file_suffix(i) # Always return it.
end
remove_file_suffix(i, also_remove_the_basename = true)
remove_newlines(i) click to toggle source
#

#remove_newlines

Get rid of the newlines.

#
# File lib/cookbooks/base/prototype.rb, line 90
def remove_newlines(i)
  i.delete("\n")
end
remove_unnecessary_data_from_url(i) click to toggle source
#

#remove_unnecessary_data_from_url

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

#
# File lib/cookbooks/base/prototype.rb, line 173
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=/,'').
    gsub(/\/download$/,'').
    gsub(/\?download$/,'').
    gsub(/-fullsrc/,'').
    gsub(/-source/,'').
    gsub(/\?use_mirror=dfn/,'').
    gsub(/\.src/,'').
    gsub(/-src/,'')
    # .gsub(/_/,'-') # This here may be controversial, hence it
                     # was disabled it as of Jun 2010.
    # i = remove_file_extension(i)
    # ^^^ We can not do the above, because program_full_name
    # must include the archive.
end
report_n_programs() click to toggle source
#

#report_n_programs

Usage example for the report functionality of this method:

report_n_programs
#
# File lib/cookbooks/base/base.rb, line 85
def report_n_programs
  consider_reporting_how_many_programs_are_registered
end
reset() click to toggle source
#

reset

#
# File lib/cookbooks/base/reset.rb, line 8
def reset
  @be_verbose  = true
  # ======================================================================= #
  # Report how many programs are registered. If true, then we will
  # report it.
  # ======================================================================= #
  @report_how_many_programs_are_registered = true
  @debug = false # Whether we will debug or not.
  @be_verbose = true
end
return_archive_type(i) click to toggle source
#

#return_archive_type

#
# File lib/cookbooks/base/prototype.rb, line 399
def return_archive_type(i)
  ::Cookbooks.return_archive_type(i)
end
return_current_hour_minutes_second() click to toggle source
#

#return_current_hour_minutes_second

#
# File lib/cookbooks/base/time.rb, line 51
def return_current_hour_minutes_second
  Time.now.strftime '%H:%M:%S'
end
return_date() click to toggle source
#

#return_date

This method wil return a date such as “21.09.2017”.

#
# File lib/cookbooks/base/time.rb, line 44
def return_date
  ::Cookbooks.return_date
end
return_day_of_the_month_based_on_utc() click to toggle source
#

#return_day_of_the_month_based_on_utc

#
# File lib/cookbooks/base/time.rb, line 78
def return_day_of_the_month_based_on_utc
  return_utc.day.to_s
end
return_full_time() click to toggle source
#

#return_full_time

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

#
# File lib/cookbooks/base/time.rb, line 60
def return_full_time
  return_date+', '+return_current_hour_minutes_second
end
return_hours_minutes_seconds_based_on_utc() click to toggle source
#

#return_hours_minutes_seconds_based_on_utc

#
# File lib/cookbooks/base/time.rb, line 92
def return_hours_minutes_seconds_based_on_utc
  _ = return_utc
  _.strftime('%H:%M:%S') 
end
return_month_based_on_this_number(i) click to toggle source
#

#return_month_based_on_this_number

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

#
# File lib/cookbooks/base/time.rb, line 126
def return_month_based_on_this_number(i)
  Date::MONTHNAMES[i.to_i]
end
return_month_based_on_utc() click to toggle source
#

#return_month_based_on_utc

#
# File lib/cookbooks/base/time.rb, line 116
def return_month_based_on_utc
  Date::MONTHNAMES[return_utc.month]
end
return_program_full_name_from_url(i)
return_utc() click to toggle source
#

#return_utc

#
# File lib/cookbooks/base/time.rb, line 17
def return_utc
  Time.now.getutc
end
return_utc_time_in_a_format_similar_to_slackware() click to toggle source
#

#return_utc_time_in_a_format_similar_to_slackware

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

Thu Sep 21 01:23:24 UTC 2017
#
# File lib/cookbooks/base/time.rb, line 104
def return_utc_time_in_a_format_similar_to_slackware
  return_weekday_based_on_utc.to_s+' '+
  return_month_based_on_utc.to_s+' '+
  return_day_of_the_month_based_on_utc+' '+
  return_hours_minutes_seconds_based_on_utc+
  ' UTC '+
  return_year_based_on_utc
end
return_weekday_based_on_utc() click to toggle source
#

#return_weekday_based_on_utc

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

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

#return_year_based_on_utc

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

rev

#
# File lib/cookbooks/base/colours.rb, line 21
def rev
  ::Colours.rev
end
sandybrown(i) click to toggle source
#

sandybrown

#
# File lib/cookbooks/base/colours.rb, line 292
def sandybrown(i)
  return KONSOLE.sandybrown(i) if use_colours?
  i
end
save_file(what, into)
Alias for: write_what_into
sdir(i = '') click to toggle source
#

sdir

#
# File lib/cookbooks/base/colours.rb, line 76
def sdir(i = '')
  return ::Colours.sdir(i) if use_colours?
  i
end
seagreen(i) click to toggle source
#

seagreen

#
# File lib/cookbooks/base/colours.rb, line 140
def seagreen(i)
  return KONSOLE.seagreen(i) if use_colours?
  i
end
set_be_silent(i = false) click to toggle source
#

#set_be_silent

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

#
# File lib/cookbooks/base/prototype.rb, line 308
def set_be_silent(i = false) # false because we assign to @be_verbose
  @be_verbose = i
end
Also aliased as: be_silent, be_quiet
set_be_verbose(i = true) click to toggle source
#

#set_be_verbose

By default we will be verbose.

#
# File lib/cookbooks/base/prototype.rb, line 285
def set_be_verbose(i = true)
  @be_verbose = i
end
Also aliased as: be_verbose
sfancy(i = '') click to toggle source
#

sfancy

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

sfile

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

#show_overview_over_available_utility_scripts

#
# File lib/cookbooks/base/base.rb, line 75
def show_overview_over_available_utility_scripts
  Cookbooks.show_overview_over_available_utility_scripts
end
silver(i = '') click to toggle source
#

silver

#
# File lib/cookbooks/base/colours.rb, line 324
def silver(i = '')
  return KONSOLE.silver(i) if use_colours?
  i
end
simp(i = '') click to toggle source
#

simp

#
# File lib/cookbooks/base/colours.rb, line 68
def simp(i = '')
  return ::Colours.simp(i) if use_colours?
  i
end
skyblue(i = '') click to toggle source
#

skyblue

#
# File lib/cookbooks/base/colours.rb, line 356
def skyblue(i = '')
  return KONSOLE.skyblue(i) if use_colours?
  i
end
slateblue(i) click to toggle source
#

slateblue

#
# File lib/cookbooks/base/colours.rb, line 188
def slateblue(i)
  return KONSOLE.slateblue(i) if use_colours?
  i
end
source_dir?()
Alias for: source_directory?
source_directory()
Alias for: source_directory?
source_directory?() click to toggle source
#

#source_directory?

#
# File lib/cookbooks/base/prototype.rb, line 416
def source_directory?
  ::Cookbooks.source_directory?
end
springgreen(i) click to toggle source
#

mediumorchid

#
# File lib/cookbooks/base/colours.rb, line 276
def springgreen(i)
  return KONSOLE.springgreen(i) if use_colours?
  i
end
steelblue(i = '') click to toggle source
#

steelblue

#
# File lib/cookbooks/base/colours.rb, line 340
def steelblue(i = '')
  return KONSOLE.steelblue(i) if use_colours?
  i
end
store_into_this_directory?() click to toggle source
#

store_into_this_directory?

#
# File lib/cookbooks/base/prototype.rb, line 323
def store_into_this_directory?
  _ = ::Cookbooks.store_into_this_directory?
  ensure_that_this_directory_exists(_) # Make sure that the directory exists.
  return _
end
Also aliased as: store_where?
store_where?()
swarn(i = '') click to toggle source
#

swarn

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

system_directory?

#
# File lib/cookbooks/base/prototype.rb, line 316
def system_directory?
  ::Cookbooks.system_directory?
end
teal(i) click to toggle source
#

teal

#
# File lib/cookbooks/base/colours.rb, line 172
def teal(i)
  return KONSOLE.teal(i) if use_colours?
  i
end
temp_dir?()
Alias for: temp_directory?
temp_directory?() click to toggle source
#

temp_directory?

#
# File lib/cookbooks/base/prototype.rb, line 501
def temp_directory?
  ::Cookbooks.temp_directory?
end
Also aliased as: temp_dir?, log_dir?
to_camelcase(i) click to toggle source
#

#to_camelcase

#
# File lib/cookbooks/base/prototype.rb, line 450
def to_camelcase(i)
  i.split('_').map { |_| _.capitalize }.join
end
today?() click to toggle source
#

today?

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

#
# File lib/cookbooks/base/time.rb, line 26
def today?
  Time.now.strftime('%d %B %Y')
end
touch( i, be_verbose = false ) click to toggle source
#

touch (touch tag)

Use this method to create a new file.

#
# File lib/cookbooks/base/prototype.rb, line 146
def touch(
    i,
    be_verbose = false
  )
  case be_verbose
  when :be_verbose
    be_verbose = true
  end
  if be_verbose
    e 'Next creating the file `'+sfile(i)+'`.'
  end
  FileUtils.touch(i)
end
Also aliased as: create_file
turquoise(i) click to toggle source
#

turquoise

#
# File lib/cookbooks/base/colours.rb, line 148
def turquoise(i)
  return KONSOLE.turquoise(i) if use_colours?
  i
end
upload_list_of_all_programs_version() click to toggle source
#

#upload_list_of_all_programs_version

#
# File lib/cookbooks/base/ftp.rb, line 21
def upload_list_of_all_programs_version
  ::Cookbooks.upload_list_of_all_programs_version
end
use_colours?() click to toggle source
#

use_colours?

Just delegate towards the variable @use_colours.

#
# File lib/cookbooks/base/colours.rb, line 47
def use_colours?
  ::Cookbooks.use_colours?
end
Also aliased as: we_may_use_colours?
use_yaml_database_for_tags?() click to toggle source
#

use_yaml_database_for_tags?

#
# File lib/cookbooks/base/base.rb, line 68
def use_yaml_database_for_tags?
  ::Cookbooks.use_yaml_database_for_tags?
end
verbose_truth(i) click to toggle source
#

#verbose_truth

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

#
# File lib/cookbooks/base/prototype.rb, line 443
def verbose_truth(i)
  ::Cookbooks.verbose_truth(i)
end
Also aliased as: vt
violet(i) click to toggle source
#

violet

#
# File lib/cookbooks/base/colours.rb, line 132
def violet(i)
  return KONSOLE.violet(i) if use_colours?
  i
end
vt(i)
Alias for: verbose_truth
we_may_use_colours?()
Alias for: use_colours?
word_wrap(this_text, n_characters_limit = 78) click to toggle source
#

#word_wrap

The first argument is the text that will be reformatted.

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

#
# File lib/cookbooks/base/prototype.rb, line 461
def word_wrap(this_text, n_characters_limit = 78)
  unless this_text.encoding.to_s.include? main_encoding?
    this_text = ensure_main_encoding_for(this_text)
  end
  this_text.gsub(/(.{1,#{n_characters_limit}})(\s+|$)/, "\\1\n")
end
write_what_into(what, into) click to toggle source
#

#write_what_into

#
# File lib/cookbooks/base/base.rb, line 33
def write_what_into(what, into)
  Cookbooks::SaveFile.write_what_into(what, into)
end
Also aliased as: save_file