class RBT::Cookbooks::MissingUseThisBuildSystemEntry

Constants

OPEN_IN_THE_EDITOR
#

OPEN_IN_THE_EDITOR

#

Public Class Methods

new( i = ARGV, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/rbt/checks_and_validations/missing_use_this_build_system_entry.rb, line 24
def initialize(
    i           = ARGV,
    run_already = true
  )
  reset
  set_commandline_arguments(
    i
  )
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :do_not_run_yet
    # ===================================================================== #
    when :do_not_run_yet
      run_already = false
    end
  end
  case run_already
  # ======================================================================= #
  # === :do_not_run_yet
  # ======================================================================= #
  when :do_not_run_yet
    run_already = false
  end
  run if run_already
end

Public Instance Methods

reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/checks_and_validations/missing_use_this_build_system_entry.rb, line 58
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @missing_use_this_build_system_entries
  # ======================================================================= #
  @missing_use_this_build_system_entries = []
  # set_be_verbose
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/checks_and_validations/missing_use_this_build_system_entry.rb, line 71
def run
  try_to_require_the_open_gem if OPEN_IN_THE_EDITOR
  is_on_roebe  = is_on_roebe?
  all_programs = all_programs?
  _be_verbose  = be_verbose?
  # ======================================================================= #
  # Next iterate over all programs in order to find those with a missing
  # ======================================================================= #
  all_programs.each {|this_program|
    dataset = action(:raw_cookbook, this_program) { :complex }
    use_this_build_system = dataset.use_which_build_system? # This can be :infer_automatically
    has_symbol_key = dataset.has_key?(:use_this_build_system)
    if dataset.has_key?('use_this_build_system') or
       has_symbol_key
      # =================================================================== #
      # All is fine in this case. We could report this, but this would
      # be very spammy.
      # =================================================================== #
      # if be_verbose
      #   opne 'The program called '+steelblue(this_program)+
      #        rev+' has a build directory entry. '+
      #        gold(cheering_person?)+rev
      # end
      if has_symbol_key and (use_this_build_system == :infer_automatically)
        _ = COOKBOOKS_BASE_DIRECTORY+"#{this_program}.yml"
        e "#{sfile(_)}#{rev} could be improved."
      end
    else
      opne steelblue(this_program)+"#{rev} does not have a "+
           lightblue('use_this_build_system')+"#{rev} entry."
      target = COOKBOOKS_BASE_DIRECTORY+"#{this_program}.yml"
      e tomato(target) if is_on_roebe
      @missing_use_this_build_system_entries << this_program
      if OPEN_IN_THE_EDITOR
        opne "#{rev}Opening in the editor as well:"
        Open.in_editor(target)
        sleep 0.5
      end
    end
  }
end