Class: RBT::Action::CreateAppDirSkeleton

Inherits:
RBT::Action show all
Defined in:
lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb

Overview

RBT::Action::CreateAppDirSkeleton

Constant Summary collapse

ARRAY_CREATE_THESE_SUBDIRECTORIES =
#

ARRAY_CREATE_THESE_SUBDIRECTORIES

This Array will list the subdirectories that are to be created.

Since as of 06.12.2019, these entries should include a trailing ‘/’.

While this is not ultimately necessary, I have found that it makes it a bit more easier to reason about these entries. We can also instantly see that these are directories.

The directory called ‘Resources/` will list various files such as the file `Dependencies`, which lists all dependencies for the given program at hand, on a GoboLinux system.

#
%w(
  bin/
  include/
  lib/
  man/
  share/
  sbin/
  Resources/
)
%w(
  gcc
  binutils
)
DEFAULT_PROGRAM_VERSION =
#

DEFAULT_PROGRAM_VERSION

This constant specifies which program-version to use if it is otherwise omitted. That is just a generic number, though.

#
'1.0.0'
DEFAULT_TEST_INPUT =
#

DEFAULT_TEST_INPUT

This should yield a fairly complicated use-case, to test the ability of this class to be useful.

#
'/home/kumar/Robert/Programs/Htop/1.0.2'
DEFAULT_RUN_ALREADY =
#

DEFAULT_RUN_ALREADY

#
true

Constants inherited from LeanPrototype

LeanPrototype::ALL_COLOUR_METHODS, LeanPrototype::ARRAY_KDE_KONSOLE_COLOURS_IN_USE, LeanPrototype::DAY_NAMES, LeanPrototype::NAMESPACE, LeanPrototype::SILENT_REDIRECTION

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LeanPrototype

#a_or_an?, #abbreviations?, #absolute_path, #action, #add_to_the_commandline_arguments, #all_binaries?, #all_files_from, #all_libraries?, #allowed_cookbook_entries?, #appdir_location_of?, #append_onto_the_internal_hash, #append_what_into, #archive_type_of?, #available_programs?, #be_quiet?, #be_verbose?, #begins_with_a_comment?, #capitalize_first_alphabetical_character, #cd_to_the_log_directory, #cd_to_the_temp_directory, #change_directory, #change_permission, #cheering_person?, #chmod, #chop_off_archive, #clear_commandline_arguments, #cliner, #coloured_and_padded_e, #coloured_and_padded_esystem, #coloured_esystem, #colourize_directory_for_system_results, #colourize_this_error, #colourize_this_file_path, #colourize_this_warning, #commandline_arguments?, #commandline_arguments_without_hyphens?, #comment, #convert_dd_mm_yyyy_to_its_long_variant, #convert_env_variable, #copy_directory, #copy_files, #cpr, #create_directory, #current_hour?, #dd_mmm_yyy, #debug, #debug?, #directory_expanded_cookbooks?, #disable_colours, #display_md5sum?, #do_not_debug, #does_the_cookbook_include_this_program?, #does_this_expanded_cookbook_file_exist_for_this_program?, #does_this_file_exist?, #does_this_file_exist_and_is_it_a_file?, #e, #eblue, #ecomment, #ecrimson, #edir, #editor?, #efancy, #eimp, #enable_colours, #enable_debug, #ensure_main_encoding_for, #eparse, #esystem, #esystem_gold, #etomato, #ewarn, #exit_program, #expanded_cookbooks_directory_exists?, #extract_this_archive, #extract_to?, #file_compiled_programs?, #file_dirname_retaining_trailing_slash, #file_predefined_installation_instructions?, #file_specification_of_registered_cookbook_entries, #find_cookbook_alias_for, #find_this_yaml_file, #first_argument?, #first_non_hyphen_argument?, #get_all_directories_from, #get_all_files_from, #get_all_programs, #get_date, #get_extended_date, #get_files_and_directories_from, #go_to_base_dir, #home_dir?, #host_system?, #infer_the_namespace, #internal_hash?, #internal_hash_set_commandline_arguments, #is_an_archive?, #is_directory?, #is_file?, #is_github_url?, #is_make_available?, #is_meson_installed?, #is_on_gobolinux?, #is_on_windows?, #is_roebe?, #is_superuser?, #is_symlink?, #is_this_a_header?, #is_this_a_library?, #is_this_program_included?, #iso_encoding?, #load_dataset_from_this_expanded_cookbook, #load_yaml, #load_yaml_file_from_the_cookbook_directory_for_this_program, #log_directory?, #main_encoding?, #meson_build_file_exists?, #months?, #move_file, #n_programs_are_available?, #n_programs_available?, #namespace?, #no_directory_exists_at, #no_directory_was_found_at, #no_opn, #no_such_file_exists, #open_in_browser, #open_in_editor, #opncomment, #opne, #opnef, #opnerev, #opnerror, #opnesystem, #opnewarn, #opnfancy, #packages_directory?, #path_to_this_expanded_cookbooks_dataset, #pkgconfig_directory?, #populate_the_internal_hash_with_default_values, #predefined_installation_instructions?, #prepend_this_commandline_argument, #program_version_of?, #project_base_directory?, #project_yaml_directory?, #query_path?, #rarrow?, #read_file, #read_file_in_default_encoding, #read_file_with_default_encoding, #readlines, #readlines_with_proper_encoding, #register_sigint, #registered_cookbook_entries?, #remove, #remove_archive_from_the_end, #remove_comments_from_each_line, #remove_directory, #remove_double_slashes, #remove_file, #remove_newlines, #remove_parens, #remove_symlink, #remove_the_first_commandline_argument, #remove_this_commandline_argument, #remove_this_entry_from_the_commandline_arguments, #remove_trailing_ANSII_escape_code, #remove_unnecessary_data_from_url, #rename, #report_pwd, #require_the_rbt_aliases, #reset_the_internal_hash, #return_all_archives_from_this_directory, #return_appdir_prefix, #return_commandline_arguments_with_leading_hyphens, #return_current_hour_minutes_second, #return_date, #return_day_of_the_month_based_on_utc, #return_full_time, #return_hours_minutes_seconds_based_on_utc, #return_location_to_this_programs_yaml_file, #return_month_based_on_this_number, #return_month_based_on_utc, #return_opnn, #return_program_information, #return_program_name_for_gobolinux_systems, #return_pwd, #return_unicode_warning_symbol_or_empty_string, #return_utc, #return_utc_time_in_a_format_similar_to_slackware, #return_weekday_based_on_utc, #return_year_based_on_utc, #rev, #run_simulation=, #run_simulation?, #sdir, #sdir_return_pwd, #set_be_silent, #set_be_verbose, #set_first_commandline_argument, #set_namespace, #set_use_opn, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #silently_create_this_directory_if_it_does_not_yet_exist, #simp, #source_base_directory?, #ssym, #stderr, #store_into_this_directory?, #string_right_arrow?, #swarn, #symlink, #sysbin_directory?, #sysetc_directory?, #sysinclude_directory?, #syslib_directory?, #sysshare_directory?, #system_directory?, #temp_directory?, #to_bool, #to_camelcase, #to_iso_encoding, #to_unicode, #today?, #touch, #try_to_require_beautiful_url, #try_to_require_the_environment_information_gem, #try_to_require_the_extracter_gem, #try_to_require_the_open_gem, #try_to_require_the_xorg_buffer, #try_to_require_wget, #try_to_return_a_special_compile_component, #unicode_cliner, #unicode_middle_cliner, #use_colours=, #use_colours?, #use_opn=, #use_opn?, #utf_encoding?, #verbose_truth, #word_wrap, #write_what_into, #write_what_into_via_unicode, #yes_or_no

Constructor Details

#initialize(commandline_arguments = DEFAULT_TEST_INPUT, run_already = DEFAULT_RUN_ALREADY, &block) ⇒ CreateAppDirSkeleton

#

initialize

#


116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 116

def initialize(
    commandline_arguments = DEFAULT_TEST_INPUT,
    run_already           = DEFAULT_RUN_ALREADY, # ← This is true by default.
    &block
  )
  reset
  _ = commandline_arguments
  # ======================================================================== #
  # === Next support :dont_run_yet if a special Array was passed
  # ======================================================================== #
  if _.is_a?(Array) and _.last.is_a?(Symbol)
    case _.pop
    # ====================================================================== #
    # === :dont_run_yet
    # ====================================================================== #
    when :dont_run_yet,
         :do_not_run_yet
      run_already = false
    end
  end
  set_commandline_arguments(
    commandline_arguments
  )
  # ======================================================================== #
  # === Handle blocks next
  # ======================================================================== #
  if block_given?
    yielded = yield
    case yielded # Handle Symbols first.
    # ====================================================================== #
    # === :disable_colours
    # ====================================================================== #
    when :disable_colours
      disable_colours
      @internal_hash[:hash_for_opn].update(use_colours: false)
    end
    # ====================================================================== #
    # === Handle Hashes given to that block next
    # ====================================================================== #
    if yielded.is_a? Hash
      # =================================================================== #
      # === :use_colours
      # =================================================================== #
      if yielded.has_key? :use_colours
        @internal_hash[:hash_for_opn].update(use_colours: false) if yielded.delete(:use_colours) == false
      end
      # =================================================================== #
      # === :use_this_directory_as_the_program_directory
      # =================================================================== #
      if yielded.has_key? :use_this_directory_as_the_program_directory
        @internal_hash[:internal_programs_directory] = yielded.delete(:use_this_directory_as_the_program_directory)
      end
      # =================================================================== #
      # === :use_opn
      # =================================================================== #
      if yielded.has_key? :use_opn
        @internal_hash[:hash_for_opn].update(
          use_opn: yielded.delete(:use_opn)
        )
      end
      # =================================================================== #
      # === :do_not_symlink_these_programs
      #
      # Handle the case where the user does not want us to symlink
      # certain programs, such as 'make'.
      # =================================================================== #
      if yielded.has_key? :do_not_symlink_these_programs
        @internal_hash[:array_do_not_symlink_these_programs] << yielded.delete(:do_not_symlink_these_programs)
        @internal_hash[:array_do_not_symlink_these_programs].flatten!
      end
    end
  end
  case run_already
  # ======================================================================== #
  # === :dont_run_yet
  # ======================================================================== #
  when :dont_run_yet,
       :do_not_run_yet
    run_already = false
  else
    if run_already and !run_already.is_a?(TrueClass) and
      (run_already =~ /^\d+$/)
      set_program_version(run_already)
      run_already = DEFAULT_RUN_ALREADY
    end
  end
  run if run_already
end

Class Method Details

.[](i = ARGV, &block) ⇒ Object

#

RBT::Action::CreateAppDirSkeleton[]

#


804
805
806
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 804

def self.[](i = ARGV, &block)
  new(i, &block)
end

Instance Method Details

#
#

Returns:

  • (Boolean)


248
249
250
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 248

def array_do_not_symlink_these_programs?
  @internal_hash[:array_do_not_symlink_these_programs]
end

#create_settings_directory(this_directory = "#{target_directory?}Settings/") ⇒ Object

#

create_settings_directory

The settings directory will be created at the target_directory?.

#


664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 664

def create_settings_directory(
    this_directory = "#{target_directory?}Settings/"
  )
  this_directory = this_directory.dup
  unless this_directory.end_with?('Settings/')
    this_directory << 'Settings/'
  end
  if in_simulation?
    opne "Normally `#{sdir(this_directory)}` would be created but"
    opne 'as we run in '+steelblue('simulation-mode')+', no change '\
         'will be made.'
  else
    opne "#{rev}Creating a directory at #{sdir(this_directory)} #{rev}next."
    create_directory(this_directory, :be_quiet) # Also create a Settings/ subdir:
  end
