class EnvironmentInformation::EnvironmentInformation
Constants
- THIS_FILE
#¶ ↑
THIS_FILE
¶ ↑THIS_FILE
= __FILE__We hardcode this since it is only relevant on my home system, anyway.
#¶ ↑
- TRY_TO_USE_HTML_COLOURS
#¶ ↑
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
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/environment_information/class/initialize.rb, line 51 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. # ======================================================================= # @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 @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 # ======================================================================= # # Add the ruby components next. # ======================================================================= # consider_adding_the_ruby_components # ← Must come before menu(). # ======================================================================= # # Invoke menu() to query for the commandline arguments. # ======================================================================= # menu run if @run_already end
Public Instance Methods
#¶ ↑
add (add tag)¶ ↑
This method can be used to add individual entries to the main array.
The entries will have two variables:
1) the name of the component (normally the program) 2) the version associated with that component
If a Symbol is given then we may use this 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/add.rb, line 40 def add( i, version_to_use = nil ) if i.is_a?(String) and i.include?(',') i = i.split(',') elsif i.is_a?(String) and i.include?('-') i = i.dup if i.frozen? i.delete!('-') end case i # ======================================================================= # # === :everything # # This entry point is meant for simply adding everything. # ======================================================================= # when :everything i = return_every_registered_component # ======================================================================= # # === :linux_kernel # ======================================================================= # when :linux_kernel i = :linux # ======================================================================= # # === :RAM # ======================================================================= # when :RAM i = :ram # Just the "alias" to the real entry. # ======================================================================= # # === :all_xorg_components # ======================================================================= # when :all_xorg_components i = return_all_xorg_components # ======================================================================= # # === envi --science # ======================================================================= # when :science_cluster i = ARRAY_SCIENCE_CLUSTER # ======================================================================= # # === envi --lfs_core_programs # ======================================================================= # when :lfs, :lfs_core_programs i = ::EnvironmentInformation.lfs_core_programs? end if i.is_a? Array i.each {|entry, version_to_use| add(entry, version_to_use) } else unless @array_display_these_components.map {|entry| entry.first }.include? i @array_display_these_components << [i, version_to_use] #@array_display_these_components.flatten! end end end
#¶ ↑
assign_components_for_the_short_format
¶ ↑
We will only display 6 components when we use the short variant.
#¶ ↑
# File lib/environment_information/class/misc.rb, line 360 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
#¶ ↑
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/ruby.rb, line 40 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
¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 237 def consider_storing_the_components_that_were_displayed ::EnvironmentInformation.consider_storing_these_results_into_a_local_file end
#¶ ↑
consider_storing_which_programs_are_not_up_to_date
¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 104 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
#¶ ↑
dataset_as_string
¶ ↑
This method must return the dataset in String format. That String must already be properly “formatted”.
#¶ ↑
# File lib/environment_information/class/misc.rb, line 546 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
#¶ ↑
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 59 def disable_colours ::EnvironmentInformation.use_colours = false end
#¶ ↑
display_these_components?¶ ↑
Note that @display_these_components is a Hash.
#¶ ↑
# File lib/environment_information/class/misc.rb, line 525 def display_these_components? @array_display_these_components end
#¶ ↑
do_compare_the_program_version
¶ ↑
This method can be used if the user wishes to also compare the program version of the installed programs.
#¶ ↑
# File lib/environment_information/class/misc.rb, line 379 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 @compare_program_versions = true end
#¶ ↑
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/misc.rb, line 440 def do_display_in_a_short_format @display_everything_in_short_format = true end
#¶ ↑
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/html.rb, line 25 def do_generate_a_html_file( styling_instructions = :bold ) # ======================================================================= # # === 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" what = dataset_as_string case styling_instructions when :bold what = HtmlTags.b(what) end what = HtmlTags.html( HtmlTags.body( HtmlTags.h1( 'Your environment', css_style: 'margin-top:1em' )+ HtmlTags.pre(what, css_style: 'font-size: larger; padding-left:1em;') ) ) ::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_run_already
¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 618 def do_not_run_already @run_already = false end
#¶ ↑
do_not_save_anything
¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 226 def do_not_save_anything @shall_the_results_be_saved = false # ======================================================================= # # We will also avoid saving the results into a local yaml file. # ======================================================================= # @store_the_results_into_local_files = false end
#¶ ↑
do_not_show_the_ruby_components
¶ ↑
#¶ ↑
# File lib/environment_information/class/ruby.rb, line 51 def do_not_show_the_ruby_components @show_ruby_version_and_gem_version = false end
#¶ ↑
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/misc.rb, line 586 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_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).
Commandline invocation:
envi --everything
#¶ ↑
# File lib/environment_information/class/misc.rb, line 252 def do_show_everything add(:everything) # Simply add everything. end
#¶ ↑
do_show_help
(help tag)¶ ↑
Show the commandline-usage through this method here.
To invoke this, try:
envi --help
#¶ ↑
# File lib/environment_information/class/help.rb, line 23 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+'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 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
#¶ ↑
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/misc.rb, line 321 def do_show_only_the_xorg_components clear_old_dataset do_not_show_the_ruby_components add(:all_xorg_components) end
#¶ ↑
dont_show_ruby_stuff
¶ ↑
Disable showing ruby + gem information.
#¶ ↑
# File lib/environment_information/class/ruby.rb, line 16 def dont_show_ruby_stuff # Dont show ruby stuff. @show_ruby_version_and_gem_version = false end
#¶ ↑
e (e tag)¶ ↑
The e() method is the general output-method for this class.
#¶ ↑
# File lib/environment_information/class/report.rb, line 210 def e(i = '') if @display_everything_in_short_format # ===================================================================== # # Display the results in a single line. # ===================================================================== # print "#{i}, " else puts i end unless @be_silent end
#¶ ↑
is_a_registered_component?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 603 def is_a_registered_component?(i) i = i.to_sym unless i.is_a? Symbol ::EnvironmentInformation.is_this_component_included?(i) end
#¶ ↑
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/misc.rb, line 142 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
#¶ ↑
log_dir?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 219 def log_dir? ::EnvironmentInformation.temp_directory? end
#¶ ↑
operating_system?¶ ↑
To quickly test this method, try:
EnvironmentInformation::EnvironmentInformation.new { :do_not_run_yet }.operating_system?
#¶ ↑
# File lib/environment_information/class/misc.rb, line 801 def operating_system? ::EnvironmentInformation.send(__method__) end
#¶ ↑
opnn¶ ↑
#¶ ↑
# File lib/environment_information/class/opn.rb, line 21 def opnn Opn.opn({ namespace: NAMESPACE, use_colours: use_colours? }) if Object.const_defined? :Opn end
#¶ ↑
report (report tag)¶ ↑
#¶ ↑
# File lib/environment_information/class/report.rb, line 50 def report if @array_display_these_components.empty? opn; e 'There are no components that can be displayed.' # And this ends here. else e clear_toplevel_hash # ===================================================================== # # Iterate over the main components next. # ===================================================================== # @array_display_these_components.each {|this_program, version| if version.nil? version = ::EnvironmentInformation.version_for?(this_program) end if version.nil? register_unavailable_program(this_program) end add_this_to_the_toplevel_hash(this_program, version) # =================================================================== # # Next do some sanitizing. # =================================================================== # case this_program.to_s # ===================================================================== # # === operating_system # ===================================================================== # when /^operating(_|-)?system$/i, /^operating(_|-)?system(_|-)?in(_|-)?use$/i this_program = 'Operating system' # ===================================================================== # # === operating_system_bit_type # ===================================================================== # when /^operating(_|-)?system(_|-)?bit(_|-)?type$/i this_program = 'Operating system bit type' # ===================================================================== # # === ram # ===================================================================== # when /^ram$/i this_program = 'RAM' # ===================================================================== # # === cflags # ===================================================================== # when /^cflags$/i this_program = 'cflags in use' # ===================================================================== # # === screen_resolution # ===================================================================== # when /^screen( |_)?resolution$/i this_program = 'Screen Resolution' # =================================================================== # # === cpflags # =================================================================== # when /^cflags$/i, /^CFLAGS in use$/i this_program = 'CFLAGS in use' # =================================================================== # # === cpuinfo # =================================================================== # when 'cpuinfo' this_program = 'CPU Model' end left_side = ::EnvironmentInformation.prepare_left_side(this_program.to_s.dup) right_side = ::EnvironmentInformation.prepare_right_side(version.to_s.ljust(6)).to_s if version.nil? right_side = dimgray('[Not found or installed.]') end this_program = this_program.dup if this_program.frozen? case this_program.to_s.strip # =================================================================== # # === Screen Resolution # =================================================================== # when /^RAM$/ right_side = right_side.dup if right_side.frozen? right_side << orange('MB RAM') # =================================================================== # # === Screen Resolution # =================================================================== # when /^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 end if right_side.include? 'steelblue' # ================================================================= # # An ad-hoc solution - we assume it was not found. # ================================================================= # right_side = '[Not found.]' if use_colours? right_side = orange(right_side) end end # =================================================================== # # === @report_the_remote_urls # # Next, honour @report_the_remote_urls if it is true. # =================================================================== # if @report_the_remote_urls if Object.const_defined?(:RBT) and RBT.respond_to?(:remote_url_for?) version = ''.dup _ = this_program.to_s.delete('-').downcase.strip 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) right_side = right_side.dup if right_side.frozen? right_side << " #{olive('→')} #{version}" end end end end e left_side+right_side _ = this_program.to_s.delete(':') # =================================================================== # # Next compare the program versions. # =================================================================== # if @compare_program_versions and may_we_try_to_use_rbt? and is_rbt_available? and RBT.does_include?(_) registered_local_version = RBT.swift_return_version_of_this_program(_.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 version.nil? # =============================================================== # # The .delete('v') part is specifically to workaround node. # =============================================================== # if Gem::Version.new(registered_local_version.delete('v').tr('_','.')) > Gem::Version.new(version) e slateblue(' ^^^^^ This program could be upgraded, '\ 'to the version ')+ steelblue(registered_local_version) end end end } e end end
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/environment_information/class/reset.rb, line 14 def reset # ======================================================================= # # === @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. # ======================================================================= # @store_the_results_into_local_files = true # ======================================================================= # # === @use_ascii_table # # Whether to use an ASCII table or whether we will not: # ======================================================================= # @use_ascii_table = false # ======================================================================= # # === @table # ======================================================================= # @table = nil # The ascii table. # ======================================================================= # # === @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 # ======================================================================= # # === @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 # ======================================================================= # # === @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. # ======================================================================= # @compare_program_versions = 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. # ======================================================================= # @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 = [] # ======================================================================= # # === @sort_alphabetically # # Whether to sort the main Hash alphabetically or not. # ======================================================================= # @sort_alphabetically = false # ======================================================================= # # === @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 # ======================================================================= # # === @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. # ======================================================================= # @generate_a_html_file = 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. # ======================================================================= # @try_to_rename_the_kde_konsole_tab = 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 # ======================================================================= # # === @report_the_remote_urls # # If this instance variable is set to true then the remote URLs will # be shown as well, on the commandline. # ======================================================================= # @report_the_remote_urls = 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 # ======================================================================= # # Add the default programs on a linux computer. # ======================================================================= # add( return_default_programs_on_a_linux_computer ) end
#¶ ↑
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/misc.rb, line 127 def result_as_array _ = dataset_as_string splitted = _.split("\n") splitted.map! {|inner_line| inner_line.split(': ').map {|entry| entry.strip } } return splitted end
#¶ ↑
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/misc.rb, line 649 def return_default_programs_on_linux ARRAY_DEFAULT_PROGRAMS_ON_LINUX end
#¶ ↑
return_every_registered_component
¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 465 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 is_rbt_available? if RBT.const_defined?(:ReportMateDesktopVersion) # =================================================================== # # 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] } end end return array # Return our findings. end
#¶ ↑
return_version_of_awk
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 695 def return_version_of_awk? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_binutils
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 702 def return_version_of_binutils? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_bison
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 772 def return_version_of_bison? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_boost
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 688 def return_version_of_boost? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_coreutils
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 709 def return_version_of_coreutils? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_diffutils
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 716 def return_version_of_diffutils? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_flex
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 779 def return_version_of_flex? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_gcc
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 723 def return_version_of_gcc? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_glibc
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 744 def return_version_of_glibc? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_gnupg
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 765 def return_version_of_gnupg? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_grep
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 758 def return_version_of_grep? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_intltool
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 751 def return_version_of_intltool? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_linux_kernel
?¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 730 def return_version_of_linux_kernel? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_ruby
?¶ ↑
#¶ ↑
# File lib/environment_information/class/ruby.rb, line 65 def return_version_of_ruby? ::EnvironmentInformation.send(__method__) end
#¶ ↑
return_version_of_rubygems
?¶ ↑
#¶ ↑
# File lib/environment_information/class/ruby.rb, line 58 def return_version_of_rubygems? ::EnvironmentInformation.send(__method__) end
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/environment_information/class/run.rb, line 14 def run # ======================================================================= # # (1) Try to rename the KDE konsole first. This will happen on # roebe-systems only. # ======================================================================= # do_rename_kde_konsole # ======================================================================= # # Only enter the report-section if we do NOT want to exit early. # ======================================================================= # do_show_help if @show_help # ======================================================================= # # ^^^ 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 # ===================================================================== # # We may only display the components if @display_result is true. # ===================================================================== # report if @display_result end # ======================================================================= # # Next check whether we should generate a .html file. This check # should come before we generate other local files. # ======================================================================= # do_generate_a_html_file if @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
#¶ ↑
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/misc.rb, line 97 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_n_registered_entries
¶ ↑
Invoke this via:
envi --n_entries
#¶ ↑
# File lib/environment_information/class/misc.rb, line 500 def show_n_registered_entries e "#{true_rev}The EnvironmentInformation project contains "\ "#{sfancy(::EnvironmentInformation.tracked_programs?.size)} "\ "#{true_rev}registered entries." end
#¶ ↑
show_the_registered_components
¶ ↑
#¶ ↑
# File lib/environment_information/class/misc.rb, line 447 def show_the_registered_components( i = ARRAY_TRACKED_PROGRAMS ) e e 'The following programs will be tracked:' e i.each_with_index {|this_program, index| index += 1 padded_index = ' '+(index.to_s+') ').rjust(5) colourized_and_padded_index = seagreen(padded_index) e colourized_and_padded_index+ steelblue(this_program) } e end
#¶ ↑
use_ascii_table
¶ ↑
We will display in ascii-table format here.
#¶ ↑
# File lib/environment_information/class/misc.rb, line 190 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
#¶ ↑
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/misc.rb, line 39 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 = [] ARRAY_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