class RBT::Cookbooks::ReportUselessDescriptions
Constants
- ALSO_OPEN_VIA_EDITOR
#¶ ↑
ALSO_OPEN_VIA_EDITOR
¶ ↑If this variable is set to true then the problematic programs, that is programs that do not have a useful description, will be opened via the editor. This is mostly useful on my home system, since I can sanitize such problematic programs before publishing the whole gem.
#¶ ↑
- DEFAULT_DESCRIPTION_OF_THE_PROGRAM
#¶ ↑
DEFAULT_DESCRIPTION_OF_THE_PROGRAM
¶ ↑This is the generic description that was used in the past for the
RBT
project. If a .yml file still contains this String then we know that it is essentially an empty description, which should be improved on.#¶ ↑
- SLEEP_FOR_THIS_AMOUNT
#¶ ↑
SLEEP_FOR_THIS_AMOUNT
¶ ↑This sleep delay is only useful if we open the .yml file via an editor.
#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
Public Instance Methods
do_not_open_files_in_the_editor()
click to toggle source
report_results()
click to toggle source
#¶ ↑
report_results
(report tag)¶ ↑
#¶ ↑
# File lib/rbt/checks_and_validations/report_useless_descriptions.rb, line 177 def report_results _ = @array_these_programs_are_problematic opne "A total of #{sfancy(_.size.to_s)} problematic "\ "descriptions were found." if _.empty? opne "This is #{lightgreen('excellent')}! All programs "\ "appear to have a useful description." else e _.each {|this_program| e " - #{simp(this_program)}" if @also_open_via_editor target = File.basename(this_program.dup) target << '.yml' unless target.end_with? '.yml' unless target.start_with? RUBY_SRC_RBT_COOKBOOKS target.prepend(RUBY_SRC_RBT_COOKBOOKS) end open_in_editor(target) sleep SLEEP_FOR_THIS_AMOUNT end } e end end
Also aliased as: report
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/checks_and_validations/report_useless_descriptions.rb, line 86 def reset super() infer_the_namespace # ======================================================================= # # === @raw_cookbook # ======================================================================= # @raw_cookbook = actions(:raw_cookbook) { :fast } # ======================================================================= # # === @array_these_programs_are_problematic # # Store the problematic programs in the following Array: # ======================================================================= # @array_these_programs_are_problematic = [] # ======================================================================= # # === @also_open_via_editor # ======================================================================= # @also_open_via_editor = ALSO_OPEN_VIA_EDITOR # ======================================================================= # # === @use_this_as_the_key_for_the_description # ======================================================================= # @use_this_as_the_key_for_the_description = :description end
run()
click to toggle source
run_through_every_available_program()
click to toggle source
#¶ ↑
run_through_every_available_program
¶ ↑
#¶ ↑
# File lib/rbt/checks_and_validations/report_useless_descriptions.rb, line 145 def run_through_every_available_program available_programs?.each {|this_program| @raw_cookbook.clear hash = @raw_cookbook.load_this_program(this_program) if hash.has_key? @use_this_as_the_key_for_the_description description = hash[@use_this_as_the_key_for_the_description] end if hash.nil? or hash.empty? this_program_is_problematic(this_program) else # =================================================================== # # Nil descriptions or empty descriptions will be reported. # =================================================================== # if description.nil? or description.strip.empty? this_program_is_problematic(this_program) # =================================================================== # # As will those programs that conform to a default, but # pretty useless, description. # =================================================================== # elsif description.strip == DEFAULT_DESCRIPTION_OF_THE_PROGRAM this_program_is_problematic(this_program) # else # Else all seems fine. end end } end
Also aliased as: iterate_over_every_available_program