end

#deconstruct_the_commandline_arguments_if_there_is_more_than_one_of_themObject

#

deconstruct_the_commandline_arguments_if_there_is_more_than_one_of_them

#


604
605
606
607
608
609
610
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 604

def deconstruct_the_commandline_arguments_if_there_is_more_than_one_of_them
  if commandline_arguments?.size > 1
    _ = commandline_arguments?
    set_program_name(_[0])
    set_program_version(_[1])
  end
end

#determine_program_name_and_program_version_from_this_directory(i = return_pwd) ⇒ Object

#

determine_program_name_and_program_version_from_this_directory

#


684
685
686
687
688
689
690
691
692
693
694
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 684

def determine_program_name_and_program_version_from_this_directory(
    i = return_pwd
  )
  _ = File.basename(i)
  prepend_this_commandline_argument(_.delete('/'))
  if _.include? '-'
    set_program_name(ProgramInformation.return_name(_))
    set_program_version(ProgramInformation.return_version(_))
  end
  set_target_directory(_)
end

#do_create_the_appdirectory_structure(_ = first_non_hyphen_argument? ) ⇒ Object Also known as: create_the_directories, create_directories, create_app_dir_skeleton_at_this_target

#

do_create_the_appdirectory_structure

The ideal situation, as input to this method, would be that the user supplied us with the full, absolute path. But this is not always possible or necessary, as input such as “glib-2.40.0” should also work just fine. The method here, thus, has to distinguish between such different use cases.

