class RBT::Gitty

Public Class Methods

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

RBT::Gitty[]

#
# File lib/rbt/utility_scripts/gitty.rb, line 131
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/gitty.rb, line 22
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

handle_this_remote_program(this_program) click to toggle source
#

handle_this_remote_program

#
# File lib/rbt/utility_scripts/gitty.rb, line 68
def handle_this_remote_program(this_program)
  opne "#{rev}Using the remote URL at #{steelblue(this_program)} #{rev}next."
  esystem "git clone #{this_program}"
  target = File.basename(this_program)
  if File.directory?(target)
    new_name = target+'-'+dd_mm_yyyy.to_s
    if File.directory? new_name
      opne 'Normally this class would create a new directory, at '+sdir(new_name)+'.'
      opne 'However had, an (old) directory with that name already exists, so'
      opne 'the class can not continue; the user has to decide what should'
      opne 'happen in this event.'
    else
      opne "Renaming the directory at #{sdir(target)}"\
           "#{rev} to #{steelblue(new_name)} #{rev}next."
      rename_directory(target, new_name) { :be_quiet }
      opne 'Done!'
      opne 'Last but not least, this directory will be turned into a'
      opne '.tar.xz archive.'
      require 'totarxz'
      to_tar_xz = ToTarXz.new(new_name)
      full_path = File.absolute_path(to_tar_xz.result?)
      if File.exist? full_path
        opne 'The archive can now be found at: '+sfile(full_path)+rev
      else
        opnn; no_file_exists_at(full_path)
      end
    end
  else
    opne 'No directory found at '+sdir(target)+rev+'.'
  end
end
let_class_installer_handle_this_program(this_program) click to toggle source
#

let_class_installer_handle_this_program

#
# File lib/rbt/utility_scripts/gitty.rb, line 52
def let_class_installer_handle_this_program(this_program)
  installer = action(:Installer, this_program) { :do_not_run_yet }
  installer.set_compile_this_program(this_program)
  installer.initialize_dataset_for(this_program)
  cd installer.base_dir? # This only works if the dataset has been set up properly before.
  # ======================================================================= #
  # Next, we will call the method download_the_latest_source_code_of_this_program()
  # which will download the latest source code of the given program at hand.
  # ======================================================================= #
  location = installer.download_the_latest_source_code_of_this_program
  opne "#{rev}The archive should now exist at: #{steelblue(location)}#{rev}"
end
notify_the_user_what_to_do_if_no_argument_was_supplied_to_this_class() click to toggle source
#

notify_the_user_what_to_do_if_no_argument_was_supplied_to_this_class

#
# File lib/rbt/utility_scripts/gitty.rb, line 44
def notify_the_user_what_to_do_if_no_argument_was_supplied_to_this_class
  opne 'Please supply an argument to this class (the program whose'
  opne "sources you want to checkout via #{steelblue('git')}#{rev})."
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/gitty.rb, line 36
def reset
  super()
  infer_the_namespace
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/gitty.rb, line 119
def run
  this_program = first_argument?
  if this_program
    work_on_this_program(this_program)
  else
    notify_the_user_what_to_do_if_no_argument_was_supplied_to_this_class
  end
end
work_on_this_program( this_program ) click to toggle source
#

work_on_this_program

#
# File lib/rbt/utility_scripts/gitty.rb, line 103
def work_on_this_program(
    this_program
  )
  # ======================================================================= #
  # First, delegate to class Installer:
  # ======================================================================= #
  if this_program.start_with?('http')
    handle_this_remote_program(this_program)
  else # else let class Installer handle the situation
    let_class_installer_handle_this_program(this_program)
  end
end