class RBT::Cookbooks::MergeCookbooks

Constants

DEFAULT_LOCATION
#

DEFAULT_LOCATION

#

Public Class Methods

new( path_where_to_store = DEFAULT_LOCATION, be_verbose = true ) click to toggle source
#

initialize

#
Calls superclass method RBT::Base::new
# File lib/rbt/cookbooks/merge_cookbooks.rb, line 26
def initialize(
    path_where_to_store = DEFAULT_LOCATION,
    be_verbose          = true
  )
  super()
  reset
  set_full_path(
    path_where_to_store+
    name_of_new_cookbook_file? # Get a default name for now.
  )
  if be_verbose
    opne 'We will store at '+sfancy(@full_path)
  end
  run
end

Public Instance Methods

name_of_new_cookbook_file?() click to toggle source
#

name_of_new_cookbook_file?

#
# File lib/rbt/cookbooks/merge_cookbooks.rb, line 61
def name_of_new_cookbook_file?
  @name_of_new_cookbook_file
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/cookbooks/merge_cookbooks.rb, line 45
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @array_merged
  # ======================================================================= #
  @array_merged = []
  # ======================================================================= #
  # === @name_of_new_cookbook_file
  # ======================================================================= #
  @name_of_new_cookbook_file = 'merged_cookbook.yml'
end
run() click to toggle source
#

run

#
# File lib/rbt/cookbooks/merge_cookbooks.rb, line 85
def run
  get_cookbooks(false).each { |entry|  # False for "don't apply filter".
    _ = read_file(entry)
    @array_merged << _ << N
    @array_merged.flatten!
  }
  save_file
end
save_file() click to toggle source
#

save_file

#
# File lib/rbt/cookbooks/merge_cookbooks.rb, line 76
def save_file
  opne "Merging cookbook file into `#{@full_path}`."
  remove_file(@full_path) if File.exist? @full_path
  write_what_into(@array_merged.join, @full_path,'w+')
end
set_full_path(i = :default) click to toggle source
#

set_full_path

#
# File lib/rbt/cookbooks/merge_cookbooks.rb, line 68
def set_full_path(i = :default)
  i = DEFAULT_LOCATION if i == :default
  @full_path = i
end