#


393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 393

def do_create_the_appdirectory_structure(
    # ====================================================================== #
    # First, determine the target based on the first argument:
    # ====================================================================== #
    _ = first_non_hyphen_argument?
  )
  _ = sanitize_this_argument(_)
  # ======================================================================== #
  # Next we must determine the program name and the program version, as
  # this may be useful at a later time.
  # ======================================================================== #
  if _.include?('-') and !_.include?('/')
    # ====================================================================== #
    # Assume input such as: glib-2.35.3
    # ====================================================================== #
    program_information = ProgramInformation.new(_)
    set_program_name(program_information.program_name?)
    set_program_version(program_information.program_version?)
    _ = internal_programs_directory?+
        program_name?.capitalize+
        '/'+
        program_version?
  else
    # ====================================================================== #
    # Must still determine the correct program name and program version:
    # ====================================================================== #
    if _.count('/') > 1 # For instance: /home/Programs/Glib/2.40.0
      splitted = _.delete_prefix(internal_programs_directory?).split('/')
      # Now the Array may look like this: ["Glib", "2.40.0"]
      set_program_name(splitted.first)
      set_program_version(splitted.last)
      _ = internal_programs_directory?+
          program_name?.capitalize+
          '/'+
          program_version?
    else
      set_program_name(_.delete('/'))
      set_program_version(:default)
    end
  end
  set_work_on_this_target_directory(_) # Determine our target directory.
  target_directory = target_directory?
  notify_the_user_what_will_be_done
  notify_the_user_about_the_target_directory(target_directory)
  create_directory(target_directory) {{ namespace: namespace? }}
  # ========================================================================== #
  # The next clause will NOT be entered if the --blank flag has been
  # passed.
  # ========================================================================== #
  if may_we_continue_past_the_create_the_main_directory_step?
    # ======================================================================== #
    # Next create the subdirectories and the Settings directory:
    # ======================================================================== #
    do_create_the_subdirectories_and_the_settings_directory(target_directory)
    # ======================================================================== #
    # The following instance variable can be used to disable the creation
    # of the Current symlink.
    # ======================================================================== #
    may_we_create_a_current_symlink = may_we_create_a_current_symlink?
    # ======================================================================== #
    # Now we have to create the Current symlink, if this is allowed - the
    # user can disable this functionality:
    # ======================================================================== #
    if may_we_create_a_current_symlink and
      !array_do_not_symlink_these_programs?.include?(program_name?.downcase.to_sym) # ← This check was added on 20.01.2020.
      create_the_current_symlink(target_directory)
    end
  end
  opne mediumseagreen('All done!')
