class RBT::Cookbooks::CheckForBlfsUpdates
Constants
- LIMIT_THE_AMOUNT_OF_PROGRAMS
#¶ ↑
LIMIT_THE_AMOUNT_OF_PROGRAMS
¶ ↑#¶ ↑
- UPDATE_REGEX
#¶ ↑
UPDATE_REGEX
¶ ↑#¶ ↑
- WORK_ON_N_PROGRAMS
#¶ ↑
WORK_ON_N_PROGRAMS
¶ ↑On how many programs we will work. This constant will only be honoured if the
LIMIT_THE_AMOUNT_OF_PROGRAMS
was set to true, though.#¶ ↑
Public Class Methods
[](i = ARGV)
click to toggle source
Public Instance Methods
blfs_url_for(i)
click to toggle source
#¶ ↑
blfs_url_for
¶ ↑
#¶ ↑
# File lib/rbt/check_for_updates/check_for_blfs_updates.rb, line 140 def blfs_url_for(i) RBT.return_blfs_page_of_this_program(i).to_s end
Also aliased as: return_blfs_page_of_this_program
colour_for_blfs_entries(i)
click to toggle source
input?()
click to toggle source
remote_webpage?()
click to toggle source
#¶ ↑
remote_webpage?¶ ↑
Query method over the remote BLFS webpage.
#¶ ↑
# File lib/rbt/check_for_updates/check_for_blfs_updates.rb, line 76 def remote_webpage? BLFS_CHANGELOG_WEBPAGE end
Also aliased as: remote_website?
report_blfs_page_of_this_program(name_of_the_program)
click to toggle source
#¶ ↑
report_blfs_page_of_this_program
¶ ↑
#¶ ↑
# File lib/rbt/check_for_updates/check_for_blfs_updates.rb, line 118 def report_blfs_page_of_this_program(name_of_the_program) _ = blfs_url_for(name_of_the_program) if _ opne 'The BLFS entry for '+sfancy(name_of_the_program)+ ' can be found at `'+colour_for_blfs_entries(_)+'`.' else opne 'The program '+sfancy(name_of_the_program)+ ' does '+swarn('NOT')+' yet have a BLFS entry. '\ 'Please add one.' end end
report_this_program(i)
click to toggle source
#¶ ↑
report_this_program
¶ ↑
#¶ ↑
# File lib/rbt/check_for_updates/check_for_blfs_updates.rb, line 191 def report_this_program(i) ljust_value = 15 # ======================================================================= # # Some entries may not have a version entry associated, such as # 'gconf". # ======================================================================= # if !does_the_cookbook_include_this_program?(i) and !i.include?('-') opne 'A new program may have been added: '+sfancy(i)+N+ (' ' * 32)+colour_for_blfs_entries(blfs_url_for(i)) else unless i.include? '-' opne 'The input `'+sfancy(i)+'` contains no - character. It '\ 'will thus' append_this = '-0.0.1' opne 'be modified towards `'+sfancy(i+append_this)+'`.' i = i.dup i << append_this end dataset_for_this_program = ProgramInformation.return_name_and_version(i, :downcase) name_of_the_program, remote_program_version = dataset_for_this_program remote_program_version.chop! if remote_program_version.end_with? '.' name_of_the_program.strip! name_of_the_program = correct_for_common_mistakes_in_program_names( name_of_the_program ) if does_the_cookbook_include_this_program? name_of_the_program opne 'The program '+sfancy(name_of_the_program.ljust(ljust_value))+ ' is included.' local_version = return_local_version_of_this_program(name_of_the_program) if local_version.to_s == remote_program_version.to_s opne "The local dataset is already up to date. Program "\ "version is: #{sfancy(remote_program_version)}" else remote_program_version.delete!('v') # =================================================================== # # In this case, the remote version is not the same as the local # version. Report this. # =================================================================== # gem_version_of_the_remote_program = gem_version(remote_program_version) gem_version_of_the_local_program = gem_version(local_version) if gem_version_of_the_remote_program and gem_version_of_the_local_program if gem_version_of_the_remote_program > gem_version_of_the_local_program opne firebrick('The BLFS homepage contains a version that is '\ 'more up to date.') opne powderblue('Local version: ')+ sfancy(local_version.to_s)+powderblue(', BLFS version: ')+ sfancy(remote_program_version)+powderblue(')') else opne powderblue('Local version: ')+ sfancy(local_version.to_s)+powderblue(', BLFS version: ')+ sfancy(remote_program_version)+powderblue(') Seems '\ 'as if the local version is more up to date than the '\ 'BLFS version.') end else opne 'Something went wrong with these two version '\ 'strings ('+sfancy(remote_program_version.to_s)+ ', '+sfancy(local_version)+').' end end report_blfs_page_of_this_program(name_of_the_program) else opne 'The program '+sfancy(name_of_the_program.ljust(ljust_value))+ ' is '+swarn('NOT')+' included.' end end end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::Cookbooks::CheckForRemoteWebpages#reset
# File lib/rbt/check_for_updates/check_for_blfs_updates.rb, line 62 def reset super() infer_the_namespace # ======================================================================= # # === @work_on_n_programs # ======================================================================= # @work_on_n_programs = WORK_ON_N_PROGRAMS end
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/check_for_updates/check_for_blfs_updates.rb, line 147 def run report_the_remote_webpage obtain_dataset_from_the_remote_webpage array = [] # Our main dataset. # ======================================================================= # # Check for "Add xyz" first. Note that the regex will make use of UTF-8 # by default, since as of January 2020. # ======================================================================= # use_this_regex = /- Adde?d? ([A-Za-z]{1,14}[0-9]{0,1})/u # See: http://rubular.com/r/gl1vSycqVf scanned_result = @dataset.scan(use_this_regex) array << scanned_result.flatten.reject {|entry| (entry == '-') or (entry == ' ') } array.flatten! # ======================================================================= # # The next regex checks for "Update to" entries. However had, the # BLFS homepage also has other formats such as # "[renodr] - Add libidn2. Fixes #9045. # ======================================================================= # use_this_regex = UPDATE_REGEX matches = @dataset.scan(use_this_regex).map {|entry| entry.join }.flatten array << matches array.flatten! array.compact! array.map! {|line| line.strip.downcase } # Keep it downcased as well. if LIMIT_THE_AMOUNT_OF_PROGRAMS # ===================================================================== # # Right now we hardcode-limit this to 15 entries. # ===================================================================== # n_programs_in_total = @work_on_n_programs array = array[0..(n_programs_in_total-1)] end array.each_with_index {|entry, index| index += 1 # ===================================================================== # # First show the colourized index. # ===================================================================== # e ; e '('+plum(index.to_s)+') '; e report_this_program(entry.strip) } end
set_input(i = '')
click to toggle source