class RBT::FeedbackInformation
Constants
- BR
- DEFAULT_PROGRAM
#¶ ↑
DEFAULT_PROGRAM
¶ ↑# ¶ ↑
- HTML_FILE
#¶ ↑
HTML_FILE
¶ ↑#¶ ↑
Public Class Methods
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: # ===================================================================== # # # ===================================================================== # _ = RBT::Cookbooks::SanitizeCookbook.new(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
feedback_url(i)
click to toggle source
reset()
click to toggle source
run()
click to toggle source
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