end

#do_create_the_subdirectories(i = target_directory?, , &block) ⇒ Object Also known as: create_these_subdirectories

#

do_create_the_subdirectories

The input argument should be the target directory.

This method will create the various subdirectories.

#


758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 758

def do_create_the_subdirectories(
    i = target_directory?,
    &block
  )
  necessary_subdirectories = necessary_subdirectories?
  opne "#{rev}Several subdirectories will be created in the directory"
  opne "#{sdir(i)} #{rev}next, namely:"
  opne "  #{sdir(necessary_subdirectories.join(', ').strip)}"
  # ======================================================================== #
  # Next create the subdirectories:
  # ======================================================================== #
  necessary_subdirectories.each {|this_subdirectory|
    new_target = "#{i}#{this_subdirectory}"
    # ====================================================================== #
    # Must first consider the case where the RBT suite is running in
    # simulation-mode.
    # ====================================================================== #
    if run_simulation? 
      opne "#{rev}We run in simulation mode, thus we will not"
      opne "create the #{steelblue('subdirectory')}"\
           " #{rev}at `#{sdir(new_target)}`."
    else
      opne "Creating the directory #{sdir(new_target)}"
      mkdir(
        new_target,
        {
          verbosity: :be_quiet,
          permissions: 0755,
          namespace:   namespace?
        }
      )
    end
  }
