class RBT::GenerateRbtConfiguration

Constants

LAST_UPDATE
#

LAST_UPDATE

Keep track when this class was last updated.

#
SAVE_NEW_FILE_HERE
#

SAVE_NEW_FILE_HERE

#
STORE_WHERE_BASE_DIR
#

STORE_WHERE_BASE_DIR

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 43
def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Public Instance Methods

_(i)
Alias for: add
add(i) click to toggle source
#

add (add tag)

This will append to @_ and will also append two newlines.

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 75
def add(i)
  @_ << i+N
end
Also aliased as: _
e_get_user_input_then_add( variable_name, desc = '' ) click to toggle source
#

e_get_user_input_then_add

Here we will combine get_user_input() with add().

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 147
def e_get_user_input_then_add(
    variable_name, desc = ''
  )
  desc = "Description: #{variable_name}" if desc.to_s.empty?
  print desc+' '
  get_user_input # Obtain the user input here.
  add ' '+variable_name+': '+@user_input
end
get_user_input() click to toggle source
#

get_user_input

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 128
def get_user_input
  _ = $stdin.gets.chomp
  case _
  when 't','' # Empty as well.
    _ = true
  when 'f'
    _ = false
  else
    _ = false
  end
  @user_input = _
  @user_input
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 53
def reset
  super()
  infer_the_namespace
  # ========================================================================== #
  # === @_
  # ========================================================================== #
  @_ = ''.dup # The result string.
  set_store_here SAVE_NEW_FILE_HERE
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 159
def run
  show_welcome_message
  opne 'We will now generate a new configuration file.'
  opne 'We will store this configuration file here: '+sfile(@store_here)
  opne 'We will guide you through the process of creating a'
  opne 'new configuration file from scratch.'
  show_last_update
  run_through_all_configure_options
  save_result # store it into a new file.
end
run_through_all_configure_options() click to toggle source
#

run_through_all_configure_options

Here we will grab all configuration entries.

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 110
def run_through_all_configure_options
  _ = RBT.config_directory?
  # ========================================================================== #
  # Load it up next.
  # ========================================================================== #
  available_keys = Dir["#{_}*.yml"].map {|entry|
    File.basename(entry).gsub!(/\.yml$/,'')
  }
  available_keys.each {|entry|
    print entry.ljust(30)+': [yes/no] or [true/false] or [t/f]'
    value = get_user_input
    add "#{entry}: #{value}"
  }
end
save_result() click to toggle source
#

save_result

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 100
def save_result # Save the result.
  opne 'Storing into `'+sfile(@store_here)+'`.'
  save_file(@_, @store_here)
end
set_store_here(i) click to toggle source
#

set_store_here

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 66
def set_store_here(i)
  @store_here = rds(i.to_s)
end
show_last_update() click to toggle source
#

show_last_update

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 92
def show_last_update
  opne 'This class (RBT::GenerateRbtConfiguration) was last '\
       'updated at: '+simp(LAST_UPDATE)
end
show_welcome_message() click to toggle source
#

show_welcome_message

#
# File lib/rbt/generate_files/generate_rbt_configuration.rb, line 82
def show_welcome_message
  cliner {
    opne 'Welcome to the '+steelblue('RBT Project')+
         ', class GenerateRbtConfiguration.'
  }
end