class RBT::Cookbooks::DownloadAllSourceArchives

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

RBT::Cookbooks::DownloadAllSourceArchives[]

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

initialize

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

Public Instance Methods

cd_to_the_archive_directory() click to toggle source
#

cd_to_the_archive_directory

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 210
def cd_to_the_archive_directory
  cd @archive_directory, :be_quiet
end
commandline_arguments?() click to toggle source
#

commandline_arguments?

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 106
def commandline_arguments?
  @commandline_arguments
end
Also aliased as: input?
consider_downloading_this_program(i) click to toggle source
#

consider_downloading_this_program

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 175
def consider_downloading_this_program(i)
  require 'rbt/cookbooks/class/class.rb'
  cd_to_the_archive_directory # Always enter the archive directory.
  # ======================================================================= #
  # Next, check whether the program exists.
  # ======================================================================= #
  _ = RBT::Cookbooks::Cookbook.new(i) { :bypass_menu_check }
  program_path = _.program_path?
  remote_url   = _.remote_url?
  unless File.exist? program_path
    this_directory = "#{@archive_directory}#{i}/"
    unless File.directory? this_directory
      opnn; e "Creating the directory `#{sdir(this_directory)}` next."
      mkdir this_directory
    end
    cd this_directory
    unless File.exist? program_path
      download(remote_url)
      opnn; e "Next downloading `#{simp(remote_url)}`."
    end
  end
end
dataset?() click to toggle source
#

dataset?

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 90
def dataset?
  @available_programs
end
download(i) click to toggle source
#

download

The download-functionality requires wget right now.

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 203
def download(i)
  esystem "wget #{i}"
end
input?()
menu(i = commandline_arguments?) click to toggle source
#

menu (menu tag)

#
process_the_programs_one_after_the_other( i = @available_programs ) click to toggle source
#

process_the_programs_one_after_the_other

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 249
def process_the_programs_one_after_the_other(
    i = @available_programs
  )
  i.each {|this_program|
    consider_downloading_this_program(this_program)
  }
end
register_this_tag(i) click to toggle source
#

register_this_tag

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 138
def register_this_tag(i)
  @tag = i
end
report_the_archive_directory_in_use() click to toggle source
#

report_the_archive_directory_in_use

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 145
def report_the_archive_directory_in_use
  if @tag
    opnn; e "All registered programs with the tag #{sfancy(@tag)}"\
            " will be downloaded into the directory:"
  else
    opnn; e 'All registered programs will be downloaded into the directory:'
  end
  e
  e sfile("  #{@archive_directory}")
  e
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 66
def reset
  super()
  @tag = nil
  @archive_directory = source_directory?
  @available_programs = available_programs? # <- Must come before the menu() call.
  @namespace = NAMESPACE
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 260
def run
  menu
  report_the_archive_directory_in_use
  process_the_programs_one_after_the_other
end
select_only_these_tags(i) click to toggle source
#

select_only_these_tags

To invoke this method, try:

download_all_source_archives --tags=plasma
#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 220
def select_only_these_tags(i)
  # ======================================================================= #
  # Ok, the user provided a tag, so we have to selectively filter for
  # programs that include only that tag. For now, we only use the
  # expanded cookbook dataset for this. Of course we must check whether
  # this directory exists or whether it does not.
  # ======================================================================= #
  if File.directory? directory_expanded_cookbooks?
    entries = Dir[directory_expanded_cookbooks?+'*.yml']
    results = entries.map {|entry|
      YAML.load_file(entry)
    }.select {|entry| entry['tags'].include? i }
    results.map! {|entry| entry['real_short_name'] }
    return results
  else
    opnn; e "No directory called #{sdir(directory_expanded_cookbooks?)} exists."
    opnn; e 'This class currently requires this directory to work.'
    opnn; e 'If you wish to auto-generate the directory and the files or that'
    opnn; e 'directory, then issue this command:'
    e
    e sfancy('  cookbooks --expand')
    e
    exit
  end
end
set_commandline_arguments(i = '') click to toggle source
#

set_commandline_arguments

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 97
def set_commandline_arguments(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @commandline_arguments = i
end
set_use_these_cookbooks(i) click to toggle source
#

set_use_these_cookbooks

The input to this method should be an Array.

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 79
def set_use_these_cookbooks(i)
  if i.is_a? Array
    i.flatten!
    i.sort!
  end
  @available_programs = i
end
show_help() click to toggle source
#

show_help (help tag)

#
# File lib/rbt/utility_scripts/download_all_source_archives.rb, line 160
def show_help
  opnn; e 'This class allows you to download source archives.'
  opnn; e 'You can also selectively download only certain entries, in'
  opnn; e 'particular those who have registered tags.'
  e
  opnn; e 'For example, if you wish to download all KDE-plasma related entries'
  opnn; e 'then you can issue the following command:'
  e
  opnn; e sfancy('  download_all_source_archives --tags=plasma')
  e
end