class RBT::Cookbooks::CopyTheIdealCookbook

Constants

SPLIT_AT_THIS_TOKEN
#

SPLIT_AT_THIS_TOKEN

#

Public Class Methods

new( i = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/cookbooks/copy_the_ideal_cookbook/copy_the_ideal_cookbook.rb, line 32
def initialize(
    i           = ARGV,
    run_already = true
  )
  reset 
  set_commandline_arguments(i)
  run if run_already
end

Public Instance Methods

clear()
Alias for: reset
file_the_ideal_cookbook?() click to toggle source
#

file_the_ideal_cookbook?

#
# File lib/rbt/cookbooks/copy_the_ideal_cookbook/copy_the_ideal_cookbook.rb, line 57
def file_the_ideal_cookbook?
  @internal_hash[:file_the_ideal_cookbook]
end
path?() click to toggle source
#

path?

#
# File lib/rbt/cookbooks/copy_the_ideal_cookbook/copy_the_ideal_cookbook.rb, line 111
def path?
  @absolute_path
end
report_the_path(i = path?) click to toggle source
#

report_the_path

#
# File lib/rbt/cookbooks/copy_the_ideal_cookbook/copy_the_ideal_cookbook.rb, line 104
def report_the_path(i = path?)
  e sfile(i)
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/cookbooks/copy_the_ideal_cookbook/copy_the_ideal_cookbook.rb, line 44
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === :file_the_ideal_cookbook
  # ======================================================================= #
  @internal_hash[:file_the_ideal_cookbook] =
    '/home/x/programming/ruby/src/rbt/doc/the_ideal_cookbook/the_ideal_cookbook.md' 
end
Also aliased as: clear
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/cookbooks/copy_the_ideal_cookbook/copy_the_ideal_cookbook.rb, line 64
def run
  _ = file_the_ideal_cookbook?
  new_target = return_pwd+File.basename(_)
  dataset = file_read(_)
  if dataset.include? SPLIT_AT_THIS_TOKEN
    dataset = dataset.split(SPLIT_AT_THIS_TOKEN).last
  end
  dataset = dataset.dup if dataset.frozen?
  first = first?
  if first and !first.empty?
    dataset.sub!(
      /^program_name_goes_in_here/,
      first
    )
    new_target = return_pwd+File.basename(first)+'.yml'
    if dataset.include? 'some_website'
      dataset.gsub!(/some_website/,first)
    end
  end
  opne "#{rev}Now generating a new cookbook file, into "\
       "the current working directory"
  opne "at `#{sfile(new_target)}`."
  # ======================================================================= #
  # Fix the last_update entry next:
  # ======================================================================= #
  if dataset.include? 'last_update:'
    dataset.sub!(
      /^ last_update: (.+)/,
      ' last_update: '+
      convert_dd_mm_yyyy_to_its_long_variant(dd_mm_yyyy.to_s)
    )
  end
  dataset.lstrip!
  write_what_into(dataset, new_target)
  @absolute_path = File.absolute_path(new_target) # And keep a reference to the absolute path as well here.
end