class AsciiParadise::Flexbox
Constants
- COLOUR_FOR_THE_TITLE
#¶ ↑
COLOUR_FOR_THE_TITLE
¶ ↑#¶ ↑
- DEFAULT_COLOURS_FOR_RBT
#¶ ↑
DEFAULT_COLOURS_FOR_RBT
¶ ↑This constant can be used to notify the default colours for the
Flexbox
to use.#¶ ↑
- MAX_VALUE_FOR_PADDING
#¶ ↑
MAX_VALUE_FOR_PADDING
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- N_LEFT_PAD_FOR_THE_RBT_PROJECT
#¶ ↑
N_LEFT_PAD_FOR_THE_RBT_PROJECT
¶ ↑#¶ ↑
- N_RIGHT_PAD_FOR_THE_RBT_PROJECT
#¶ ↑
N_RIGHT_PAD_FOR_THE_RBT_PROJECT
¶ ↑#¶ ↑
- SHOW_REMOTE_URLS_BY_DEFAULT
#¶ ↑
SHOW_REMOTE_URLS_BY_DEFAULT
¶ ↑If this constant is set to true then the
Flexbox
will also try to show the two entries “url1” and “homepage”, if these are available.#¶ ↑
- TEST_INPUT
#¶ ↑
TEST_INPUT
¶ ↑This is simply a hardcoded String that can be used to quickly test the
Flexbox
, without depending on an external project, such as the “rbt” gem.#¶ ↑
- 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
Flexbox
will try to useUnicode
symbols for the commandline interface. This may look nicer, depending on the terminal and encoding in use.#¶ ↑
- UNICODE_SYMBOL_TO_USE_FOR_THE_TOP_LEFT_AREA
#¶ ↑
UNICODE_SYMBOL_TO_USE_FOR_THE_TOP_LEFT_AREA
¶ ↑This emoji provides some little “graphical” modification to the flexbox title.
#¶ ↑
- VERTICAL_ASCII_BAR
#¶ ↑
VERTICAL_ASCII_BAR
¶ ↑#¶ ↑
Public Class Methods
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 132 def initialize( commandline_arguments = nil, run_already = true, &block ) try_to_require_external_dependencies # Must come early. reset set_commandline_arguments( commandline_arguments ) case run_already when :do_not_run_yet run_already = false end # ======================================================================= # # === Handle blocks given next # ======================================================================= # if block_given? yielded = yield if yielded.is_a? Hash # =================================================================== # # === :show_required_dependencies_on # # This entry point allows us to specify the dependencies to be # used. # =================================================================== # if yielded.has_key? :show_required_dependencies_on set_show_required_dependencies( yielded[:show_required_dependencies_on] ) end # =================================================================== # # === :use_this_dataset # =================================================================== # if yielded.has_key? :use_this_dataset set_use_this_as_dataset( yielded[:use_this_dataset] ) end # =================================================================== # # === :do_what # =================================================================== # if yielded.has_key? :do_what set_do_what( yielded[:do_what] ) end # =================================================================== # # === :use_colours # =================================================================== # if yielded.has_key? :use_colours @use_colours = yielded[:use_colours] end # =================================================================== # # === :use_this_dataset # =================================================================== # if yielded.has_key? :use_this_dataset _ = yielded[:use_this_dataset] prepare_the_compile_dataset(_) end end end run if run_already end
Public Instance Methods
#¶ ↑
add_this_to_the_right_padding
¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 439 def add_this_to_the_right_padding(i) @n_right_pad += i end
#¶ ↑
autoexpand (auto tag, autoexpand tag)¶ ↑
This method will try to automatically expand the left-pad and right-pad values if any individual entry is “too long”. It thus exists mostly as a convenience feature.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 717 def autoexpand # ======================================================================= # # (1) First, handle the left side properly and correctly. We must find # the largest element. # ======================================================================= # left_side = @hash[:left_side] max_n_left = left_side.map {|entry| entry.size }.max.to_i if max_n_left > left_pad? set_left_padding(max_n_left) end # ======================================================================= # # (2) Next, handle the right side properly and correctly. We must # find the largest element. # ======================================================================= # right_side = @hash[:right_side] max_n_right = right_side.map {|entry| entry.to_s.size }.max.to_i if max_n_right > right_pad? set_right_padding(max_n_right+1) end end
#¶ ↑
cliner (cliner tag)¶ ↑
Specialized cliner-variant. It also responds to certain block arguments such as :top or :bottom.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 492 def cliner( use_n_tokens = :default, use_this_token = :infer ) case use_n_tokens when :default use_n_tokens = return_combined_value_from_both_padding_values end case use_this_token when :infer if really_use_unicode? use_this_token = Roebe.horizontal_block else use_this_token = '-' end end result = use_this_token * use_n_tokens if block_given? yielded = yield case yielded # ===================================================================== # # === :middle # ===================================================================== # when :middle result[0,1] = @vertical result << @vertical # =================================================================== # # And change the "centerpiece" too: # =================================================================== # result[left_pad?+3,1] = @vertical # ===================================================================== # # === :top # ===================================================================== # when :top result[0,1] = Roebe.top_left_corner result << Roebe.top_right_corner.dup # =================================================================== # # And change the "centerpiece" too: # =================================================================== # result[left_pad?+3,1] = Roebe.centerpiece_and_down # ===================================================================== # # === :bottom # ===================================================================== # when :bottom result[0,1] = Roebe.bottom_left_corner result << Roebe.bottom_right_corner.dup # =================================================================== # # And change the "centerpiece" too: # =================================================================== # result[left_pad?+3,1] = Roebe.centerpiece_and_up end end result end
#¶ ↑
colourize_border
¶ ↑
This method can be used to colourize the border.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 325 def colourize_border( use_this_colour = :default ) case use_this_colour when :default use_this_colour = DEFAULT_COLOURS_FOR_RBT[:default_colour_for_the_border] when :none use_this_colour = nil end @use_this_colour_for_the_border = use_this_colour end
#¶ ↑
colourize_right_side_with_these_colours
¶ ↑
This method can be used to colourize the right-hand side of the table via a specific colour. This is currently simply a hardcoded Array. Perhaps one day we should transition into a Hash, but Arrays are simpler to use so we will stick with them for now.
If you wish to use the default colours here, use this:
colourize_right_side_with_these_colours :default
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 803 def colourize_right_side_with_these_colours(*i) i.flatten! if i.flatten.first == :default i = %i( cadetblue mediumslateblue paleturquoise steelblue slateblue steelblue royalblue orchid steelblue royalblue steelblue steelblue mediumseagreen steelblue steelblue steelblue steelblue violet ) end @array_colourize_right_side_with_these_colours = i end
#¶ ↑
colourize_this_in_that_colour
¶ ↑
The default colour will be the colour used for the border, if otherwise not specified.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 308 def colourize_this_in_that_colour( this, that_colour = @use_this_colour_for_the_border ) if this and this.include? 'No CFLAGS in use.' that_colour = :crimson # Use another colour in this case. end if that_colour and this Colours.send(that_colour, this) end end
#¶ ↑
colourize_this_via_the_default_border_colour
¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 340 def colourize_this_via_the_default_border_colour(i) if @use_colours and @use_this_colour_for_the_border return colourize_this_in_that_colour(i, @use_this_colour_for_the_border) else return i end end
#¶ ↑
compile_dataset?¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 1319 def compile_dataset? @compile_dataset end
#¶ ↑
compile_this_program?¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 944 def compile_this_program? @compile_this_program end
#¶ ↑
display (display tag, report tag)¶ ↑
This is the method that will display the content of the flexbox-table.
You can style the colour of the border in one method call, such as by using:
flexbox.display {{ border: :steelblue }}
To not use any border-colouring, use this:
flexbox.display {{ border: :none }}
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 1370 def display left_pad = left_pad? right_pad = right_pad? vertical_bar = vertical_bar? use_colours = use_colours? if block_given? yielded = yield if yielded.is_a? Hash # =================================================================== # # === :border # =================================================================== # if yielded.has_key? :border set_border_colour( yielded.delete(:border) ) end end end # ======================================================================= # # First display the top-cliner: # ======================================================================= # top_ecliner right_side = right_side? middle_ecliner _return_potentially_colourized_vertical_token = return_potentially_colourized_vertical_token # ======================================================================= # # Display the content next by iterating through the left-side of the # main (data) hash. # ======================================================================= # left_side?.each_with_index {|left_side_content, index| # ===================================================================== # # Build up our result-string next. This one will be shown to the user. # ===================================================================== # result = ' '.dup result << _return_potentially_colourized_vertical_token result << " #{left_side_content.to_s.ljust(@n_left_pad)} " # ===================================================================== # # Obtain a reference to the right-side "content". # ===================================================================== # right_side_content = right_side[index].to_s # ===================================================================== # # Modify the required-dependencies via a leading right-side arrow next. # ===================================================================== # case left_side_content when /^Required dependencies on/ right_side_content.prepend('→ ') end if right_side_content.size > right_pad # =================================================================== # # Do some padding then. This is typically done for the entry # "configure options", since that may become very long. # =================================================================== # splitted = ::AsciiParadise.wrap_at(right_side_content, 56).split("\n") index = 0 # =================================================================== # # splitted is an Array - and we have 3 different paths to proceed # from here, past this point. # =================================================================== # splitted.map! {|entry| index += 1 if index == 1 # =============================================================== # # All entries with exactly one member: these are the default and # most commonly seen variants. So we handle that case first. # =============================================================== # "#{entry.strip.ljust(@n_right_pad)}#{vertical_bar}\n" elsif index == splitted.size # =============================================================== # # This variant will NOT append a vertical bar. # =============================================================== # ' '+vertical_bar+(' ' * (left_pad+2))+vertical_bar+' '+ entry.strip.ljust(@n_right_pad)+"\n" else # =============================================================== # # This variant will append a vertical_bar. It is for e. g. # long configure_options entries, such as for "glibc". # =============================================================== # ' '+vertical_bar+(' ' * (left_pad+2))+vertical_bar+' '+ entry.strip.ljust(@n_right_pad)+ vertical_bar+ "\n" end } right_side_content = splitted.join right_side_content_properly_padded = right_side_content.chomp else right_side_content_properly_padded = right_side_content.ljust(@n_right_pad) end result << _return_potentially_colourized_vertical_token # ===================================================================== # # Next colourize the right-hand side of the table: # ===================================================================== # if use_colours and !@array_colourize_right_side_with_these_colours.empty? # =================================================================== # # === Program path # =================================================================== # case left_side_content when 'Required dependencies on:' right_side_content_properly_padded = tomato(right_side_content_properly_padded) when 'Program path:' # ================================================================= # # Split up the program path and colourize is a bit: # ================================================================= # _ = right_side_content_properly_padded.split('/') right_side_content_properly_padded = colourize_this_in_that_colour( _[0 .. -2].join('/')+'/', @array_colourize_right_side_with_these_colours[index] )+royalblue(_.last) else right_side_content_properly_padded = colourize_this_in_that_colour( right_side_content_properly_padded, @array_colourize_right_side_with_these_colours[index] ) end end result << ' '+ right_side_content_properly_padded.to_s # ← Add the right side next. result << _return_potentially_colourized_vertical_token e result } middle_ecliner bottom_ecliner end
#¶ ↑
do_what=¶ ↑
This method can be used to determine which action is to be done.
Available actions are:
- compiling - extracting - installing
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 670 def do_what=(i = 'Compiling') @do_this_action = i end
#¶ ↑
enable_rbt_specific_behaviour
¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 980 def enable_rbt_specific_behaviour # ======================================================================= # # Do not autoexpand the Flexbox when we display data from the RBT # project. # ======================================================================= # @shall_we_autoexpand = false # ======================================================================= # # Set the proper values for the RBT project. # ======================================================================= # set_proper_padding_for_the_rbt_project # use_this_title = "#{UNICODE_SYMBOL_TO_USE_FOR_THE_TOP_LEFT_AREA} Infobox" use_this_title = "Infobox" set_title(use_this_title) # ======================================================================= # # Obtain a handle to the compile-dataset next. # ======================================================================= # dataset = compile_dataset? return if dataset.nil? array = [] @do_this_action = if extract_only? 'Extracting' elsif has_to_be_compiled? 'Compiling' else 'Installing' end # ======================================================================= # # === Compiling (or installing or extracting) this program: # # Note that the display-string can be different, e. g. such as # in "Installing this program" instead. # ======================================================================= # array << "#{extracting_compiling_or_installing?} this program:" array << dataset.query_for(array.last) # ======================================================================= # # === Assumed Operating System: # ======================================================================= # array << 'Assumed Operating System:' array << dataset.query_for(array.last) # ======================================================================= # # === Prefix: # # Show the prefix in use, but not if it is a .gem file. # ======================================================================= # unless is_it_a_gem? array << 'Prefix:' array << dataset.query_for(array.last) end if program_path? # ======================================================================= # # === Program version: # ======================================================================= # array << 'Program version:' array << dataset.query_for(array.last) # ======================================================================= # # === Program path: # ======================================================================= # array << 'Program path:' array << dataset.query_for(array.last) # ======================================================================= # # === configure options: # # These will only be shown when not empty. # ======================================================================= # configure_options = return_configure_options_or_meson_options_or_no_options unless configure_options.empty? array << 'configure options:' array << configure_options end if configure_options # ======================================================================= # # === Will be extracted towards: # # Note that this must show the FULL path to the extracted target, # not just the base directory. # ======================================================================= # array << 'Will be extracted towards:' array << extract_to_this_directory?.to_s+ ' (or rather '+ extract_to_this_directory?.to_s+ dataset.query_for('program_name_and_program_version').to_s+ '/)' # ======================================================================= # # === Keep the archive extracted: # # This information is not shown if we work on a .gem file, though. # ======================================================================= # unless is_it_a_gem? array << 'Keep the archive extracted:' array << keep_extracted? end # ======================================================================= # # === Will ccache be used: # # This entry point will show whether ccache will be used or whether # it will not be used. # ======================================================================= # array << 'Will ccache be used:' array << dataset.query_for(array.last) # ======================================================================= # # === CFLAGS in use: # # These will only be shown if the program at hand has to be compiled, # as otherwise they do not appear to be relevant for programs that # are NOT to be compiled. # ======================================================================= # if does_the_program_have_to_be_compiled? array << 'CFLAGS in use:' array << dataset.query_for(array.last) end # ======================================================================= # # === Show if we try to use a static build # # This should come shortly before the display of the build-directory. # ======================================================================= # if dataset.build_static? array << 'Compile statically:' array << "#{vt(dataset.build_static?.to_s)}." end # ======================================================================= # # === Query whether we will use a build directory or whether we will not: # # We will also show the path to it IF it exists. If the path to the # build directory does NOT exist then we will not shown it, logically. # ======================================================================= # array << 'Use a build directory:' _ = dataset.query_for(array.last) if _ _ = "#{verbose_truth(_.to_s)}, at #{build_directory?}" elsif _.is_a? FalseClass _ = verbose_truth(_.to_s)+'.' end array << _ # ======================================================================= # # === Display preinstallation steps, but only if this entry exists # ======================================================================= # preinstall = preinstall? if preinstall and preinstall.is_a?(Array) and !preinstall.empty? array << 'Preinstallation action:' _ = preinstall.join(', ').strip _.chop! if _.end_with? ',' array << _ end # ======================================================================= # # === Display postinstallation steps, but only if this entry exists # # This entry point will query whether postinstallation steps are # used by the program at hand. If so then it will be displayed; # otherwise we will not display it. (Most programs do not have a # post-installation step, so nothing will be shown normally in # these cases.) # ======================================================================= # postinstall = postinstall? if postinstall and postinstall.is_a?(Array) and !postinstall.empty? array << 'Postinstallation action:' _ = postinstall.join(', ').strip _.chop! if _.end_with? ',' array << _ end # ======================================================================= # # === Host architecture in use: # # Display the x86 or x64 type of the computer at hand. # # This is put right before the required dependencies and autogen. # ======================================================================= # array << 'Host architecture in use' array << host_architecture? # ======================================================================= # # === Show whether we will use autogen, but only if we really do # # This should come after the required-dependencies and the host # architecture in user, but before the build system in use. # ======================================================================= # use_autogen = use_autogen? if use_autogen array << 'Use autogen:' array << "#{verbose_truth(use_autogen)}." end # ======================================================================= # # === Build system to be used: # # We need to do an additional check here, since there are situations # where the .yml file at hand may have a "run_configure: no" entry, # so it makes no sense to insinuate that the build system type is # based on configure. # ======================================================================= # array << 'Build system to be used:' use_this_build_system = use_which_build_system? if (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, as that option was specifically disabled, # e. g. through the corresponding .yml file. # ===================================================================== # use_this_build_system = '(unknown / unspecified)' end array << use_this_build_system # ======================================================================= # # === Parameters for make # # These come right before "Compiler to be used". # ======================================================================= # parameters_to_make = parameters_to_make? if parameters_to_make.respond_to? :reject 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? ',' array << 'Parameters for make:' array << parameters_to_make # :seagreen end end # ======================================================================= # # === Compiler to be used: # # This will show the compiler that is to be used in the current run. # It only makes sense to display these if the program at hand has to # be compiled, though; so we will first check for that via the # following code. # ======================================================================= # if does_the_program_have_to_be_compiled? array << 'Compiler to be used:' array << compiler_to_use? end array << 'Type in use:' array << type_in_use? # ======================================================================= # # Show the remote URLs but only if this functionality has been enabled. # ======================================================================= # if @show_remote_urls # ===================================================================== # # === URL to the source archive: # # This entry point is also called "url1". # ===================================================================== # url1 = url1? if (url1.size+1) > right_padding_size? add_n = ( url1.size - right_padding_size? )+1 if (add_n + right_padding?) > MAX_VALUE_FOR_PADDING add_n = (MAX_VALUE_FOR_PADDING - right_padding?) - 1 end add_this_to_the_right_padding( add_n ) end array << 'URL to the source archive:' array << url1 # ===================================================================== # # === Then finally add the homepage: # # If the homepage entry does not exist we will show this as well. # ===================================================================== # value_for_the_homepage_entry = dataset.query_for('Homepage:') if value_for_the_homepage_entry and !value_for_the_homepage_entry.empty? array << 'Homepage:' homepage = value_for_the_homepage_entry if homepage.nil? or homepage.empty? homepage = '[No homepage entry has been registered for this program.]' end array << homepage end end # ======================================================================= # # === Handle the required dependencies next # # This entry-point should come right after the host architecture, and # is optional. Since as of November 2020 the entry is now shown # after the homepage is displayed. # # The instance variable @show_required_dependencies determines # whether we will show the required dependencies. # ======================================================================= # if @show_required_dependencies _ = 'Required dependencies on:' deps = dataset.query_for(_) if deps and !deps.empty? array << _ if deps.respond_to? :join array << deps.join(', ').strip.to_s end end end fill_with_this_array(array) # This array was built up within this method. use_default_colour_for_the_border colourize_right_side_with_these_colours :default sanitize_right_side end
#¶ ↑
extract_to?¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 1311 def extract_to? @compile_dataset.query_for(__method__) end
#¶ ↑
extracting_compiling_or_installing
?¶ ↑
This method will return one of three possible, different strings.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 654 def extracting_compiling_or_installing? @do_this_action end
#¶ ↑
fill_the_table
(fill tag)¶ ↑
The input to this method should be an Array.
This is the main “fill” method for passing data into the flexbox-table.
The input can be a String as well, in which case this method may process the input String and turn it into an Array.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 1510 def fill_the_table(i) clear_hash # We will always reset the main hash when invoking this method. # ======================================================================= # # === Transform Strings given next # ======================================================================= # if i.is_a?(String) and (i.count("\n") > 1) and # Has at the least two newlines. i.include?(VERTICAL_ASCII_BAR) # And has at the least one '|' token. i = i.split(VERTICAL_ASCII_BAR).map {|entry| entry.strip } end even = i.select.with_index { |_, entry| entry.even? } odd = i.select.with_index { |_, entry| entry.odd? } # ======================================================================= # # Push it into the main-hash next: # ======================================================================= # @hash[:left_side] << even @hash[:right_side] << odd flatten_the_main_hash autoexpand if @shall_we_autoexpand end
#¶ ↑
location_to_the_build_directory?¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 833 def location_to_the_build_directory? @compile_dataset.send(__method__) end
#¶ ↑
prepare_the_compile_dataset
¶ ↑
This very important method will initialize the @compile_dataset object. This dataset is the one that will be displayed by class Flexbox
ultimately.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 1540 def prepare_the_compile_dataset( i = @compile_this_program ) # ======================================================================= # # First check if the input is a RBT::Compile class. # ======================================================================= # if i.is_a?(RBT::Compile) @compile_dataset = i.dup enable_rbt_specific_behaviour elsif i.is_a?(String) and RBT.is_this_program_included?(i) @compile_dataset = RBT::Compile.new(i) { :do_not_run_yet } elsif i.is_a?(String) # Bit pointless checks but still. # ===================================================================== # # Turn strings into the corresponding dataset. # ===================================================================== # i = RBT::Cookbooks::SanitizeCookbook.new(i) else if i @compile_dataset = i else e 'Unhandled state: '+i.to_s end end end
#¶ ↑
prepare_the_flexbox_for_displaying_this_program
¶ ↑
This method can be used to prepare data fed into the Flexbox
from the RBT project, for display purposes on the commandline. This data may typically describe how a certain application is to be installed/compiled.
In fact - this was the primary use case for creating the Flexbox
class to begin with.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 1281 def prepare_the_flexbox_for_displaying_this_program(i) # ======================================================================= # # This entry point here is for displaying the dataset from the RBT # project. # ======================================================================= # require 'rbt/requires/require_the_cookbook_class.rb' require 'rbt/requires/require_the_compile_class.rb' set_compile_this_program(i) enable_rbt_specific_behaviour end
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
AsciiParadise::Base#reset
# File lib/ascii_paradise/flexbox/flexbox.rb, line 200 def reset super() # ======================================================================= # # === @namespace # ======================================================================= # @namespace = NAMESPACE # ======================================================================= # # === @compile_dataset # # This variable must be nil initially. # ======================================================================= # @compile_dataset = nil # ======================================================================= # # === @show_required_dependencies # # If the variable @show_required_dependencies is set to true then # dependencies will be shown, unless there are no dependencies # (aka when they are empty or nil). # # This value has been set to true since as of November 2019. # ======================================================================= # @show_required_dependencies = true # ======================================================================= # # === @use_unicode_or_ascii # # This can either just use "-" or the equivalent unicode symbol. # # The only two allowed ways are :unicode and :ascii. # ======================================================================= # if TRY_TO_USE_UNICODE_SYMBOLS_FOR_THE_COMMANDLINE_USER_INTERFACE @use_unicode_or_ascii = :unicode else @use_unicode_or_ascii = :ascii end # ======================================================================= # # === @n_left_pad # # This variable determines how much we will pad to the left-hand # side (the left column). # ======================================================================= # @n_left_pad = 15 # ======================================================================= # # === @n_right_pad # # This variable determines how much we will pad to the left-hand # side (the left column). # ======================================================================= # @n_right_pad = 25 # ======================================================================= # # === @vertical # ======================================================================= # @vertical = return_vertical_bar # ======================================================================= # # === @do_this_action # ======================================================================= # @do_this_action = 'Compiling' # ======================================================================= # # === @show_remote_urls # ======================================================================= # @show_remote_urls = SHOW_REMOTE_URLS_BY_DEFAULT # ======================================================================= # # === @use_colours # ======================================================================= # @use_colours = true # ======================================================================= # # === @shall_we_autoexpand # ======================================================================= # @shall_we_autoexpand = true # ======================================================================= # # === @array_colourize_right_side_with_these_colours # ======================================================================= # @array_colourize_right_side_with_these_colours = [] # ======================================================================= # # === @use_this_colour_for_the_border # ======================================================================= # @use_this_colour_for_the_border = nil # ======================================================================= # # === @use_this_title # # If this variable is set to a non-nil value then it will be used # to show a title for the flexbox. By default this is nil, thus we # will not use a title by default. # ======================================================================= # @use_this_title = nil # ======================================================================= # # === @hash # # This variable will keep the "left side" and the "right side" of the # flexbox-table. # ======================================================================= # @hash = {} @hash[:left_side] = [] @hash[:right_side] = [] end
#¶ ↑
return_configure_options_or_meson_options_or_no_options
¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 877 def return_configure_options_or_meson_options_or_no_options if @compile_dataset.use_configure_options? @compile_dataset.query_for_configure_options_or_meson_options('configure options:') else false end end
#¶ ↑
return_vertical_bar
¶ ↑
This will return a vertical bar, e. g. either '|', or the corresponding Unicode
representation - the latter of which is done through the Roebe namespace.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 406 def return_vertical_bar if really_use_unicode? Roebe.vertical_block else VERTICAL_ASCII_BAR end end
#¶ ↑
right_pad?¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 741 def right_pad? @n_right_pad end
#¶ ↑
sanitize_right_side
¶ ↑
This method is currently only used to replace true/false boolean values with verbose “Yes.” or “No.” strings.
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 593 def sanitize_right_side @hash[:right_side].map! {|entry| if entry.is_a? TrueClass entry = 'Yes.' elsif entry.is_a? FalseClass entry = 'No.' end entry } end
#¶ ↑
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/ascii_paradise/flexbox/flexbox.rb, line 1349 def set_compile_this_program(i = '') i = i.first if i.is_a? Array i = i.dup @compile_this_program = i end
#¶ ↑
set_do_this_action
¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 958 def set_do_this_action(i) @do_this_action = i end
#¶ ↑
top_ecliner
(top tag)¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 561 def top_ecliner result = cliner { :top } # ======================================================================= # # Next see whether we will use a title or not. # ======================================================================= # title = title? if title result[1, title.size+2] = " #{title} " end if colourize_border? if title # Colourize the title next. # =================================================================== # # In this case we will colourize this differently. # =================================================================== # splitted = result.split(' ') splitted[0] = Colours.send(@use_this_colour_for_the_border, splitted[0]) splitted[1] = Colours.send(COLOUR_FOR_THE_TITLE, splitted[1]) splitted[2] = Colours.send(@use_this_colour_for_the_border, splitted[2]) result = splitted.join(' ') else result = Colours.send(@use_this_colour_for_the_border, result) end end e " #{rev}#{result}" end
#¶ ↑
try_to_require_external_dependencies
¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 446 def try_to_require_external_dependencies begin require 'roebe/toplevel_methods/unicode/popular_unicode_symbols.rb' rescue LoadError; end begin require 'rbt/toplevel_methods/available_programs.rb' rescue LoadError; end end
#¶ ↑
use_unicode?¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 424 def use_unicode? @use_unicode_or_ascii == :unicode end
#¶ ↑
verbose_truth
¶ ↑
#¶ ↑
# File lib/ascii_paradise/flexbox/flexbox.rb, line 390 def verbose_truth(i) case i.to_s when 'true' 'Yes' when 'false' 'No' end end