class RBT::Cookbooks::FindDirectoryEntriesWithoutCorrespondingYamlFile

Constants

ARRAY_UNIMPORTANT_DIRECTORY
#

ARRAY_UNIMPORTANT_DIRECTORY

The entries in this constant will be filtered away.

#

Public Class Methods

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

RBT::Cookbooks::FindDirectoryEntriesWithoutCorrespondingYamlFile[]

#
# File lib/rbt/checks_and_validations/find_directory_entries_without_corresponding_yaml_file.rb, line 131
def self.[](i = '')
  new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/checks_and_validations/find_directory_entries_without_corresponding_yaml_file.rb, line 46
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(i)
  run if run_already
end

Public Instance Methods

filter_away_unimportant_directories(i) click to toggle source
#

filter_away_unimportant_directories

#
# File lib/rbt/checks_and_validations/find_directory_entries_without_corresponding_yaml_file.rb, line 121
def filter_away_unimportant_directories(i)
  i.reject {|entry|
    _ = File.basename(entry).sub(/\.yml$/,'')
    ARRAY_UNIMPORTANT_DIRECTORY.include? _
  }
end
input?() click to toggle source
#

input?

#
# File lib/rbt/checks_and_validations/find_directory_entries_without_corresponding_yaml_file.rb, line 75
def input?
  @input
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/checks_and_validations/find_directory_entries_without_corresponding_yaml_file.rb, line 58
def reset
  super()
  infer_the_namespace
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/checks_and_validations/find_directory_entries_without_corresponding_yaml_file.rb, line 82
def run
  archive_dir = archive_dir?
  array_missing_yaml_files = []
  if File.directory? archive_dir
    # ===================================================================== #
    # If the directory exists, obtain all subdirectories there.
    # ===================================================================== #
    all_subdirectories = Dir["#{archive_dir}*"].select {|entry| File.directory? entry }
    all_subdirectories.each {|entry|
      entry = File.basename(entry)
      possible_yaml_file_location = individual_cookbooks_dir?+entry+'.yml'
      if File.exist? possible_yaml_file_location
        # ================================================================ #
        # Then this is fine.
        # ================================================================ #
      else
        # ================================================================ #
        # Else store it so that we can report it a bit later.
        # ================================================================ #
        array_missing_yaml_files << possible_yaml_file_location
      end
    }
  else
    opne "No directory called `#{sdir(archive_dir)} exists.`"
  end
  array_missing_yaml_files = filter_away_unimportant_directories(array_missing_yaml_files)
  unless array_missing_yaml_files.empty?
    opne tomato(array_missing_yaml_files.size.to_s)+
         ' yaml files are missing:'
    array_missing_yaml_files.each {|i|
      e 'No file exists at'
      e "  `#{sfile(i)}`"
    }
  end
end
set_input(i = '') click to toggle source
#

set_input

#
# File lib/rbt/checks_and_validations/find_directory_entries_without_corresponding_yaml_file.rb, line 66
def set_input(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @input = i
end