end

#do_create_the_subdirectories_and_the_settings_directory(i) ⇒ Object

#

do_create_the_subdirectories_and_the_settings_directory

#


469
470
471
472
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 469

def do_create_the_subdirectories_and_the_settings_directory(i)
  do_create_the_subdirectories(i)
  create_settings_directory(i)
end
#
#


324
325
326
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 324

def do_not_create_a_current_symlink
  set_create_current_symlink(false)
end

#do_not_create_anything_aside_from_the_main_directoryObject

#

do_not_create_anything_aside_from_the_main_directory

#


655
656
657
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 655

def do_not_create_anything_aside_from_the_main_directory
  @internal_hash[:may_we_continue_past_the_create_the_main_directory_step] = false
end

#internal_programs_directory?Boolean

#

internal_programs_directory?

#

Returns:

  • (Boolean)


730
731
732
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 730

def internal_programs_directory?
  @internal_hash[:internal_programs_directory]
end

#may_we_continue_past_the_create_the_main_directory_step?Boolean

#

may_we_continue_past_the_create_the_main_directory_step?

#

Returns:

  • (Boolean)


255
256
257
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 255

def may_we_continue_past_the_create_the_main_directory_step?
  @internal_hash[:may_we_continue_past_the_create_the_main_directory_step]
end

#may_we_create_a_current_symlink?Boolean

#
#

Returns:

  • (Boolean)


270
271
272
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 270

def may_we_create_a_current_symlink?
  @internal_hash[:may_we_create_a_current_symlink]
end
#

menu (menu tag)

#


338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 338

