class RBT::CopyTheseArchives

Public Class Methods

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

RBT::CopyTheseArchives[]

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

initialize

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

Public Instance Methods

copy_this_archive(i) click to toggle source
#

copy_this_archive

#
# File lib/rbt/utility_scripts/copy_these_archives.rb, line 92
def copy_this_archive(i)
  this_dir = return_pwd
  opne "Now copying #{sfile(i)} to the current working "\
       "directory (#{sdir(this_dir)})."
  copy_file(i, this_dir)
end
reset() click to toggle source
#

reset (reset tag)

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

run (run tag)

#
# File lib/rbt/utility_scripts/copy_these_archives.rb, line 53
def run
  commandline_arguments?.each {|this_target|
    full_target_path = this_target.dup
    if RBT.respond_to? :swift_return_version_of_this_program
      version_of_the_program = return_version_of_this_program(this_target)
    else
      require 'rbt/requires/require_the_cookbook_class.rb'
      version_of_the_program = RBT::Cookbooks::SanitizeCookbook.new(this_target) { :fast }.program_version?
    end
    unless this_target.include? '/'
      unless File.file?(this_target)
        full_target_path = src_dir?+this_target
      end
    end
    # ===================================================================== #
    # this_target may now look like this:
    #
    #   /home/x/src/linux
    #
    # We will next have to obtain the most recent version of the program.
    # ===================================================================== #
    unless full_target_path.end_with? '/'
      full_target_path << '/'
    end
    # ===================================================================== #
    # Now we can attempt to find a locally existing file. We will grab the
    # first entry found, if the result is not empty.
    # ===================================================================== #
    use_this_target = full_target_path+this_target+'-'+version_of_the_program+'*'
    possible_files = Dir[use_this_target]
    unless possible_files.empty?
      copy_this_archive(possible_files.first)
    end
  }
end