class RBT::Action::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::Action::AggregateInformationFromTheExpandedCookbooks[]

#
# File lib/rbt/actions/individual_actions/information/aggregate_information_from_the_expanded_cookbooks.rb, line 161
def self.[](i = ARGV)
  new(i)
end
new( i = ARGV, run_already = true, &block ) click to toggle source
#

initialize

#
# File lib/rbt/actions/individual_actions/information/aggregate_information_from_the_expanded_cookbooks.rb, line 51
def initialize(
    i           = ARGV,
    run_already = true,
    &block
  )
  reset
  set_commandline_arguments(i)
  run if run_already
end

Public Instance Methods

hash?() click to toggle source
#

hash?

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

is_the_main_hash_empty?

#
# File lib/rbt/actions/individual_actions/information/aggregate_information_from_the_expanded_cookbooks.rb, line 118
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/actions/individual_actions/information/aggregate_information_from_the_expanded_cookbooks.rb, line 109
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::Action#reset
# File lib/rbt/actions/individual_actions/information/aggregate_information_from_the_expanded_cookbooks.rb, line 64
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/actions/individual_actions/information/aggregate_information_from_the_expanded_cookbooks.rb, line 143
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 "#{rev}Is the directory at #{sdir(_)} #{rev}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/actions/individual_actions/information/aggregate_information_from_the_expanded_cookbooks.rb, line 125
def store_the_big_hash_into_a_new_yaml_file
  e "#{rev}Next storing this big hash ("+
    "#{@hash.keys.size.to_s}#{rev}) 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
  e '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/actions/individual_actions/information/aggregate_information_from_the_expanded_cookbooks.rb, line 85
def work_through_the_cookbook_dataset_found_in_this_directory(i)
  opnn { :no_trailing }
  e
  e
  e "#{rev}Obtaining all entries from"
  e "#{rev}  #{sdir(i)}"
  e "#{rev}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