class Cookbooks::IncrementProgramVersion
Constants
- DEFAULT_PROGRAM
#¶ ↑
DEFAULT_PROGRAM¶ ↑
#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE¶ ↑
#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
Public Instance Methods
assign_url_to_dataset_url(use_this_dataset)
click to toggle source
check_for_incremented_remote_versions( i = url? )
click to toggle source
#¶ ↑
#check_for_incremented_remote_versions¶ ↑
This is the method that will check for the remote versions.
#¶ ↑
# File lib/cookbooks/utility_scripts/increment_program_version.rb, line 94 def check_for_incremented_remote_versions( i = url? ) original_version = ProgramInformation.return_version(i) opnn; e 'The input-version was `'+sfancy(original_version)+'`.' original_split = original_version.split('.') splitted = original_split # ======================================================================= # # === Minor Version Check # # First check for minor-version part. We must be careful here because # some programs use a version scheme such as "009", such as usbutils. # ======================================================================= # splitted_last_part = splitted.last if splitted_last_part if splitted_last_part.start_with? '0' new_number = splitted_last_part.to_i + 1 last_part = new_number.to_s.rjust(splitted_last_part.to_s.size,'0') else last_part = splitted_last_part.to_i + 1 # Increment the last part here. end else opnn; e 'A nil value occurred so something must have went wrong.' pp splitted end splitted[-1] = last_part.to_s minor_increment = splitted.join('.') url_for_minor_version = i.gsub(/#{original_version}/, minor_increment) opnn; e "Now trying the URL `#{sfancy(url_for_minor_version)}`." # ======================================================================= # # === Query via Wget whether a remote file exists # ======================================================================= # if Object.const_defined? :Wget does_it_exist = Wget.check_if_remote_file_exists(url_for_minor_version) if does_it_exist # Minor increment exist, download it. register_and_install_this_program(url_for_minor_version) else opnn; e 'There was '+seagreen('no minor release')+' for `'+ sfancy(url_for_minor_version)+'`.' end else report_that_wget_is_missing_then_exit end # ======================================================================= # # Check for another minor-version again. # ======================================================================= # last_part = splitted.last.to_i + 1 # Increment the last part here again. splitted[-1] = last_part.to_s minor_increment = splitted.join('.') url_for_minor_version = i.gsub(/#{original_version}/, minor_increment) opnn; e "Now trying the URL `#{sfancy(url_for_minor_version)}`." # ======================================================================= # # === Query via Wget whether a remote file exists # ======================================================================= # if Object.const_defined? :Wget does_it_exist = Wget.check_if_remote_file_exists(url_for_minor_version) if does_it_exist # Minor increment exist, download it. register_and_install_this_program(url_for_minor_version) else opnn; e 'There was '+seagreen('no minor release')+' for `'+ sfancy(url_for_minor_version)+'`.' end else report_that_wget_is_missing_then_exit end # ======================================================================= # # === Check the subversion next, which is simply a '.1' added. # ======================================================================= # splitted = (original_version+'.1').split('.') url_for_subversion = splitted.join('.') url_for_subversion = i.gsub(/#{original_version}/, url_for_subversion) opnn; e 'Now trying the URL `'+sfancy(url_for_subversion)+'`.' subversion_version_exists = Wget.check_if_remote_file_exists(url_for_subversion) if subversion_version_exists register_and_install_this_program(url_for_subversion) else opnn; e 'There was '+seagreen('no subversion release')+ ' release for '+sfancy(url_for_subversion)+'.' end # ======================================================================= # # === Middle Version Check # # Next check for the middle version part. # ======================================================================= # splitted = original_version.split('.') splitted[1] = (splitted[1].to_i + 1).to_s splitted[-1] = '0' # Last bit is 0. middle_increment = splitted.join('.') url_for_middle_version = i.gsub(/#{original_version}/, middle_increment) _ = "/#{original_split[0]}.#{original_split[1]}/" if url_for_middle_version.include? _ # Then apply a .gsub() url_for_middle_version.gsub!(/#{_}/,"/#{splitted[0]}.#{splitted[1]}/") end opnn; e "Now trying the URL `#{sfancy(url_for_middle_version)}`." middle_version_exists = Wget.check_if_remote_file_exists(url_for_middle_version) if middle_version_exists register_and_install_this_program(url_for_middle_version) else opnn; e 'There was '+seagreen('no middle release')+' release for '+ sfancy(url_for_middle_version)+'.' end # ======================================================================= # # === Major Version Check # # Next check for the middle version part. # ======================================================================= # splitted = original_version.split('.') splitted[0] = splitted[0].to_i + 1 splitted[1] = '0' # Middle bit is now 0 as well. splitted[-1] = '0' # Last bit is 0. major_increment = splitted.join('.') url_for_major_version = i.gsub(/#{original_version}/, major_increment) _ = "/#{original_split[0]}.#{original_split[1]}/" if url_for_major_version.include? _ # Then apply a .gsub() url_for_major_version.gsub!(/#{_}/,"/#{splitted[0]}.#{splitted[1]}/") end opnn; e 'Now trying the URL `'+sfancy(url_for_major_version)+'`.' major_version_exists = Wget.check_if_remote_file_exists(url_for_major_version) if major_version_exists register_and_install_this_program(url_for_major_version) else opnn; e "There was #{seagreen('no major release')} for "\ "#{sfancy(url_for_major_version)}." end end
check_for_missing_homepage_entry()
click to toggle source
#¶ ↑
#check_for_missing_homepage_entry¶ ↑
#¶ ↑
# File lib/cookbooks/utility_scripts/increment_program_version.rb, line 282 def check_for_missing_homepage_entry homepage = @dataset.homepage?.to_s if homepage.empty? if is_on_roebe? # =================================================================== # # Only roebe gets extra notifications. # =================================================================== # opnn; e "The program #{sfancy(@dataset.short_name?)} has no "\ "#{orange('homepage: entry')}. Consider adding one." end end end
dataset?()
click to toggle source
determine_dataset(i = input?)
click to toggle source
determine_whether_the_program_exists_or_not()
click to toggle source
#¶ ↑
#determine_whether_the_program_exists_or_not¶ ↑
#¶ ↑
# File lib/cookbooks/utility_scripts/increment_program_version.rb, line 305 def determine_whether_the_program_exists_or_not _ = program_name? # ======================================================================= # # === try_to_update_this_program binutils # ======================================================================= # if ::Cookbooks.does_include? _ opnn; e 'The program '+sfancy(_)+' is included. The program will '\ 'proceed.' determine_dataset assign_url_to_dataset_url(dataset?) check_for_incremented_remote_versions # Here we check for different remote versions. else opnn; e 'The program '+sfancy(_)+' is '+swarn('NOT')+' included. '\ 'Can not proceed.' end end
exit_program()
click to toggle source
input?()
click to toggle source
#¶ ↑
input?¶ ↑
#¶ ↑
# File lib/cookbooks/utility_scripts/increment_program_version.rb, line 85 def input? @input end
Also aliased as: program_name?
opnn()
click to toggle source
register_and_install_this_program(i, shall_we_exit = true)
click to toggle source
#¶ ↑
#register_and_install_this_program¶ ↑
#¶ ↑
# File lib/cookbooks/utility_scripts/increment_program_version.rb, line 262 def register_and_install_this_program(i, shall_we_exit = true) opnn; e 'We found a match towards the URL `'+simp(i)+'`.' # ======================================================================= # # Delegate towards class Cookbooks::UpdateEntry in this case. # ======================================================================= # Cookbooks::UpdateEntry.new(i) exit_program if shall_we_exit end
report_that_wget_is_missing_then_exit()
click to toggle source
reset()
click to toggle source
run()
click to toggle source
set_input(i = DEFAULT_PROGRAM)
click to toggle source
#¶ ↑
#set_input¶ ↑
#¶ ↑
# File lib/cookbooks/utility_scripts/increment_program_version.rb, line 61 def set_input(i = DEFAULT_PROGRAM) i = i.first if i.is_a? Array if i.nil? # If the user did not provide any input-argument here. if Dir.pwd.include? archive_dir? i = Dir['*'].first # Just pick the first entry in this case. if i if i.include? '-' i = ProgramInformation.return_name(i) end else opnn; e 'There does not appear to be any file in that directory.' i = nil end else i = DEFAULT_PROGRAM end end i = i.to_s.dup.delete('-_').downcase @input = i end