class RBT::Cookbooks::ScanForMissingLastUpdateEntries
Constants
- SHALL_WE_EXIT_WHEN_ENCOUNTERING_PROBLEMS
#¶ ↑
SHALL_WE_EXIT_WHEN_ENCOUNTERING_PROBLEMS
¶ ↑#¶ ↑
Public Class Methods
Public Instance Methods
backup_this_file(i)
click to toggle source
#¶ ↑
backup_this_file
¶ ↑
This will store into /Depot/Temp/BackupForCookbooks/
#¶ ↑
# File lib/rbt/checks_and_validations/scan_for_missing_last_update_entries.rb, line 174 def backup_this_file(i) from_here = individual_cookbooks_directory?+File.basename(i) _ = rbt_log_dir?+'BackupForCookbooks/' mkdir(_) unless Dir.exist? _ to_there = _+File.basename(i) opne 'We will backup the file '+sfile(i)+' to `'+sfile(to_there)+'`.' copy_file(from_here, to_there) end
do_scan()
click to toggle source
#¶ ↑
do_scan
¶ ↑
#¶ ↑
# File lib/rbt/checks_and_validations/scan_for_missing_last_update_entries.rb, line 186 def do_scan all_programs?.each {|program| program.downcase! _ = return_location_to_this_programs_yaml_file(program) if File.exist? _ # Ok, the file exists. begin dataset = YAML.load_file(_) rescue ArgumentError => error e 'An ArgumentError happened for the program `'+ sfancy(program.to_s)+'`.' pp error e 'Please fix this.' exit end if dataset.nil? e 'Some problem was found for the file '+sfile(_)+'.' end program = program.to_s # =================================================================== # # Check whether the variable program still ends with '.yml'. # If so we chop this part away. # =================================================================== # if program.end_with? '.yml' program.sub!(/\.yml$/,'') end last_update = dataset[program] # ['last_update:'] if last_update if last_update.has_key? 'last_update' else if @input.nil? opne "#{rev}A problem with #{sfancy(program.to_s)}#{rev}." opne rev+'Showcasing the data-structure:' pp last_update pp last_update.class end if @input opnn unless @input.include? 'besilent' end _ = File.basename(_) @array_with_the_results << _ display_this_string = sfancy(_) if @input unless @input.include? 'besilent' display_this_string << ' has no last_update entry.' end end e display_this_string if fix_missing_entries? fix_this_missing_entry(_) # Fix this wrongful information. end end else opne rev+'Something went wrong for `'+simp(program.to_s)+rev+'`.' opne rev+'We could not find an entry called '+sfancy('last_update:') opne rev+'We will display the faulty dataset next.' cliner { pp dataset } if SHALL_WE_EXIT_WHEN_ENCOUNTERING_PROBLEMS opne 'Exiting now, as requested by the constant' opnn; efancy 'SHALL_WE_EXIT_WHEN_ENCOUNTERING_PROBLEMS.' exit end end else opne "The file at #{sfile(_)} does not exist. Exiting now." exit end } end
fix_missing_entries?()
click to toggle source
fix_this_missing_entry(i)
click to toggle source
#¶ ↑
fix_this_missing_entry
¶ ↑
Use this method to fix a wrongful entry among the individual cookbook entries.
#¶ ↑
# File lib/rbt/checks_and_validations/scan_for_missing_last_update_entries.rb, line 128 def fix_this_missing_entry(i) i = individual_cookbooks_directory?+File.basename(i) what = N+' last_update: '+return_proper_time opne rev+'We will next append `'+simp(what.delete(N))+rev+ '` into the file at: `'+sfile(temp_directory?+File.basename(i))+ rev+'`.' backup_this_file(i) copy_file(i, temp_directory?) into = temp_directory?+File.basename(i) append_what_into(what, into) end
report_how_many_programs_are_missing_the_last_update_entry()
click to toggle source
#¶ ↑
report_how_many_programs_are_missing_the_last_update_entry
¶ ↑
#¶ ↑
# File lib/rbt/checks_and_validations/scan_for_missing_last_update_entries.rb, line 88 def report_how_many_programs_are_missing_the_last_update_entry opne "We have a total of #{sfancy(results?.size.to_s)}"\ " #{rev}programs without a #{swarn('last_update: entry')}." if results?.size.to_i == 0 opne 'Excellent! That means that all cookbook files are valid,' opne rev+"in regards to the #{sfancy('last_update tag')}#{rev}. "+ gold(return_cheering_person) e e rev+'The directory that was checked for this was the following one:' e e " #{sdir(individual_cookbooks_directory?)}" e end end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/checks_and_validations/scan_for_missing_last_update_entries.rb, line 49 def reset super() infer_the_namespace # ======================================================================= # # === @array_with_the_results # ======================================================================= # @array_with_the_results = [] # ======================================================================= # # === @fix_missing_entries # # By default we will not auto-fix flawed entries. # ======================================================================= # @fix_missing_entries = false end
results?()
click to toggle source
return_proper_time()
click to toggle source
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/checks_and_validations/scan_for_missing_last_update_entries.rb, line 271 def run check_against_menu do_scan # Do the scan part now. report_how_many_programs_are_missing_the_last_update_entry # We finally report how many "faulty" programs we have discovered. try_to_show_problematic_programs end
set_input(i = '')
click to toggle source
show_help()
click to toggle source
try_to_show_problematic_programs()
click to toggle source
#¶ ↑
try_to_show_problematic_programs
¶ ↑
#¶ ↑
# File lib/rbt/checks_and_validations/scan_for_missing_last_update_entries.rb, line 258 def try_to_show_problematic_programs _ = results? unless _.empty? _.each {|this_program| opne "#{rev}This program has a problematic last_entry: "\ "#{sfancy(this_program)}" } end end