class Cookbooks::ExpandCookbooks

Constants

NAMESPACE
#

NAMESPACE

#
STORE_HERE
#

STORE_HERE

#

Public Class Methods

new( expand_which_programs = :all_of_them, run_already = true ) click to toggle source
#

initialize

#
Calls superclass method
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 37
def initialize(
    expand_which_programs = :all_of_them,
    run_already           = true
  )
  super()
  reset
  set_expand_these_programs(expand_which_programs)
  run if run_already
end

Public Instance Methods

base_dir_to_store_expanded_cookbooks?() click to toggle source
#

base_dir_to_store_expanded_cookbooks?

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 152
def base_dir_to_store_expanded_cookbooks?
  Cookbooks.base_dir_to_store_expanded_cookbooks?
end
consider_updating_program_version_and_url_file() click to toggle source
#

#consider_updating_program_version_and_url_file

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 177
def consider_updating_program_version_and_url_file
  if is_on_roebe?
    # ===================================================================== #
    # On my home system I will auto-update that file as well.
    # ===================================================================== #
    Cookbooks.create_program_version_url_file
  end
end
ensure_that_the_base_directory_exists() click to toggle source
#

#ensure_that_the_base_directory_exists

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 129
def ensure_that_the_base_directory_exists
  unless File.directory? base_dir_to_store_expanded_cookbooks?
    mkdir base_dir_to_store_expanded_cookbooks?
  end
end
inform_the_user_what_we_will_do_next() click to toggle source
#

#inform_the_user_what_we_will_do_next

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 138
def inform_the_user_what_we_will_do_next
  if main_array?.size < 2
    opnn; e 'We will now expand the program named '+
             sfancy(return_default_program_name_as_string)+
            ' towards its individual yaml file.'
  else
    opnn; e 'We will now expand the whole dataset stored into '\
            'the individual yaml files.'
  end
end
main_array?() click to toggle source
#

main_array?

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 75
def main_array?
  @expand_these_programs
end
obtain_available_cookbooks() click to toggle source
#

#obtain_available_cookbooks

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 115
def obtain_available_cookbooks
  @cookbooks = ::Cookbooks.available_programs
end
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Base#opnn
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 122
def opnn
  super(NAMESPACE)
end
reset() click to toggle source
#

reset

#
Calls superclass method Cookbooks::Base#reset
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 107
def reset
  super()
  obtain_available_cookbooks
end
return_default_program_name_as_string() click to toggle source
#

#return_default_program_name_as_string

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 82
def return_default_program_name_as_string
  main_array?.first.to_s
end
run() click to toggle source
#

run

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 189
def run
  ensure_that_the_base_directory_exists
  inform_the_user_what_we_will_do_next
  work_on_each_cookbook
  consider_updating_program_version_and_url_file
end
set_expand_these_programs( i = :all_of_them ) click to toggle source
#

#set_expand_these_programs

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 50
def set_expand_these_programs(
    i = :all_of_them
  )
  if i.is_a? Array
    i = i.first
  end
  i = :all_of_them if i.nil? # Assign to the default value, in this case.
  case i
  # ======================================================================= #
  # === expand_cookbooks --help
  # ======================================================================= #
  when /^-?-?help/
    show_help(:then_exit)
  when :all_of_them
    i = @cookbooks
  end
  unless i.is_a? Array
    i = [i] # Turn it into an Array.
  end
  @expand_these_programs = i
end
show_help(also_exit = false) click to toggle source
#

#show_help

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 89
def show_help(also_exit = false)
  case also_exit
  when :then_exit
    also_exit = true
  end
  opnn; e 'This class will expand the given arguments (program names) '\
          'into .yml files.'
  e
  e 'Invocation example:'
  e
  e sfancy('  expand_cookbooks rubyprogressbar')
  e
  exit if also_exit
end
work_on_each_cookbook() click to toggle source
#

#work_on_each_cookbook

Work on each cookbook and save the dataset as a hash.

#
# File lib/cookbooks/utility_scripts/expand_cookbooks.rb, line 161
def work_on_each_cookbook
  @expand_these_programs.each {|program|
    _ = Cookbooks::Cookbook.new(program) { :bypass_menu }
    hash = _.hash?
    dataset_to_save = YAML.dump(hash)
    what = dataset_to_save
    into = base_dir_to_store_expanded_cookbooks?+program+'.yml'
    opnn; e "Now storing the hash from `#{simp(program)}"\
            "` into `#{sfile(into)}`."
    write_what_into(what, into)
  }
end