class RBT::AggregateInformationFromTheExpandedCookbooks

Constants

STORE_THE_NEW_YAML_FILE_HERE
#

STORE_THE_NEW_YAML_FILE_HERE

Since as of August 2022 we use a dedicated, separate directory for storing the .yml file. Before tha twe stored into the expanded cookbook directory directly, and this caused subsequent scripts to struggle as old assumptions such as “one .yml file per expanded cookbook dataset” in the given directory was no longer correct.

#

Public Class Methods

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

RBT::AggregateInformationFromTheExpandedCookbooks[]

#
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 155
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 48
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

hash?() click to toggle source
#

hash?

#
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 76
def hash?
  @hash
end
is_the_main_hash_empty?() click to toggle source
#

is_the_main_hash_empty?

#
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 112
def is_the_main_hash_empty?
  @hash.empty?
end
load_up_the_existing_dataset( from_here = STORE_THE_NEW_YAML_FILE_HERE ) click to toggle source
#

load_up_the_existing_dataset

This method can be used to load the existing dataset from a .yml file that has been generated before.

#
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 103
def load_up_the_existing_dataset(
    from_here = STORE_THE_NEW_YAML_FILE_HERE
  ) 
  @hash = YAML.load_file(from_here)
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 62
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @hash
  #
  # This is our main Hash storing everything. \o/
  # ======================================================================= #
  @hash = {}
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 137
def run
  _ = directory_expanded_cookbooks?
  if File.directory? _
    work_through_the_cookbook_dataset_found_in_this_directory(_)
    if is_the_main_hash_empty?
      opne "Unfortunately no entries could be found."
      opne "Is the directory at #{sdir(_)} empty?"
    else
      store_the_big_hash_into_a_new_yaml_file
    end
  else
    opnn; no_file_exists_at(_)
  end
end
store_the_big_hash_into_a_new_yaml_file() click to toggle source
#

store_the_big_hash_into_a_new_yaml_file

#
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 119
def store_the_big_hash_into_a_new_yaml_file
  opne 'Next storing this big hash ('+
       @hash.keys.size.to_s+') in a new .yml file.'
  what = YAML.dump(@hash)
  into = STORE_THE_NEW_YAML_FILE_HERE
  unless File.dirname(into)
    mkdir(into) { :be_quiet }
  end
  opne 'The specific file will stored here:'
  e
  e sfile("  #{into}")
  e
  write_what_into(what, into)
end
work_through_the_cookbook_dataset_found_in_this_directory(i) click to toggle source
#

work_through_the_cookbook_dataset_found_in_this_directory

#
# File lib/rbt/information/aggregate_information_from_the_expanded_cookbooks.rb, line 83
def work_through_the_cookbook_dataset_found_in_this_directory(i)
  opne "Obtaining all entries from #{sdir(i)} next - "\
       "this may take a while."
  all_entries = Dir["#{i}*.yml"]
  all_entries.each {|this_yaml_file|
    name_of_the_program = File.basename(this_yaml_file).
                               sub(/#{File.extname(this_yaml_file)}$/,'')
    dataset = YAML.load_file(this_yaml_file)
    new_hash = {}
    new_hash[name_of_the_program] = dataset
    @hash.update(new_hash)
  }
end