def menu(
    i = commandline_arguments_with_leading_hyphens?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # (case tag)
    # ====================================================================== #
    # === rcp --PWD
    # ====================================================================== #
    when /^-?-?PWD$/i
      determine_program_name_and_program_version_from_this_directory(return_pwd)
    # ====================================================================== #
    # === rcp --blank
    #
    # --empty is an alias to this entry point.
    #
    # Usage example:
    #
    #   rcp wesnoth-10.0.0 --blank
    #
    # ====================================================================== #
    when /^-?-?blank$/i,
         /^-?-?empty$/i
      do_not_create_anything_aside_from_the_main_directory
    # ====================================================================== #
    # === rcp --no-current-symlink
    # ====================================================================== #
    when /^-?-?no(-|_| )?current(-|_| )?symlink$/i
      do_not_create_a_current_symlink
    # ====================================================================== #
    # === rcp --hash?
    # ====================================================================== #
    when /^-?-?hash\?$/
      pp return_hash_for_opn
      exit
    # ====================================================================== #
    # === rcp --help
    # ====================================================================== #
    when /^-?-?help$/i
      show_help
      exit
    end
  end
end

#necessary_subdirectories?Boolean Also known as: subdirectories?

#

necessary_subdirectories?

#

Returns:

  • (Boolean)


597
598
599
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 597

def necessary_subdirectories?
  ARRAY_CREATE_THESE_SUBDIRECTORIES
end

#notify_the_user_about_the_target_directory(i = target_directory? ) ⇒ Object

#

notify_the_user_about_the_target_directory

#


477
478
479
480
481
482
483
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 477

def notify_the_user_about_the_target_directory(
    i = target_directory?
  )
  opne "#{rev}Next creating an #{steelblue('AppDir')} #{rev}skeleton "\
       "structure at the target directory"
  opne "#{sdir(i)}"
end

#notify_the_user_what_will_be_doneObject

#

notify_the_user_what_will_be_done

Feedback information back to the user.

In June 2007 the amount of information displayed throught his method was reduced. Currently this method is invoked whenever this class creates the main directory hierarchy.

#


494
495
496
497
498
499
500
501
502
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 494

def notify_the_user_what_will_be_done
  opnn; ee sfancy(return_program_name_and_program_version.downcase)
  if be_verbose?
    ee " #{rev}(#{simp('Program name')}: #{sfancy(program_name?)}"\
       "#{rev} and #{simp('Program Version')}#{rev}: "\
       "#{sfancy(program_version?)}#{rev})"
  end
  e # And a newline afterwards.
end

#opnn(&block) ⇒ Object

#

opnn (opnn tag)

#


331
332
333
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 331

def opnn(&block)
  super(return_hash_for_opn, &block)
end

#program_name?Boolean Also known as: program_name, name, name?

#

program_name?

#

Returns:

  • (Boolean)


545
546
547
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 545

def program_name?
  @internal_hash[:program_name]
end

#program_version?Boolean Also known as: version?, version

#

program_version?

#

Returns:

  • (Boolean)


554
555
556
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 554

def program_version?
  @internal_hash[:program_version]
end

#resetObject

#

reset (reset tag)

#


208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 208

def reset
  super()
  infer_the_namespace
  # ======================================================================== #
  # === :hash_for_opn
  # ======================================================================== #
  @internal_hash[:hash_for_opn] = return_hash_for_opn
  # ======================================================================== #
  # === :may_we_create_a_current_symlink
  # ======================================================================== #
  @internal_hash[:may_we_create_a_current_symlink] = true
  # ======================================================================== #
  # === :may_we_continue_past_the_create_the_main_directory_step
  # ======================================================================== #
  @internal_hash[:may_we_continue_past_the_create_the_main_directory_step] = true
  # ======================================================================== #
  # === :array_do_not_symlink_these_programs
  #
  # The following Array will skip setting the symlink called
  # 'Current'. This is necessary sometimes for when we upgrade
  # certain programs, such as make, as the symlinkat /usr/bin/make
  # must work at all times, if we are to compile software from
  # source via an AppDir based approach.
  #
  # A constant will populate this Array initialize. This has been
  # confirmed in September 2022.
  # ======================================================================== #
  @internal_hash[:array_do_not_symlink_these_programs] = ARRAY_KEEP_SYMLINKS_FOR_THESE_PROGRAMS
  # ======================================================================== #
  # === :internal_programs_directory
  #
  # We need to use another internal programs directory, so that we
  # can modify the target of this class.
  # ======================================================================== #
  @internal_hash[:internal_programs_directory] = programs_directory?
end

#return_hash_for_opnObject

#

return_hash_for_opn

#


277
278
279
280
281
282
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 277

def return_hash_for_opn
 {
   namespace:   namespace?,
   use_colours: use_colours?
 }
end

#return_inferred_path_from_the_program_name_and_the_program_version(program_name = program_name?, , program_version = program_version? ) ⇒ Object Also known as: full_target?

#

return_inferred_path_from_the_program_name_and_the_program_version

This method will assemble the proper base directory under the local AppDir (/Programs) hierarchy, including the program name, and the program version at hand.

It will thus assume (infer) a path.

In order for this to work, both @program_name and @program_version must have been determined.

#


624
625
626
627
628
629
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 624

def return_inferred_path_from_the_program_name_and_the_program_version(
    program_name    = program_name?,
    program_version = program_version?
  )
  "#{program_dir?}#{program_name.capitalize}/#{program_version}/"
end

#return_program_name_and_program_versionObject

#

return_program_name_and_program_version

#


287
288
289
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 287

def return_program_name_and_program_version
  "#{program_name?.capitalize}-#{program_version?}"
end

#runObject

#

run (run tag)

#


796
797
798
799
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 796

def run
  menu
  do_create_the_appdirectory_structure
end

#sanitize_this_argument(i) ⇒ Object

#

sanitize_this_argument

#


699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 699

def sanitize_this_argument(i)
  i = i.flatten.first.to_s if i.is_a? Array
  if is_an_archive?(i)
    i = remove_archive_at_the_end(i.dup)
  end
  # ======================================================================== #
  # Next comes a bit of an ad-hoc sanitizing event. In the past we
  # also removed every '_' in the string, but since as of April 2019
  # this was realised to not be ideal, due to input such as
  # "LibreOffice_6.2.2.2" which is valid. Thus, only the first '_'
  # is replaced with a '-', if there is only a single '_' in that
  # string.
  # ======================================================================== #
  if i.end_with? '_Linux_x86-64'
    i.delete_suffix!('_Linux_x86-64')
  end
  if i.include?('_') and
    (i.count('_') == 1) and
    !i.include?('-')
    i.tr!('_','-') # Example: "LibreOffice_96.2.2.2"
  end
  if i.end_with?('/') and (i.count('/') == 1)
    i = i.dup if i.frozen?
    i.chop!
  end
  return i
end
#
#


262
263
264
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 262

def set_may_we_create_a_current_symlink(i)
  @internal_hash[:may_we_create_a_current_symlink] = i
end

#set_program_name(i = '') ⇒ Object

#

set_program_name

#


737
738
739
740
741
742
743
744
745
746
747
748
749
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 737

def set_program_name(
    i = ''
  )
  if i
    i = i.dup
    i.downcase! # ← This is always done. On GoboLinux, we may have to change this lateron.
    i.delete!('-') if i.include? '-'
    if is_on_gobolinux?
      i = return_program_name_for_gobolinux_systems(i)
    end
  end
  @internal_hash[:program_name] = i
end

#set_program_version(i = DEFAULT_PROGRAM_VERSION) ⇒ Object Also known as: set_version

#

set_program_version

This method will set the program version of our program at hand.

1.0.0 is the default program version to use.

#


522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 522

def set_program_version(
    i = DEFAULT_PROGRAM_VERSION
  )
  case i
  # ======================================================================== #
  # === :default
  # ======================================================================== #
  when :default
    i = DEFAULT_PROGRAM_VERSION
  end
  i = i.dup if i.frozen?
  i.chop! if i.end_with? '.'
  # ======================================================================== #
  # Get rid of any possible file extensions next.
  # ======================================================================== #
  i = remove_file_extension(i) if i.include? '.'
  i.delete!('/') if i.include? '/'
  @internal_hash[:program_version] = i
end

#set_work_on_this_target_directory(i) ⇒ Object Also known as: set_target_directory

#

set_work_on_this_target_directory

This method will simply do a full assignment, without any further checks.

#


638
639
640
641
642
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 638

def set_work_on_this_target_directory(i)
  i = i.dup if i.frozen?
  i << '/' unless i.end_with?('/')
  @internal_hash[:work_on_this_target_directory] = i
end

#show_helpObject

#

show_help (help tag)

Invocation example:

rcp --help
#


299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 299

def show_help
  programs_dir = internal_programs_directory?
  opnn { :no_trailing }
  e
  e
  e "This class will create programs under the "\
    "#{sdir(programs_dir)} #{rev}hierarchy."
  e
  e 'You can test this class by issuing any of the following:'
  e
  efancy "  rcp #{programs_dir}Htop/1.0.1"
  efancy '  rcp htop-1.0.1'
  e
  e 'A few commandline flags are supported. For instance, you can'
  e 'use --blank or --empty to avoid creating any directory, file'
  e 'or symlink in the target (main) directory that will be created.'
  e 'This may be useful in some situations, such as when the meson'
  e 'build system would otherwise complain about already existing'
  e 'directories. In most cases, though, --blank or --empty will'
  e 'be rarely needed.'
end

#target_directory_and_program_name?Boolean

#

target_directory_and_program_name?

This method will return a String that includes the target directory, and the program name at hand. It also MUST return a trailing ‘/’ character.

#

Returns:

  • (Boolean)


511
512
513
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 511

def target_directory_and_program_name?
  "#{internal_programs_directory?}#{program_name?.capitalize}/"
end

#work_on_this_target_directory?Boolean Also known as: target?, target_directory?

#

work_on_this_target_directory?

#

Returns:

  • (Boolean)


647
648
649
# File 'lib/rbt/actions/individual_actions/create_app_dir_skeleton/create_app_dir_skeleton.rb', line 647

def work_on_this_target_directory?
  @internal_hash[:work_on_this_target_directory]
end