class RBT::KernelConfigSanitizer
Public Class Methods
[](i = ARGV)
click to toggle source
new( commandline_arguments = ARGV, run_already = true )
click to toggle source
Public Instance Methods
proceed_with_the_main_task()
click to toggle source
#¶ ↑
proceed_with_the_main_task
¶ ↑
This will only be called if @dataset has been assigned - see above.
#¶ ↑
# File lib/rbt/utility_scripts/kernel_config_sanitizer/kernel_config_sanitizer.rb, line 74 def proceed_with_the_main_task the_file_has_been_modified = false new_file_content = ''.dup # Store into this file. content_of_the_config_file_as_array = readlines('.config') # content_of_the_config_file_as_string = content_of_the_config_file_as_array.join(N) keys_that_have_to_be_sanitized = @dataset.keys # Next append '=': keys_that_have_to_be_sanitized.map! {|entry| entry = entry.dup if entry.frozen? entry << '=' } opne "#{rev}Next attempting to sanitize the "\ "#{steelblue('Linux Kernel Configuration')}#{rev}." opne "This is done by ensuring that #{keys_that_have_to_be_sanitized.size} "\ "entries exist in the way the .yml" opne "file at #{sfancy(yaml_file?)}#{rev}" opne "#{rev}has specified." index_for_the_specified_keys_in_the_config_file = 0 content_of_the_config_file_as_array.each {|this_line| unless this_line.start_with?('# ') # Ignore comments. this_line.rstrip! if keys_that_have_to_be_sanitized.any? {|inner_line| this_line.include?(inner_line) } index_for_the_specified_keys_in_the_config_file += 1 # =================================================================== # # In this case we will modify on the key. # =================================================================== # work_on_this_key_next = keys_that_have_to_be_sanitized.select {|most_inner_line| this_line.include?(most_inner_line) }.flatten if work_on_this_key_next.is_a? Array work_on_this_key_next = work_on_this_key_next.first end opne "#{royalblue(index_for_the_specified_keys_in_the_config_file.to_s+') ')}"\ "#{tomato('Now modifying')} #{lightgreen(this_line)}"\ "#{tomato(', for the key')} "\ "#{steelblue(work_on_this_key_next.delete('='))}"\ "#{rev}#{tomato('.')}" the_file_has_been_modified = true use_this_value = @dataset[work_on_this_key_next.delete('=')] case use_this_value when 'yes', true use_this_value = 'y' end target = use_this_value this_line = work_on_this_key_next+target end new_file_content << "#{this_line}#{N}" end } if the_file_has_been_modified into = absolute_path('.config') opne "#{rev}Saving into the file #{sfancy(into)}#{rev} next." what = new_file_content write_what_into(what, into) end end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/kernel_config_sanitizer/kernel_config_sanitizer.rb, line 40 def reset super() infer_the_namespace # ======================================================================= # # === @dataset # ======================================================================= # @dataset = nil end
run()
click to toggle source