class EnvironmentInformation::EnvironmentInformation

Constants

THE_PROGRAM_IS_NOT_INSTALLED_OR_COULD_NOT_BE_FOUND
#

THE_PROGRAM_IS_NOT_INSTALLED_OR_COULD_NOT_BE_FOUND

#
THIS_FILE
#

EnvironmentInformation::EnvironmentInformation::THIS_FILE

THIS_FILE = __FILE__

We hardcode this since it is only relevant on my home system, anyway.

#
TRY_TO_USE_HTML_COLOURS
#

EnvironmentInformation::EnvironmentInformation::TRY_TO_USE_HTML_COLOURS

If true then we will try to use the konsole-colours, when possible.

These are part of the colours gem, so this adds a dependency on the colours gem.

#

Public Class Methods

[](i = ARGV, &block) click to toggle source
#

EnvironmentInformation::EnvironmentInformation[]

#
# File lib/environment_information/class/class.rb, line 2543
def self.[](i = ARGV, &block)
  new(i, &block)
end
new( commandline_arguments = nil, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/environment_information/class/class.rb, line 76
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  register_sigint
  reset
  # ======================================================================= #
  # Next, we handle special run-mode variants.
  # ======================================================================= #
  case run_already
  when :do_show_everything
    do_show_everything
    run_already = true
  end
  # ======================================================================= #
  # And set @run_already, so that menu() can overrule it lateron.
  # ======================================================================= #
  @run_already = run_already
  set_commandline_arguments(
    commandline_arguments
  )
  # ======================================================================= #
  # === Handle blocks
  #
  # Next blocks will be handled. This must come after the reset() method.
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded # case tag
    # ===================================================================== #
    # === :do_not_use_rbt
    # ===================================================================== #
    when :do_not_use_rbt
      @internal_hash[:may_we_try_to_use_rbt] = false
    # ===================================================================== #
    # === :disable_colours
    # ===================================================================== #
    when :disable_colours
      disable_colours
    # ===================================================================== #
    # === :disable_colours_and_do_not_store_into_a_local_file
    # ===================================================================== #
    when :disable_colours_and_do_not_store_into_a_local_file
      disable_colours
      do_not_save_anything
    # ===================================================================== #
    # === :do_not_run_yet
    # ===================================================================== #
    when :do_not_run_yet
      @run_already = false
    else
      # =================================================================== #
      # Handle Hashes given in the block.
      # =================================================================== #
      if yielded.is_a? Hash
        # ================================================================= #
        # === :use_n_tokens
        # ================================================================= #
        if yielded.has_key? :use_n_tokens
          set_use_n_tokens(yielded.delete(:use_n_tokens))
        # ================================================================= #
        # === :n_tokens
        # ================================================================= #
        elsif yielded.has_key? :n_tokens
          set_use_n_tokens(yielded.delete(:n_tokens))
        end
        # ================================================================= #
        # === :use_colours
        # ================================================================= #
        if yielded.has_key? :use_colours
          set_use_colours(yielded.delete(:use_colours))
        end
        # ================================================================= #
        # === :be_silent
        # ================================================================= #
        if yielded.has_key? :be_silent
          set_be_silent(yielded.delete(:be_silent))
        end
        # ================================================================= #
        # === :show_ruby_stuff
        # ================================================================= #
        if yielded.has_key? :show_ruby_stuff
          if yielded.delete(:show_ruby_stuff) == false
            dont_show_ruby_stuff
          end
        end
      end
    end
  end
  # ======================================================================= #
  # First, we will add the default programs on a linux computer. The
  # later invocation to menu() can change this, but we also want to
  # provide "useful defaults" for users to benefit from this gem.
  # ======================================================================= #
  add_the_default_programs_on_a_linux_computer
  # ======================================================================= #
  # Add the ruby components next. This must come before menu().
  # ======================================================================= #
  consider_adding_the_ruby_components
  # ======================================================================= #
  # Invoke menu() to query and honour the commandline arguments.
  # ======================================================================= #
  menu
  run if @run_already
end

Public Instance Methods

add( i ) click to toggle source
#

add (add tag)

This method can be used to add individual entries to the main array called @array_report_these_programs.

The format for add() contains only one component, which appears on the left side, and denotes the name of the program or component that we wish to query, such as “php” or “ruby” and so forth.

Some Symbols will be used as a “pointer” towards an Array of registered programs.

Note that (1) will be converted into a Symbol if it is a String.

If the second entry (2) is nil, then the version will be inferred at “runtime” within the method display(). Otherwise display() will simply use the passed version (which should be a String in that case, then).

Before we can add an entry to the main dataset, we have to check whether it is a registered entry altogether. If it is not registered, the user has to be notified about this fact. This notification will ONLY happen if the associated version is nil; if a specific version is supplied then this method will assume that the program should be displayed anyway.

An Array can also be supplied to this method, if necessary.

#
# File lib/environment_information/class/class.rb, line 415
def add(
    i
  )
  if i.is_a?(String) and i.include?(',')
    # ===================================================================== #
    # Strings containing ',' will be split accordingly.
    # ===================================================================== #
    i = i.split(',')
  elsif i.is_a?(String) and i.include?('-')
    # ===================================================================== #
    # Strings containing '-' will lose that '-'.
    # ===================================================================== #
    i = i.dup if i.frozen?
    i.delete!('-')
  end
  [i].flatten.compact.each {|entry|
    case entry
    # ===================================================================== #
    # === :everything
    #
    # This entry point is meant for simply adding everything.
    # ===================================================================== #
    when :everything
      entry = return_every_registered_component
    # ===================================================================== #
    # === Rubygems installation directory
    # ===================================================================== #
    when :rubygems_installation_directory,
         /^rubygems( |_)?installation( |_)?directory\??$/i
      entry = 'rubygems_installation_directory'
    # ===================================================================== #
    # === cflags
    # ===================================================================== #
    when :cflags,
         /^cflags$/i
      entry = 'CFLAGS in use'
    # ===================================================================== #
    # === screen_resolution
    # ===================================================================== #
    when :screen_resolution,
         /^screen( |_)?resolution$/i
      entry = 'Screen Resolution'
    # ===================================================================== #
    # === ram
    # ===================================================================== #
    when :ram,
         /^ram$/i
      entry = 'RAM'
    # ===================================================================== #
    # === cpuinfo
    # ===================================================================== #
    when :cpuinfo,
         /^cpuinfo$/i
      entry = 'CPU Model'
    # ===================================================================== #
    # === operating_system_bit_type
    # ===================================================================== #
    when :operating_system_bit_type,
         /^operating(_|-)?system(_|-)?bit(_|-)?type$/i
      entry = 'Operating system bit type'
    # ===================================================================== #
    # === :operating_system
    # ===================================================================== #
    when :operating_system,
         /^operating(_|-)?system$/i,
         /^operating(_|-)?system(_|-)?in(_|-)?use$/i
      entry = 'Operating system'
    # ===================================================================== #
    # === cpflags
    # ===================================================================== #
    when /^cflags$/i,
         /^CFLAGS in use$/i
      entry = 'CFLAGS in use'
    # ===================================================================== #
    # === :pkgconfig_entries
    # ===================================================================== #
    when :pkgconfig_entries
      entry = ::EnvironmentInformation.return_pkgconfig_based_programs
    # ===================================================================== #
    # === :all_xorg_components
    # ===================================================================== #
    when :all_xorg_components
      entry = return_all_xorg_components
    # ===================================================================== #
    # === envi --science
    # ===================================================================== #
    when :science_cluster
      entry = ARRAY_SCIENCE_CLUSTER
    # ===================================================================== #
    # === envi --lfs_core_programs
    # ===================================================================== #
    when :lfs,
         :lfs_core_programs
     entry = ::EnvironmentInformation.lfs_core_programs?
    # ===================================================================== #
    # === :linux_kernel
    # ===================================================================== #
    when :linux_kernel
      i = :linux
    # ===================================================================== #
    # === :RAM
    # ===================================================================== #
    when :RAM
      entry = :ram # Just the "alias" to the real entry.
    end
    unless @array_report_these_programs.include? entry
      @array_report_these_programs << entry
      @array_report_these_programs.flatten!
    end
  }
end
add_default_linux_programs()
add_ruby_and_rubygems() click to toggle source
#

add_ruby_and_rubygems

#
# File lib/environment_information/class/class.rb, line 546
def add_ruby_and_rubygems
  add(:ruby)
  add(:rubygems)
  add(:rubygems_installation_directory)
end
add_the_default_programs_on_a_linux_computer() click to toggle source
#

add_the_default_programs_on_a_linux_computer

#
# File lib/environment_information/class/class.rb, line 534
def add_the_default_programs_on_a_linux_computer
  # ======================================================================= #
  # Add the default programs on a linux computer.
  # ======================================================================= #
  add(
    return_default_programs_on_a_linux_computer
  )
end
Also aliased as: add_default_linux_programs
add_this_to_the_toplevel_hash(a, b) click to toggle source
#

add_this_to_the_toplevel_hash

#
# File lib/environment_information/class/class.rb, line 555
def add_this_to_the_toplevel_hash(a, b)
  a = a.to_sym unless a.is_a? Symbol
  ::EnvironmentInformation.hash?[a] = b
end
Also aliased as: register_onto_the_main_hash
append( i )
Alias for: add
append_this_to_main_string( i )
Alias for: add
array_obtain_these_programs?()
array_with_entries?()
assign_components_for_the_short_format() click to toggle source
#

assign_components_for_the_short_format

We will only display 6 components when we use the short variant.

#
# File lib/environment_information/class/class.rb, line 898
def assign_components_for_the_short_format
  clear_old_dataset
  dont_show_ruby_stuff
  add(%i(
    operating_system
    operating_system_bit_type
    cpuinfo
    cflags
    RAM
    screen_resolution
  ))
end
be_quiet()
Alias for: be_silent
be_silent() click to toggle source
#

be_silent

#
# File lib/environment_information/class/class.rb, line 1012
def be_silent
  @be_silent = true
end
Also aliased as: be_quiet
be_silent?() click to toggle source
#

be_silent?

#
# File lib/environment_information/class/class.rb, line 1026
def be_silent?
  @be_silent
end
bit_type?() click to toggle source
#

bit_type?

#
# File lib/environment_information/class/class.rb, line 1360
def bit_type?
  ::EnvironmentInformation.operating_system_bit_type
end
blue(i = '') click to toggle source
#

blue

#
# File lib/environment_information/class/colours.rb, line 38
def blue(i = '')
  if i.empty?
    ::Colours::BLUE
  end if use_colours?
end
build_up_the_main_string( report_these_programs = @array_report_these_programs )
can_we_query_the_mate_desktop?() click to toggle source
#

can_we_query_the_mate_desktop?

#
# File lib/environment_information/class/class.rb, line 875
def can_we_query_the_mate_desktop?
  is_rbt_available? and RBT.const_defined?(:ReportMateDesktopVersion)
end
cflags_in_use?() click to toggle source
#

cflags_in_use?

#
# File lib/environment_information/class/class.rb, line 1402
def cflags_in_use?
  ::EnvironmentInformation.cflags_in_use?
end
clear_hash_and_missing_components() click to toggle source
#

clear_hash_and_missing_components

#
# File lib/environment_information/class/class.rb, line 1439
def clear_hash_and_missing_components
  clear_toplevel_hash
  clear_missing_components
end
clear_main_dataset()
clear_missing_components() click to toggle source
#

clear_missing_components

#
# File lib/environment_information/class/class.rb, line 1447
def clear_missing_components
  ::EnvironmentInformation.clear_missing_components
end
clear_old_dataset() click to toggle source
#

clear_old_dataset

#
# File lib/environment_information/class/class.rb, line 1137
def clear_old_dataset
  @array_report_these_programs.clear
end
clear_the_main_dataset() click to toggle source
#

clear_the_main_dataset

#
# File lib/environment_information/class/class.rb, line 1171
def clear_the_main_dataset
  clear_old_dataset
  do_not_display_the_ruby_components
end
clear_toplevel_hash() click to toggle source
#

clear_toplevel_hash

#
# File lib/environment_information/class/class.rb, line 1181
def clear_toplevel_hash
  ::EnvironmentInformation.clear_hash
end
col1() click to toggle source
#

col1

The “first” colour to be used.

#
# File lib/environment_information/class/colours.rb, line 110
def col1
  if use_colours?
    Colours::BOLD_BLUE
  else
    ''
  end
end
colourize_this_in_the_right_side_colour(i) click to toggle source
#

colourize_this_in_the_right_side_colour

#
# File lib/environment_information/class/colours.rb, line 16
def colourize_this_in_the_right_side_colour(i)
  if use_colours?
    ::Colours.send(::EnvironmentInformation.colour_for_the_right_side, i)
  else
    i
  end
end
commandline?() click to toggle source
#

commandline?

Whether we run in the “commandline mode” or whether we run in the GUI or WWW/HTML mode.

#
# File lib/environment_information/class/class.rb, line 1005
def commandline?
  @runmode == :commandline
end
compare_program_version?()
compare_program_versions?() click to toggle source
#

compare_program_versions?

#
# File lib/environment_information/class/class.rb, line 1481
def compare_program_versions?
  @internal_hash[:compare_program_versions]
end
Also aliased as: compare_program_version?
compare_via_gem_version(i) click to toggle source
#

compare_via_gem_version

#
# File lib/environment_information/class/class.rb, line 1697
def compare_via_gem_version(i)
  begin
    Gem::Version.new(i)
  rescue ArgumentError => error
    e Colours.tomato(error)
    e "#{rev}We will continue nonetheless (#{i})"
    return nil
  end
end
components?()
consider_adding_the_ruby_components() click to toggle source
#

consider_adding_the_ruby_components

This method can be used to consider adding the ruby-components, which means “ruby” itself, rubygems “gem”, and the rubygems installation directory.

#
# File lib/environment_information/class/class.rb, line 1632
def consider_adding_the_ruby_components
  if @show_ruby_version_and_gem_version
    add(
      return_all_ruby_components # Combine three calls into one here - all related to ruby.
    )
  end
end
consider_storing_the_components_that_were_displayed() click to toggle source
#

consider_storing_the_components_that_were_displayed

#
# File lib/environment_information/class/class.rb, line 846
def consider_storing_the_components_that_were_displayed
  if store_the_results_into_local_files?
    ::EnvironmentInformation.consider_storing_these_results_into_a_local_file
  end
end
consider_storing_which_components_were_displayed()
consider_storing_which_programs_are_not_up_to_date() click to toggle source
#

consider_storing_which_programs_are_not_up_to_date

#
# File lib/environment_information/class/class.rb, line 1341
def consider_storing_which_programs_are_not_up_to_date
  if shall_we_really_store_which_programs_are_not_up_to_date?
    into = FILE_THESE_PROGRAMS_CAN_BE_UPGRADED
    what = YAML.dump(@array_these_programs_not_up_to_date)
    if File.directory?('/home/Temp/rbt/')
      into = "/home/Temp/rbt/#{File.basename(into)}"
    else
      into = "#{log_dir?}#{File.basename(into)}"
    end
    opnn; e 'We will also store which programs are not up to date.'
    opnn; e "These will be stored into the file at `#{sfile(into)}`."
    ::EnvironmentInformation.write_what_into(what, into)
  end
end
cpu_model?() click to toggle source
#

cpu_model?

#
# File lib/environment_information/class/class.rb, line 1378
def cpu_model?
  ::EnvironmentInformation.cpuinfo?
end
crimson(i = '') click to toggle source
#

crimson

#
# File lib/environment_information/class/colours.rb, line 137
def crimson(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.crimson(i)
  end
  return i
end
cyan( i = '', use_colours = use_colours? ) click to toggle source
#

cyan

#
# File lib/environment_information/class/colours.rb, line 27
def cyan(
    i = '', use_colours = use_colours?
  )
  if i.empty?
    Colours::CYAN
  end if use_colours
end
darkgreen(i = '') click to toggle source
#

darkgreen

#
# File lib/environment_information/class/colours.rb, line 147
def darkgreen(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.darkgreen(i)
  end
  return i
end
darkolivegreen(i = '') click to toggle source
#

darkolivegreen

#
# File lib/environment_information/class/colours.rb, line 239
def darkolivegreen(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.darkolivegreen(i)
  end
  return i
end
dataset?()
dataset_as_string() click to toggle source
#

dataset_as_string

This method must return the dataset in String format. That String must already be properly “formatted”.

#
# File lib/environment_information/class/class.rb, line 1191
def dataset_as_string
  _ = ''.dup # Put the information onto that String here.
  main_dataset?.each {|entry|
    if entry.is_a? Array
      entry = entry.first # The second entry is ignored in that event.
    end
    # ===================================================================== #
    # Before we can use .send() we have to check whether EnvironmentInformation
    # actually responds to that method. If not then we will simply skip
    # this snippet for now; but this may have to be changed at some
    # point in the future, to more elegantly handle failure. (Sep 2019).
    # ===================================================================== #
    use_this_method = "return_version_of_#{entry}".to_sym
    if ::EnvironmentInformation.respond_to? use_this_method
      program_version = ::EnvironmentInformation.send(
        use_this_method
      )
      entry = "  #{entry}:"
      _ << "#{entry} #{program_version}#{N}"
    end
  }
  return _ # And return the generated String.
end
Also aliased as: string?, string, main_string?, stringified
dimgray(i = '') click to toggle source
#

dimgray

#
# File lib/environment_information/class/colours.rb, line 157
def dimgray(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.dimgray(i)
  end
  return i
end
disable_colours() click to toggle source
#

disable_colours

Call this method when you wish to disable the colours. Note that this will disable colours on the toplevel.

#
# File lib/environment_information/class/colours.rb, line 79
def disable_colours
  ::EnvironmentInformation.use_colours = false
end
Also aliased as: no_colours
display( report_these_programs = @array_report_these_programs )
display_the_components( report_these_programs = @array_report_these_programs )
display_the_dataset( report_these_programs = @array_report_these_programs )
display_the_main_components( report_these_programs = @array_report_these_programs )
display_these_components?() click to toggle source
#

display_these_components?

Note that @display_these_components is a Hash.

#
# File lib/environment_information/class/class.rb, line 1771
def display_these_components?
  @array_report_these_programs
end
display_which_components?()
do_compare_the_program_version( be_verbose = true ) click to toggle source
#

do_compare_the_program_version

This method can be used if the user wishes to also compare the program version of the installed programs. This functionality depends on the rbt gem, and the RBT namespace.

#
# File lib/environment_information/class/class.rb, line 1468
def do_compare_the_program_version(
    be_verbose = true
  )
  if be_verbose
    @array_show_this_to_the_user <<
      'The program versions will also be compared.'
  end
  @internal_hash[:compare_program_versions] = true
end
do_display_in_a_short_format() click to toggle source
#

do_display_in_a_short_format

The short-format means that we will use only a compact set of programs to display. For example, “make” and “bash” will not be displayed, neither “binutils” or “ruby”.

#
# File lib/environment_information/class/class.rb, line 1565
def do_display_in_a_short_format
  @display_everything_in_short_format = true
end
do_exit_the_program() click to toggle source
#

do_exit_the_program

#
# File lib/environment_information/class/class.rb, line 988
def do_exit_the_program
  @do_exit_the_program = true
end
do_feedback_everything()
Alias for: run
do_generate_a_html_file( styling_instructions = :none ) click to toggle source
#

do_generate_a_html_file (html tag)

The action-method that will generate the html file. This depends on the gem html_tags, with module HtmlTags though.

To invoke this method, do:

envi --generate-html-file
#
# File lib/environment_information/class/class.rb, line 664
def do_generate_a_html_file(
    styling_instructions = :none
  )
  # ======================================================================= #
  # === Ensure that the html_tags project is available
  # ======================================================================= #
  unless Object.const_defined? :HtmlTags
    begin
      require 'html_tags'
    rescue LoadError
      e 'html_tags is not available. Considering installing it via:'
      e
      e '  gem install html_tags'
      e
    end
  end
  # ======================================================================= #
  # === Define where to store the .html file in question
  # ======================================================================= #
  this_html_file = "#{::EnvironmentInformation.temp_directory?}environment_information.html"
  # ======================================================================= #
  # Obtain the main dataset next.
  # ======================================================================= #
  what = dataset_as_string
  case styling_instructions
  when :bold
    what = HtmlTags.b(what)
  end
  what = HtmlTags.html(
    HtmlTags.title('Information about the local environment')+
    HtmlTags.body(
      HtmlTags.h1(
        'Your environment',
        css_style: 'margin-top: 0.5em; margin-bottom: 0.5em; padding: 2px;'
      )+
      HtmlTags.pre(
        what,
        css_style: 'font-weight: bold; font-size: 2em; padding-left: 1.0em; margin-top:2px;'
      )
    )
  )
  ::EnvironmentInformation.write_what_into(what, this_html_file)
  # ======================================================================= #
  # Notify the user what has been done.
  # ======================================================================= #
  if File.exist? this_html_file
    opnn; e "Generated a HTML file at `#{sfile(this_html_file)}`."
  end
end
do_not_display_the_result() click to toggle source
#

do_not_display_the_result

#
# File lib/environment_information/class/class.rb, line 1041
def do_not_display_the_result
  @display_result = false
end
do_not_display_the_ruby_components()
do_not_run()
Alias for: do_not_run_already
do_not_run_already() click to toggle source
#

do_not_run_already

#
# File lib/environment_information/class/class.rb, line 1098
def do_not_run_already
  @run_already = false
end
Also aliased as: do_not_run
do_not_save_anything() click to toggle source
#

do_not_save_anything

#
# File lib/environment_information/class/class.rb, line 1550
def do_not_save_anything
  @shall_the_results_be_saved = false
  # ======================================================================= #
  # We will also avoid saving the results into a local yaml file.
  # ======================================================================= #
  @internal_hash[:store_the_results_into_local_files] = false
end
Also aliased as: do_not_store_anything
do_not_show_the_ruby_components() click to toggle source
#

do_not_show_the_ruby_components

#
# File lib/environment_information/class/class.rb, line 1643
def do_not_show_the_ruby_components
  @show_ruby_version_and_gem_version = false
end
do_not_store_anything()
do_rename_kde_konsole( use_this_title = 'Environment Information' ) click to toggle source
#

do_rename_kde_konsole

This will attempt to rename the KDE Konsole tab, but only if we are on roebe.

#
# File lib/environment_information/class/class.rb, line 1051
def do_rename_kde_konsole(
    use_this_title = 'Environment Information'
  )
  begin
    require 'roebe/requires/require_kde_konsole.rb'
  rescue LoadError; end  
  if try_to_rename_the_kde_konsole_tab? and
     is_on_roebe? and
     Object.const_defined?(:Roebe) and
     Roebe.const_defined?(:KdeKonsole)
    Roebe.rename_konsole(use_this_title)
  end
end
do_report_the_remote_urls() click to toggle source
#

do_report_the_remote_urls

Enable the reporting of the remote URLs, if available.

#
# File lib/environment_information/class/class.rb, line 1730
def do_report_the_remote_urls
  @internal_hash[:report_the_remote_urls] = true
end
do_show_almost_everything_excluding_the_default_linux_programs() click to toggle source
#

do_show_almost_everything_excluding_the_default_linux_programs

This is similar to do_show_everything() but it will not show the default linux programs.

#
# File lib/environment_information/class/class.rb, line 813
def do_show_almost_everything_excluding_the_default_linux_programs
  these_programs   = return_every_registered_component
  default_programs = return_default_programs
  # ======================================================================= #
  # Next subtract those that are part in the default_programs.
  # ======================================================================= #
  these_programs.reject! {|entry|
    default_programs.include? entry
  }
  add(these_programs)
end
do_show_everything() click to toggle source
#

do_show_everything (everything tag, full tag)

This method can be used when the user wishes to enable seeing full information about his local environment (on the computer).

This will always display EVERY registered component.

Commandline invocation:

envi --everything
#
# File lib/environment_information/class/class.rb, line 838
def do_show_everything
  add(:everything) # Simply add everything.
end
do_show_full_information()
Alias for: do_show_everything
do_show_help() click to toggle source
#

do_show_help (help tag)

Show the commandline-usage through this method here.

To invoke this, try:

envi --help
#
# File lib/environment_information/class/class.rb, line 588
def do_show_help
  e
  lpad = "#{col1}    "
  e "#{rev}The following options are available for "\
    "#{simp('class EnvironmentInformation:')}#{rev}#{N}#{N}"
  if ASCIITABLE_IS_AVAILABLE
    e col1+'    asciitable        '+rev+'# Print in Ascii Table format'
  end
  e lpad+'html              '+rev+'# Save the environment information '\
    'into a .html file'
  e lpad+'gui               '+rev+'# Start the GTK gui bindings; some '\
    'aliases are possible such as --GUI'
  e lpad+'nocolours         '+rev+'# Disable colours '\
    '(--disable-colours also works)'
  e lpad+'noruby            '+rev+'# dont show ruby-related environment '\
    'information'
  e lpad+'help              '+rev+'# show some help'
  e lpad+'xorg              '+rev+'# show some xorg-specific '\
    'components (also --xorg-components)'
  e lpad+'OS                '+rev+'# show the OS then exit'
  e lpad+'full              '+rev+'# show full information, including '\
    'GTK, Glib, Atk and Pango Version'
  e '                      # ^^^ This is probably the most useful usage.'
  e lpad+'openssl           '+rev+'# display openssl option'
  e lpad+'REALLY_ALL        '+rev+'# also compare the program_versions '\
    '(--really-everything is an alias to this)'
  e lpad+'save              '+rev+'# display the result, then '\
    'save it into a file'
  e lpad+'sinatra           '+rev+'# start the sinatra-interface '\
    'of the environment_information project'
  e lpad+'version           '+rev+'# show the version of '\
    'EnvironmentInformation in use'
  e lpad+'--show-remote-url '+rev+'# show the remote URLs '\
    'of a program (requires the RBT project)'
  e lpad+'padding=value     '+rev+'# set to another padding value'
  e lpad+'--one-liner       '+rev+'# show everything compacted, without a newline'
  e lpad+'--nentries?       '+rev+'# feedback how many entries are tracked in total'
  e rev+N+'The above commands should be commandline arguments, '\
    'such as: "'+teal('envi full')+rev+'".'
  e
  e "#{rev}Do note that you can prefix the above commands via "\
    "a leading --, of course."
  e
  # ======================================================================= #
  # Show a simple usage example next:
  # ======================================================================= #
  e 'Usage example:'
  e
  e steelblue(
      '    envi --version'
    )
  e
  e rev+'If you wish to show only some programs, you could '\
    'use the following:'
  e
  e steelblue(
      '    envi --use-these-programs=bash,binutils,bison,yacc,bzip2,coreutils,diff,find,gawk,gcc'
    )
  e steelblue(
      '    envi --use-these-programs=:lfs'
    )
  e true_rev # Reset via Colours.rev here.
  do_exit_the_program
end
Also aliased as: show_help
do_show_only_the_operating_system() click to toggle source
#

do_show_only_the_operating_system

To invoke this method, try:

envi --os?
#
# File lib/environment_information/class/class.rb, line 867
def do_show_only_the_operating_system
  clear_old_dataset
  add(:operating_system)
end
do_show_only_the_xorg_components() click to toggle source
#

do_show_only_the_xorg_components

This method will essentially clear the old dataset before adding all xorg-components to the display-part of this class.

The components that are appended here, are defined in the file constants/array_tracked_components.rb - so if you wish to add new xorg-related entries, you should modify the entries in that .rb file.

#
# File lib/environment_information/class/class.rb, line 1128
def do_show_only_the_xorg_components
  clear_old_dataset
  do_not_show_the_ruby_components
  add(:all_xorg_components)
end
do_sort_alphabetically( display_these_components = display_which_components? ) click to toggle source
#

do_sort_alphabetically (sort tag)

Some entries are Symbols, which is why we have to call .to_s in the method here.

#
# File lib/environment_information/class/class.rb, line 1540
def do_sort_alphabetically(
    display_these_components = display_which_components?
  )
  _ = display_these_components.sort_by {|name, version| name.to_s }
  set_main_array(_)
end
dont_show_ruby_stuff() click to toggle source
#

dont_show_ruby_stuff

Disable showing ruby + gem information.

#
# File lib/environment_information/class/class.rb, line 1608
def dont_show_ruby_stuff # Dont show ruby stuff.
  @show_ruby_version_and_gem_version = false
end
Also aliased as: show_no_ruby
e(i = '') click to toggle source
#

e (e tag)

The e() method is the general output-method for this class.

#
# File lib/environment_information/class/class.rb, line 1713
def e(i = '')
  unless @be_silent
    if use_one_line_to_show_the_result? # This will just use "print".
      ::EnvironmentInformation.ee(i)
    else
      ::EnvironmentInformation.e(
        i, display_everything_in_short_format: @display_everything_in_short_format
      )
    end
  end
end
empty_main_array()
empty_main_dataset()
enable_colours() click to toggle source
#

enable_colours

#
# File lib/environment_information/class/colours.rb, line 69
def enable_colours
  ::EnvironmentInformation.use_colours = true
end
enable_sort_alphabetically() click to toggle source
#

enable_sort_alphabetically

#
# File lib/environment_information/class/class.rb, line 1579
def enable_sort_alphabetically
  @internal_hash[:sort_alphabetically] = true
end
feedback()
Alias for: run
feedback_everything()
Alias for: run
gui?() click to toggle source
#

gui?

#
# File lib/environment_information/class/class.rb, line 995
def gui?
  @runmode == :gui
end
is_a_registered_component?(i) click to toggle source
#

is_a_registered_component?

#
# File lib/environment_information/class/class.rb, line 785
def is_a_registered_component?(i)
  ::EnvironmentInformation.is_this_component_included?(i)
end
Also aliased as: is_an_allowed_entry?
is_an_allowed_entry?(i)
is_rbt_available_and_may_we_try_to_use_rbt?() click to toggle source
#

is_rbt_available_and_may_we_try_to_use_rbt?

#
# File lib/environment_information/class/class.rb, line 1488
def is_rbt_available_and_may_we_try_to_use_rbt?
  is_rbt_available? and may_we_try_to_use_rbt?
end
is_this_program_included?(i) click to toggle source
#

is_this_program_included?

#
# File lib/environment_information/class/class.rb, line 1263
def is_this_program_included?(i)
  ::EnvironmentInformation.is_this_program_included?(i)
end
lightgreen(i = '') click to toggle source
#

lightgreen

#
# File lib/environment_information/class/colours.rb, line 249
def lightgreen(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.lightgreen(i)
  end
  return i
end
limegreen(i = '') click to toggle source
#

limegreen

#
# File lib/environment_information/class/colours.rb, line 229
def limegreen(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.limegreen(i)
  end
  return i
end
load_dataset_from_this_file(i) click to toggle source
#

load_dataset_from_this_file

This method can be used to read which programs will be displayed from a local file, rather than rely on the pre-set default.

#
# File lib/environment_information/class/class.rb, line 1327
def load_dataset_from_this_file(i)
  if File.exist? i
    File.readlines(i).map {|entry|
      entry.delete('-').strip # ← Clean up the input a little bit.
    }
  else
    opnn; e "No file exists at `#{sfile(i)}`."
  end
end
main_array?()
main_dataset?()
main_entry?()
main_hash?() click to toggle source
#

main_hash?

#
# File lib/environment_information/class/class.rb, line 1789
def main_hash?
  ::EnvironmentInformation.hash?
end
main_string?()
Alias for: dataset_as_string
may_we_try_to_use_rbt?() click to toggle source
#

may_we_try_to_use_rbt?

#
# File lib/environment_information/class/class.rb, line 914
def may_we_try_to_use_rbt?
  @internal_hash[:may_we_try_to_use_rbt]
end
mediumpurple(i = '') click to toggle source
#

mediumpurple

#
# File lib/environment_information/class/colours.rb, line 259
def mediumpurple(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.mediumpurple(i)
  end
  return i
end
menu( i = @commandline_arguments ) click to toggle source
#

menu (menu tag)

This method constitutes the “menu” interface for class EnvironmentInformation. It usually deals with the commandline-given arguments stored in ARGV.

#
no_colours()
Alias for: disable_colours
olive(i = '') click to toggle source
#

olive

#
# File lib/environment_information/class/colours.rb, line 219
def olive(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.olive(i)
  end
  return i
end
olivedrab(i = '') click to toggle source
#

olivedrab

This one will be used for the right-hand side.

#
# File lib/environment_information/class/colours.rb, line 209
def olivedrab(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.olivedrab(i)
  end
  return i
end
open_this_file_in_editor() click to toggle source
#

open_this_file_in_editor

#
# File lib/environment_information/class/class.rb, line 1105
def open_this_file_in_editor
  _ = "bluefish #{THIS_FILE}"
  e _; system _; exit
end
operating_system?() click to toggle source
#

operating_system?

To quickly test this method, try:

EnvironmentInformation::EnvironmentInformation.new { :do_not_run_yet }.operating_system?
#
# File lib/environment_information/class/class.rb, line 1317
def operating_system?
  ::EnvironmentInformation.send(__method__)
end
opn()
Alias for: opnn
opnn() click to toggle source
#

opnn

#
# File lib/environment_information/class/class.rb, line 1586
def opnn
  if TRY_TO_MAKE_USE_OF_THE_OPN_GEM_IF_IT_IS_AVAILABLE and
     Object.const_defined?(:Opn)
    Opn.opn({
      namespace:   NAMESPACE,
      use_colours: use_colours?
    })
  end
end
Also aliased as: opn
orange(i = '') click to toggle source
#

orange

#
# File lib/environment_information/class/colours.rb, line 277
def orange(i = '')
  return ::Colours.orange(i) if use_colours?
  return i
end
output()
Alias for: run
programs?()
ram?() click to toggle source
#

ram?

#
# File lib/environment_information/class/class.rb, line 1386
def ram?
  ::EnvironmentInformation.ram?
end
register_not_found(i)
register_onto_the_main_hash(a, b)
register_sigint() click to toggle source
#

register_sigint

#
# File lib/environment_information/class/class.rb, line 1599
def register_sigint
  Signal.trap('SIGINT') { e; exit }
end
register_the_available_components_and_show_them_at_once( report_these_programs = @array_report_these_programs ) click to toggle source
#

register_the_available_components_and_show_them_at_once (report tag)

This method can be used to register information about the various components. It will also instantly display the component at hand, to avoid “lagging” behaviour on the commandline.

#
# File lib/environment_information/class/class.rb, line 1800
def register_the_available_components_and_show_them_at_once(
    report_these_programs = @array_report_these_programs
  )
  if report_these_programs.empty?
    opn; e 'There are no components that can be displayed.' # And this ends here.
  else
    # ===================================================================== #
    # Always clear the main Array before proceeding here.
    # ===================================================================== #
    clear_missing_components
    toplevel_hash = ::EnvironmentInformation.hash?
    hash_use_this_for_the_query = ::EnvironmentInformation.all_the_queries
    # ===================================================================== #
    # Iterate over the registered programs next.
    # ===================================================================== #
    report_these_programs.each {|this_program|
      # =================================================================== #
      # First, determine the left_side and the right_side.
      # =================================================================== #
      left_side  = this_program.to_s.dup
      right_side = nil
      case this_program
      # =================================================================== #
      # === RAM
      # =================================================================== #
      when :ram,
           /^RAM$/i
        right_side = ram?.to_s.dup
        right_side = right_side.dup if right_side.frozen?
        # ================================================================= #
        # Append 'MB RAM' in orange colour next, with some padding.
        # This is just a small visual "enhancement" that I quite like.
        # ================================================================= #
        right_side << orange(' MB RAM')
      # =================================================================== #
      # === Rubygems installation directory
      # =================================================================== #
      when :rubygems_installation_directory,
           /^rubygems( |_)?installation( |_)?directory\??$/i
        right_side = rubygems_installation_directory?
      # =================================================================== #
      # === cflags
      # =================================================================== #
      when :cflags,
           /^cflags$/i,
           /^cflags(_|-| )?in(_|-| )?use$/i
        right_side = cflags_in_use?
      # =================================================================== #
      # === Screen resolution
      #
      # This is a bit "special" in the sense that we will colourize
      # the middle 'x', if found, and if colours are used.
      # =================================================================== #
      when :screen_resolution,
           /^screen( |_)?resolution$/i
        right_side = screen_resolution?
        if right_side.include?('x') and use_colours?
          splitted = right_side.split('x')
          right_side = colourize_this_in_the_right_side_colour(splitted.first)+
                       royalblue('x')+
                       colourize_this_in_the_right_side_colour(splitted.last)
        end
      # =================================================================== #
      # === CPU Model
      # =================================================================== #
      when /^cpuinfo$/i,
           /^CPU(_|-| )?Model/
        right_side = cpu_model?
      # =================================================================== #
      # === Operating system bit type
      # =================================================================== #
      when /^operating(_|-| )?system(_|-| )?bit(_|-| )?type$/i
        right_side = bit_type?
      # =================================================================== #
      # === Operating system
      # =================================================================== #
      when /^Operating(_|-| )?system$/i,
           :operating_system
        right_side = ::EnvironmentInformation.operating_system
      end
      # =================================================================== #
      # Find the corresponding entry next while including aliases:
      # =================================================================== #
      this_program = this_program.to_sym # These are stored as symbol.
      this_program = ::EnvironmentInformation.return_alias_to(this_program)
      _ = hash_use_this_for_the_query[this_program] # This holds the instruction for the program at hand.
      if hash_use_this_for_the_query.has_key? this_program
        if _.to_s.start_with? 'pkg'
          # =============================================================== #
          # === :pkgconfig
          #
          # This is by far the simplest solution.
          # =============================================================== #
          right_side = @pkg_config_query.return_version_of(this_program)
          add_this_to_the_toplevel_hash(left_side, right_side)
        # ================================================================= #
        # === :version
        #
        # Here we will handle simple versions, e. g. "lftp --version"
        # entries, and similar.
        # ================================================================= #
        elsif (_ == :version) or (_ == :short_version)
          # =============================================================== #
          # Pass into class EnvironmentInformation::Queries::SimpleVersion next:
          # =============================================================== #
          right_side = @simple_version_query.return_version_of(this_program)
          add_this_to_the_toplevel_hash(left_side, right_side)
        # ================================================================= #
        # The next entry is specifically for the program called
        # double-conversion:
        # ================================================================= #
        elsif _ == :special_entry_for_doubleconversion
          right_side = nil
          target_file = '/usr/lib/cmake/double-conversion/double-conversionConfigVersion.cmake'
          if File.exist? target_file
            dataset = File.read(target_file)
            right_side = dataset.scan(
                           /PACKAGE_VERSION "(.+)"/
                         ).flatten.first.to_s
          end
          if right_side 
            add_this_to_the_toplevel_hash(left_side, right_side)
          end
        else
          # =============================================================== #
          # Else we will pass through class ComplexVersion:
          # =============================================================== #
          right_side = @complex_version_query.return_version_of(this_program)
          add_this_to_the_toplevel_hash(left_side, right_side)
        end
      # =================================================================== #
      # The next clause has been written specifically to allow querying
      # the mate-desktop components.
      # =================================================================== #
      elsif toplevel_hash.has_key?(this_program) and
            toplevel_hash[this_program] # ← This is thus non-nil.
        right_side = toplevel_hash[this_program] 
      end
      if right_side.nil?
        register_unavailable_program(this_program)
      end
      # =================================================================== #
      # === @internal_hash[:report_the_remote_urls]
      #
      # Next, honour @internal_hash[:report_the_remote_urls] if it is
      # set to true.
      # =================================================================== #
      if report_the_remote_urls? and
         is_rbt_available? and
         RBT.respond_to?(:remote_url_for?)
        version = ''.dup
        _ = this_program.to_s.delete('-').downcase.strip.to_sym
        if RBT.does_include?(_)
          remote_url = RBT.remote_url_for?(_, :return_as_string)
          if is_a_registered_component? _
            if version.frozen?
              version = version.dup
            end
            version << lightgreen(remote_url)
            if right_side # We can only continue if the program is available.
              # In theory we could show the URL anyway, but for the time
              # being, at the least, we will not show the URL.
              right_side = right_side.dup if right_side.frozen?
              right_side << " #{olive('→')} #{version}"
            end
          end
        end
      end
      # =================================================================== #
      # The next method is defined in base.rb.
      # =================================================================== #
      report_left_right(
        left_side,
        right_side,
        :default_colour,
        :default_colour,
        :default_colour,
        !use_one_line_to_show_the_result?
      )
      # =================================================================== #
      # Next compare the program versions with the local versions.
      # =================================================================== #
      if compare_program_versions? and
         is_rbt_available_and_may_we_try_to_use_rbt? and
         RBT.respond_to?(:swift_return_version_of_this_program) and
         RBT.does_include?(left_side.to_s.strip)
        # ================================================================= #
        # Example:
        #
        #   RBT.swift_return_version_of_this_program(:gettext)
        #
        # ================================================================= #
        registered_local_version = RBT.swift_return_version_of_this_program(
          left_side.to_s.strip.to_sym
        ).to_s
        # ================================================================= #
        # We ignore gtk2 when it comes to the version-check.
        # ================================================================= #
        next if this_program == :gtk2
        # ================================================================= #
        # Next use Gem::Version to compare them, but not if the version
        # is nil.
        # ================================================================= #
        unless right_side.nil?
          # =============================================================== #
          # The .delete('v') is specifically for libuv or node.
          # =============================================================== #
          registered_local_version = registered_local_version.to_s.
                                     delete('v').
                                     tr('_','.')
          a = compare_via_gem_version(registered_local_version)
          b = compare_via_gem_version(right_side)
          if a and b and (a > b)
            result = ''.dup
            if use_one_line_to_show_the_result?
              result << mediumaquamarine(' ← ')
            else # else this is the default.
              result << lightblue('     ^^^^ ')
            end
            result << slateblue('This program could be '\
                      'upgraded, to the version ')+
                      steelblue(registered_local_version)
            e result
          end if registered_local_version =~ /\d+/
        end
      end
    }
  end
end
register_unavailable_program(i) click to toggle source
#

register_unavailable_program

Programs that were not be found can be registered through this method.

#
# File lib/environment_information/class/class.rb, line 1369
def register_unavailable_program(i)
  i = i.to_sym # Let's store only Symbols.
  @array_unavailable_programs << i
end
Also aliased as: register_not_found
report( report_these_programs = @array_report_these_programs )
report_result( report_these_programs = @array_report_these_programs )
report_the_installed_KDE_software_suite() click to toggle source
#

report_the_installed_KDE_software_suite

#
# File lib/environment_information/class/class.rb, line 723
def report_the_installed_KDE_software_suite
  begin
    require 'rbt/toplevel_methods/toplevel_methods.rb'
    require 'rbt/toplevel_methods/try_to_return_a_special_compile_component.rb'
    require 'rbt/toplevel_methods/swift_return_version_of_this_program.rb'
    array = RBT.return_kde_apps
    append_this = ''.dup
    if array and !array.empty?
      e 'Now working through all registered KDE applications, trying to'
      e 'show their version on the commandline:'
      e
      array.each {|this_program|
        append_this.clear
        # ================================================================= #
        # The next line of code was added in August 2022 because ksmoothdock
        # is misbehaving. At a later time we may have to review this;
        # ideally we should not need any such ad-hoc exceptions ever.
        # ================================================================= #
        next if this_program == 'ksmoothdock'
        print gold(
          ('  '+this_program+':').ljust(40)
        )
        cmd_to_use = "#{this_program} --version 2>&1"
        version = `#{cmd_to_use}`
        if version.include? "command not found\n"
          version = THE_PROGRAM_IS_NOT_INSTALLED_OR_COULD_NOT_BE_FOUND
        else
          if version
            # Remove the name of the program here e. g. "kcachegrind 21.12.1"
            version.sub!(/#{this_program}/,'')
            most_recent_version = ::RBT.swift_return_version_of_this_program(this_program.strip.downcase)
            if RBT.is_this_version_higher_than_that_version?(
                most_recent_version.to_s,
                version.to_s,
                :do_not_report_any_errors
              )
              append_this << orange(
                "\n      ^^^ This program could "\
                "be updated to version "+
                most_recent_version.to_s
              )
            end
          end
        end
        version.strip!
        if version.include? 'The program is not installed'
          e lightblue(version)+append_this
        else
          e steelblue(version)+append_this
        end
      }
      e
    else
      e 'The array appears to be empty.'
    end
    exit
  rescue LoadError; end
end
report_the_remote_urls?() click to toggle source
#

report_the_remote_urls?

#
# File lib/environment_information/class/class.rb, line 1495
def report_the_remote_urls?
  @internal_hash[:report_the_remote_urls]
end
report_version() click to toggle source
#

report_version

#
# File lib/environment_information/class/class.rb, line 1760
def report_version
  require 'environment_information/toplevel_methods/menu.rb'
  ::EnvironmentInformation.report_version
  @do_exit_the_program = true
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/environment_information/class/class.rb, line 185
def reset
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  @internal_hash = {}
  # ======================================================================= #
  # === :report_the_remote_urls
  #
  # If this instance variable is set to true then the remote URLs will
  # be shown as well, on the commandline.
  # ======================================================================= #
  @internal_hash[:report_the_remote_urls] = false
  # ======================================================================= #
  # === :try_to_rename_the_kde_konsole_tab
  #
  # The following instance variable will determine as to whether we will
  # try to make use of the KDE Konsole and rename the tab of the konsole
  # there.
  #
  # Since as of October 2018 we will not use the KDE konsole by default
  # anymore. This may change at a later moment in time, though.
  # ======================================================================= #
  @internal_hash[:try_to_rename_the_kde_konsole_tab] = false
  # ======================================================================= #
  # === :generate_a_html_file
  #
  # If the next instance variable is set to true then a html file will
  # be generated. By default this will not happen, though.
  # ======================================================================= #
  @internal_hash[:generate_a_html_file] = false
  # ======================================================================= #
  # === :store_the_results_into_local_files
  #
  # If the following variable is set to true then the project will
  # generate local files too, e. g. yaml files and what not.
  # ======================================================================= #
  @internal_hash[:store_the_results_into_local_files] = true
  # ======================================================================= #
  # === :use_ascii_table
  #
  # Whether to use an ASCII table or whether we will not:
  # ======================================================================= #
  @internal_hash[:use_ascii_table] = false
  # ======================================================================= #
  # === :table
  # ======================================================================= #
  @internal_hash[:table] = nil # The ascii table.
  # ======================================================================= #
  # === :compare_program_versions
  #
  # This instance variable can be used to also compare the program
  # versions, if the RBT project is available.
  #
  # By default this will not be done, though.
  # ======================================================================= #
  @internal_hash[:compare_program_versions] = false
  # ======================================================================= #
  # === :use_one_line_to_show_the_result
  # ======================================================================= #
  @internal_hash[:use_one_line_to_show_the_result] = false
  # ======================================================================= #
  # === :sort_alphabetically
  #
  # Whether to sort the main Hash alphabetically or not.
  # ======================================================================= #
  @internal_hash[:sort_alphabetically] = false
  # ======================================================================= #
  # === @pkg_config_query
  # ======================================================================= #
  @pkg_config_query = ::EnvironmentInformation::Queries::PkgConfig.new
  # ======================================================================= #
  # === @simple_version_query
  # ======================================================================= #
  @simple_version_query = ::EnvironmentInformation::Queries::SimpleVersion.new
  # ======================================================================= #
  # === @complex_version_query
  # ======================================================================= #
  @complex_version_query = ::EnvironmentInformation::Queries::ComplexVersion.new
  # ======================================================================= #
  # === @array_report_these_programs
  #
  # This Array denotes which programs are to be reported.
  #
  # By default it is empty.
  # ======================================================================= #
  @array_report_these_programs = []
  # ======================================================================= #
  # === @array_unavailable_programs
  #
  # Programs which could not be found can be registered into the following
  # Array.
  # ======================================================================= #
  @array_unavailable_programs = []
  # ======================================================================= #
  # === @runmode
  #
  # The @runmode variable can be :commandline or :gui or :www.
  # ======================================================================= #
  @runmode = :commandline
  # ======================================================================= #
  # === @show_everything
  #
  # If the following instance variable is set to true then this class
  # will try to show every registered (and thus, available) component.
  #
  # By default this is not wanted, so it is disabled. The user has to
  # specifically enable this option via the commandline, if so
  # desired, and thus overrule this default value.
  # ======================================================================= #
  @show_everything = false
  # ======================================================================= #
  # === @display_result
  #
  # If the following instance variable is true, which is the case by
  # default, then this class will report to the user on the commandline.
  #
  # If it is set to false then nothing will be displayed; this is
  # useful when you only want to obtain the dataset, without
  # showing anything to the user.
  # ======================================================================= #
  @display_result = true
  # ======================================================================= #
  # === @be_silent
  #
  # By default, this class is not silent, meaning that it will display
  # information to the user.
  # ======================================================================= #
  @be_silent = false
  # ======================================================================= #
  # === :may_we_try_to_use_rbt
  #
  # Whether we may query RBT for additional help or not. By default
  # we will try to make use of RBT.
  # ======================================================================= #
  @internal_hash[:may_we_try_to_use_rbt] = true
  # ======================================================================= #
  # === @array_show_this_to_the_user
  #
  # The following Array can be used to show messages to the user.
  # ======================================================================= #
  @array_show_this_to_the_user = []
  # ======================================================================= #
  # === @array_display_these_components
  #
  # This Array will display the components on the commandline.
  #
  # Take note that the order is important: the entries that appear first
  # will be displayed earlier. In other words: first entries will be
  # shown first as well.
  # ======================================================================= #
  @array_display_these_components = []
  # ======================================================================= #
  # === @show_ruby_version_and_gem_version
  #
  # This instance variable determines whether class EnvironmentInformation
  # will display the ruby version and the gem version.
  #
  # By default we will do so, but there may be situations where this
  # may be unwanted, or not a good idea, such as in a minimal system
  # where no ruby is running, or if the user only wants to display
  # very little information.
  # ======================================================================= #
  @show_ruby_version_and_gem_version = true
  # ======================================================================= #
  # === @display_everything_in_short_format
  #
  # This variable determines whether we will use a compact-display or
  # whether there will be one-entry-per-program instead.
  # ======================================================================= #
  @display_everything_in_short_format = false
  # ======================================================================= #
  # === @run_already
  #
  # This variable will be true by default.
  # ======================================================================= #
  @run_already = true
  # ======================================================================= #
  # === @show_help
  #
  # If this variable is set to true, then we will only show help, then
  # exit the program.
  # ======================================================================= #
  @show_help = false
  # ======================================================================= #
  # === @do_exit_the_program
  #
  # The following variable can determine when we exit from this class.
  # By default we will not exist early.
  # ======================================================================= #
  @do_exit_the_program = false
  # ======================================================================= #
  # === @array_these_programs_not_up_to_date
  #
  # This Array can be used to save into a local file which programs
  # are not up to date.
  # ======================================================================= #
  if is_on_roebe?
    @array_these_programs_not_up_to_date = []
  end
end
result()
Alias for: result_as_array
result?()
result_as_array() click to toggle source
#

result_as_array

The lines that we will have inside of this method, may look like this:

"  operating_system:                 GNU/Linux\n"
#
# File lib/environment_information/class/class.rb, line 1159
def result_as_array
  _ = dataset_as_string
  splitted = _.split("\n")
  splitted.map! {|inner_line|
    inner_line.split(': ').map {|entry| entry.strip }
  }
  return splitted
end
Also aliased as: result
return_all_ruby_components() click to toggle source
#

return_all_ruby_components

Combine three calls into one here - all related to ruby.

#
# File lib/environment_information/class/class.rb, line 1617
def return_all_ruby_components
  %i(
    ruby
    rubygems
    rubygems_installation_directory
  )
end
return_all_xorg_components()
Alias for: xorg_components?
return_default_programs()
return_default_programs_on_a_linux_computer()
return_default_programs_on_linux() click to toggle source
#

return_default_programs_on_linux

This method should return the “main” programs on a linux computer, the most important entries.

#
# File lib/environment_information/class/class.rb, line 802
def return_default_programs_on_linux
  ARRAY_DEFAULT_PROGRAMS_ON_LINUX
end
return_every_registered_component() click to toggle source
#

return_every_registered_component

#
# File lib/environment_information/class/class.rb, line 1409
def return_every_registered_component
  array = ::EnvironmentInformation.tracked_programs?+
          ::EnvironmentInformation.tracked_non_programs?+
          ::EnvironmentInformation.science_cluster?+
          ::EnvironmentInformation.xorg_components?
  array = array.flatten.uniq
  # ======================================================================= #
  # === The mate-desktop
  #
  # Since as of 31.03.2019 we will also try to show the mate-desktop
  # components if the RBT project is available/installed.
  # ======================================================================= #
  if can_we_query_the_mate_desktop?
    # ===================================================================== #
    # Keep in mind that this Array is nested, so the name is
    # included as well as the version.
    # ===================================================================== #
    _ = RBT.return_mate_desktop_version_array
    _.each {|a,b|
      # array << [a, b]
      array << a
      register_onto_the_main_hash(a, b)
    }
  end
  return array # Return our findings.
end
return_remote_gtk2_version() click to toggle source
#

return_remote_gtk2_version

Be wary when using this method, as it may slow down the whole application, due to making remote web-based queries.

#
# File lib/environment_information/class/class.rb, line 1457
def return_remote_gtk2_version
  ::EnvironmentInformation.return_remote_gtk2_version
end
return_version_of_awk()
return_version_of_awk?() click to toggle source
#

return_version_of_awk?

#
# File lib/environment_information/class/class.rb, line 1221
def return_version_of_awk?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_awk
return_version_of_binutils()
return_version_of_binutils?() click to toggle source
#

return_version_of_binutils?

#
# File lib/environment_information/class/class.rb, line 1228
def return_version_of_binutils?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_binutils
return_version_of_bison()
return_version_of_bison?() click to toggle source
#

return_version_of_bison?

#
# File lib/environment_information/class/class.rb, line 1298
def return_version_of_bison?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_bison
return_version_of_boost()
return_version_of_boost?() click to toggle source
#

return_version_of_boost?

#
# File lib/environment_information/class/class.rb, line 1509
def return_version_of_boost?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_boost
return_version_of_busyboxy()
return_version_of_busyboxy?() click to toggle source
#

return_version_of_busyboxy?

#
# File lib/environment_information/class/class.rb, line 1502
def return_version_of_busyboxy?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_busyboxy
return_version_of_coreutils()
return_version_of_coreutils?() click to toggle source
#

return_version_of_coreutils?

#
# File lib/environment_information/class/class.rb, line 1235
def return_version_of_coreutils?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_coreutils
return_version_of_diffutils()
return_version_of_diffutils?() click to toggle source
#

return_version_of_diffutils?

#
# File lib/environment_information/class/class.rb, line 1242
def return_version_of_diffutils?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_diffutils
return_version_of_flex()
return_version_of_flex?() click to toggle source
#

return_version_of_flex?

#
# File lib/environment_information/class/class.rb, line 1305
def return_version_of_flex?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_flex
return_version_of_gcc()
return_version_of_gcc?() click to toggle source
#

return_version_of_gcc?

#
# File lib/environment_information/class/class.rb, line 1249
def return_version_of_gcc?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_gcc
return_version_of_glibc()
return_version_of_glibc?() click to toggle source
#

return_version_of_glibc?

#
# File lib/environment_information/class/class.rb, line 1270
def return_version_of_glibc?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_glibc
return_version_of_gnupg()
return_version_of_gnupg?() click to toggle source
#

return_version_of_gnupg?

#
# File lib/environment_information/class/class.rb, line 1291
def return_version_of_gnupg?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_gnupg
return_version_of_grep()
return_version_of_grep?() click to toggle source
#

return_version_of_grep?

#
# File lib/environment_information/class/class.rb, line 1284
def return_version_of_grep?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_grep
return_version_of_intltool()
return_version_of_intltool?() click to toggle source
#

return_version_of_intltool?

#
# File lib/environment_information/class/class.rb, line 1277
def return_version_of_intltool?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_intltool
return_version_of_linux_kernel()
return_version_of_linux_kernel?() click to toggle source
#

return_version_of_linux_kernel?

#
# File lib/environment_information/class/class.rb, line 1256
def return_version_of_linux_kernel?
  ::EnvironmentInformation.send(__method__)
end
return_version_of_operating_system()
Alias for: operating_system?
return_version_of_ruby()
return_version_of_ruby?() click to toggle source
#

return_version_of_ruby?

#
# File lib/environment_information/class/class.rb, line 1657
def return_version_of_ruby?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_ruby
return_version_of_rubygems()
return_version_of_rubygems?() click to toggle source
#

return_version_of_rubygems?

#
# File lib/environment_information/class/class.rb, line 1650
def return_version_of_rubygems?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_rubygems
return_version_of_xvid()
return_version_of_xvid?() click to toggle source
#

return_version_of_xvid?

#
# File lib/environment_information/class/class.rb, line 1516
def return_version_of_xvid?
  ::EnvironmentInformation.send(__method__)
end
Also aliased as: return_version_of_xvid
rev() click to toggle source
#

rev

#
# File lib/environment_information/class/colours.rb, line 86
def rev
  if use_colours?
    Colours::GREEN
  else
    ''
  end
end
royalblue(i = '') click to toggle source
#

royalblue

#
# File lib/environment_information/class/colours.rb, line 167
def royalblue(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.royalblue(i)
  end
  return i
end
rubygems_installation_directory?() click to toggle source
#

rubygems_installation_directory?

#
# File lib/environment_information/class/class.rb, line 1665
def rubygems_installation_directory?
  ::EnvironmentInformation.rubygems_installation_directory?
end
run() click to toggle source
#

run (run tag)

#
# File lib/environment_information/class/class.rb, line 2495
def run
  # ======================================================================= #
  # Try to rename the KDE konsole first. This will happen on
  # roebe-systems only.
  # ======================================================================= #
  do_rename_kde_konsole
  # ======================================================================= #
  # ^^^ This check happens here again because menu() is allowed to
  # toggle this variable.
  # ======================================================================= #
  if @display_everything_in_short_format
    assign_components_for_the_short_format # Handle the short format here.
  end
  do_sort_alphabetically if sort_alphabetically? # ← Must come before the report-step.
  unless @do_exit_the_program
    # ===================================================================== #
    # === Report step
    #
    # We may only display the components if @display_result is true.
    # ===================================================================== #
    if @display_result
      register_the_available_components_and_show_them_at_once
    end
  end
  # ======================================================================= #
  # === Consider generating a .html file
  #
  # The user may want to generate a .html file, so the following
  # functionality allows the user to do so. This check should
  # ideally come before other local files are generated.
  # ======================================================================= #
  do_generate_a_html_file if @internal_hash[:generate_a_html_file]
  if commandline? and store_the_results_into_local_files?
    # ===================================================================== #
    # Only store local files if the variable
    # @store_the_results_into_local_files is true.
    # ===================================================================== #
    consider_storing_the_components_that_were_displayed
    consider_storing_which_programs_are_not_up_to_date
  end
end
screen_resolution?() click to toggle source
#

screen_resolution?

#
# File lib/environment_information/class/class.rb, line 1394
def screen_resolution?
  ::EnvironmentInformation.screen_resolution?
end
seagreen(i = '') click to toggle source
#

seagreen

#
# File lib/environment_information/class/colours.rb, line 197
def seagreen(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.seagreen(i)
  end
  return i
end
set_additional( i )
Alias for: add
set_be_silent(i = true) click to toggle source
#

set_be_silent

#
# File lib/environment_information/class/class.rb, line 1019
def set_be_silent(i = true)
  @be_silent = i
end
set_display_these_components(i)
Alias for: set_main_array
set_main_array(i) click to toggle source
#

set_main_array

#
# File lib/environment_information/class/class.rb, line 964
def set_main_array(i)
  @array_report_these_programs = i
end
set_report_these_programs(i)
Alias for: set_main_array
set_runmode_gui() click to toggle source
#

set_runmode_gui

#
# File lib/environment_information/class/class.rb, line 974
def set_runmode_gui
  @runmode = :gui
end
set_runmode_html() click to toggle source
#

set_runmode_html

#
# File lib/environment_information/class/class.rb, line 981
def set_runmode_html
  @runmode = :html
end
set_use_colours(i = '') click to toggle source
#

set_use_colours

#
# File lib/environment_information/class/colours.rb, line 55
def set_use_colours(i = '')
  ::EnvironmentInformation.set_use_colours(true)
end
set_use_this_as_main_input(i)
Alias for: set_main_array
sfancy(i = '') click to toggle source
#

sfancy

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

sfile

#
# File lib/environment_information/class/colours.rb, line 121
def sfile(i)
  return ::Colours.sfile(i) if use_colours?
  return i
end
shall_we_really_store_which_programs_are_not_up_to_date?() click to toggle source
#

shall_we_really_store_which_programs_are_not_up_to_date?

This method will also honour whether the user is on a roebe-like system or whether the user is not.

#
# File lib/environment_information/class/class.rb, line 1147
def shall_we_really_store_which_programs_are_not_up_to_date?
  is_on_roebe? and !@array_these_programs_not_up_to_date.empty?
end
show_everything?() click to toggle source
#

show_everything?

#
# File lib/environment_information/class/class.rb, line 1084
def show_everything?
  @show_everything
end
show_full_information()
Alias for: do_show_everything
show_help()
Alias for: do_show_help
show_help?() click to toggle source
#

show_help?

#
# File lib/environment_information/class/class.rb, line 1690
def show_help?
  @show_help
end
show_n_registered_entries() click to toggle source
#

show_n_registered_entries

Invoke this via:

envi --n_entries
#
# File lib/environment_information/class/class.rb, line 887
def show_n_registered_entries
  e "#{true_rev}The EnvironmentInformation project contains "\
    "#{sfancy(::EnvironmentInformation.tracked_programs?.size)} "\
    "#{true_rev}registered entries."
end
show_no_ruby()
show_only_the_components_from_this_dataset(i)
Alias for: set_main_array
show_the_registered_components( i = tracked_programs? ) click to toggle source
#

show_the_registered_components

#
# File lib/environment_information/class/class.rb, line 1737
def show_the_registered_components(
    i = tracked_programs?
  )
  e
  e 'The following programs will be tracked:'
  e
  use_one_line_to_show_the_result = use_one_line_to_show_the_result?
  i.each_with_index {|this_program, index| index += 1
    if use_one_line_to_show_the_result
      padded_index = index.to_s+') '
    else
      padded_index = '  '+(index.to_s+') ').rjust(5)
    end
    colourized_and_padded_index = seagreen(padded_index)
    e colourized_and_padded_index+
      steelblue(this_program)
  }
  e
end
show_these_components?()
show_these_entries( i )
Alias for: add
simp(i, use_colours = use_colours?) click to toggle source
#

simp

#
# File lib/environment_information/class/colours.rb, line 47
def simp(i, use_colours = use_colours?)
  return ::Colours.simp(i) if use_colours
  return i
end
slateblue(i = '') click to toggle source
#

slateblue

#
# File lib/environment_information/class/colours.rb, line 177
def slateblue(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.slateblue(i)
  end
  return i
end
sort_alphabetically?() click to toggle source
#

sort_alphabetically?

#
# File lib/environment_information/class/class.rb, line 1572
def sort_alphabetically?
  @internal_hash[:sort_alphabetically]
end
start_gtk_component() click to toggle source
#

start_gtk_component

To invoke this method from the commandline, do:

envi --start-gtk
#
# File lib/environment_information/class/class.rb, line 1528
def start_gtk_component
  require 'environment_information/gui/gtk3/environment_information.rb'
  ::EnvironmentInformation.run_gtk
  @do_exit_the_program = true
end
start_the_sinatra_interface() click to toggle source
#

start_the_sinatra_interface

#
# File lib/environment_information/class/class.rb, line 1033
def start_the_sinatra_interface
  require 'environment_information/www/sinatra_interface.rb'
  ::EnvironmentInformation.start_sinatra_interface
end
steelblue(i = '') click to toggle source
#

steelblue

#
# File lib/environment_information/class/colours.rb, line 187
def steelblue(i = '')
  if use_colours? and TRY_TO_USE_HTML_COLOURS
    i = ::Colours.steelblue(i)
  end
  return i
end
store_the_results_into_local_files?() click to toggle source
#

store_the_results_into_local_files?

#
# File lib/environment_information/class/class.rb, line 855
def store_the_results_into_local_files?
  @internal_hash[:store_the_results_into_local_files]
end
string()
Alias for: dataset_as_string
string?()
Alias for: dataset_as_string
stringified()
Alias for: dataset_as_string
teal(i = '') click to toggle source
#

teal

#
# File lib/environment_information/class/colours.rb, line 269
def teal(i = '')
  return ::Colours.teal(i) if use_colours?
  return i
end
tracked_programs?() click to toggle source
#

tracked_programs?

#
# File lib/environment_information/class/class.rb, line 792
def tracked_programs?
  ARRAY_TRACKED_PROGRAMS
end
true_rev() click to toggle source
#

true_rev

#
# File lib/environment_information/class/colours.rb, line 97
def true_rev
  if use_colours?
    Colours::REV
  else
    ''
  end
end
try_to_load_dataset_from_this_file(i)
try_to_read_content_from_this_file(i)
try_to_rename_the_kde_konsole_tab?() click to toggle source
#

try_to_rename_the_kde_konsole_tab?

#
# File lib/environment_information/class/class.rb, line 1091
def try_to_rename_the_kde_konsole_tab?
  @internal_hash[:try_to_rename_the_kde_konsole_tab]
end
update_version_for( i )
Alias for: add
use_ascii_table() click to toggle source
#

use_ascii_table

We will display in ascii-table format here.

#
# File lib/environment_information/class/class.rb, line 1070
def use_ascii_table
  disable_colours # Can't use colours right now. Perhaps at a later time.
  extend Terminal::Table::TableHelper
  @table = table ['Name', 'Version']
  @table.style = {
    padding_left:  2,
    width:       110 # Set the width here.
  }
  @use_ascii_table = true
end
use_colours?() click to toggle source
#

use_colours?

#
# File lib/environment_information/class/colours.rb, line 62
def use_colours?
  ::EnvironmentInformation.use_colours?
end
use_one_line_to_show_the_result?() click to toggle source
#

use_one_line_to_show_the_result?

#
# File lib/environment_information/class/class.rb, line 2488
def use_one_line_to_show_the_result?
  @internal_hash[:use_one_line_to_show_the_result]
end
work_on_the_programs_directory_only( use_this_as_programs_directory = '/home/Programs/' ) click to toggle source
#

work_on_the_programs_directory_only

This works on the /home/Programs/ directory directly.

Invocation example:

envi --work-on-programs-directory-only
#
# File lib/environment_information/class/class.rb, line 935
def work_on_the_programs_directory_only(
    use_this_as_programs_directory = '/home/Programs/'
  )
  # ======================================================================= #
  # 1) First, we have to determine which programs are available.
  # ======================================================================= #
  e "#{rev}Determining which programs are available at the prefix "\
    "#{steelblue(use_this_as_programs_directory)}:"
  array_these_programs_are_available = []
  tracked_programs?.each {|entry|
    target = "#{use_this_as_programs_directory}#{entry.capitalize}"
    if File.directory?(target)
      # =================================================================== #
      # In this case we know that this target exists.
      # =================================================================== #
      array_these_programs_are_available << entry
    end
  }
  # ======================================================================= #
  # 2) Checking these programs next.
  # ======================================================================= #
  clear_main_dataset
  add(array_these_programs_are_available)
  ::EnvironmentInformation.set_prefix_to_use(use_this_as_programs_directory)
end
work_through_the_programs( report_these_programs = @array_report_these_programs )
write_what_into(what, into) click to toggle source
#

write_what_into

#
# File lib/environment_information/class/class.rb, line 921
def write_what_into(what, into)
  ::EnvironmentInformation.write_what_into(what, into)
end
xorg_components?() click to toggle source
#

xorg_components?

#
# File lib/environment_information/class/class.rb, line 1113
def xorg_components?
  ::EnvironmentInformation.xorg_components?
end
Also aliased as: return_all_xorg_components