class Cookbooks::ShowDependenciesOn

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

initialize

#
Calls superclass method
# File lib/cookbooks/utility_scripts/show_dependencies_on.rb, line 36
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/cookbooks/utility_scripts/show_dependencies_on.rb, line 65
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/cookbooks/utility_scripts/show_dependencies_on.rb, line 118
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 = 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/cookbooks/utility_scripts/show_dependencies_on.rb, line 75
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/cookbooks/utility_scripts/show_dependencies_on.rb, line 102
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
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Base#opnn
# File lib/cookbooks/utility_scripts/show_dependencies_on.rb, line 111
def opnn
  super(NAMESPACE)
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/cookbooks/utility_scripts/show_dependencies_on.rb, line 82
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?)+':'
  i.each_with_index {|entry, index|
    index += 1
    index = index.to_s.rjust(i.size.to_s.size)
    if Object.const_defined? :Colours
      index = slateblue(index.to_s)
    end
    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 Cookbooks::Base#reset
# File lib/cookbooks/utility_scripts/show_dependencies_on.rb, line 49
def reset
  super()
  @array_programs = []
end
run() click to toggle source
#

run

#
# File lib/cookbooks/utility_scripts/show_dependencies_on.rb, line 133
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/cookbooks/utility_scripts/show_dependencies_on.rb, line 57
def set_input(i)
  i = i.join(' ') if i.is_a? Array
  @input = i
end