Class: RBT::LeanPrototype
- Inherits:
-
Object
- Object
- RBT::LeanPrototype
- Defined in:
- lib/rbt/lean_prototype/lean_prototype.rb
Overview
RBT::LeanPrototype
Direct Known Subclasses
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- DAY_NAMES =
#
DAY_NAMES
The addition of this constant was necessary due to upstream MRI ruby removing the RFC2822_DAY_NAME constant from time.rb.
#
%w( Sun Mon Tue Wed Thu Fri Sat )
- ALL_COLOUR_METHODS =
#
ALL_COLOUR_METHODS
#
::Colours::HtmlColoursMethods
- SILENT_REDIRECTION =
#
SILENT_REDIRECTION
This can simply be appended.
#
' > /dev/null'
- ARRAY_KDE_KONSOLE_COLOURS_IN_USE =
#
ARRAY_KDE_KONSOLE_COLOURS_IN_USE
Next, we will define the KONSOLE Colours that can be used.
#
%w( aliceblue aquamarine blueviolet cadetblue cornflowerblue crimson cyan darkcyan darkgoldenrod darkgreen darkorchid darkseagreen darkslateblue darkturquoise deepskyblue dodgerblue firebrick forestgreen gold gray grey green hotpink khaki lightblue lightseagreen lightgoldenrodyellow lightgreen lightsalmon lightskyblue lightslategray lightsteelblue limegreen mediumaquamarine mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred navajowhite olive olivedrab orange orangebrown orangered orchid palevioletred paleturquoise peru plum powderblue royalblue salmon saddlebrown sandybrown seagreen silver skyblue slateblue slategray springgreen steelblue rosybrown teal tomato turquoise violet yellow yellowgreen )
Instance Method Summary collapse
-
#a_or_an?(i) ⇒ Boolean
# === a_or_an?.
-
#abbreviations? ⇒ Boolean
# === abbreviations?.
-
#absolute_path(i) ⇒ Object
# === absolute_path.
-
#action(action_that_is_desired = nil, optional_argument1 = nil, options_hash = {}, &block) ⇒ Object
(also: #actions)
# === action (action tag).
-
#add_to_the_commandline_arguments(i) ⇒ Object
(also: #append_to_the_commandline_arguments, #append_these_options_to_the_commandline, #append_to_the_commandline)
# === add_to_the_commandline_arguments.
-
#all_binaries? ⇒ Boolean
# === all_binaries? ========================================================================= #.
-
#all_files_from(this_directory) ⇒ Object
# === all_files_from ========================================================================= #.
-
#all_libraries? ⇒ Boolean
# === all_libraries? ========================================================================= #.
-
#allowed_cookbook_entries?(i = RBT.file_registered_cookbook_entries) ⇒ Boolean
# === allowed_cookbook_entries?.
-
#appdir_location_of?(i) ⇒ Boolean
# === appdir_location_of?.
-
#append_onto_the_internal_hash(i) ⇒ Object
(also: #append_onto_the_main_hash)
# === append_onto_the_internal_hash ========================================================================= #.
-
#append_what_into(what, into) ⇒ Object
# === append_what_into ========================================================================= #.
-
#archive_type_of?(i) ⇒ Boolean
(also: #return_archive_type, #archive_type_of, #archive_type?, #determine_archive_type)
# === archive_type_of?.
-
#available_programs? ⇒ Boolean
(also: #all_programs?, #all_programs, #all_available_programs?, #available_programs, #available_cookbooks?, #available_cookbooks, #return_available_programs, #get_cookbooks)
# === available_programs? ========================================================================= #.
-
#be_quiet? ⇒ Boolean
# === be_quiet? ========================================================================= #.
-
#be_verbose? ⇒ Boolean
# === be_verbose? ========================================================================= #.
-
#begins_with_a_comment?(i) ⇒ Boolean
# === begins_with_a_comment? ========================================================================= #.
-
#capitalize_first_alphabetical_character(i = '/programs') ⇒ Object
# === capitalize_first_alphabetical_character.
-
#cd_to_the_log_directory ⇒ Object
# === cd_to_the_log_directory ========================================================================= #.
-
#cd_to_the_temp_directory(be_verbose = :be_quiet) ⇒ Object
# === cd_to_the_temp_directory.
-
#change_directory(i, optional_arguments = nil) ⇒ Object
(also: #chdir, #change_dir, #cd)
# === change_directory (cd tag).
-
#change_permission(file = 'test', use_this_uid_number = '1000') ⇒ Object
(also: #chown)
# === change_permission (chown tag).
-
#cheering_person? ⇒ Boolean
(also: #return_cheering_person, #cheering_person, #cheerful_person, #cheering_ascii_person)
# === cheering_person?.
-
#chmod(i) ⇒ Object
# === chmod ========================================================================= #.
-
#chop_off_archive(i) ⇒ Object
# === chop_off_archive.
-
#clear_commandline_arguments ⇒ Object
(also: #clear_commandline_options)
# === clear_commandline_arguments ========================================================================= #.
-
#cliner(optional_arguments = nil, use_this_colour = nil) ⇒ Object
# === cliner ========================================================================= #.
-
#coloured_and_padded_e(i, use_colours = use_colours?, , optional_arguments = nil) ⇒ Object
# === coloured_and_padded_e ========================================================================= #.
-
#coloured_and_padded_esystem(i, use_colours = use_colours?, , optional_arguments = :inner_padding, use_this_primary_colour = :cornflowerblue, &block) ⇒ Object
(also: #colourize_this_important_system_command, #ecolourize_this_important_system_command, #colourized_esystem_with_padding, #colourized_and_padded_esystem)
# === coloured_and_padded_esystem.
-
#coloured_esystem(i) ⇒ Object
(also: #colourized_esystem)
# === coloured_esystem ========================================================================= #.
-
#colourize_directory_for_system_results(i) ⇒ Object
# === colourize_directory_for_system_results.
-
#colourize_this_error(i) ⇒ Object
# === colourize_this_error.
-
#colourize_this_file_path(i, colour1 = :slateblue, colour2 = :royalblue) ⇒ Object
# === colourize_this_file_path.
-
#colourize_this_warning(i) ⇒ Object
(also: #colourize_for_warnings)
# === colourize_this_warning ========================================================================= #.
-
#commandline_arguments? ⇒ Boolean
(also: #input?, #arguments?, #all_arguments?, #commandline?, #commandline_options?, #commandline, #commandline_args?)
# === commandline_arguments? ========================================================================= #.
-
#commandline_arguments_without_hyphens?(i = commandline_arguments? ) ⇒ Boolean
(also: #reject_entries_starting_with_hyphens, #non_hyphen_arguments, #non_hyphened_arguments, #non_hyphened_arguments?)
# === commandline_arguments_without_hyphens?.
-
#comment(i) ⇒ Object
# === comment ========================================================================= #.
-
#convert_dd_mm_yyyy_to_its_long_variant(i = dd_mm_yyyy.to_s) ⇒ Object
# === convert_dd_mm_yyyy_to_its_long_variant ========================================================================= #.
-
#convert_env_variable(i) ⇒ Object
(also: #convert_global_env, #sanitize_for_environment_variable)
# === convert_env_variable.
-
#copy_directory(from, to = return_pwd, be_verbose = false) ⇒ Object
# === copy_directory.
-
#copy_files(from, to = return_pwd, be_verbose = false, use_namespace = true, &block) ⇒ Object
(also: #copy_file, #copy, #cp)
# === copy_files (copy tag, cp tag, copy file tag).
-
#cpr(from, to = return_pwd) ⇒ Object
# === cpr.
-
#create_directory(i = '/Users/Packages/', be_verbose = :be_quiet, permissions = :default, &block) ⇒ Object
(also: #mkdir, #mkdir_p, #ensure_that_this_directory_exists, #create_directory_if_it_does_not_yet_exist)
# === create_directory (mkdir tag).
-
#current_hour? ⇒ Boolean
(also: #return_time)
# === current_hour?.
-
#dd_mmm_yyy ⇒ Object
# === dd_mmm_yyy.
-
#debug(i) ⇒ Object
# === debug.
-
#debug? ⇒ Boolean
# === debug? ========================================================================= #.
-
#directory_expanded_cookbooks? ⇒ Boolean
(also: #directory_expanded_cookbooks, #base_dir_to_store_expanded_cookbooks?, #expanded_cookbooks?, #expanded_cookbook_directory?)
# === directory_expanded_cookbooks? ========================================================================= #.
-
#disable_colours ⇒ Object
(also: #do_not_use_colours, #disable_colors)
# === disable_colours.
-
#display_md5sum? ⇒ Boolean
(also: #show_md5sum?)
# === display_md5sum? ========================================================================= #.
-
#do_not_debug ⇒ Object
# === do_not_debug ========================================================================= #.
-
#does_the_cookbook_include_this_program?(i) ⇒ Boolean
# === does_the_cookbook_include_this_program? ========================================================================= #.
-
#does_this_expanded_cookbook_file_exist_for_this_program?(i) ⇒ Boolean
(also: #does_the_expanded_cookbook_file_exist_for_this_program?, #expanded_cookbook_file_exists_for?)
# === does_this_expanded_cookbook_file_exist_for_this_program?.
-
#does_this_file_exist?(i, prepend_this = nil) ⇒ Boolean
# === does_this_file_exist? ========================================================================= #.
-
#does_this_file_exist_and_is_it_a_file?(i) ⇒ Boolean
# === does_this_file_exist_and_is_it_a_file? ========================================================================= #.
-
#e(i = '', optional_colours = nil, use_colours = use_colours? ) ⇒ Object
# === e (e tag).
-
#eblue(i = '') ⇒ Object
# === eblue ========================================================================= #.
-
#ecomment(i = '', use_colours = use_colours? ) ⇒ Object
# === ecomment ========================================================================= #.
-
#ecrimson(i = '') ⇒ Object
# === ecrimson.
-
#edir(i = return_pwd) ⇒ Object
# === edir ========================================================================= #.
-
#editor? ⇒ Boolean
# === editor? ========================================================================= #.
-
#efancy(i = '') ⇒ Object
# === efancy ========================================================================= #.
-
#eimp(i) ⇒ Object
# === simp ========================================================================= #.
-
#enable_colours ⇒ Object
(also: #set_use_colours, #do_use_colours)
# === enable_colours ========================================================================= #.
-
#enable_debug ⇒ Object
# === enable_debug ========================================================================= #.
-
#ensure_main_encoding_for(i, use_this_encoding = USE_MAIN_ENCODING) ⇒ Object
# === ensure_main_encoding_for.
-
#eparse(i) ⇒ Object
# === eparse ========================================================================= #.
-
#esystem(i, use_this_colour = nil) ⇒ Object
# === esystem.
-
#esystem_gold(i) ⇒ Object
# === esystem_gold.
-
#etomato(i) ⇒ Object
# === etomato ========================================================================= #.
-
#ewarn(i = '') ⇒ Object
# === ewarn ========================================================================= #.
-
#exit_program(symbol_exit = :standalone, optional_message = nil, use_this_as_exit_value = 0, &block) ⇒ Object
# === exit_program (exit tag).
-
#expanded_cookbooks_directory_exists?(target = directory_expanded_cookbooks? ) ⇒ Boolean
(also: #expanded_directory_exists?, #directory_expanded_cookbooks_exists?)
# === expanded_cookbooks_directory_exists?.
-
#extract_this_archive(i, extract_to = return_pwd) ⇒ Object
# === extract_this_archive ========================================================================= #.
-
#extract_to?(optional_argument = nil) ⇒ Boolean
# === extract_to? ========================================================================= #.
-
#file_compiled_programs? ⇒ Boolean
# === file_compiled_programs? ========================================================================= #.
-
#file_dirname_retaining_trailing_slash(i) ⇒ Object
# === file_dirname_retaining_trailing_slash.
-
#file_predefined_installation_instructions? ⇒ Boolean
(also: #file_predefined_installation_instructions)
# === file_predefined_installation_instructions? ========================================================================= #.
-
#file_specification_of_registered_cookbook_entries ⇒ Object
# === file_specification_of_registered_cookbook_entries ========================================================================= #.
-
#find_cookbook_alias_for(i) ⇒ Object
# === find_cookbook_alias_for.
-
#find_this_yaml_file(i = :poppler) ⇒ Object
(also: #return_yaml_file_for)
# === find_this_yaml_file.
-
#first_argument? ⇒ Boolean
(also: #first?, #first_commandline_argument?)
# === first_argument? ========================================================================= #.
-
#first_non_hyphen_argument?(i = commandline_arguments_without_hyphens? ) ⇒ Boolean
(also: #return_first_non_hyphen_argument, #first_non_hyphened_argument_from_the_commandline_arguments, #first_non_hyphened_argument?)
# === first_non_hyphen_argument? ========================================================================= #.
-
#get_all_directories_from(here = return_pwd, return_full_path = false) ⇒ Object
(also: #get_dir_listing, #get_directory_listing, #get_directories_from)
# === get_all_directories_from.
-
#get_all_files_from(i) ⇒ Object
(also: #get_files_from)
# === get_all_files_from ========================================================================= #.
-
#get_all_programs(from = "#{RBT.programs_directory?}*") ⇒ Object
# === get_all_programs (all programs tag).
-
#get_date ⇒ Object
# === get_date.
-
#get_extended_date ⇒ Object
# === get_extended_date.
-
#get_files_and_directories_from(i = return_pwd) ⇒ Object
# === get_files_and_directories_from ========================================================================= #.
-
#go_to_base_dir(be_verbose = true) ⇒ Object
(also: #go_to_the_base_directory)
# === go_to_base_dir.
-
#home_dir? ⇒ Boolean
# === home_dir? ========================================================================= #.
-
#host_system? ⇒ Boolean
(also: #host_architecture?, #host_achiteture_in_use?)
# === host_system? ========================================================================= #.
-
#infer_the_namespace ⇒ Object
# === infer_the_namespace.
-
#initialize(i = ARGV, run_already = true, &block) ⇒ LeanPrototype
constructor
# === initialize ========================================================================= #.
-
#internal_hash? ⇒ Boolean
(also: #ihash, #ihash?, #internal_hash, #return_default_internal_hash)
# === internal_hash? ========================================================================= #.
-
#internal_hash_set_commandline_arguments(i = ARGV) ⇒ Object
(also: #set_commandline_arguments, #set_input, #set_commandline)
# === internal_hash_set_commandline_arguments.
-
#is_an_archive?(i) ⇒ Boolean
(also: #is_archive?, #is_this_an_archive?)
# === is_an_archive?.
-
#is_directory?(i) ⇒ Boolean
# === is_directory? ========================================================================= #.
-
#is_file?(i) ⇒ Boolean
# === is_file? ========================================================================= #.
-
#is_github_url?(i = url1? ) ⇒ Boolean
(also: #is_a_github_url?)
# === is_github_url?.
-
#is_make_available?(path = query_path? ) ⇒ Boolean
# === is_make_available?.
-
#is_meson_installed? ⇒ Boolean
# === is_meson_installed? ========================================================================= #.
-
#is_on_gobolinux? ⇒ Boolean
(also: #are_we_on_gobolinux?)
# === is_on_gobolinux?.
-
#is_on_windows? ⇒ Boolean
(also: #are_we_on_windows?)
# === is_on_windows? ========================================================================= #.
-
#is_roebe? ⇒ Boolean
(also: #is_on_roebe?, #on_roebe?)
# === is_roebe?.
-
#is_superuser? ⇒ Boolean
# === is_superuser? ========================================================================= #.
-
#is_symlink?(i) ⇒ Boolean
# === is_symlink? ========================================================================= #.
-
#is_this_a_header?(i) ⇒ Boolean
# === is_this_a_header?.
-
#is_this_a_library?(i) ⇒ Boolean
# === is_this_a_library?.
-
#is_this_program_included?(i) ⇒ Boolean
(also: #included?, #includes?, #program_was_found?, #include?, #is_included?, #includes_this_program?, #is_this_program_registered?, #is_the_program_included?, #does_include?, #is_this_program_part_of_the_RBT_project?)
# === is_this_program_included?.
-
#iso_encoding? ⇒ Boolean
# === iso_encoding? ========================================================================= #.
-
#load_dataset_from_this_expanded_cookbook(i, &block) ⇒ Object
(also: #return_dataset_from_expanded_cookbook, #return_dataset_from_this_expanded_cookbook, #quickly_obtain_expanded_cookbook_dataset_from)
# === load_dataset_from_this_expanded_cookbook.
-
#load_yaml(i) ⇒ Object
# === load_yaml.
-
#load_yaml_file_from_the_cookbook_directory_for_this_program(i) ⇒ Object
# === load_yaml_file_from_the_cookbook_directory_for_this_program.
-
#log_directory? ⇒ Boolean
(also: #rbt_temp_directory?, #log_dir?, #rbt_log_dir, #rbt_log_dir?, #rbt_log_directory?, #rbt_temp_dir?, #rbt_logs?)
# === log_directory?.
-
#main_encoding? ⇒ Boolean
# === main_encoding? ========================================================================= #.
-
#meson_build_file_exists?(at_this_location = return_pwd, use_build_directory = false) ⇒ Boolean
(also: #meson_file_exists?)
# === meson_build_file_exists?.
-
#months? ⇒ Boolean
# === months?.
-
#move_file(this_file, where_to, be_verbose = true) ⇒ Object
(also: #mv, #rename_file, #rename_directory)
# === move_file (move tag, mv tag).
-
#n_programs_are_available? ⇒ Boolean
# === n_programs_are_available? ========================================================================= #.
-
#n_programs_available? ⇒ Boolean
(also: #n_programs_available)
# === n_programs_available? ========================================================================= #.
-
#namespace? ⇒ Boolean
# === namespace? ========================================================================= #.
-
#no_directory_exists_at(i) ⇒ Object
# === no_directory_exists_at ========================================================================= #.
-
#no_directory_was_found_at(to) ⇒ Object
# === no_directory_was_found_at ========================================================================= #.
-
#no_opn ⇒ Object
(also: #disable_opn)
# === no_opn ========================================================================= #.
-
#no_such_file_exists(i, be_verbose = true, &block) ⇒ Object
(also: #no_file_exists_at)
# === no_such_file_exists ========================================================================= #.
-
#open_in_browser(i = nil) ⇒ Object
# === open_in_browser ========================================================================= #.
-
#open_in_editor(i) ⇒ Object
(also: #open_this_file)
# === open_in_editor.
-
#opncomment(i = '') ⇒ Object
# === opncomment ========================================================================= #.
-
#opne(i = nil, use_opn = use_opn? ) ⇒ Object
# === opne (opne tag) ========================================================================= #.
-
#opnef(i) ⇒ Object
# === opnef (opnef tag) ========================================================================= #.
-
#opnerev(i = nil, use_opn = use_opn? ) ⇒ Object
(also: #orev)
# === opnerev ========================================================================= #.
-
#opnerror(i, use_this_as_namespace = namespace? ) ⇒ Object
# === opnerror (opnerror tag).
-
#opnesystem(i) ⇒ Object
# === opnesystem ========================================================================= #.
-
#opnewarn(i) ⇒ Object
(also: #opnwarn, #owarn)
# === opnewarn ========================================================================= #.
-
#opnfancy(i = '') ⇒ Object
# === opnfancy ========================================================================= #.
-
#opnn(i = namespace?, , use_opn = use_opn?, , &block) ⇒ Object
(also: #output_namespace?)
# === opnn (opnn tag).
-
#packages_directory? ⇒ Boolean
# === packages_directory? ========================================================================= #.
-
#path_to_this_expanded_cookbooks_dataset(i) ⇒ Object
(also: #return_file_to_the_expanded_cookbooks_dataset)
# === path_to_this_expanded_cookbooks_dataset.
-
#pkgconfig_directory? ⇒ Boolean
# === pkgconfig_directory? ========================================================================= #.
-
#populate_the_internal_hash_with_default_values ⇒ Object
# === populate_the_internal_hash_with_default_values ========================================================================= #.
-
#predefined_installation_instructions? ⇒ Boolean
# === predefined_installation_instructions? ========================================================================= #.
-
#prepend_this_commandline_argument(i) ⇒ Object
# === prepend_this_commandline_argument ========================================================================= #.
-
#program_version_of?(i) ⇒ Boolean
# === program_version_of? ========================================================================= #.
-
#project_base_directory? ⇒ Boolean
(also: #project_base_dir?)
# === project_base_directory? ========================================================================= #.
-
#project_yaml_directory? ⇒ Boolean
(also: #rbt_path?, #project_yaml_dir?, #yaml_dir?, #yaml_directory?)
# === project_yaml_directory?.
-
#query_path? ⇒ Boolean
# === query_path?.
-
#rarrow? ⇒ Boolean
(also: #rarrow)
# === rarrow? ========================================================================= #.
-
#read_file(i) ⇒ Object
(also: #read_this_file)
# === read_file (read tag).
-
#read_file_in_default_encoding(i, use_this_encoding = ::RBT.encoding?) ⇒ Object
(also: #default_read, #file_read, #read_read)
# === read_file_in_default_encoding ========================================================================= #.
-
#read_file_with_default_encoding(i) ⇒ Object
# === read_file_with_default_encoding ========================================================================= #.
-
#readlines(i) ⇒ Object
# === readlines.
-
#readlines_with_proper_encoding(i, use_this_encoding = main_encoding? ) ⇒ Object
(also: #default_readlines, #proper_readlines)
# === readlines_with_proper_encoding.
-
#register_sigint(optional_message = nil, use_this_as_exit_code = 0) ⇒ Object
# === register_sigint ========================================================================= #.
-
#registered_cookbook_entries? ⇒ Boolean
# === registered_cookbook_entries? ========================================================================= #.
-
#remove(this_target, be_verbose = false) ⇒ Object
# === remove (remove tag).
-
#remove_archive_from_the_end(i) ⇒ Object
(also: #remove_archive_at_the_end, #remove_file_archive_at_the_end, #remove_archive_stuff_from_the_end, #remove_file_extension_from)
# === remove_archive_from_the_end This method will remove the “archive part” of the given input, such as by removing “.tar.xz” from the given input argument (which ought to be a String).
-
#remove_comments_from_each_line(i) ⇒ Object
# === remove_comments_from_each_line.
-
#remove_directory(this_directory, be_verbose = false, &block) ⇒ Object
(also: #remove_dir, #remove_these_directories, #remove_directories, #remove_this_directory)
# === remove_directory.
-
#remove_double_slashes(i) ⇒ Object
(also: #rds)
# === remove_double_slashes (rds tag).
-
#remove_file(i, report_the_action = false) ⇒ Object
(also: #delete, #delete_file, #remove_files, #remove_these_files)
# === remove_file (remove tag).
-
#remove_newlines(i) ⇒ Object
# === remove_newlines.
-
#remove_parens(i) ⇒ Object
# === remove_parens.
-
#remove_symlink(i) ⇒ Object
(also: #remove_this_symlink)
# === remove_symlink.
-
#remove_the_first_commandline_argument ⇒ Object
# === remove_the_first_commandline_argument ========================================================================= #.
-
#remove_this_commandline_argument(i, from = commandline_arguments? ) ⇒ Object
# === remove_this_commandline_argument.
-
#remove_this_entry_from_the_commandline_arguments(i) ⇒ Object
# === remove_this_entry_from_the_commandline_arguments ========================================================================= #.
-
#remove_trailing_ANSII_escape_code(i) ⇒ Object
# === remove_trailing_ANSII_escape_code.
-
#remove_unnecessary_data_from_url(i) ⇒ Object
(also: #return_program_full_name_from_url)
# === remove_unnecessary_data_from_url.
-
#rename(old_name, new_name) ⇒ Object
# === rename ========================================================================= #.
-
#report_pwd ⇒ Object
(also: #verbose_report_pwd)
# === report_pwd ========================================================================= #.
-
#require_the_rbt_aliases ⇒ Object
# === require_the_rbt_aliases ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#reset_the_internal_hash ⇒ Object
# === reset_the_internal_hash ========================================================================= #.
-
#return_all_archives_from_this_directory(i) ⇒ Object
# === return_all_archives_from_this_directory ========================================================================= #.
-
#return_appdir_prefix(i) ⇒ Object
(also: #return_appdir_prefix_for)
# === return_appdir_prefix ========================================================================= #.
-
#return_commandline_arguments_with_leading_hyphens(i = commandline_arguments? ) ⇒ Object
(also: #commandline_arguments_containing_leading_hyphens?, #commandline_arguments_with_leading_hyphens?, #commandline_arguments_with_hyphens?, #return_arguments_with_leading_hyphens, #return_commandline_arguments_with_hyphens, #return_entries_with_leading_hyphens, #hyphen_commandline_arguments?, #return_hyphened_commandline_arguments, #hyphen_arguments, #hyphened_arguments?)
# === return_commandline_arguments_with_leading_hyphens.
-
#return_current_hour_minutes_second ⇒ Object
(also: #ss_mm_hh, #hh_mm_ss)
# === return_current_hour_minutes_second.
-
#return_date ⇒ Object
(also: #return_current_date, #return_current_time, #dd_mm_yyyy)
# === return_date.
-
#return_day_of_the_month_based_on_utc ⇒ Object
# === return_day_of_the_month_based_on_utc ========================================================================= #.
-
#return_full_time ⇒ Object
# === return_full_time.
-
#return_hours_minutes_seconds_based_on_utc ⇒ Object
# === return_hours_minutes_seconds_based_on_utc ========================================================================= #.
-
#return_location_to_this_programs_yaml_file(i) ⇒ Object
# === return_location_to_this_programs_yaml_file.
-
#return_month_based_on_this_number(i) ⇒ Object
# === return_month_based_on_this_number.
-
#return_month_based_on_utc ⇒ Object
# === return_month_based_on_utc ========================================================================= #.
-
#return_opnn(i = nil) ⇒ Object
# === return_opnn ========================================================================= #.
-
#return_program_information(i) ⇒ Object
(also: #return_program_name)
# === return_program_information ========================================================================= #.
-
#return_program_name_for_gobolinux_systems(i) ⇒ Object
# === return_program_name_for_gobolinux_systems.
-
#return_pwd ⇒ Object
(also: #return_current_pwd, #pwd?, #get_pwd)
# === return_pwd ========================================================================= #.
-
#return_unicode_warning_symbol_or_empty_string ⇒ Object
# === return_unicode_warning_symbol_or_empty_string ========================================================================= #.
-
#return_utc ⇒ Object
# === return_utc.
-
#return_utc_time_in_a_format_similar_to_slackware ⇒ Object
# === return_utc_time_in_a_format_similar_to_slackware.
-
#return_weekday_based_on_utc ⇒ Object
# === return_weekday_based_on_utc.
-
#return_year_based_on_utc ⇒ Object
# === return_year_based_on_utc ========================================================================= #.
-
#rev ⇒ Object
# === rev (rev tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#run_simulation=(i = false) ⇒ Object
# === run_simulation.
-
#run_simulation? ⇒ Boolean
(also: #run_simulation, #in_simulation?)
# === run_simulation?.
-
#sdir(i = '') ⇒ Object
# === sdir ========================================================================= #.
-
#sdir_return_pwd ⇒ Object
# === sdir_return_pwd.
-
#set_be_silent(i = false) ⇒ Object
(also: #be_silent, #be_quiet, #set_be_quiet, #do_not_be_verbose, #set_do_not_be_verbose)
# === set_be_silent.
-
#set_be_verbose(i = true) ⇒ Object
(also: #be_verbose, #be_verbose=)
# === set_be_verbose.
-
#set_first_commandline_argument(i) ⇒ Object
# === set_first_commandline_argument ========================================================================= #.
-
#set_namespace(i) ⇒ Object
(also: #set_the_namespace)
# === set_namespace ========================================================================= #.
-
#set_use_opn(i = true) ⇒ Object
(also: #do_use_opn)
# === set_use_opn ========================================================================= #.
-
#set_xorg_buffer(i) ⇒ Object
# === set_xorg_buffer ========================================================================= #.
-
#sfancy(i = '') ⇒ Object
# === sfancy ========================================================================= #.
-
#sfile(i = '') ⇒ Object
# === sfile ========================================================================= #.
-
#silent_redirection? ⇒ Boolean
(also: #original_stdout, #original_stdout?)
# === silent_redirection? ========================================================================= #.
-
#silently_create_this_directory_if_it_does_not_yet_exist(i) ⇒ Object
# === silently_create_this_directory_if_it_does_not_yet_exist ========================================================================= #.
-
#simp(i = '', use_colours = use_colours?) ) ⇒ Object
(also: #simportant)
# === simp ========================================================================= #.
-
#source_base_directory? ⇒ Boolean
(also: #archive_dir?, #source_directory?, #source_directory, #source_dir?, #src_dir?)
# === source_base_directory? ========================================================================= #.
-
#ssym(i) ⇒ Object
# === ssym ========================================================================= #.
-
#stderr(i = '', use_puts_or_print = :puts) ⇒ Object
# === stderr.
-
#store_into_this_directory? ⇒ Boolean
(also: #store_where?)
# === store_into_this_directory? ========================================================================= #.
-
#string_right_arrow? ⇒ Boolean
(also: #right_arrow?)
# === string_right_arrow? ========================================================================= #.
-
#swarn(i = '', use_colours = use_colours? ) ⇒ Object
# === swarn ========================================================================= #.
-
#symlink(existing, new_location = nil, be_verbose = true, use_colours = RBT.use_colours?) ⇒ Object
(also: #do_symlink, #symlink_file, #symlink_this_file, #create_symlink)
# === symlink (symlink tag).
-
#sysbin_directory? ⇒ Boolean
(also: #usr_bin?)
# === sysbin_directory? ========================================================================= #.
-
#sysetc_directory? ⇒ Boolean
(also: #etc_dir?)
# === sysetc_directory? ========================================================================= #.
-
#sysinclude_directory? ⇒ Boolean
(also: #include_dir?)
# === sysinclude_directory? ========================================================================= #.
-
#syslib_directory? ⇒ Boolean
(also: #lib_dir?)
# === syslib_directory? ========================================================================= #.
-
#sysshare_directory? ⇒ Boolean
(also: #share_dir?)
# === sysshare_directory? ========================================================================= #.
-
#system_directory? ⇒ Boolean
# === system_directory? ========================================================================= #.
-
#temp_directory? ⇒ Boolean
(also: #temp_dir?, #temp?)
# === temp_directory? ========================================================================= #.
-
#to_bool(i) ⇒ Object
(also: #to_boolean)
# === to_bool ========================================================================= #.
-
#to_camelcase(i) ⇒ Object
# === to_camelcase ========================================================================= #.
-
#to_iso_encoding(i) ⇒ Object
# === to_iso_encoding ========================================================================= #.
-
#to_unicode(i) ⇒ Object
# === to_unicode.
-
#today?(display_in_long_format = true) ⇒ Boolean
# === today?.
-
#touch(i, be_verbose = false) ⇒ Object
(also: #create_file, #touch_file)
# === touch (touch tag).
-
#try_to_require_beautiful_url ⇒ Object
# === try_to_require_beautiful_url ========================================================================= #.
-
#try_to_require_the_environment_information_gem ⇒ Object
# === try_to_require_the_environment_information_gem ========================================================================= #.
-
#try_to_require_the_extracter_gem ⇒ Object
# === try_to_require_the_extracter_gem ========================================================================= #.
-
#try_to_require_the_open_gem ⇒ Object
# === try_to_require_the_open_gem ========================================================================= #.
-
#try_to_require_the_xorg_buffer ⇒ Object
# === try_to_require_the_xorg_buffer ========================================================================= #.
-
#try_to_require_wget ⇒ Object
# === try_to_require_wget ========================================================================= #.
-
#try_to_return_a_special_compile_component(i) ⇒ Object
# === try_to_return_a_special_compile_component ========================================================================= #.
-
#unicode_cliner(a = :default, b = :default, &block) ⇒ Object
# === unicode_cliner ========================================================================= #.
-
#unicode_middle_cliner(a = :default, b = :default) ⇒ Object
# === unicode_middle_cliner ========================================================================= #.
-
#use_colours=(i = true) ⇒ Object
# === use_colours= ========================================================================= #.
-
#use_colours? ⇒ Boolean
(also: #we_may_use_colours?)
# === use_colours?.
-
#use_opn=(i = true) ⇒ Object
# === use_opn= ========================================================================= #.
-
#use_opn? ⇒ Boolean
(also: #show_opnn?)
# === use_opn? ========================================================================= #.
-
#utf_encoding? ⇒ Boolean
# === utf_encoding? ========================================================================= #.
-
#verbose_truth(i, optional_arguments = nil) ⇒ Object
(also: #vt, #verbose_truth?)
# === verbose_truth.
-
#word_wrap(this_text, n_characters_limit = :default) ⇒ Object
(also: #wrap_at)
# === word_wrap.
-
#write_what_into(what, into, permissions_to_use = '755') ⇒ Object
(also: #save_file, #save_what_into, #store_what_into, #save_what_to)
# === write_what_into.
-
#write_what_into_via_unicode(what, into, permissions_to_use = '755') ⇒ Object
# === write_what_into_via_unicode.
-
#yes_or_no(i, optional_instructions = nil) ⇒ Object
# === yes_or_no.
Constructor Details
#initialize(i = ARGV, run_already = true, &block) ⇒ LeanPrototype
#
initialize
#
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 97 def initialize( i = ARGV, run_already = true, &block ) reset set_commandline_arguments(i) # ======================================================================= # # Next handle blocks given to the class. # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :no_colours # ===================================================================== # when :no_colours disable_colours else # =================================================================== # # === Handle Hash given in blockform # =================================================================== # if yielded.is_a? Hash # ================================================================= # # === :use_colours # ================================================================= # if yielded.has_key? :use_colours _ = yielded.delete :use_colours if _ == false disable_colours end end end end end run if run_already end |
Instance Method Details
#a_or_an?(i) ⇒ Boolean
#
a_or_an?
For proper english titles, we can use “a” or “an”.
#
1201 1202 1203 1204 1205 1206 1207 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1201 def a_or_an?(i) if i.start_with?('a','i','o','u') 'an' else 'a' end end |
#abbreviations? ⇒ Boolean
#
abbreviations?
Easier getter-method over the available abbreviations.
#
1336 1337 1338 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1336 def abbreviations? RBT.hash_aliases_to_the_available_programs? end |
#absolute_path(i) ⇒ Object
#
absolute_path
This method will ensure that there is a trailing ‘/’ on the returned result, if it is a directory.
#
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1346 def absolute_path(i) _ = File.absolute_path(i) # ======================================================================= # # Only append if it is a directory. # ======================================================================= # if File.directory?(_) and !_.end_with?('/') _ = _.dup if _.frozen? _ << '/' end return _ end |
#action(action_that_is_desired = nil, optional_argument1 = nil, options_hash = {}, &block) ⇒ Object Also known as: actions
#
action (action tag)
This method bundles together all “actionable components”. It thus ties options to the user in a convenient manner, without needing to remember the name of classes or where the code resides at. All the user has to know is the name of the action itself, and they are good to go.
This method is a simpler wrapper over the toplevel RBT.action() code.
#
3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3140 def action( action_that_is_desired = nil, optional_argument1 = nil, # This is typically the main input to this method. = {}, &block ) unless ::RBT.respond_to? :action require 'rbt/requires/require_actions.rb' end RBT.action( action_that_is_desired, optional_argument1, , &block ) end |
#add_to_the_commandline_arguments(i) ⇒ Object Also known as: append_to_the_commandline_arguments, append_these_options_to_the_commandline, append_to_the_commandline
#
add_to_the_commandline_arguments
Simply append to the commandline options through this method here.
#
901 902 903 904 905 906 907 908 909 910 911 912 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 901 def add_to_the_commandline_arguments(i) # ======================================================================= # # First check whether the input is a Hash: # ======================================================================= # if i.is_a? Hash if i.has_key? :commandline_arguments i = i.delete(:commandline_arguments) end end @internal_hash[:commandline_arguments] << i @internal_hash[:commandline_arguments].flatten! end |
#all_binaries? ⇒ Boolean
#
all_binaries?
#
445 446 447 448 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 445 def all_binaries? require 'rbt/toplevel_methods/all_binaries.rb' RBT.all_binaries? end |
#all_files_from(this_directory) ⇒ Object
#
all_files_from
#
1400 1401 1402 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1400 def all_files_from(this_directory) Dir[rds(this_directory+'/*')].select {|entry| File.file?(entry) } end |
#all_libraries? ⇒ Boolean
#
all_libraries?
#
323 324 325 326 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 323 def all_libraries? require 'rbt/toplevel_methods/all_libraries.rb' RBT.all_libraries? end |
#allowed_cookbook_entries?(i = RBT.file_registered_cookbook_entries) ⇒ Boolean
#
allowed_cookbook_entries?
This method will load the .yml file containing all registered cookbook entries.
#
697 698 699 700 701 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 697 def allowed_cookbook_entries?( i = RBT.file_registered_cookbook_entries ) YAML.load_file(i) if File.exist? i end |
#appdir_location_of?(i) ⇒ Boolean
#
appdir_location_of?
Give an input of something like ‘foo’, this method will return a path such as ‘/Programs/Foo/Current’.
#
213 214 215 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 213 def appdir_location_of?(i) "#{programs_dir?}#{i.capitalize}/Current" end |
#append_onto_the_internal_hash(i) ⇒ Object Also known as: append_onto_the_main_hash
#
append_onto_the_internal_hash
#
1228 1229 1230 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1228 def append_onto_the_internal_hash(i) @internal_hash.update(i) end |
#append_what_into(what, into) ⇒ Object
#
append_what_into
#
1760 1761 1762 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1760 def append_what_into(what, into) RBT.append_what_into(what, into) end |
#archive_type_of?(i) ⇒ Boolean Also known as: return_archive_type, archive_type_of, archive_type?, determine_archive_type
#
archive_type_of?
Determine the archive type of the given input, such as ‘.tar.xz’ and so forth.
#
1432 1433 1434 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1432 def archive_type_of?(i) RBT.return_archive_type(i) end |
#available_programs? ⇒ Boolean Also known as: all_programs?, all_programs, all_available_programs?, available_programs, available_cookbooks?, available_cookbooks, return_available_programs, get_cookbooks
#
available_programs?
#
2404 2405 2406 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2404 def available_programs? RBT.available_programs? end |
#be_quiet? ⇒ Boolean
#
be_quiet?
#
1957 1958 1959 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1957 def be_quiet? !@internal_hash[:be_verbose] end |
#be_verbose? ⇒ Boolean
#
be_verbose?
#
1950 1951 1952 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1950 def be_verbose? @internal_hash[:be_verbose] end |
#begins_with_a_comment?(i) ⇒ Boolean
#
begins_with_a_comment?
#
3230 3231 3232 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3230 def begins_with_a_comment?(i) i.start_with? '#' end |
#capitalize_first_alphabetical_character(i = '/programs') ⇒ Object
#
capitalize_first_alphabetical_character
This method will capitalize on the given input, but it will act on the first alphabetical character. So for example, if we input a string such as “/programs” then this method will return “/Programs”.
#
2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2601 def capitalize_first_alphabetical_character( i = '/programs' ) new_string = ''.dup capitalized_already = false i.chars.each {|char| if capitalized_already else if char =~ /[a-zA-Z]/ char.upcase! capitalized_already = true end end new_string << char } new_string end |
#cd_to_the_log_directory ⇒ Object
#
cd_to_the_log_directory
#
1449 1450 1451 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1449 def cd_to_the_log_directory cd log_directory? end |
#cd_to_the_temp_directory(be_verbose = :be_quiet) ⇒ Object
#
cd_to_the_temp_directory
This will cd to the temp directory, while being quiet.
#
823 824 825 826 827 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 823 def cd_to_the_temp_directory( be_verbose = :be_quiet ) cd temp_directory?, be_verbose end |
#change_directory(i, optional_arguments = nil) ⇒ Object Also known as: chdir, change_dir, cd
#
change_directory (cd tag)
Change into the given directory.
The second argument to this method can be used to do additional tasks, such as creating the directory if it does not yet exist.
#
1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1986 def change_directory( i, optional_arguments = nil ) be_verbose = false # ======================================================================= # # First, handle Symbol-keywords given as first argument. # ======================================================================= # case i when :log_directory i = log_directory? end if block_given? yielded = yield case yielded when :be_verbose be_verbose = true end end # ======================================================================= # # Past this point, the variable `i` ought to be a String. # ======================================================================= # i = i.to_s unless i.is_a? String case optional_arguments # ======================================================================= # # === :be_quiet # ======================================================================= # when :be_quiet, :quiet, :silent, :be_silent, :do_not_report_anything be_verbose = false # ======================================================================= # # === :be_verbose # ======================================================================= # when :be_verbose, true be_verbose = true # ======================================================================= # # === :create_the_directory_if_it_does_not_exist # ======================================================================= # when :create_the_directory_if_it_does_not_exist FileUtils.mkdir_p(i) unless File.directory? i # ======================================================================= # # === :verbose_create_the_directory_if_it_does_not_exist # ======================================================================= # when :verbose_create_the_directory_if_it_does_not_exist, :ensure_that_the_directory_exists unless File.directory? i if be_verbose opne "#{rev}The directory at `#{sdir(i)}#{rev}` does not exist." opne "#{rev}It will be created now." end FileUtils.mkdir_p(i) end end i = i.dup if i.frozen? i << '/' unless i.end_with? '/' i = rds(i) # Added this here as of May 2014. # ======================================================================= # # Perform the cd-action next. # ======================================================================= # if File.directory? i if be_verbose e "#{rev}Changing into the directory `#{sdir(i.to_s)}#{rev}` now." end Dir.chdir(i) if File.directory? i # This is the actual cd-action. end end |
#change_permission(file = 'test', use_this_uid_number = '1000') ⇒ Object Also known as: chown
#
change_permission (chown tag)
This simple method can be used to change permissions, by making use of FileUtils.chown().
#
3249 3250 3251 3252 3253 3254 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3249 def ( file = 'test', use_this_uid_number = '1000' ) FileUtils.chown(use_this_uid_number, use_this_uid_number, file) # Hardcoded right now. end |
#cheering_person? ⇒ Boolean Also known as: return_cheering_person, cheering_person, cheerful_person, cheering_ascii_person
#
cheering_person?
This is just an ASCII “person” that is presently cheering. It is meant to indicate success and/or happiness. For instance, if a compilation-run has succeeded then we may display such a cheering ASCII “person”.
I found this to be cute and neat - and it is also somewhat useful, as I tend to use the colour gold for this. Thus it is a slight visual cue, e. g.:
e steelblue('All went well!' )+gold(cheering_person?)
#
843 844 845 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 843 def cheering_person? '\o/' end |
#chmod(i) ⇒ Object
#
chmod
#
2370 2371 2372 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2370 def chmod(i) RBT.chmod(i) end |
#chop_off_archive(i) ⇒ Object
#
chop_off_archive
Remove the trailing part of an archive, for the most part. This isn’t very sophisticated but it “just works” for most cases (TM).
#
1912 1913 1914 1915 1916 1917 1918 1919 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1912 def chop_off_archive(i) if i.include? '#' # Chop off at '#' characters. i = i[0 .. (i.index('#') - 1)] end i.sub!(/\.source$/,'') if i.include? 'source' i.sub!(/-stable$/,'') if i.end_with? '-stable' return RBT.remove_file_extension(i) end |
#clear_commandline_arguments ⇒ Object Also known as: clear_commandline_options
#
clear_commandline_arguments
#
3641 3642 3643 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3641 def clear_commandline_arguments @internal_hash[:commandline_arguments] = [] end |
#cliner(optional_arguments = nil, use_this_colour = nil) ⇒ Object
#
cliner
#
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1013 def cliner( optional_arguments = nil, use_this_colour = nil ) if block_given? RBT.cliner(optional_arguments, use_this_colour) { yield } else RBT.cliner(optional_arguments, use_this_colour) end end |
#coloured_and_padded_e(i, use_colours = use_colours?, , optional_arguments = nil) ⇒ Object
#
coloured_and_padded_e
#
1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1534 def coloured_and_padded_e( i, use_colours = use_colours?, optional_arguments = nil ) case use_colours # ======================================================================= # # === :default # ======================================================================= # when :default use_colours = use_colours? end # ======================================================================= # # Next, modify this command if it includes "--prefix=". # In that event we will colourize it a bit; the prefix will # be colourized in another colour. # ======================================================================= # if i and i.include?('--prefix=') and use_colours i = i.dup # ===================================================================== # # === Colourize the prefix, in cornflowerblue(). # ===================================================================== # i.sub!(/(--prefix=)(\/.+?)\s/, # See: https://rubular.com/r/Df8OzLqXGd '\1'+ cornflowerblue('\2 ')+ ::Colours.remove_escape_sequences( teal('') ) ) end case optional_arguments # ======================================================================= # # === :inner_padding # # Also use inner-padding here. # ======================================================================= # when :inner_padding i = i.dup i.prepend(' ') end e e i, :fancy_colours # or: teal(i) e end |
#coloured_and_padded_esystem(i, use_colours = use_colours?, , optional_arguments = :inner_padding, use_this_primary_colour = :cornflowerblue, &block) ⇒ Object Also known as: colourize_this_important_system_command, ecolourize_this_important_system_command, colourized_esystem_with_padding, colourized_and_padded_esystem
#
coloured_and_padded_esystem
Usage example:
coloured_and_padded_esystem('ls', true, nil, :cornflowerblue)
#
3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3495 def coloured_and_padded_esystem( i, use_colours = use_colours?, optional_arguments = :inner_padding, use_this_primary_colour = :cornflowerblue, &block ) # ======================================================================= # # We need to work on a copy, as we use colours, and system() does # not understand ANSI escape sequences - hence the copy next. # ======================================================================= # this_command_will_be_passed_to_system_directly = i.dup # ======================================================================= # # === Handle blocks next # ======================================================================= # if block_given? yielded = yield # ===================================================================== # # === Handle Symbols first # ===================================================================== # if yielded.is_a? Symbol if ::Colours.is_this_html_colour_included?(yielded) use_colours = true use_this_primary_colour = yielded end end end case use_colours # ======================================================================= # # === :default # ======================================================================= # when :default use_colours = use_colours? end # ======================================================================= # # Next, modify this command if it includes "--prefix=". # # In that event we will colourize it a bit; the prefix will # be colourized in another colour. # ======================================================================= # if i and i.include?('--prefix=') and use_colours i = i.dup # ===================================================================== # # === Colourize the prefix, in cornflowerblue(). # ===================================================================== # i.sub!(/(--prefix=)(\/.+?)\s/, # See: https://rubular.com/r/Df8OzLqXGd '\1'+ send(use_this_primary_colour, '\2 ')+ ::Colours.remove_escape_sequences( teal('') ) ) end case optional_arguments # ======================================================================= # # === :inner_padding # # Also use inner-padding here. # ======================================================================= # when :inner_padding i = i.dup i.prepend(' ') end e if use_colours and use_this_primary_colour.is_a?(Symbol) e "#{rev}#{::Colours.send(use_this_primary_colour, i)}" else e "#{rev}#{i}", :fancy_colours # or: teal(i) end e system(this_command_will_be_passed_to_system_directly) end |
#coloured_esystem(i) ⇒ Object Also known as: colourized_esystem
#
coloured_esystem
#
1582 1583 1584 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1582 def coloured_esystem(i) esystem i, :fancy_colours end |
#colourize_directory_for_system_results(i) ⇒ Object
#
colourize_directory_for_system_results
This method is to colourize directories that are given via system() or similar calls. In theory, we could use sdir(), but I wanted to have another colour.
#
2222 2223 2224 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2222 def colourize_directory_for_system_results(i) lightslategray(i) end |
#colourize_this_error(i) ⇒ Object
#
colourize_this_error
This method in particular attempts to colourize some errors.
#
2292 2293 2294 2295 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2292 def colourize_this_error(i) return darkgoldenrod(i) if use_colours? return i end |
#colourize_this_file_path(i, colour1 = :slateblue, colour2 = :royalblue) ⇒ Object
#
colourize_this_file_path
This method will colourize a “file path”. So for example, if you have a file path such as “/opt/foo/bar.rb”, then this method will colourize the directory in one colour, and the file itself (bar.rb) in another colour.
The whole idea behind this is to be easily able to separate which part is the directory and which part is the file.
If no ‘/’ has been given then the input will be returned unmodified.
The colour for this can be controlled by the input-arguments.
#
2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2253 def colourize_this_file_path( i, colour1 = :slateblue, # ← This is the colour for the directory. colour2 = :royalblue # ← This is the colour for the file. ) if i.include? '/' if use_colours? dirname = File.dirname(i) basename = File.basename(i) dirname = send(colour1, dirname+'/') basename = send(colour2, basename) i = "#{dirname}#{basename}" end end i end |
#colourize_this_warning(i) ⇒ Object Also known as: colourize_for_warnings
#
colourize_this_warning
#
2300 2301 2302 2303 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2300 def colourize_this_warning(i) return firebrick(i) if use_colours? return i end |
#commandline_arguments? ⇒ Boolean Also known as: input?, arguments?, all_arguments?, commandline?, commandline_options?, commandline, commandline_args?
#
commandline_arguments?
#
962 963 964 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 962 def commandline_arguments? @internal_hash[:commandline_arguments] end |
#commandline_arguments_without_hyphens?(i = commandline_arguments? ) ⇒ Boolean Also known as: reject_entries_starting_with_hyphens, non_hyphen_arguments, non_hyphened_arguments, non_hyphened_arguments?
#
commandline_arguments_without_hyphens?
As above, but reversed.
#
977 978 979 980 981 982 983 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 977 def commandline_arguments_without_hyphens?( i = commandline_arguments? ) i.select {|entry| entry and !entry.start_with?('--') } end |
#comment(i) ⇒ Object
#
comment
#
2363 2364 2365 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2363 def comment(i) Colours.comment(i) # Delegate to class Colours for this. end |
#convert_dd_mm_yyyy_to_its_long_variant(i = dd_mm_yyyy.to_s) ⇒ Object
#
convert_dd_mm_yyyy_to_its_long_variant
#
3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3401 def convert_dd_mm_yyyy_to_its_long_variant( i = dd_mm_yyyy.to_s ) i = i.to_s if i.include? '.' splitted = i.split('.') splitted[1] = return_month_based_on_this_number(splitted[1]).to_s splitted = splitted.join(' ') return splitted end return i end |
#convert_env_variable(i) ⇒ Object Also known as: convert_global_env, sanitize_for_environment_variable
#
convert_env_variable
This method can be used to convert a ENV variable, such as $BLA, into its corresponding “real” value.
#
2448 2449 2450 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2448 def convert_env_variable(i) RBT.convert_global_env(i) end |
#copy_directory(from, to = return_pwd, be_verbose = false) ⇒ Object
#
copy_directory
This method can be used to copy a directory from a certain location to the specified (second argument) target directory.
#
2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2827 def copy_directory( from, to = return_pwd, be_verbose = false ) case to # ======================================================================= # # === :be_verbose # ======================================================================= # when :be_verbose to = return_pwd be_verbose = true end case be_verbose when :be_verbose be_verbose = true end if be_verbose e "#{rev}Now copying the directory `#{sdir(from)}#{rev}` "\ "to `#{sdir(to)}#{rev}`." end FileUtils.cp_r(from, to) end |
#copy_files(from, to = return_pwd, be_verbose = false, use_namespace = true, &block) ⇒ Object Also known as: copy_file, copy, cp
#
copy_files (copy tag, cp tag, copy file tag)
Use this if you need to copy a file.
#
1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1798 def copy_files( from, to = return_pwd, be_verbose = false, use_namespace = true, &block ) # ======================================================================= # # === Handle blocks first # ======================================================================= # if block_given? yielded = yield case yielded when :be_verbose be_verbose = true end end case be_verbose # case tag when :be_verbose be_verbose = true end case to when '.' to = return_pwd end # ======================================================================= # # The next method is defined in the file 'prototype.rb'. # ======================================================================= # from = sanitize_for_environment_variable(from) if from.include? '$' to = sanitize_for_environment_variable(to) if to.include? '$' # ======================================================================= # # Since as of June 2011, we will also automatically create # the base directory should it not yet exist. # ======================================================================= # unless File.exist? File.dirname(to) create_directory(File.dirname(to)) end if File.exist? from if be_verbose if use_namespace opne "#{rev}Now copying the file `#{sfile(from)}#{rev}`" opne "to `#{sfile(to)}#{rev}`." else e "#{rev}Now copying the file `#{sfile(from)}#{rev}`" e "to `#{sfile(to)}#{rev}`." end end FileUtils.cp(from, to) else e "#{rev}Can not copy the file `#{sfile(from)}#{rev}` as "\ "it does not appear to exist." end end |
#cpr(from, to = return_pwd) ⇒ Object
#
cpr
This method can be used to recursively copy to a target directory.
#
1736 1737 1738 1739 1740 1741 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1736 def cpr( from, to = return_pwd ) FileUtils.cp_r(from, to) end |
#create_directory(i = '/Users/Packages/', be_verbose = :be_quiet, permissions = :default, &block) ⇒ Object Also known as: mkdir, mkdir_p, ensure_that_this_directory_exists, create_directory_if_it_does_not_yet_exist
#
create_directory (mkdir tag)
Consistently use this when you want to create a directory for the RBT-Project.
#
2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2646 def create_directory( i = '/Users/Packages/', be_verbose = :be_quiet, = :default, &block ) yielded = nil # Will be filled up if a block is given. unless i.end_with? '/' i = i.dup if i.frozen? i << '/' end # ========================================================================= # # === Handle blocks next # ========================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :be_quiet # ===================================================================== # when :be_quiet be_verbose = false # ===================================================================== # # === :be_verbose # ===================================================================== # when :be_verbose be_verbose = true end end unless File.directory? i if be_verbose.is_a? Hash # =================================================================== # # We have to handle other keys first, in particular the permissions # key: # =================================================================== # if be_verbose.has_key? :permissions = be_verbose.delete(:permissions) end # =================================================================== # # === :be_quiet # =================================================================== # if be_verbose.has_key? :be_quiet be_verbose = be_verbose.delete(:be_quiet) # =================================================================== # # === :verbosity # =================================================================== # elsif be_verbose.has_key? :verbosity be_verbose = be_verbose.delete(:verbosity) end end case be_verbose # ===================================================================== # # === :be_quiet # ===================================================================== # when :be_quiet, :be_silent be_verbose = false end unless File.directory? i if be_verbose opne "#{rev}Creating the directory `#{sdir(i)}#{rev}` now." end RBT.create_directory( i, , :be_quiet, :do_not_use_opn ) { yielded } # ^^^ We are already verbose above, and handle opn on # our own. end end end |
#current_hour? ⇒ Boolean Also known as: return_time
#
current_hour?
Consistently use this method whenever you wish to return the current hour.
#
3394 3395 3396 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3394 def current_hour? ::Time.now.strftime('%H:%M:%S') # '04:21:14' end |
#dd_mmm_yyy ⇒ Object
#
dd_mmm_yyy
This method-format is specifically the default for cookbook-files.
#
2901 2902 2903 2904 2905 2906 2907 2908 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2901 def dd_mmm_yyy current_day = ::Time.now.strftime('%d') # This will return a string such as "30". return current_day+ ' '+ Date::MONTHNAMES[Date.today.month][0,3].capitalize+ ' '+ ::Time.now.strftime('%Y') end |
#debug(i) ⇒ Object
#
debug
Debug functionality here.
#
2501 2502 2503 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2501 def debug(i) cliner { ewarn(i) } end |
#debug? ⇒ Boolean
#
debug?
#
991 992 993 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 991 def debug? @internal_hash[:debug] end |
#directory_expanded_cookbooks? ⇒ Boolean Also known as: directory_expanded_cookbooks, base_dir_to_store_expanded_cookbooks?, expanded_cookbooks?, expanded_cookbook_directory?
#
directory_expanded_cookbooks?
#
1614 1615 1616 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1614 def RBT. end |
#disable_colours ⇒ Object Also known as: do_not_use_colours, disable_colors
#
disable_colours
Use this method if you wish to disable colours. Invoke it only when you really do wish to disable the colours.
#
2751 2752 2753 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2751 def disable_colours @internal_hash[:use_colours] = false end |
#display_md5sum? ⇒ Boolean Also known as: show_md5sum?
#
display_md5sum?
#
3268 3269 3270 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3268 def display_md5sum? RBT.display_md5sum? end |
#do_not_debug ⇒ Object
#
do_not_debug
#
1005 1006 1007 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1005 def do_not_debug @internal_hash[:debug] = false end |
#does_the_cookbook_include_this_program?(i) ⇒ Boolean
#
does_the_cookbook_include_this_program?
#
3457 3458 3459 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3457 def does_the_cookbook_include_this_program?(i) RBT.does_include?(i) end |
#does_this_expanded_cookbook_file_exist_for_this_program?(i) ⇒ Boolean Also known as: does_the_expanded_cookbook_file_exist_for_this_program?, expanded_cookbook_file_exists_for?
#
does_this_expanded_cookbook_file_exist_for_this_program?
This method can be used to determine whether an expanded cookbook dataset exists for a given program at hand.
#
813 814 815 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 813 def (i) return File.exist?((i)) end |
#does_this_file_exist?(i, prepend_this = nil) ⇒ Boolean
#
does_this_file_exist?
#
244 245 246 247 248 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 244 def does_this_file_exist?( i, prepend_this = nil ) ::RBT.does_this_file_exist?(i, prepend_this) end |
#does_this_file_exist_and_is_it_a_file?(i) ⇒ Boolean
#
does_this_file_exist_and_is_it_a_file?
#
3305 3306 3307 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3305 def does_this_file_exist_and_is_it_a_file?(i) ::RBT.does_this_file_exist_and_is_it_a_file?(i) end |
#e(i = '', optional_colours = nil, use_colours = use_colours? ) ⇒ Object
#
e (e tag)
The second argument can be a Symbol such as :fancy_colours.
#
3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3466 def e( i = '', optional_colours = nil, use_colours = use_colours? ) if use_colours case optional_colours # =================================================================== # # === :fancy_colours # =================================================================== # when :fancy_colours optional_colours = :mediumslateblue else puts i end puts "#{::Colours.send(optional_colours, i)}#{rev}" if optional_colours else puts i end end |
#eblue(i = '') ⇒ Object
#
eblue
#
2283 2284 2285 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2283 def eblue(i = '') e steelblue(i) end |
#ecomment(i = '', use_colours = use_colours? ) ⇒ Object
#
ecomment
#
2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2622 def ecomment( i = '', use_colours = use_colours? ) if use_colours ::Colours.ecomment(i) else e i end end |
#ecrimson(i = '') ⇒ Object
#
ecrimson
This is mostly for debug-related output, e. g. colourize something via the colour red (or rather, crimson) quickly.
#
2276 2277 2278 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2276 def ecrimson(i = '') e crimson(i) end |
#edir(i = return_pwd) ⇒ Object
#
edir
#
2157 2158 2159 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2157 def edir(i = return_pwd) e sdir(i) end |
#editor? ⇒ Boolean
#
editor?
#
3260 3261 3262 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3260 def editor? RBT.editor? end |
#efancy(i = '') ⇒ Object
#
efancy
#
2188 2189 2190 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2188 def efancy(i = '') e sfancy(i) end |
#eimp(i) ⇒ Object
#
simp
#
2211 2212 2213 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2211 def eimp(i) e simp(i) end |
#enable_colours ⇒ Object Also known as: set_use_colours, do_use_colours
#
enable_colours
#
2740 2741 2742 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2740 def enable_colours @internal_hash[:use_colours] = true end |
#enable_debug ⇒ Object
#
enable_debug
#
998 999 1000 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 998 def enable_debug @internal_hash[:debug] = true end |
#ensure_main_encoding_for(i, use_this_encoding = USE_MAIN_ENCODING) ⇒ Object
#
ensure_main_encoding_for
The input to this method should be a String object.
#
410 411 412 413 414 415 416 417 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 410 def ensure_main_encoding_for( i, use_this_encoding = USE_MAIN_ENCODING ) unless i.encoding.to_s.include? use_this_encoding i = i.force_encoding(use_this_encoding) end return i end |
#eparse(i) ⇒ Object
#
eparse
#
2345 2346 2347 2348 2349 2350 2351 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2345 def eparse(i) if use_colours? Colours.eparse(i) else e i end end |
#esystem(i, use_this_colour = nil) ⇒ Object
#
esystem
Combine system() with output of the command.at hand.
#
1591 1592 1593 1594 1595 1596 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1591 def esystem( i, use_this_colour = nil ) RBT.esystem(i, use_this_colour) end |
#esystem_gold(i) ⇒ Object
#
esystem_gold
A variant for esystem(), via the gold colour on the commandline.
#
1526 1527 1528 1529 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1526 def esystem_gold(i) e gold(i) system i end |
#etomato(i) ⇒ Object
#
etomato
#
2356 2357 2358 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2356 def etomato(i) e tomato(i) end |
#ewarn(i = '') ⇒ Object
#
ewarn
#
2318 2319 2320 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2318 def ewarn(i = '') e swarn(i) # ← This method will already check for use of colours. end |
#exit_program(symbol_exit = :standalone, optional_message = nil, use_this_as_exit_value = 0, &block) ⇒ Object
#
exit_program (exit tag)
This is a wrapper to exit, that is, to exit a program. Either we just exit; or we return the special symbol :break
A few Symbols may be passed as block to this method, indicating special behaviour. For instance, the Symbol :exit_no_matter_what shall indicate that this method ought to exit at all times, no matter what.
#
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1865 def exit_program( symbol_exit = :standalone, = nil, use_this_as_exit_value = 0, &block ) e if # ======================================================================= # # If we give a number, assume this to be the exit code which we will # use for exiting there. # ======================================================================= # if symbol_exit.to_s =~ /\d+/ use_this_as_exit_value = symbol_exit.to_i end if block_given? symbol_exit = yield # This variable may now be a Symbol, such as: :exit_no_matter_what end case symbol_exit # ======================================================================= # # === :connected # ======================================================================= # when :connected, :chained, :continue return :break # i.e. when you run it from a shell. Return the Symbol :break. # ======================================================================= # # === :standalone # ======================================================================= # when :standalone, # ← Added because I like to read the symbol :standalone. :may_we_exit, :exit_no_matter_what, :default, 'default', 'def', true exit(use_this_as_exit_value) else # this is the default, just like with :standalone too exit(use_this_as_exit_value) end end |
#expanded_cookbooks_directory_exists?(target = directory_expanded_cookbooks? ) ⇒ Boolean Also known as: expanded_directory_exists?, directory_expanded_cookbooks_exists?
#
expanded_cookbooks_directory_exists?
This method will try and check to see if the expanded-cookbooks directory exists. If this directory exists then this method will return true; otherwise this method will return false.
#
1059 1060 1061 1062 1063 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1059 def ( target = ) return File.directory?(target) end |
#extract_this_archive(i, extract_to = return_pwd) ⇒ Object
#
extract_this_archive
#
3117 3118 3119 3120 3121 3122 3123 3124 3125 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3117 def extract_this_archive( i, extract_to = return_pwd ) if File.exist?(i) try_to_require_the_extracter_gem action(:extract, i, to: extract_to) end end |
#extract_to?(optional_argument = nil) ⇒ Boolean
#
extract_to?
#
3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3030 def extract_to?( optional_argument = nil ) #result = "#{temp_directory?}" result = "#{log_directory?}" if optional_argument result = result.dup _ = remove_archive_from_the_end( File.basename(optional_argument) ) _ = return_program_name(_) result << _ end return rds("#{result}/") end |
#file_compiled_programs? ⇒ Boolean
#
file_compiled_programs?
#
2377 2378 2379 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2377 def file_compiled_programs? RBT.file_compiled_programs? end |
#file_dirname_retaining_trailing_slash(i) ⇒ Object
#
file_dirname_retaining_trailing_slash
This method will invoke File.dirname(), but it will ensure that the last character of the result returned will be a ‘/’, if the given input also ended with a ‘/’ token.
#
1372 1373 1374 1375 1376 1377 1378 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1372 def file_dirname_retaining_trailing_slash(i) if i.end_with?('/') return "#{File.dirname(i)}/" else return File.dirname(i) end end |
#file_predefined_installation_instructions? ⇒ Boolean Also known as: file_predefined_installation_instructions
#
file_predefined_installation_instructions?
#
2582 2583 2584 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2582 def file_predefined_installation_instructions? RBT.file_predefined_installation_instructions end |
#file_specification_of_registered_cookbook_entries ⇒ Object
#
file_specification_of_registered_cookbook_entries
#
670 671 672 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 670 def file_specification_of_registered_cookbook_entries ::RBT.file_specification_of_registered_cookbook_entries end |
#find_cookbook_alias_for(i) ⇒ Object
#
find_cookbook_alias_for
This method depends on the Cookbooks gem.
It allows us to find the registered alias for a given program, and thus acts as an “input-sanitizer”.
#
2492 2493 2494 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2492 def find_cookbook_alias_for(i) RBT.find_cookbook_alias_for(i) end |
#find_this_yaml_file(i = :poppler) ⇒ Object Also known as: return_yaml_file_for
#
find_this_yaml_file
This method can be used to find a proper yaml file.
We will delegate to Cookbooks for this though.
We will return the absolute path to the .yml file in question.
Usage example:
find_this_yaml_file(:poppler) # => "/home/x/programming/ruby/src/rbt/lib/rbt/yaml/individual_cookbooks/poppler.yml"
#
3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3171 def find_this_yaml_file(i = :poppler) i = i.to_s # ======================================================================= # # The next check has to be explicit for File.file? as well, because # a local directory with that name may exist, which we would not # want to have. # ======================================================================= # if File.exist?(i) and File.file?(i) i else RBT.return_location_of_this_yaml_file(i) end end |
#first_argument? ⇒ Boolean Also known as: first?, first_commandline_argument?
#
first_argument?
#
3619 3620 3621 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3619 def first_argument? @internal_hash[:commandline_arguments].first end |
#first_non_hyphen_argument?(i = commandline_arguments_without_hyphens? ) ⇒ Boolean Also known as: return_first_non_hyphen_argument, first_non_hyphened_argument_from_the_commandline_arguments, first_non_hyphened_argument?
#
first_non_hyphen_argument?
#
942 943 944 945 946 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 942 def first_non_hyphen_argument?( i = commandline_arguments_without_hyphens? ) i.first end |
#get_all_directories_from(here = return_pwd, return_full_path = false) ⇒ Object Also known as: get_dir_listing, get_directory_listing, get_directories_from
#
get_all_directories_from
This method can be used to obtain all directories from the given (first) input argument.
#
1151 1152 1153 1154 1155 1156 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1151 def get_all_directories_from( here = return_pwd, return_full_path = false ) RBT.get_all_directories_from(here, return_full_path) end |
#get_all_files_from(i) ⇒ Object Also known as: get_files_from
#
get_all_files_from
#
1164 1165 1166 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1164 def get_all_files_from(i) return RBT.get_all_files_from(i) end |
#get_all_programs(from = "#{RBT.programs_directory?}*") ⇒ Object
#
get_all_programs (all programs tag)
Simply returns all programs from the $PROGRAMS directory.
#
436 437 438 439 440 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 436 def get_all_programs( from = "#{RBT.programs_directory?}*" ) Dir[from] # The constant PROGRAMS is set in config.rb. It has a trailing / end |
#get_date ⇒ Object
#
get_date
This method will return a String such as “21 Sep 2023”.
#
2868 2869 2870 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2868 def get_date ::RBT.get_date end |
#get_extended_date ⇒ Object
#
get_extended_date
This method will return a String such as “21 September 2023”.
#
2877 2878 2879 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2877 def get_extended_date ::RBT.get_extended_date end |
#get_files_and_directories_from(i = return_pwd) ⇒ Object
#
get_files_and_directories_from
#
1219 1220 1221 1222 1223 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1219 def get_files_and_directories_from( i = return_pwd ) RBT.get_files_and_directories_from(i) end |
#go_to_base_dir(be_verbose = true) ⇒ Object Also known as: go_to_the_base_directory
#
go_to_base_dir
Simply go to the temp-directory.
#
2510 2511 2512 2513 2514 2515 2516 2517 2518 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2510 def go_to_base_dir( be_verbose = true ) _ = temp_dir? if be_verbose opne "Changing to `#{sdir(_)}`." end cd(_) end |
#home_dir? ⇒ Boolean
#
home_dir?
#
2425 2426 2427 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2425 def home_dir? rds("#{ENV['HOME']}/") # We ensure here that a trailing '/' is part of the result. end |
#host_system? ⇒ Boolean Also known as: host_architecture?, host_achiteture_in_use?
#
host_system?
#
2396 2397 2398 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2396 def host_system? RBT.determine_host_architecture end |
#infer_the_namespace ⇒ Object
#
infer_the_namespace
This will assume the true namespace from the inspectable name.
#
871 872 873 874 875 876 877 878 879 880 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 871 def infer_the_namespace _ = inspect.to_s.delete('<') if _.include? ' ' _ = _.split(' ').first.delete('#') if _.include? ':' _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::') end end set_the_namespace(_) # And assign it here. end |
#internal_hash? ⇒ Boolean Also known as: ihash, ihash?, internal_hash, return_default_internal_hash
#
internal_hash?
#
1465 1466 1467 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1465 def internal_hash? @internal_hash end |
#internal_hash_set_commandline_arguments(i = ARGV) ⇒ Object Also known as: set_commandline_arguments, set_input, set_commandline
#
internal_hash_set_commandline_arguments
This method will set the commandline arguments.
#
3590 3591 3592 3593 3594 3595 3596 3597 3598 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3590 def internal_hash_set_commandline_arguments( i = ARGV ) i = [i].flatten.compact if @internal_hash.nil? reset_the_internal_hash # Trying this since as of 10.06.2023. end @internal_hash[:commandline_arguments] = i end |
#is_an_archive?(i) ⇒ Boolean Also known as: is_archive?, is_this_an_archive?
#
is_an_archive?
Query-method to determine whether the given input is assumed to be an archive. An archive is something like “foobar-1.0.tar.xz”.
#
1927 1928 1929 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1927 def is_an_archive?(i) return RBT.is_an_archive?(i) end |
#is_directory?(i) ⇒ Boolean
#
is_directory?
#
1278 1279 1280 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1278 def is_directory?(i) File.directory? i end |
#is_file?(i) ⇒ Boolean
#
is_file?
#
1192 1193 1194 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1192 def is_file?(i) File.file? i end |
#is_github_url?(i = url1? ) ⇒ Boolean Also known as: is_a_github_url?
#
is_github_url?
This method will return true if the main url (url1) is a github url.
#
424 425 426 427 428 429 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 424 def is_github_url?( i = url1? ) i and (i.start_with?('https://github.com/') or i.start_with?('http://github.com/')) end |
#is_make_available?(path = query_path? ) ⇒ Boolean
#
is_make_available?
This method will attempt to find out whether make is available. It will do so by checking on the available path of the host ruby.
#
709 710 711 712 713 714 715 716 717 718 719 720 721 722 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 709 def is_make_available?( path = query_path? ) is_make_available = false # By default it is assumed that make is NOT available. if path.include? ':' check_these_directories = path.split(':') check_these_directories.each {|dir| if File.exist?("#{dir}/make") is_make_available = true # Yup, make is available. end } end return is_make_available end |
#is_meson_installed? ⇒ Boolean
#
is_meson_installed?
#
3574 3575 3576 3577 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3574 def is_meson_installed? _ = `meson 2>&1` !_.include?('meson: command not found') end |
#is_on_gobolinux? ⇒ Boolean Also known as: are_we_on_gobolinux?
#
is_on_gobolinux?
The method is_on_gobolinux? can be used to query whether the host system is using GoboLinux (a linux distribution) or whether it is not.
#
2437 2438 2439 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2437 def is_on_gobolinux? RBT.is_on_gobolinux? end |
#is_on_windows? ⇒ Boolean Also known as: are_we_on_windows?
#
is_on_windows?
#
648 649 650 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 648 def is_on_windows? RBT.is_on_windows? end |
#is_roebe? ⇒ Boolean Also known as: is_on_roebe?, on_roebe?
#
is_roebe?
If we are on our local computer, or on another computer.
#
787 788 789 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 787 def is_roebe? RBT.is_roebe? end |
#is_superuser? ⇒ Boolean
#
is_superuser?
#
1442 1443 1444 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1442 def is_superuser? Process.uid == 0 end |
#is_symlink?(i) ⇒ Boolean
#
is_symlink?
#
383 384 385 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 383 def is_symlink?(i) File.symlink?(i) end |
#is_this_a_header?(i) ⇒ Boolean
#
is_this_a_header?
This method determines whether the given input argument could be considered to be a header-file.
#
237 238 239 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 237 def is_this_a_header?(i) i.strip.end_with?('.h') end |
#is_this_a_library?(i) ⇒ Boolean
#
is_this_a_library?
This method will check whether the given input is assumed to be a library or whether it is not. If the input ends with .so or .a then this is considered to be a library, by this method.
The check inside of the method body will ensure this.
#
285 286 287 288 289 290 291 292 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 285 def is_this_a_library?(i) ( i.strip.end_with?('.so') or i.strip.end_with?('.a') or i.strip.end_with?('.o') or i.strip.include?('.so.') # <- For e. g. "libfoo.so.1.2.3" ) end |
#is_this_program_included?(i) ⇒ Boolean Also known as: included?, includes?, program_was_found?, include?, is_included?, includes_this_program?, is_this_program_registered?, is_the_program_included?, does_include?, is_this_program_part_of_the_RBT_project?
#
is_this_program_included?
This method will return a Boolean value (true or false).
#
3441 3442 3443 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3441 def is_this_program_included?(i) available_programs?.include?(i) end |
#iso_encoding? ⇒ Boolean
#
iso_encoding?
#
1178 1179 1180 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1178 def iso_encoding? ENCODING_ISO end |
#load_dataset_from_this_expanded_cookbook(i, &block) ⇒ Object Also known as: return_dataset_from_expanded_cookbook, return_dataset_from_this_expanded_cookbook, quickly_obtain_expanded_cookbook_dataset_from
#
load_dataset_from_this_expanded_cookbook
This method will attempt to load the dataset from an expanded cookbook dataset. In order for this to work, the file must exist locally.
#
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 301 def ( i, &block ) i = i.to_s unless i.is_a? String # We need Strings. if File.file?(i) use_this_file = i.dup else use_this_file = (i) end if File.exist? use_this_file load_yaml(use_this_file) # Load the .yml file here, if it exists. else no_file_exists_at(use_this_file, &block) return nil end end |
#load_yaml(i) ⇒ Object
#
load_yaml
This is a slightly slimpler alternative to load .yml files for the RBT project.
#
334 335 336 337 338 339 340 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 334 def load_yaml(i) begin YAML.load_file(i) rescue Psych::SyntaxError => error pp error end end |
#load_yaml_file_from_the_cookbook_directory_for_this_program(i) ⇒ Object
#
load_yaml_file_from_the_cookbook_directory_for_this_program
This method can be used to load the specific .yml file from the cookbook directory.
#
368 369 370 371 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 368 def load_yaml_file_from_the_cookbook_directory_for_this_program(i) target_file = "#{RBT.cookbook_directory?}#{i}.yml" load_yaml(target_file) end |
#log_directory? ⇒ Boolean Also known as: rbt_temp_directory?, log_dir?, rbt_log_dir, rbt_log_dir?, rbt_log_directory?, rbt_temp_dir?, rbt_logs?
#
log_directory?
This will return a String such as “/Depot/Temp/rbt/”.
Several aliases exist to this method, such as the commonly used variant called log_dir?.
#
3054 3055 3056 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3054 def log_directory? RBT.log_directory? end |
#main_encoding? ⇒ Boolean
#
main_encoding?
#
641 642 643 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 641 def main_encoding? USE_THIS_ENCODING end |
#meson_build_file_exists?(at_this_location = return_pwd, use_build_directory = false) ⇒ Boolean Also known as: meson_file_exists?
#
meson_build_file_exists?
When we check for the file called “meson.build”, we must also keep in mind that we may use a build directory. This is the reason why the following code uses a variable.
#
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 739 def meson_build_file_exists?( at_this_location = return_pwd, use_build_directory = false ) case at_this_location # ======================================================================= # # === :default # ======================================================================= # when :default at_this_location = return_pwd end if File.exist?(at_this_location) and File.file?(at_this_location) return true else # ===================================================================== # # Next check whether we do use a build directory or whether we do not. # ===================================================================== # if use_build_directory # =================================================================== # # Check the directory below the one given next: # =================================================================== # target_file = File.absolute_path("#{at_this_location}../meson.build") check_for_this_file = target_file else check_for_this_file = "#{at_this_location}meson.build" end return File.exist?(check_for_this_file) # Perform the check here. end end |
#months? ⇒ Boolean
#
months?
This method will simply return all months in a given year, via their english names, such as ‘May’, ‘April’.
This will be returned as an Array.
#
2859 2860 2861 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2859 def months? Date::MONTHNAMES.compact end |
#move_file(this_file, where_to, be_verbose = true) ⇒ Object Also known as: mv, rename_file, rename_directory
#
move_file (move tag, mv tag)
Move a file via this method here. Use this consistently whenever you move a file. Could also be done via File.mv().
#
680 681 682 683 684 685 686 687 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 680 def move_file( this_file, where_to, be_verbose = true ) if be_verbose e "#{rev}Moving from #{sfile(this_file)} to #{sfile(where_to)}." end FileUtils.mv(this_file, where_to) end |
#n_programs_are_available? ⇒ Boolean
#
n_programs_are_available?
#
2418 2419 2420 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2418 def n_programs_are_available? available_programs?.size end |
#n_programs_available? ⇒ Boolean Also known as: n_programs_available
#
n_programs_available?
#
391 392 393 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 391 def n_programs_available? RBT.n_programs_available? end |
#namespace? ⇒ Boolean
#
namespace?
#
885 886 887 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 885 def namespace? @internal_hash[:namespace] end |
#no_directory_exists_at(i) ⇒ Object
#
no_directory_exists_at
#
2468 2469 2470 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2468 def no_directory_exists_at(i) e "#{rev}No directory exists at `#{sdir(i)}#{rev}`." end |
#no_directory_was_found_at(to) ⇒ Object
#
no_directory_was_found_at
#
3659 3660 3661 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3659 def no_directory_was_found_at(to) orev "No directory was found at `#{sdir(to)}#{rev}`." end |
#no_opn ⇒ Object Also known as: disable_opn
#
no_opn
#
1638 1639 1640 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1638 def no_opn @internal_hash[:use_opn] = false end |
#no_such_file_exists(i, be_verbose = true, &block) ⇒ Object Also known as: no_file_exists_at
#
no_such_file_exists
#
2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2546 def no_such_file_exists( i, be_verbose = true, &block ) if block_given? yielded = yield case yielded when :be_quiet be_verbose = false end end if be_verbose e "#{rev}#{tomato('No file called `')}"\ "#{sfile(i)}#{rev}"\ "#{tomato('` appears to exist.')}" end end |
#open_in_browser(i = nil) ⇒ Object
#
open_in_browser
#
3312 3313 3314 3315 3316 3317 3318 3319 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3312 def open_in_browser(i = nil) if i begin require 'open' Open.in_browser(i) rescue LoadError; end end end |
#open_in_editor(i) ⇒ Object Also known as: open_this_file
#
open_in_editor
This will open a cookbook .yml file in the editor.
#
3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3277 def open_in_editor(i) if i.is_a? Array i.each {|entry| open_in_editor(entry) } else i = i.to_s.dup unless i.end_with? '.yml' i << '.yml' end if is_on_roebe? # =================================================================== # # On my home system. # =================================================================== # unless i.start_with?(RUBY_SRC_RBT_COOKBOOKS) or i.include?('/') i.prepend RUBY_SRC_RBT_COOKBOOKS end else unless i.include? individual_cookbooks_dir? i.prepend(individual_cookbooks_dir?) end end esystem "#{editor?} #{i}" end end |
#opncomment(i = '') ⇒ Object
#
opncomment
#
1716 1717 1718 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1716 def opncomment(i = '') opnn; ecomment i end |
#opne(i = nil, use_opn = use_opn? ) ⇒ Object
#
opne (opne tag)
#
3332 3333 3334 3335 3336 3337 3338 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3332 def opne( i = nil, use_opn = use_opn? ) opn(namespace: namespace?) if use_opn e i if i end |
#opnef(i) ⇒ Object
#
opnef (opnef tag)
#
3324 3325 3326 3327 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3324 def opnef(i) opn(namespace: namespace?) if use_opn? ee i end |
#opnerev(i = nil, use_opn = use_opn? ) ⇒ Object Also known as: orev
#
opnerev
#
3343 3344 3345 3346 3347 3348 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3343 def opnerev( i = nil, use_opn = use_opn? ) opne "#{rev}#{i}", use_opn end |
#opnerror(i, use_this_as_namespace = namespace? ) ⇒ Object
#
opnerror (opnerror tag)
This will combine opn() with stderr-output.
#
1603 1604 1605 1606 1607 1608 1609 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1603 def opnerror( i, use_this_as_namespace = namespace? ) opn(namespace: use_this_as_namespace) if use_opn? stderr i # Use standard-error output. end |
#opnesystem(i) ⇒ Object
#
opnesystem
#
1670 1671 1672 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1670 def opnesystem(i) opnn; esystem i end |
#opnewarn(i) ⇒ Object Also known as: opnwarn, owarn
#
opnewarn
#
1701 1702 1703 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1701 def opnewarn(i) opne swarn(i) end |
#opnfancy(i = '') ⇒ Object
#
opnfancy
#
1709 1710 1711 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1709 def opnfancy(i = '') opne sfancy(i) end |
#opnn(i = namespace?, , use_opn = use_opn?, , &block) ⇒ Object Also known as: output_namespace?
#
opnn (opnn tag)
The abbreviation “opn” stands for “output program name”. This also describes the major functionality of this method - we will try to display the name of the program that generates a particular output, so that the user can understand which component may have went wrong.
#
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1682 def opnn( i = namespace?, use_opn = use_opn?, &block ) if use_opn if i.is_a? String i = { namespace: i, use_colours: use_colours? } end RBT.opnn(i, &block) # ← Let that method handle this. end end |
#packages_directory? ⇒ Boolean
#
packages_directory?
#
1048 1049 1050 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1048 def packages_directory? return ::RBT.packages_directory? end |
#path_to_this_expanded_cookbooks_dataset(i) ⇒ Object Also known as: return_file_to_the_expanded_cookbooks_dataset
#
path_to_this_expanded_cookbooks_dataset
This method shall attempt to return the full path to the expanded cookbooks directory dataset of a given program.
For example, if the input to this method is ‘htop’ then this method should return ‘htop.yml’, or rather, ‘/home/Temp/rbt/expanded_cookbooks/htop.yml’.
#
2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2766 def (i) i = i.to_s.dup i = remove_archive_at_the_end( File.basename(i) ) # ======================================================================= # # The next check leads to problems for input such as "0install.yml". # Unfortunately I did not explain why I added the following line, # so I have removed it on 13.09.2019 again. # # If it is to be re-added, it has to be explained why it is there; # and if not, then it is suggested to remove the code eventually. # ======================================================================= # # if i =~ /\d+/ # i = ProgramInformation.return_program_name(i) # end # ======================================================================= # i << '.yml' unless i.end_with? '.yml' "#{}#{i}" end |
#pkgconfig_directory? ⇒ Boolean
#
pkgconfig_directory?
#
1212 1213 1214 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1212 def pkgconfig_directory? return "#{syslib_dir?}pkgconfig/" end |
#populate_the_internal_hash_with_default_values ⇒ Object
#
populate_the_internal_hash_with_default_values
#
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 151 def populate_the_internal_hash_with_default_values # ======================================================================= # # === :namespace # # We must initialize this variable here so that subclasses can make # use of it from the very beginning. # ======================================================================= # set_the_namespace( { namespace: NAMESPACE } ) # ======================================================================= # # === :commandline_arguments # ======================================================================= # @internal_hash[:commandline_arguments] = [] # ======================================================================= # # === :be_verbose # ======================================================================= # @internal_hash[:be_verbose] = true # ======================================================================= # # === :use_colours # ======================================================================= # @internal_hash[:use_colours] = RBT.use_colours? # Use the default value for RBT. # ======================================================================= # # === :run_simulation # # This variable will determine whether we run in simulation mode or not. # ======================================================================= # @internal_hash[:run_simulation] = RBT.configuration?.run_simulation # ======================================================================= # # === :use_opn # ======================================================================= # @internal_hash[:use_opn] = true # ======================================================================= # # === :debug # ======================================================================= # @internal_hash[:debug] = RBT.shall_we_debug? end |
#predefined_installation_instructions? ⇒ Boolean
#
predefined_installation_instructions?
#
2589 2590 2591 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2589 def predefined_installation_instructions? RBT.predefined_installation_instructions? end |
#prepend_this_commandline_argument(i) ⇒ Object
#
prepend_this_commandline_argument
#
3605 3606 3607 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3605 def prepend_this_commandline_argument(i) @internal_hash[:commandline_arguments].prepend(i) end |
#program_version_of?(i) ⇒ Boolean
#
program_version_of?
#
2801 2802 2803 2804 2805 2806 2807 2808 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2801 def program_version_of?(i) if Object.const_defined? :ProgramInformation if i.include?('-') return ProgramInformation.return_program_version(i) end end return i end |
#project_base_directory? ⇒ Boolean Also known as: project_base_dir?
#
project_base_directory?
#
3075 3076 3077 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3075 def project_base_directory? RBT.project_base_directory? end |
#project_yaml_directory? ⇒ Boolean Also known as: rbt_path?, project_yaml_dir?, yaml_dir?, yaml_directory?
#
project_yaml_directory?
This will return the path to the yaml directory.
#
774 775 776 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 774 def project_yaml_directory? RBT.yaml_directory? end |
#query_path? ⇒ Boolean
3213 3214 3215 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3213 def query_path? ENV['PATH'].dup # .dup-ing it is better in the long run. end |
#rarrow? ⇒ Boolean Also known as: rarrow
#
rarrow?
#
227 228 229 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 227 def rarrow? cadetblue(string_right_arrow?) end |
#read_file(i) ⇒ Object Also known as: read_this_file
#
read_file (read tag)
Use this method whenever you want to read in a file.
#
3000 3001 3002 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3000 def read_file(i) File.read(i) if File.exist? i end |
#read_file_in_default_encoding(i, use_this_encoding = ::RBT.encoding?) ⇒ Object Also known as: default_read, file_read, read_read
#
read_file_in_default_encoding
#
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1383 def read_file_in_default_encoding( i, use_this_encoding = ::RBT.encoding? ) if File.exist? i File.read( i, encoding: use_this_encoding ) else e "#{rev}Can not read file `#{i}` as it does not exist." end end |
#read_file_with_default_encoding(i) ⇒ Object
#
read_file_with_default_encoding
#
3007 3008 3009 3010 3011 3012 3013 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3007 def read_file_with_default_encoding(i) if File.exist? i File.read(i, encoding: 'UTF-8') else return i end end |
#readlines(i) ⇒ Object
#
readlines
This is added in the event that we may wish to use a special encoding, by default, one day.
#
1502 1503 1504 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1502 def readlines(i) File.readlines(i) end |
#readlines_with_proper_encoding(i, use_this_encoding = main_encoding? ) ⇒ Object Also known as: default_readlines, proper_readlines
#
readlines_with_proper_encoding
File.readlines() variant with proper encoding.
#
1511 1512 1513 1514 1515 1516 1517 1518 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1511 def readlines_with_proper_encoding( i, use_this_encoding = main_encoding? ) File.readlines( i, encoding: use_this_encoding ) end |
#register_sigint(optional_message = nil, use_this_as_exit_code = 0) ⇒ Object
#
register_sigint
#
795 796 797 798 799 800 801 802 803 804 805 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 795 def register_sigint( = nil, use_this_as_exit_code = 0 ) Signal.trap('SIGINT') { if e end exit(use_this_as_exit_code) } end |
#registered_cookbook_entries? ⇒ Boolean
#
registered_cookbook_entries?
#
655 656 657 658 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 655 def registered_cookbook_entries? require 'rbt/constants/constants.rb' RBT.registered_cookbook_entries? end |
#remove(this_target, be_verbose = false) ⇒ Object
#
remove (remove tag)
General remove entry-method. If you wish to delete a file or a directory or a symlink, use this method.
#
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1090 def remove( this_target, be_verbose = false ) if this_target.is_a? Array this_target.each {|entry| remove(entry, be_verbose) } else # ===================================================================== # # The next check requires a rescue clause, because the file may no # longer exist. # ===================================================================== # begin type = File.ftype(this_target) rescue Errno::ENOENT type = 'missing_entry' end if File.exist? this_target case type # case tag # =================================================================== # # === remove_symlink # =================================================================== # when 'link','missing_entry' # This entry is for symlinks. remove_symlink(this_target) # =================================================================== # # === remove_file # =================================================================== # when 'file' remove_file(this_target, be_verbose) # =================================================================== # # === remove_directory # =================================================================== # when 'directory' remove_directory(this_target) else # This else clause will not be entered, I think. ewarn "Not removing `#{simp(this)}` as \"#{simp(type)}\" is "\ "not registered." end else if be_verbose opne swarn('WARNING: file ')+ this_target.to_s+ swarn(' does not exist.') opne swarn('Thus, it can not be removed.') end end end end |
#remove_archive_from_the_end(i) ⇒ Object Also known as: remove_archive_at_the_end, remove_file_archive_at_the_end, remove_archive_stuff_from_the_end, remove_file_extension_from
#
remove_archive_from_the_end
This method will remove the “archive part” of the given input, such as by removing “.tar.xz” from the given input argument (which ought to be a String).
#
2572 2573 2574 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2572 def remove_archive_from_the_end(i) RBT.remove_archive_from_the_end(i) end |
#remove_comments_from_each_line(i) ⇒ Object
#
remove_comments_from_each_line
This method will remove each comment from a given line. Assume multiline input that will have trailing “ # foobar” comments which will be removed.
#
349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 349 def remove_comments_from_each_line(i) if i.include? ' # ' i = i.split(N).map {|line| if line.include? ' # ' line = line[0 .. (line.index('#') - 1)] line.strip! end line }.join(N) end i end |
#remove_directory(this_directory, be_verbose = false, &block) ⇒ Object Also known as: remove_dir, remove_these_directories, remove_directories, remove_this_directory
#
remove_directory
Consistently use this method in order to remove one or more directories.
Note that ‘/’ is always protected though.
#
2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2935 def remove_directory( this_directory, be_verbose = false, &block ) # ======================================================================= # # Handle blocks given to this method next: # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :be_verbose # ===================================================================== # when :be_verbose be_verbose = true end end if this_directory.is_a? Array this_directory.each {|entry| # Recursive call here. remove_directory(entry, be_verbose) } elsif this_directory.is_a? String case be_verbose when :be_verbose be_verbose = true end this_directory = rds(this_directory).strip # Don't want double slashes in it. if File.directory? this_directory case this_directory # case tag # =================================================================== # # / can never be removed through this method here - at the least # this is our intent. # =================================================================== # when '/' # We will never remove '/', ever. e "#{rev}The #{sdir('/')} #{rev}directory can not be removed "\ "via this method." # Tiny "safeguard". # =================================================================== # # RBT.temp_directory? # =================================================================== # when RBT.temp_directory? e "#{rev}Will not remove directory `#{sdir(this_directory)}#{rev}`." # Another tiny "safeguard". else if File.exist?(this_directory) and (this_directory.size > 1) if be_verbose e "#{rev}Removing the directory `#{sdir(this_directory)}#{rev}` "\ "next." end FileUtils.rm_rf(this_directory) # Finally remove the directory. end end end else e "#{rev}Unknown input: #{this_directory.class}#{rev}" end end |
#remove_double_slashes(i) ⇒ Object Also known as: rds
#
remove_double_slashes (rds tag)
Replace // with / in a given string.
#
1478 1479 1480 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1478 def remove_double_slashes(i) return RBT.rds(i) end |
#remove_file(i, report_the_action = false) ⇒ Object Also known as: delete, delete_file, remove_files, remove_these_files
#
remove_file (remove tag)
Use this method whenever you wish to remove a file.
The first input argument to this method shall be the file that we wish to remove. This means the “file path”, so the path to the file has to be provided, such as “/opt/foobar.md”. An Array can also be given, which will lead to batch-removal of the given files at hand.
The second input argument to this method, called ‘report_the_action`, determines whether we will be verbose or whether we will not be verbose. Verbose here means that we will notify the user what we are doing or about to do; not verbose means that we will be silent when we remove the target file.
#
1780 1781 1782 1783 1784 1785 1786 1787 1788 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1780 def remove_file( i, report_the_action = false ) if i.is_a? Array i.each {|entry| remove_file(entry, report_the_action) } else RBT.remove_file(i, report_the_action) end end |
#remove_newlines(i) ⇒ Object
#
remove_newlines
Get rid of the newlines.
#
3239 3240 3241 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3239 def remove_newlines(i) i.delete("\n") end |
#remove_parens(i) ⇒ Object
#
remove_parens
This method will turn something like (‘FOO’) into ‘FOO’
#
1287 1288 1289 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1287 def remove_parens(i) i.delete('()') end |
#remove_symlink(i) ⇒ Object Also known as: remove_this_symlink
#
remove_symlink
This method can be used to selectively remove a symlink.
#
455 456 457 458 459 460 461 462 463 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 455 def remove_symlink(i) if i.is_a? Array i.each {|entry| remove_symlink(entry) } else if File.symlink?(i) # Check whether we have a symlink here. File.delete(i) end end end |
#remove_the_first_commandline_argument ⇒ Object
#
remove_the_first_commandline_argument
#
3648 3649 3650 3651 3652 3653 3654 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3648 def remove_the_first_commandline_argument if @internal_hash[:commandline_arguments] and @internal_hash[:commandline_arguments][0] @internal_hash[:commandline_arguments][0] = nil # Get rid of the first element here. @internal_hash[:commandline_arguments].compact! end end |
#remove_this_commandline_argument(i, from = commandline_arguments? ) ⇒ Object
#
remove_this_commandline_argument
This method can be used to remove a specific argument from the commandline arguments.
#
3630 3631 3632 3633 3634 3635 3636 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3630 def remove_this_commandline_argument( i, from = commandline_arguments? ) from.reject! {|line| line =~ /#{Regexp.quote(i)}/ } end |
#remove_this_entry_from_the_commandline_arguments(i) ⇒ Object
#
remove_this_entry_from_the_commandline_arguments
#
953 954 955 956 957 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 953 def remove_this_entry_from_the_commandline_arguments(i) commandline_arguments?.reject! {|entry| entry == i } end |
#remove_trailing_ANSII_escape_code(i) ⇒ Object
#
remove_trailing_ANSII_escape_code
This method can be used if you need to get rid of trailing ANSII escape sequences from a given String.
#
2335 2336 2337 2338 2339 2340 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2335 def remove_trailing_ANSII_escape_code(i) if use_colours? i = ::Colours.remove_trailing_ANSII_escape_code(i) end i end |
#remove_unnecessary_data_from_url(i) ⇒ Object Also known as: return_program_full_name_from_url
#
remove_unnecessary_data_from_url
This method removes some meaningless information that can be found in some URLs.
#
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 536 def remove_unnecessary_data_from_url(i) i = i.first if i.is_a? Array i = i.to_s.dup i = File.basename(i) i.gsub(/download\?file=/,''). sub(/\/download$/,''). sub(/\?download$/,''). gsub(/-fullsrc/,''). gsub(/-source/,''). gsub(/\?use_mirror=dfn/,''). gsub(/\.src/,''). gsub(/-src/,'') # .gsub(/_/,'-') # This here may be controversial, hence it # was disabled as of June 2010. # i = remove_file_extension(i) # ^^^ We can not do the above, because program_full_name # must include the archive. end |
#rename(old_name, new_name) ⇒ Object
#
rename
#
2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2530 def rename(old_name, new_name) if File.exist? old_name begin File.rename(old_name, new_name) rescue Errno::ENOTEMPTY e 'old_name was: '+old_name e 'new_name was: '+new_name e 'Either directory was not empty.' exit end end end |
#report_pwd ⇒ Object Also known as: verbose_report_pwd
#
report_pwd
#
272 273 274 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 272 def report_pwd e "#{rev}The current directory is `#{sdir_return_pwd}#{rev}`." end |
#require_the_rbt_aliases ⇒ Object
#
require_the_rbt_aliases
#
634 635 636 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 634 def require_the_rbt_aliases require 'rbt/aliases/aliases.rb' end |
#reset ⇒ Object
#
reset (reset tag)
#
138 139 140 141 142 143 144 145 146 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 138 def reset # ======================================================================= # # === @internal_hash # # This definition for the internal Hash *must* come first. # ======================================================================= # @internal_hash = {} populate_the_internal_hash_with_default_values end |
#reset_the_internal_hash ⇒ Object
#
reset_the_internal_hash
#
192 193 194 195 196 197 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 192 def reset_the_internal_hash # ======================================================================= # # === @internal_hash # ======================================================================= # @internal_hash = {} end |
#return_all_archives_from_this_directory(i) ⇒ Object
#
return_all_archives_from_this_directory
#
1185 1186 1187 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1185 def return_all_archives_from_this_directory(i) RBT.return_all_archives_from_this_directory(i) end |
#return_appdir_prefix(i) ⇒ Object Also known as: return_appdir_prefix_for
#
return_appdir_prefix
#
203 204 205 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 203 def return_appdir_prefix(i) return RBT.return_appdir_prefix(i) end |
#return_commandline_arguments_with_leading_hyphens(i = commandline_arguments? ) ⇒ Object Also known as: commandline_arguments_containing_leading_hyphens?, commandline_arguments_with_leading_hyphens?, commandline_arguments_with_hyphens?, return_arguments_with_leading_hyphens, return_commandline_arguments_with_hyphens, return_entries_with_leading_hyphens, hyphen_commandline_arguments?, return_hyphened_commandline_arguments, hyphen_arguments, hyphened_arguments?
#
return_commandline_arguments_with_leading_hyphens
This will select all commandline-arguments with leading ‘–’ characters.
#
922 923 924 925 926 927 928 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 922 def return_commandline_arguments_with_leading_hyphens( i = commandline_arguments? ) i.select {|entry| entry and entry.start_with?('--') } end |
#return_current_hour_minutes_second ⇒ Object Also known as: ss_mm_hh, hh_mm_ss
#
return_current_hour_minutes_second
This method will return the current time, in HH::MM::SS format.
#
3203 3204 3205 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3203 def return_current_hour_minutes_second ::Time.now.strftime '%H:%M:%S' # => "16:08:40" end |
#return_date ⇒ Object Also known as: return_current_date, return_current_time, dd_mm_yyyy
#
return_date
This method wil return a date (a day), such as “21.09.2017” or “03.06.2018” - in other words, the dd.mm.yyyy format.
#
3430 3431 3432 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3430 def return_date RBT.return_date end |
#return_day_of_the_month_based_on_utc ⇒ Object
#
return_day_of_the_month_based_on_utc
#
3362 3363 3364 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3362 def return_day_of_the_month_based_on_utc return_utc.day.to_s end |
#return_full_time ⇒ Object
#
return_full_time
This method will return a String such as ‘21.09.2017, 03:03:09’.
#
3355 3356 3357 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3355 def return_full_time "#{return_date}, #{return_current_hour_minutes_second}" end |
#return_hours_minutes_seconds_based_on_utc ⇒ Object
#
return_hours_minutes_seconds_based_on_utc
#
3376 3377 3378 3379 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3376 def return_hours_minutes_seconds_based_on_utc _ = return_utc _.strftime('%H:%M:%S') end |
#return_location_to_this_programs_yaml_file(i) ⇒ Object
#
return_location_to_this_programs_yaml_file
Easier access-method to determine where the yaml file may be.
#
401 402 403 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 401 def return_location_to_this_programs_yaml_file(i) RBT.return_location_to_this_programs_yaml_file(i) end |
#return_month_based_on_this_number(i) ⇒ Object
#
return_month_based_on_this_number
The input to this method should be an Integer, for the month, such as 1,2,3 and so forth.
#
3420 3421 3422 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3420 def return_month_based_on_this_number(i) Date::MONTHNAMES[i.to_i] end |
#return_month_based_on_utc ⇒ Object
#
return_month_based_on_utc
#
3384 3385 3386 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3384 def return_month_based_on_utc Date::MONTHNAMES[return_utc.month] end |
#return_opnn(i = nil) ⇒ Object
#
return_opnn
#
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1645 def return_opnn( i = nil ) hash = { namespace: namespace?, be_verbose: false } if i if i.is_a? String i = { namespace: i } end hash.update(i) end opnn(hash) end |
#return_program_information(i) ⇒ Object Also known as: return_program_name
#
return_program_information
#
3018 3019 3020 3021 3022 3023 3024 3025 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3018 def return_program_information(i) if Object.const_defined? :ProgramInformation if i.include?('-') i = ProgramInformation.return_real_short_name(i) end end return i end |
#return_program_name_for_gobolinux_systems(i) ⇒ Object
#
return_program_name_for_gobolinux_systems
This method should ideally return the program name for GoboLinux systems. Right now it does not work, largely because I have not found out a reliable way to determine the program name on GoboLinux-like systems.
#
2461 2462 2463 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2461 def return_program_name_for_gobolinux_systems(i) return i end |
#return_pwd ⇒ Object Also known as: return_current_pwd, pwd?, get_pwd
#
return_pwd
#
253 254 255 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 253 def return_pwd RBT.return_pwd end |
#return_unicode_warning_symbol_or_empty_string ⇒ Object
#
return_unicode_warning_symbol_or_empty_string
#
2384 2385 2386 2387 2388 2389 2390 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2384 def return_unicode_warning_symbol_or_empty_string if Object.const_defined?(:Roebe) and Roebe.respond_to?(:unicode_warning_symbol) Roebe.unicode_warning_symbol else '' end end |
#return_utc ⇒ Object
#
return_utc
This method will return a Time object that is in UTC format, such as “2018-12-28 14:09:26 UTC”.
#
3223 3224 3225 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3223 def return_utc ::Time.now.getutc end |
#return_utc_time_in_a_format_similar_to_slackware ⇒ Object
#
return_utc_time_in_a_format_similar_to_slackware
Slackware changelog uses a format such as this one here, in a UTC format:
Thu Sep 21 01:23:24 UTC 2017
#
2919 2920 2921 2922 2923 2924 2925 2926 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2919 def return_utc_time_in_a_format_similar_to_slackware return "#{return_weekday_based_on_utc.to_s} "\ "#{return_month_based_on_utc.to_s} "\ "#{return_day_of_the_month_based_on_utc} "\ "#{return_hours_minutes_seconds_based_on_utc}"\ " UTC "\ "#{return_year_based_on_utc}" end |
#return_weekday_based_on_utc ⇒ Object
#
return_weekday_based_on_utc
This will return e. g. ‘Mon’ or ‘Fri’ or something like that.
It depends on the constant RFC2822_DAY_NAME.
#
3192 3193 3194 3195 3196 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3192 def return_weekday_based_on_utc _ = return_utc wday = _.wday return DAY_NAMES[wday] end |
#return_year_based_on_utc ⇒ Object
#
return_year_based_on_utc
#
3369 3370 3371 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3369 def return_year_based_on_utc return_utc.year.to_s end |
#rev ⇒ Object
#
rev (rev tag)
#
2325 2326 2327 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2325 def rev ::RBT.rev(use_colours?) end |
#run ⇒ Object
#
run (run tag)
#
3582 3583 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3582 def run end |
#run_simulation=(i = false) ⇒ Object
#
run_simulation
Setter method for the ivar @run_simulation.
This way we can run in simulation mode. That way, we won’t do any modifications, we will only assume that certain things be done.
#
2480 2481 2482 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2480 def run_simulation=(i = false) @internal_hash[:run_simulation] = i end |
#run_simulation? ⇒ Boolean Also known as: run_simulation, in_simulation?
#
run_simulation?
This method will tell us whether we shall we run in simulation mode or whether we shall not. The default is false, as in, we will not run in simulation mode.
The simulation mode is required to tell the user what we would do, without actually doing any of these changes. It is a “dry run”, a test run.
#
566 567 568 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 566 def run_simulation? @internal_hash[:run_simulation] end |
#sdir(i = '') ⇒ Object
#
sdir
#
2172 2173 2174 2175 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2172 def sdir(i = '') return ::RBT.sdir(i) if use_colours? return i end |
#sdir_return_pwd ⇒ Object
#
sdir_return_pwd
This method will simply colourize the returned String from the method return_pwd().
#
265 266 267 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 265 def sdir_return_pwd sdir(return_pwd) end |
#set_be_silent(i = false) ⇒ Object Also known as: be_silent, be_quiet, set_be_quiet, do_not_be_verbose, set_do_not_be_verbose
#
set_be_silent
Set whether we will be verbose or whether we will not.
#
1937 1938 1939 1940 1941 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1937 def set_be_silent( i = false # false because we assign to @internal_hash[:be_verbose] ) @internal_hash[:be_verbose] = i end |
#set_be_verbose(i = true) ⇒ Object Also known as: be_verbose, be_verbose=
#
set_be_verbose
By default we will be verbose.
#
1966 1967 1968 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1966 def set_be_verbose(i = true) @internal_hash[:be_verbose] = i end |
#set_first_commandline_argument(i) ⇒ Object
#
set_first_commandline_argument
#
3612 3613 3614 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3612 def set_first_commandline_argument(i) @internal_hash[:commandline_arguments][0] = i end |
#set_namespace(i) ⇒ Object Also known as: set_the_namespace
#
set_namespace
#
892 893 894 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 892 def set_namespace(i) @internal_hash[:namespace] = i end |
#set_use_opn(i = true) ⇒ Object Also known as: do_use_opn
#
set_use_opn
#
1624 1625 1626 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1624 def set_use_opn(i = true) # Must remain true by default. @internal_hash[:use_opn] = i end |
#set_xorg_buffer(i) ⇒ Object
#
set_xorg_buffer
#
663 664 665 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 663 def set_xorg_buffer(i) ::RBT.set_xorg_buffer(i) end |
#sfancy(i = '') ⇒ Object
#
sfancy
#
2195 2196 2197 2198 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2195 def sfancy(i = '') return ::RBT.sfancy(i) if use_colours? return i end |
#sfile(i = '') ⇒ Object
#
sfile
#
2180 2181 2182 2183 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2180 def sfile(i = '') return ::RBT.sfile(i) if use_colours? return i end |
#silent_redirection? ⇒ Boolean Also known as: original_stdout, original_stdout?
#
silent_redirection?
#
727 728 729 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 727 def silent_redirection? @internal_hash[:silent_redirection] end |
#silently_create_this_directory_if_it_does_not_yet_exist(i) ⇒ Object
#
silently_create_this_directory_if_it_does_not_yet_exist
#
2636 2637 2638 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2636 def silently_create_this_directory_if_it_does_not_yet_exist(i) create_directory(i, :be_quiet) end |
#simp(i = '', use_colours = use_colours?) ) ⇒ Object Also known as: simportant
#
simp
#
2164 2165 2166 2167 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2164 def simp(i = '', use_colours = use_colours?) return ::RBT.simp(i) if use_colours return i end |
#source_base_directory? ⇒ Boolean Also known as: archive_dir?, source_directory?, source_directory, source_dir?, src_dir?
#
source_base_directory?
#
2813 2814 2815 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2813 def source_base_directory? RBT.source_base_directory? end |
#ssym(i) ⇒ Object
#
ssym
#
2203 2204 2205 2206 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2203 def ssym(i) return RBT.ssym(i) if use_colours? i end |
#stderr(i = '', use_puts_or_print = :puts) ⇒ Object
#
stderr
This method is used specifically to indicate errors to the user.
#
2727 2728 2729 2730 2731 2732 2733 2734 2735 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2727 def stderr( i = '', use_puts_or_print = :puts ) if use_colours? i = orangered(i) end RBT.stderr(i, use_puts_or_print) end |
#store_into_this_directory? ⇒ Boolean Also known as: store_where?
#
store_into_this_directory?
#
1456 1457 1458 1459 1460 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1456 def store_into_this_directory? _ = RBT.store_into_this_directory? ensure_that_this_directory_exists(_) # Make sure that the directory exists. return _ end |
#string_right_arrow? ⇒ Boolean Also known as: right_arrow?
#
string_right_arrow?
#
220 221 222 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 220 def string_right_arrow? '→' end |
#swarn(i = '', use_colours = use_colours? ) ⇒ Object
#
swarn
#
2308 2309 2310 2311 2312 2313 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2308 def swarn( i = '', use_colours = use_colours? ) return ::RBT.swarn(i) if use_colours return i end |
#symlink(existing, new_location = nil, be_verbose = true, use_colours = RBT.use_colours?) ⇒ Object Also known as: do_symlink, symlink_file, symlink_this_file, create_symlink
#
symlink (symlink tag)
Wrapper to symlinking something.
The first argument should be the existing target.
The second argument shall be the name of the new location.
Since as of November 2019, the following syntax is supported as well:
symlink(
from: @target_directory+'lib64',
to: @target_directory+'lib'
)
#
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 483 def symlink( existing, new_location = nil, be_verbose = true, use_colours = RBT.use_colours? # Here we need colours/colours.rb ) # ======================================================================= # # === Handle blocks next # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :be_quiet # ===================================================================== # when :be_quiet be_verbose = false end end # ======================================================================= # # === Handle Hashes next # ======================================================================= # if existing.is_a? Hash # ===================================================================== # # === :to # ===================================================================== # if existing.has_key?(:to) and new_location.nil? new_location = existing.delete(:to) end # ===================================================================== # # === :from # ===================================================================== # if existing.has_key?(:from) existing = existing.delete(:from) end end ::RBT.symlink( existing, new_location, be_verbose, use_colours ) end |
#sysbin_directory? ⇒ Boolean Also known as: usr_bin?
#
sysbin_directory?
#
3089 3090 3091 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3089 def sysbin_directory? RBT.sysbin_directory? end |
#sysetc_directory? ⇒ Boolean Also known as: etc_dir?
#
sysetc_directory?
#
1141 1142 1143 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1141 def sysetc_directory? RBT.sysetc_directory? end |
#sysinclude_directory? ⇒ Boolean Also known as: include_dir?
#
sysinclude_directory?
#
3103 3104 3105 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3103 def sysinclude_directory? RBT.sysinclude_directory? end |
#syslib_directory? ⇒ Boolean Also known as: lib_dir?
#
syslib_directory?
#
3110 3111 3112 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3110 def syslib_directory? RBT.syslib_directory? end |
#sysshare_directory? ⇒ Boolean Also known as:
#
sysshare_directory?
#
3096 3097 3098 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3096 def sysshare_directory? RBT.sysshare_directory? end |
#system_directory? ⇒ Boolean
#
system_directory?
#
3082 3083 3084 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3082 def system_directory? RBT.system_directory? end |
#temp_directory? ⇒ Boolean Also known as: temp_dir?, temp?
#
temp_directory?
#
3067 3068 3069 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 3067 def temp_directory? RBT.temp_directory? end |
#to_bool(i) ⇒ Object Also known as: to_boolean
#
to_bool
#
1361 1362 1363 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1361 def to_bool(i) RBT.to_bool(i) end |
#to_camelcase(i) ⇒ Object
#
to_camelcase
#
2523 2524 2525 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2523 def to_camelcase(i) i.split('_').map { |_| _.capitalize }.join end |
#to_iso_encoding(i) ⇒ Object
#
to_iso_encoding
#
1171 1172 1173 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1171 def to_iso_encoding(i) i.force_encoding(ENCODING_ISO) end |
#to_unicode(i) ⇒ Object
#
to_unicode
This method will “convert” into the Unicode-encoding.
#
855 856 857 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 855 def to_unicode(i) i.force_encoding(ENCODING_UTF) end |
#today?(display_in_long_format = true) ⇒ Boolean
#
today?
This method will return a String such as “21 September 2017”.
#
2886 2887 2888 2889 2890 2891 2892 2893 2894 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2886 def today?( display_in_long_format = true ) if display_in_long_format # This is the default. Time.now.strftime('%d %B %Y') # => "28 December 2018" else Time.now.strftime('%d.%m.%Y') # => "28.12.2018" end end |
#touch(i, be_verbose = false) ⇒ Object Also known as: create_file, touch_file
#
touch (touch tag)
Use this unified method whenever you wish to create a new file, like the UNIX “touch” command.
#
1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1410 def touch( i, be_verbose = false ) case be_verbose when :be_verbose be_verbose = true end if be_verbose e "#{rev}Next creating the file `#{sfile(i)}`." end FileUtils.touch(i) end |
#try_to_require_beautiful_url ⇒ Object
#
try_to_require_beautiful_url
#
610 611 612 613 614 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 610 def try_to_require_beautiful_url begin require 'beautiful_url' rescue LoadError; end end |
#try_to_require_the_environment_information_gem ⇒ Object
#
try_to_require_the_environment_information_gem
#
601 602 603 604 605 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 601 def try_to_require_the_environment_information_gem begin require 'environment_information' rescue LoadError; end end |
#try_to_require_the_extracter_gem ⇒ Object
#
try_to_require_the_extracter_gem
#
574 575 576 577 578 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 574 def try_to_require_the_extracter_gem begin require 'extracter' rescue LoadError; end end |
#try_to_require_the_open_gem ⇒ Object
#
try_to_require_the_open_gem
#
592 593 594 595 596 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 592 def try_to_require_the_open_gem begin require 'open' rescue LoadError; end end |
#try_to_require_the_xorg_buffer ⇒ Object
#
try_to_require_the_xorg_buffer
#
619 620 621 622 623 624 625 626 627 628 629 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 619 def try_to_require_the_xorg_buffer begin require 'xorg_buffer' # or: require 'xorg_buffer/module' rescue LoadError if RUBY_PLATFORM.include?('linux') and is_on_roebe? puts 'The gem called `xorg_buffer` is unavailable. '\ 'Consider installing it.' end end end |
#try_to_require_wget ⇒ Object
#
try_to_require_wget
#
583 584 585 586 587 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 583 def try_to_require_wget begin require 'wget' rescue LoadError; end end |
#try_to_return_a_special_compile_component(i) ⇒ Object
#
try_to_return_a_special_compile_component
#
376 377 378 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 376 def try_to_return_a_special_compile_component(i) action(:try_to_return_a_special_compile_component, i) end |
#unicode_cliner(a = :default, b = :default, &block) ⇒ Object
#
unicode_cliner
#
1027 1028 1029 1030 1031 1032 1033 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1027 def unicode_cliner( a = :default, b = :default, &block ) ::RBT.unicode_cliner(a, b, &block) end |
#unicode_middle_cliner(a = :default, b = :default) ⇒ Object
#
unicode_middle_cliner
#
1038 1039 1040 1041 1042 1043 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1038 def unicode_middle_cliner( a = :default, b = :default ) ::RBT.unicode_cliner(a, b) { :unicode_middle_horizontal_bar } end |
#use_colours=(i = true) ⇒ Object
#
use_colours=
#
2150 2151 2152 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2150 def use_colours=(i = true) @internal_hash[:use_colours] = i end |
#use_colours? ⇒ Boolean Also known as: we_may_use_colours?
#
use_colours?
Query whether we may use colours or not.
#
2143 2144 2145 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 2143 def use_colours? @internal_hash[:use_colours] end |
#use_opn=(i = true) ⇒ Object
#
use_opn=
#
1631 1632 1633 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1631 def use_opn=(i = true) @internal_hash[:use_opn] = i end |
#use_opn? ⇒ Boolean Also known as: show_opnn?
#
use_opn?
#
1663 1664 1665 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1663 def use_opn? @internal_hash[:use_opn] end |
#utf_encoding? ⇒ Boolean
#
utf_encoding?
#
862 863 864 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 862 def utf_encoding? ENCODING_UTF end |
#verbose_truth(i, optional_arguments = nil) ⇒ Object Also known as: vt, verbose_truth?
#
verbose_truth
This will give us back “yes” or “no”, in String form.
#
1270 1271 1272 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1270 def verbose_truth(i, optional_arguments = nil) RBT.verbose_truth(i, optional_arguments) end |
#word_wrap(this_text, n_characters_limit = :default) ⇒ Object Also known as: wrap_at
#
word_wrap
The first argument is the text that will be reformatted.
The second argument is at which position we will wrap it.
#
1489 1490 1491 1492 1493 1494 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1489 def word_wrap( this_text, n_characters_limit = :default # This should be equal to 78. ) ::RBT.wrap_at(this_text, n_characters_limit) end |
#write_what_into(what, into, permissions_to_use = '755') ⇒ Object Also known as: save_file, save_what_into, store_what_into, save_what_to
#
write_what_into
Delegate towards the SaveFile functionality here.
#
1748 1749 1750 1751 1752 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1748 def write_what_into( what, into, = '755' ) RBT.write_what_into(what, into, ) end |
#write_what_into_via_unicode(what, into, permissions_to_use = '755') ⇒ Object
#
write_what_into_via_unicode
Delegate towards the SaveFile functionality here.
#
1725 1726 1727 1728 1729 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1725 def write_what_into_via_unicode( what, into, = '755' ) RBT.write_what_into_via_unicode(what, into, ) end |
#yes_or_no(i, optional_instructions = nil) ⇒ Object
#
yes_or_no
Return ‘Yes.’ or ‘No.’ through this method here.
#
1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 |
# File 'lib/rbt/lean_prototype/lean_prototype.rb', line 1296 def yes_or_no( i, optional_instructions = nil ) case i when true,'true' i = 'Yes.' when false,'false' i = 'No.' end case optional_instructions # ======================================================================= # # === :minimalistic # ======================================================================= # when :minimalistic i = i.downcase.delete('.') if i end return i end |