class Cookbooks::ReportUselessDescriptions

Constants

ALSO_OPEN_VIA_EDITOR
#

ALSO_OPEN_VIA_EDITOR

#
DEFAULT_DESCRIPTION_OF_THE_PROGRAM
#

DEFAULT_DESCRIPTION_OF_THE_PROGRAM

#
NAMESPACE
#

NAMESPACE

#

Public Class Methods

[](i = '') click to toggle source
#

[]

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 212
def self.[](i = '')
  self.new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 56
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(i)
  menu
  run if run_already
end

Public Instance Methods

do_not_open_files_in_the_editor() click to toggle source
#

#do_not_open_files_in_the_editor

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 180
def do_not_open_files_in_the_editor
  @also_open_via_editor = false
end
input?() click to toggle source
#

input?

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 104
def input?
  @input
end
iterate_over_every_available_program() click to toggle source
#

#iterate_over_every_available_program

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 118
def iterate_over_every_available_program
  @available_programs.each {|this_program|
    _ = individual_cookbooks_dir?+this_program+'.yml'
    dataset = YAML.load_file(_)[this_program]
    if dataset.nil?
      this_program_is_problematic(this_program)
    else
      description = dataset['description']
      # =================================================================== #
      # 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
menu(i = @input) click to toggle source
#

menu (menu tag)

#
obtain_available_programs() click to toggle source
#

#obtain_available_programs

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 111
def obtain_available_programs
  @available_programs = ::Cookbooks.available_programs?
end
open_in_editor(i) click to toggle source
#

#open_in_editor

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 187
def open_in_editor(i)
  i = i.to_s.dup
  unless i.end_with? '.yml'
    i << '.yml'
  end
  if is_on_roebe?
    i.prepend "#{RUBY_SRC_DIR_AT_HOME}cookbooks/lib/cookbooks/yaml/individual_cookbooks/"
  else
    i.prepend individual_cookbooks_dir?
  end
  OpenInEditor[i]
end
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Base#opnn
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 153
def opnn
  super(NAMESPACE)
end
report()
Alias for: report_results
report_results() click to toggle source
#

#report_results (report tag)

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 160
def report_results
  _ = @array_these_programs_are_problematic
  opnn; e "We found a total of #{sfancy(_.size.to_s)} problematic programs."
  if _.empty?
    opnn; e 'This is '+lightgreen('excellent')+'! All programs '\
            'appear to have a useful description.'
  else
    _.each {|this_program|
      e '  - '+simp(this_program)
      if @also_open_via_editor
      open_in_editor this_program
        sleep 0.6
      end
    }
  end
end
Also aliased as: report
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method Cookbooks::Base#reset
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 69
def reset
  super()
  @array_these_programs_are_problematic = []
  @also_open_via_editor = ALSO_OPEN_VIA_EDITOR
end
run() click to toggle source
#

run (run tag)

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 203
def run
  obtain_available_programs
  iterate_over_every_available_program
  report_results
end
set_input(i = '') click to toggle source
#

#set_input

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 78
def set_input(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @input = i
end
this_program_is_problematic(this_program) click to toggle source
#

#this_program_is_problematic

#
# File lib/cookbooks/validation/report_useless_descriptions.rb, line 146
def this_program_is_problematic(this_program)
  @array_these_programs_are_problematic << this_program
end