class RBT::Infobox
Constants
- COLOURS
#¶ ↑
COLOURS
¶ ↑#¶ ↑
- LEFT_PADDED_VERTICAL_BAR
#¶ ↑
LEFT_PADDED_VERTICAL_BAR
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- TRY_TO_USE_UNICODE_SYMBOLS_FOR_THE_COMMANDLINE_USER_INTERFACE
#¶ ↑
TRY_TO_USE_UNICODE_SYMBOLS_FOR_THE_COMMANDLINE_USER_INTERFACE
¶ ↑If the following constant is set to true then the
Infobox
will use Unicode symbols for the commandline interface. This may look nixer, depending on the terminal.#¶ ↑
- VERTICAL_BAR
#¶ ↑
VERTICAL_BAR
¶ ↑#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
new( i = nil, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
Ideally you should pass the cookbook-dataset to this method as the first parameter.
#¶ ↑
# File lib/rbt/infobox/infobox.rb, line 40 def initialize( i = nil, # Use the cookbook-dataset here. run_already = true ) reset set_compile_this_program(i) case run_already when :do_not_run_yet run_already = false end if block_given? yielded = yield if yielded.is_a? Hash if yielded.has_key? :use_ccache @use_ccache = yielded[:use_ccache] end if yielded.has_key? :show_required_dependencies_on @show_required_dependencies = yielded[:show_required_dependencies_on] end if yielded.has_key? :use_this_dataset set_use_this_as_dataset( yielded[:use_this_dataset] ) end if yielded.has_key? :do_what set_do_what(yielded[:do_what]) end end end run if run_already end
Public Instance Methods
add_this_number_to_hliner(i)
click to toggle source
add_this_number_to_right_just(i)
click to toggle source
ascii_hliner( i = :default, extra_arguments = nil ) { || ... }
click to toggle source
#¶ ↑
ascii_hliner
¶ ↑
Do a vertical bar through this method.
#¶ ↑
# File lib/rbt/infobox/infobox.rb, line 336 def ascii_hliner( i = :default, extra_arguments = nil ) case i when :default i = " #{return_vertical_bar_while_respecting_unicode}" end i = i.dup if i.frozen? if extra_arguments if extra_arguments.is_a? Symbol case extra_arguments when :box_drawings_heavy_up_and_left_and_right if really_use_unicode? i[1,1] = box_drawings_heavy_up_and_right i[-1,1] = box_drawings_heavy_up_and_left end when :box_drawings_heavy_up_and_right if really_use_unicode? i[1,1] = box_drawings_heavy_up_and_right end when :box_drawings_heavy_up_and_left if really_use_unicode? i[-1,1] = box_drawings_heavy_up_and_left end end end end if block_given? yielded = yield case yielded when :heavy_up_and_horizontal if really_use_unicode? i[33,1] = return_box_drawings_heavy_up_and_horizontal end end end e i end
ascii_hliner_with_this_text( this_text = ' Infobox ', &block )
click to toggle source
#¶ ↑
ascii_hliner_with_this_text
¶ ↑
#¶ ↑
# File lib/rbt/infobox/infobox.rb, line 414 def ascii_hliner_with_this_text( this_text = ' Infobox ', &block ) yielded = nil yielded = block.call if block _ = " #{return_vertical_bar_while_respecting_unicode}".dup # ======================================================================= # # Next, add the message, in powderblue() colour: # ======================================================================= # _[2, this_text.size] = powderblue(this_text) if really_use_unicode? _[59,1] = box_drawings_heavy_down_and_horizontal _[1,1] = box_drawings_heavy_down_and_right case yielded when :box_drawings_heavy_down_and_left _ [-1,1] = box_drawings_heavy_down_and_left end end e _ end
blank_line()
click to toggle source
#¶ ↑
blank_line
¶ ↑
#¶ ↑
# File lib/rbt/infobox/infobox.rb, line 182 def blank_line e ' '+return_vertical_bar_while_honouring_unicode+' '.ljust(@ljust_to_the_left - 2)+ ' '+return_vertical_bar_while_honouring_unicode+' '.rjust(@n_just_to_the_right + 1)+ ' '+return_vertical_bar_while_honouring_unicode end
box_drawings_heavy_down_and_horizontal()
click to toggle source
box_drawings_heavy_down_and_left()
click to toggle source
box_drawings_heavy_down_and_right()
click to toggle source
box_drawings_heavy_up_and_left()
click to toggle source
box_drawings_heavy_up_and_right()
click to toggle source
cflags_in_use?()
click to toggle source
colourized_verbose_truth(i)
click to toggle source
compile_this_program?()
click to toggle source
#¶ ↑
compile_this_program?¶ ↑
#¶ ↑
# File lib/rbt/infobox/infobox.rb, line 112 def compile_this_program? @compile_this_program end
Also aliased as: input?
compiler_to_use?()
click to toggle source
complete_left_padding_with_this_text(i)
click to toggle source
#¶ ↑
complete_left_padding_with_this_text
¶ ↑
#¶ ↑
# File lib/rbt/infobox/infobox.rb, line 290 def complete_left_padding_with_this_text(i) "#{consider_replacing_this_input_with_vertial_unicode_bar(LEFT_PADDED_VERTICAL_BAR)}#{i}:".ljust(@ljust_to_the_left)+' '+ return_vertical_bar_while_honouring_unicode+' ' end
consider_replacing_this_input_with_vertial_unicode_bar(i)
click to toggle source
default_colour(i = '')
click to toggle source
determine_padding_size_to_use(i)
click to toggle source
display( a = 'Prefix', b = '' )
click to toggle source
#¶ ↑
display (display tag)¶ ↑
#¶ ↑
# File lib/rbt/infobox/display.rb, line 14 def display( a = 'Prefix', b = '' ) if a.is_a?(String) and a.end_with?(':') a = a.dup if a.frozen? a.chop! end # ======================================================================= # # === Handle Arrays first # ======================================================================= # if b.is_a? Array b = b.dup # Need to work on a copy in this case. first_element = b.shift.ljust(45)+rev+return_vertical_bar_while_honouring_unicode if a.include? 'Required dependencies on' first_element = olivedrab(first_element) end b.map! {|entry| padded_entry = entry.ljust(44) if a.include? 'Required dependencies on' colourized_and_padded_entry = olivedrab(padded_entry) else colourized_and_padded_entry = default_colour(padded_entry) end rev+' '+return_vertical_bar_while_honouring_unicode+(' ' * 31)+ return_vertical_bar_while_honouring_unicode+ ' '+ colourized_and_padded_entry+rev } # ===================================================================== # # Reformat these Arrays: # ===================================================================== # # The remaining elements have to be padded into the proper field. # ===================================================================== # b = ([first_element] + b).join(N) end if b.is_a?(String) and b.include?('$') b = convert_global_env(b) end # ======================================================================= # # First, define a default - which is slateblue as colour. Or rather # the colour returned via the method default_colour(). # ======================================================================= # result = complete_left_padding_with_this_text(a)+ default_colour(b.to_s.ljust(@n_just_to_the_right))+' '+ return_vertical_bar_while_honouring_unicode if a.include? 'Prefix' result = complete_left_padding_with_this_text(a)+ skyblue(b.to_s.ljust(@n_just_to_the_right))+' '+ return_vertical_bar_while_honouring_unicode elsif a.include? 'Program path' result = complete_left_padding_with_this_text(a)+ colourize_this_file_path(b.ljust(44))+' '+ return_vertical_bar_while_honouring_unicode elsif a.include? 'this program' result = complete_left_padding_with_this_text(a)+ lightsteelblue(b.ljust(@n_just_to_the_right))+' '+ return_vertical_bar_while_honouring_unicode elsif a.include? 'Will be extracted towards' result = complete_left_padding_with_this_text(a)+ mediumslateblue(b.ljust(@n_just_to_the_right))+' '+ return_vertical_bar_while_honouring_unicode elsif a.include? 'CFLAGS in use' # ===================================================================== # # Next, two possibilities - colourize it, or do not colourize it. # ===================================================================== # if b.empty? result = complete_left_padding_with_this_text(a)+ crimson(b.ljust(@n_just_to_the_right))+' '+ return_vertical_bar_while_honouring_unicode else result = complete_left_padding_with_this_text(a)+ default_colour(b.ljust(@n_just_to_the_right))+' '+ return_vertical_bar_while_honouring_unicode end # ======================================================================= # # === Handle configure options next # ======================================================================= # elsif a.include? 'configure options' # ===================================================================== # # We have to wrap too long lines next: # ===================================================================== # if b.size > 78 b = word_wrap(b, 44) # =================================================================== # # Must still make this prettier. # =================================================================== # b = b.split(N) first_line = b[0]; b[0] = nil; b.compact! first_line = first_line.ljust(45) first_line << return_vertical_bar_while_honouring_unicode b.map! {|entry| entry.prepend(' '+return_vertical_bar_while_honouring_unicode+ (' ' * 31)+return_vertical_bar_while_honouring_unicode+' ' ) entry = entry.ljust(80) entry << return_vertical_bar_while_honouring_unicode entry } colourized_in_slateblue = slateblue( first_line+N+b.join(N) ) result = complete_left_padding_with_this_text(a)+ colourized_in_slateblue.gsub( /\|/, rev+return_vertical_bar_while_honouring_unicode+default_colour ) end end e result end
do_what=(i = 'Compiling')
click to toggle source
#¶ ↑
do_what=¶ ↑
This method can be used to determine which action is to be done.
#¶ ↑
# File lib/rbt/infobox/infobox.rb, line 241 def do_what=(i = 'Compiling') @do_this_action = i end
Also aliased as: set_do_what
enable_ccache()
click to toggle source
extract_to?()
click to toggle source
extracting_compiling_or_installing()
click to toggle source
keep_extracted?()
click to toggle source
padded_colourize_of_this_input( i, use_this_colour = :seagreen )
click to toggle source
parameters_to_make?()
click to toggle source
postinstall?()
click to toggle source
really_use_unicode?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::Base#reset
# File lib/rbt/infobox/infobox.rb, line 75 def reset super() @do_this_action = 'Compiling' @ljust_to_the_left = 32 @n_just_to_the_right = 44 @use_ccache = false # ======================================================================= # # If the next variable is true then dependencies will be shown, # unless they are empty/nil. This value should be false by default. # ======================================================================= # @show_required_dependencies = false @vertical_bar = VERTICAL_BAR.dup @namespace = NAMESPACE end
return_box_drawings_heavy_up_and_horizontal()
click to toggle source
return_horizontal_interface_token()
click to toggle source
return_vertical_bar_while_honouring_unicode()
click to toggle source
return_vertical_bar_while_respecting_unicode()
click to toggle source
rev()
click to toggle source
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/infobox/run.rb, line 14 def run _ = compile_this_program? if _.nil? opnn; e 'Please supply the name of the program to show.' return end # ======================================================================= # # Right now, only .program_path? can lead to a longer padding size. # ======================================================================= # determine_padding_size_to_use(_.program_path?) ascii_hliner_with_this_text { :box_drawings_heavy_down_and_left } blank_line display extracting_compiling_or_installing+' this program', _.short_program_name? # ======================================================================= # # === Prefix # # Show the prefix, but not if it is a .gem file. # ======================================================================= # display 'Prefix', _.prefix? unless _.program_path?.end_with? '.gem' display 'Program version', _.program_version? display 'Program path', _.program_path? # ======================================================================= # # === Display where we will extract the archive into # ======================================================================= # display 'Will be extracted towards', extract_to? # ======================================================================= # # === Keep the archive extracted # # Note that this setting may be removed at a later time - not sure # yet (June 2018). # # We will not display this information if it is a .gem file though. # ======================================================================= # unless _.program_path?.end_with? '.gem' display 'Keep the archive extracted', colourized_verbose_truth(keep_extracted?) end # ======================================================================= # # === Show whether we will use ccache or not # ======================================================================= # e complete_left_padding_with_this_text('Will ccache be used')+ colourized_verbose_truth(@use_ccache.to_s)+' '+return_vertical_bar_while_honouring_unicode # ======================================================================= # # === Show the CFLAGS in use # ======================================================================= # display 'CFLAGS in use', cflags_in_use? # ======================================================================= # # === Show if we try to use a static build # ======================================================================= # if _.build_static? e complete_left_padding_with_this_text('Compile statically')+ colourized_verbose_truth(_.build_static?.to_s)+' '+ return_vertical_bar_while_honouring_unicode end # ======================================================================= # # === Display whether we will use a build directory # # This used to be a conditional check, via "if _.use_build_directory?", # but since as of 18.09.2018 we will show this no matter what. # ======================================================================= # display 'Use a build directory', colourized_verbose_truth(_.use_build_dir?) # ======================================================================= # # === Display the configure options # ======================================================================= # use_these_configure_options = _.configuration_options? if use_these_configure_options unless _.configuration_options?.empty? display 'configure options', use_these_configure_options end end # ======================================================================= # # === Display postinstall step, but only if it exists # ======================================================================= # if postinstall? and !postinstall?.empty? display 'Postinstall action', postinstall?.join(' ') end # ======================================================================= # # === Display x86 or x64 type # ======================================================================= # display 'Host architecture in use', RBT.determine_host_architecture if @show_required_dependencies display 'Required dependencies on', _.dependencies? end # ======================================================================= # # === Show whether we will use autogen, but only if we really do # ======================================================================= # if _.use_autogen? display 'Use autogen', colourized_verbose_truth(true) end # ======================================================================= # # === Show the build system in use next # # We have to be mindful of situations such as when "configure" would # be displayed, but the .yml file has a "run_configure: no" entry. # ======================================================================= # use_this_build_system = _.use_which_build_system? if (input?.run_configure? == false) and (use_this_build_system == 'configure') # ===================================================================== # # In this case the program does not use configure at all, so it # does not make a whole lot of sense to insinuate that 'configure' # is used, naturally. # ===================================================================== # use_this_build_system = '(unknown / unspecified)' end display 'Build system to be used', padded_colourize_of_this_input(use_this_build_system, :seagreen) # ======================================================================= # # === Parameters for make # ======================================================================= # unless parameters_to_make?.reject {|entry| entry.nil? or entry.empty? }.empty? joined = parameters_to_make? if joined.is_a? Array joined = joined.join(',').strip end joined.chop! if joined.end_with? ',' display 'Parameters for make', padded_colourize_of_this_input(joined, :seagreen) end # ======================================================================= # # === Show the compiler that will be used for the current run # ======================================================================= # display 'Compiler to be used:', padded_colourize_of_this_input(compiler_to_use?, :mediumpurple) blank_line ascii_hliner(:default, :box_drawings_heavy_up_and_left_and_right) { :heavy_up_and_horizontal } e end
set_compile_this_program(i = '')
click to toggle source
#¶ ↑
set_compile_this_program
¶ ↑
This will assign to the program to be used; it should be an instance of the main data-loader class.
#¶ ↑
# File lib/rbt/infobox/infobox.rb, line 96 def set_compile_this_program(i = '') i = i.first if i.is_a? Array i = i.dup if i.is_a? String # ===================================================================== # # Turn strings into the corresponding dataset. # ===================================================================== # require 'rbt/cookbooks/class/cookbooks.rb' i = RBT::Cookbooks::Cookbook.new(i) { :bypass_menu } end @compile_this_program = i end
Also aliased as: set_use_this_as_dataset
set_use_ccache(i)
click to toggle source
try_to_use_unicode_symbols_for_the_commandline_user_interface?()
click to toggle source
#¶ ↑
try_to_use_unicode_symbols_for_the_commandline_user_interface?¶ ↑
#¶ ↑
# File lib/rbt/infobox/misc.rb, line 25 def try_to_use_unicode_symbols_for_the_commandline_user_interface? TRY_TO_USE_UNICODE_SYMBOLS_FOR_THE_COMMANDLINE_USER_INTERFACE end
Also aliased as: use_unicode?