class RBT::Cookbooks::ReportTheseProgramsCouldBeUpdated

Constants

REGEX_FOR_DISTROWATCH_PROGRAMS
#

REGEX_FOR_DISTROWATCH_PROGRAMS

#

Public Class Methods

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

RBT::ReportTheseProgramsCouldBeUpdated[]

#
# File lib/rbt/check_for_updates/report_these_programs_could_be_updated.rb, line 145
def self.[](i = '')
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/check_for_updates/report_these_programs_could_be_updated.rb, line 32
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

check_entries_on_distrowatch() click to toggle source
#

check_entries_on_distrowatch

#
# File lib/rbt/check_for_updates/report_these_programs_could_be_updated.rb, line 65
def check_entries_on_distrowatch
  use_this_regex = REGEX_FOR_DISTROWATCH_PROGRAMS
  e rev+'First checking for new entries at '+yellow(+'distrowatch')+rev+'.'
  e
  dataset = URI.openopen(distrowatch_url?).read
  scanned = dataset.scan(use_this_regex)
  e 'The following programs were discovered (and reported as new) at distrowatch:'
  e
  # ======================================================================= #
  # Iterate over our Array next:
  # ======================================================================= #
  scanned.each {|this_program, this_version|
    is_it_registered_locally_or_not = false
    if RBT.does_include?(this_program.downcase.delete('-_'))
      is_it_registered_locally_or_not = true
    end
    append_version_information_string = ''.dup
    verbose_truth_is_it_registered_locally_or_not = verbose_truth(
      is_it_registered_locally_or_not
    )
    if verbose_truth_is_it_registered_locally_or_not.include? 'No'
      verbose_truth_is_it_registered_locally_or_not = verbose_truth_is_it_registered_locally_or_not.dup
      verbose_truth_is_it_registered_locally_or_not.sub!(
        /No/, crimson('No')
      )
      verbose_truth_is_it_registered_locally_or_not = 
        verbose_truth_is_it_registered_locally_or_not.delete('.')+cadetblue('. ')
    else
      # =================================================================== #
      # In this case the program is registered locally. Determine the
      # version too, in this case.
      # =================================================================== #
      verbose_truth_is_it_registered_locally_or_not = cadetblue(
        verbose_truth_is_it_registered_locally_or_not
      )
      append_version_information_string << darkgreen(' The local version is: ')
      the_local_version_is_this = RBT.swift_return_version_of_this_program(
        this_program.downcase.delete('-_').to_sym
      ).to_s 
      append_version_information_string << limegreen(the_local_version_is_this)
      if the_local_version_is_this == this_version
        # All is fine.
      else
        unless Gem::Version.new(the_local_version_is_this) > Gem::Version.new(this_version)
          register_unequal_version_for(
            this_program.delete('-_').to_sym
          )
        end
      end
    end
    e '  '+
      sfancy(
        this_program.downcase.ljust(25)
      )+
      royalblue(this_version.ljust(8))+' '+
      slateblue(' [Is it included locally: ')+
      verbose_truth_is_it_registered_locally_or_not+
      slateblue(']')+
      append_version_information_string
    # ===================================================================== #
    # Also report if we could update this next
    # ===================================================================== #
    if @array_these_programs_could_be_updated.include?(this_program.delete('-_').to_sym)
      e crimson('   ^^^ this program is registered '\
        'and could be updated')
    end
  }
  e
end
register_unequal_version_for(i) click to toggle source
#

register_unequal_version_for

#
# File lib/rbt/check_for_updates/report_these_programs_could_be_updated.rb, line 58
def register_unequal_version_for(i)
  @array_these_programs_could_be_updated << i
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/rbt/check_for_updates/report_these_programs_could_be_updated.rb, line 46
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @array_these_programs_could_be_updated
  # ======================================================================= #
  @array_these_programs_could_be_updated = []
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/check_for_updates/report_these_programs_could_be_updated.rb, line 138
def run
  check_entries_on_distrowatch
end