class RBT::SaveTheAvailableProgramsVersions

Public Class Methods

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

RBT::SaveTheAvailableProgramsVersions[]

#
# File lib/rbt/utility_scripts/save_the_available_programs_versions.rb, line 184
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/save_the_available_programs_versions.rb, line 30
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :do_not_store
    # ===================================================================== #
    when :do_not_store
      @report_and_store_into_a_local_text_file = false
    end
  end
  run if run_already
end

Public Instance Methods

fill_up_the_result_variable() click to toggle source
#

fill_up_the_result_variable

This method will populate @result with the proper content/data.

It will make use of class RawCookbook for this.

#
# File lib/rbt/utility_scripts/save_the_available_programs_versions.rb, line 78
def fill_up_the_result_variable
  # ======================================================================= #
  # We must store these entries:
  #
  #   (1) program name
  #   (2) program version
  #   (3) last update of this program
  #   (4) remote URL
  #
  # ======================================================================= #
  available_programs?.each {|this_program|
    # ===================================================================== #
    # The variable this_program looks like this:
    #
    #   /home/Programs/Ruby/2.7.1/lib/ruby/site_ruby/2.7.0/rbt/yaml/cookbooks/gnote.yml
    #
    # ===================================================================== #
    _ = @raw_cookbook.load_this_program(this_program)
    # ===================================================================== #
    # All information is obtained from class RawCookbook. This means that
    # we have to pass Strings towards the [] method.
    # ===================================================================== #
    original_url1 = _['url1'].dup
    url1 = _['url1']
    last_update = _['last_update']
    if _.has_key? 'program_name_and_program_version'
      url1 = _['program_name_and_program_version']
      url1 = sanitize_url1_entry(url1, _)
    end
    program_name = remove_archive_from_the_end(
      ProgramInformation.return_program_name(
        File.basename(url1)
      )
    )
    program_version = remove_archive_from_the_end(
      ProgramInformation.return_program_version(
        File.basename(url1)
      )
    )
    # ===================================================================== #
    # Next, we need to rescue github-URLs.
    # ===================================================================== #
    if url1.include?('//github.com') and
      program_name.empty? and
      program_version.empty?
      _ = RBT.return_program_name_and_program_version_from_this_github_url(url1)
      program_name    = ProgramInformation.return_name(_)
      program_version = ProgramInformation.return_version(_)
    end
    @result << "#{program_name.downcase.ljust(25)} "\
               "#{program_version.ljust(12)} "\
               "#{last_update.ljust(12)} "\
               "#{original_url1}\n"
  }
end
report_the_result() click to toggle source
#

report_the_result

#
# File lib/rbt/utility_scripts/save_the_available_programs_versions.rb, line 137
def report_the_result
  e @result
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/save_the_available_programs_versions.rb, line 54
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @result
  # ======================================================================= #
  @result = ''.dup
  # ======================================================================= #
  # === @raw_cookbook
  # ======================================================================= #
  @raw_cookbook = RBT.raw_cookbook
  # ======================================================================= #
  # === @report_and_store_into_a_local_text_file
  # ======================================================================= #
  @report_and_store_into_a_local_text_file = true
end
result?() click to toggle source
#

result?

#
# File lib/rbt/utility_scripts/save_the_available_programs_versions.rb, line 144
def result?
  @result
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/save_the_available_programs_versions.rb, line 165
def run
  fill_up_the_result_variable
  if @report_and_store_into_a_local_text_file
    report_the_result
    store_the_result_into_a_local_text_file
    if is_on_roebe?
      into = RUBY_SRC_DIR_RBT_YAML+
             'programs_version/'\
             'the_expanded_coobkook_dataset_was_last_updated_on_this_day.yml'
      opne 'Storing into the file `'+sfile(into)+'` next.'
      what = dd_mm_yyyy
      write_what_into(what, into)
    end
  end
end
store_the_result_into_a_local_text_file() click to toggle source
#

store_the_result_into_a_local_text_file

#
# File lib/rbt/utility_scripts/save_the_available_programs_versions.rb, line 151
def store_the_result_into_a_local_text_file
  what = @result
  into = "#{RUBY_SRC_DIR_RBT_YAML}programs_version/"\
         "available_programs_versions.md"
  opne 'Now storing into this file:'
  e
  e "  #{sfile(into)}"
  e
  write_what_into(what, into)
end