class Cookbooks::ScanForMissingLastUpdateEntries
Constants
- NAMESPACE
#¶ ↑
NAMESPACE¶ ↑
#¶ ↑
- SHALL_WE_EXIT_WHEN_ENCOUNTERING_PROBLEMS
#¶ ↑
SHALL_WE_EXIT_WHEN_ENCOUNTERING_PROBLEMS¶ ↑
#¶ ↑
- TEMP_DIR
#¶ ↑
TEMP_DIR¶ ↑
#¶ ↑
Public Class Methods
Public Instance Methods
all_programs?()
click to toggle source
backup_this_file(i)
click to toggle source
#¶ ↑
#backup_this_file¶ ↑
This will store into /Depot/Temp/BackupForCookbooks/
#¶ ↑
# File lib/cookbooks/validation/scan_for_missing_last_update_entries.rb, line 160 def backup_this_file(i) from_here = individual_cookbooks_directory?+File.basename(i) _ = temp_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/cookbooks/validation/scan_for_missing_last_update_entries.rb, line 186 def do_scan all_programs?.each {|program| program = program.downcase _ = INDIVIDUAL_COOKBOOKS_DIRECTORY+program+'.yml' 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 last_update = dataset[program.to_s] # ['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/cookbooks/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_DIR+File.basename(i))+'`.' backup_this_file(i) copy_file(i, TEMP_DIR) into = TEMP_DIR+File.basename(i) append_what_into(what, into) end
opnn()
click to toggle source
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/cookbooks/validation/scan_for_missing_last_update_entries.rb, line 82 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 '+simp('last_update tag')+'.' e opnn; e 'The directory that we did check for this was:' e opnn; e ' '+sdir(INDIVIDUAL_COOKBOOKS_DIRECTORY) 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/cookbooks/validation/scan_for_missing_last_update_entries.rb, line 258 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/cookbooks/validation/scan_for_missing_last_update_entries.rb, line 245 def try_to_show_problematic_programs _ = results? unless _.empty? _.each {|this_program| opnn; e 'This program has a problematic last_entry: '+ sfancy(this_program) } end end