class RBT::FeedbackInformation

Constants

BR
DEFAULT_PROGRAM
#

DEFAULT_PROGRAM

#
HTML_FILE
#

HTML_FILE

#

Public Class Methods

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

initialize

#
# File lib/rbt/utility_scripts/feedback_information.rb, line 55
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(i)
  run if run_already
end

Public Instance Methods

create_html_page(hash_result) click to toggle source
#

create_html_page (html tag)

This method will create a new HTML info page.

It expects a hash as input.

Pass a hash with arrays to create a HTML Info page.

Valid input i.e. the hash_result would be something like this:

{
  "zebra"=>"http://www.zebra.org/",
  "zee"=>"http://sourceforge.net/projects/zee/"
}
#
# File lib/rbt/utility_scripts/feedback_information.rb, line 175
def create_html_page(hash_result)
  require 'rbt/requires/require_the_cookbook_class.rb'
  # ======================================================================= #
  # Start to create the HTML page next.
  # ======================================================================= #
  result = ''.dup
  result << Cyberweb.return_strict_doctype
  result << Cyberweb.return_html_start
  result << Cyberweb.return_head_start
  hash_result.each_pair { |key, url| # key is i.e. php
    basename = File.basename(key).
               delete_suffix('.gz').
               delete_suffix('.tar').
               delete_suffix('.bz2')
    result << '<b style="font-size:2em;">'+basename+'</b>:<br>'
    result << '<p style="font-size:1.05em; padding-left:2.2em;text-indent:0.22em">'
    # Get description of the program in question next:
    # ===================================================================== #
    _ = action(:SanitizeCookbook, key) { :fast }
    description = _.desc?
    result << string_s(
      '<b style="color:darkgreen;text-decoration:underline">Description:</b><br><br>'
    )
    result << '</p>'
    begin
      result << '<p style="margin-top:5px; font-size:1.05em; padding-left:2.2em; text-indent:1.5em">'
      if description
        result << description.gsub(/\n/,'<br>').delete('"')
      else
        opnwarn "No description entry for `#{key}`."
      end
      result << '</p>'
    rescue ArgumentError
      opne 'ArgumentError happened for `'+key+'`: byte-error in wrong encoding'
    end
    # ===================================================================== #
    # Next, we will build-up the URLs.
    # ===================================================================== #
    result << BR+string_s( '<b style="color:darkblue"># URL(s) for '+basename+': </b>' )
    result << BR
    if url.is_a? Array
      url = url.join
    end
    result << string_s('wget <a href="'+url+'">'+url+'</a>',
                :css_style => 'margin-left:2em'
              )
    result << N << BR
    result << '</p>'
  }
  result << Cyberweb.return_html_fin
  ensure_that_target_directory_exists
  # ======================================================================= #
  # Last but not least, write this into a html page
  # ======================================================================= #
  remove_file(HTML_FILE)
  write_what_into(result, HTML_FILE)
  opne 'A HTML file was created at:'
  efile "  #{HTML_FILE}"
end
ensure_that_target_directory_exists() click to toggle source
#

ensure_that_target_directory_exists

#
# File lib/rbt/utility_scripts/feedback_information.rb, line 153
def ensure_that_target_directory_exists
  _ = File.dirname(HTML_FILE)
  mkdir(_) unless Dir.exist? _
end
feedback_url(i) click to toggle source
#

feedback_url

Only report a match if we include it.

#
# File lib/rbt/utility_scripts/feedback_information.rb, line 137
def feedback_url(i)
  RBT.find_url_for(i)
end
reset() click to toggle source
#

reset (reset tag)

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

run (run tag)

#
# File lib/rbt/utility_scripts/feedback_information.rb, line 238
def run
  run_on_every_program
end
run_on_every_program( this_program = DEFAULT_PROGRAM ) click to toggle source
#

run_on_every_program

This will walk over each program given and report the URL.

Obviously, this may take a long time.

#
# File lib/rbt/utility_scripts/feedback_information.rb, line 113
def run_on_every_program(
    this_program = DEFAULT_PROGRAM
  )
  this_program = DEFAULT_PROGRAM if this_program.nil?
  opne 'Feedback information about these programs next: '
  e @input.join(',  ')
  hash_result = {}
  @input.each { |program|
    program = program.strip # remove whitespace first
    program.downcase!
    padded_program = ('`'+sfancy(program)+'`').ljust(38)
    opne 'Fetching URL(s) for '+padded_program+' and '\
         'adding it to the main hash.'
    _ = feedback_url(program)
    hash_result[program] = _
  }
  create_html_page(hash_result) # We pass our hash to it.
end
set_input( i = 'all' ) click to toggle source
#

set_input

#
# File lib/rbt/utility_scripts/feedback_information.rb, line 75
def set_input(
    i = 'all'
  )
  # ======================================================================= #
  # For now, if the input is an Array, we will just grab the first entry.
  # ======================================================================= #
  i = i.first if i.is_a? Array
  i = i.to_s.dup if i
  # ======================================================================= #
  # Convert to Array if first argument is of String type.
  # We assume they will be delineated by a ',' in this case though.
  # ======================================================================= #
  i = i.split(',') if i.is_a? String
  if i.is_a? Array
    i.map! {|entry|
      case entry
      when 'all','everything' # Shortcuts to assign ALL program names.
        entry = available_programs?
      end
      entry
    }
    i.flatten!
  end
  case i.to_s # And also for Strings.
  when 'all','everything' # Shortcuts to assign ALL program names.
    i = available_programs?
  end
  i = i.sort
  @input = i
end
string_s( i = '', hash = {} ) click to toggle source
#

string_s

#
# File lib/rbt/utility_scripts/feedback_information.rb, line 144
def string_s(
    i = '', hash = {}
  )
  HtmlTags.span(i, hash)
end