class RBT::ChainCompile

Constants

ARRAY_DEFAULT_COMPILE_THESE_PROGRAMS
#

ARRAY_DEFAULT_COMPILE_THESE_PROGRAMS

#

Public Class Methods

[](i = ARGV) click to toggle source
#

RBT::ChainCompile[]

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 213
def self.[](i = ARGV)
  new(i)
end
new( i = ARRAY_DEFAULT_COMPILE_THESE_PROGRAMS, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 36
def initialize(
    i           = ARRAY_DEFAULT_COMPILE_THESE_PROGRAMS,
    run_already = true
  )
  reset
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    when :require_compile_base
      require_compile_base
    end
  end
  menu(i) # Intercept here for the commandline arguments.
  set_compile_these_programs(i)
  run if run_already
end

Public Instance Methods

compile_these_programs?() click to toggle source
#

compile_these_programs?

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 136
def compile_these_programs? 
  @compile_these_programs
end
Also aliased as: input?
do_compile_this_program(i) click to toggle source
#

do_compile_this_program

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 171
def do_compile_this_program(i)
  ::RBT::Installer.new(i)
end
input?()
menu(i) click to toggle source
#

menu (menu tag)

#
notify_the_user_which_programs_we_will_compile( i = input? ) click to toggle source
#

notify_the_user_which_programs_we_will_compile

This method will notify the user which programs we are about to compile next.

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 146
def notify_the_user_which_programs_we_will_compile(
    i = input?
  )
  n_programs = i.size.to_s
  opne "We will compile these `#{sfancy(n_programs)}` programs:"
  opne '  '+simp(i.join(', ').strip.chop)
end
Also aliased as: show_compile_chain
prepare()
require_compile_base() click to toggle source
#

require_compile_base

We need to have a separate require-step, in order to avoid circular require warnings.

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 74
def require_compile_base
  require 'rbt/installer/installer.rb'
  # ======================================================================= #
  # === @array_help_options
  # ======================================================================= #
  @array_help_options = RBT::ARRAY_HELP_OPTIONS
end
Also aliased as: prepare
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/chain_compile.rb, line 59
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @array_help_options
  # ======================================================================= #
  @array_help_options = []
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 206
def run
  start_batch_compilation
end
sanitize_compile_these_programs(i = input?) click to toggle source
#

sanitize_compile_these_programs

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 178
def sanitize_compile_these_programs(i = input?)
  i.flatten! # Just in case.
  i.map! {|entry|
    entry = entry.dup if entry.frozen?
    entry.strip! # Don't want whitespace there.
    RBT.try_to_find_shortcut_for_a_chain_compiled_program(entry)
  }
  # ======================================================================= #
  # Next, perform a separate conversion.
  # ======================================================================= #
  i.map! {|entry|
    _ = RBT.return_chained_programs # Get a handler here.
    entry = _[entry] if _.has_key? entry
    if entry.include?(',') and entry.is_a?(String)
      entry = entry.split(',')
    end
    if entry.is_a? Array
      entry.map!(&:strip)
      entry.reject!(&:empty?)
    end
    entry
  }
  i.flatten! if i.is_a? Array
end
Also aliased as: sanitize_input
sanitize_input(i = input?)
set_compile_these_programs( i = ARRAY_DEFAULT_COMPILE_THESE_PROGRAMS ) click to toggle source
#

set_compile_these_programs

Use this method to assign to @compile_these_programs. After that, we will sanitize the input.

If you pass in ?, then we will return the available chained programs.

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 120
def set_compile_these_programs(
    i = ARRAY_DEFAULT_COMPILE_THESE_PROGRAMS
  )
  i = ARRAY_DEFAULT_COMPILE_THESE_PROGRAMS if i.nil?
  i = ARRAY_DEFAULT_COMPILE_THESE_PROGRAMS if i.empty?
  if i.is_a? String
    i = i.split(',') if i.include? ','
  end
  i = [i] unless i.is_a? Array
  @compile_these_programs = i
  sanitize_compile_these_programs
end
show_compile_chain( i = input? )
start_batch_compilation() click to toggle source
#

start_batch_compilation (batch tag)

#
# File lib/rbt/utility_scripts/chain_compile.rb, line 157
def start_batch_compilation
  notify_the_user_which_programs_we_will_compile
  # ======================================================================= #
  # The input has to be sanitized past this point here.
  # ======================================================================= #
  input?.each {|this_program|
    opne "Now compiling `#{simp(this_program)}`."
    do_compile_this_program(this_program)
  }
end