class RBT::Cookbooks::ScanForMissingLastUpdateEntries
Constants
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- 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/validation/scan_for_missing_last_update_entries.rb, line 162 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) opnn; e '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/validation/scan_for_missing_last_update_entries.rb, line 174 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 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? opnn; e "A problem with #{sfancy(program.to_s)}." opnn; e '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 opnn; e 'Something went wrong for `'+simp(program.to_s)+'`.' opnn; e 'We could not find an entry called '+sfancy('last_update:') opnn; e 'We will display the faulty dataset next.' cliner { pp dataset } if SHALL_WE_EXIT_WHEN_ENCOUNTERING_PROBLEMS opnn; e 'Exiting now, as requested by the constant' opnn; efancy 'SHALL_WE_EXIT_WHEN_ENCOUNTERING_PROBLEMS.' exit end end else opnn; e "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/validation/scan_for_missing_last_update_entries.rb, line 118 def fix_this_missing_entry(i) i = individual_cookbooks_directory?+File.basename(i) what = N+' last_update: '+return_proper_time opnn; e 'We will next append `'+simp(what.delete(N))+'` into '\ 'the file at: `'+sfile(temp_directory?+File.basename(i))+'`.' 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/validation/scan_for_missing_last_update_entries.rb, line 80 def report_how_many_programs_are_missing_the_last_update_entry opnn; e "We have a total of #{sfancy(results?.size.to_s)}"\ " programs without a #{swarn('last_update: entry')}." if results?.size.to_i == 0 opnn; e 'Excellent! That means that all cookbook files are valid,' opnn; e "in regards to the #{sfancy('last_update tag')}. "+ gold(return_cheering_person) e opnn; e 'The directory that we did check for this was:' e e " #{sdir(individual_cookbooks_directory?)}" e end end
reset()
click to toggle source
results?()
click to toggle source
return_proper_time()
click to toggle source
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/validation/scan_for_missing_last_update_entries.rb, line 254 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