class RBT::Cookbooks::ShowDependenciesOn

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

new( i = nil, run_already = true ) click to toggle source
#

initialize

#
Calls superclass method RBT::Base::new
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 38
def initialize(
    i           = nil,
    run_already = true
  )
  super()
  reset
  set_input(i)
  run if run_already
end

Public Instance Methods

add(i) click to toggle source
#

add

#
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 68
def add(i)
  if i.include? '.'
    i = File.basename(i).gsub(File.extname(i), '')
  end
  @array_programs << i
end
fetch_all_programs_that_depend_on_the_given_input() click to toggle source
#

fetch_all_programs_that_depend_on_the_given_input

#
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 112
def fetch_all_programs_that_depend_on_the_given_input
  all_cookbook_files = cookbook_files?(:show_full_path)
  all_cookbook_files.each {|file|
    file = File.basename(file)
    dataset = RBT::Cookbooks::Cookbook.new(file) { :bypass_menu }
    data = dataset.dependencies_on?
    unless data.nil?
      add(file) if data.include? input? # Add it if the input is part of the dependencies.
    end
  }
end
input?() click to toggle source
#

input?

#
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 78
def input?
  @input
end
notify_the_user_that_this_might_take_a_while() click to toggle source
#

notify_the_user_that_this_might_take_a_while

#
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 103
def notify_the_user_that_this_might_take_a_while
  opnn; e 'Scanning through the available programs next to find out'
  opnn; e 'which programs depend on '+sfancy(input?)+'. This may take a while,'
  opnn; e 'please be patient.'
end
report( i = @array_programs )
report_which_programs_depend_on_the_given_input( i = @array_programs ) click to toggle source
#

report_which_programs_depend_on_the_given_input (report tag)

#
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 85
def report_which_programs_depend_on_the_given_input(
    i = @array_programs
  )
  opnn; e 'These '+sfancy(i.size.to_s)+' programs '\
          'depend on '+simp(input?.to_s)+':'
  i.each_with_index {|entry, index|
    index += 1
    index = index.to_s.rjust(i.size.to_s.size)
    index = slateblue(index.to_s)
    index = ('('+index.to_s+')').rjust(4)
    entry = teal(entry)
    e '  '+index.to_s+' '+entry
  }
end
Also aliased as: report
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 51
def reset
  super()
  @array_programs = []
  @namespace = NAMESPACE
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 127
def run
  notify_the_user_that_this_might_take_a_while
  fetch_all_programs_that_depend_on_the_given_input
  report_which_programs_depend_on_the_given_input
end
set_input(i) click to toggle source
#

set_input

#
# File lib/rbt/utility_scripts/show_dependencies_on.rb, line 60
def set_input(i)
  i = i.join(' ') if i.is_a? Array
  @input = i
end