Class: RBT::Action::Cookbooks::SuggestCookbookFor

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

Overview

RBT::Action::Cookbooks::SuggestCookbookFor

Constant Summary

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, #opnn, #otomato, #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_name, #return_program_name_for_gobolinux_systems, #return_program_name_via_program_information, #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, #rpn, #run_simulation=, #run_simulation?, #sdir, #sdir_return_pwd, #set_be_silent, #set_be_verbose, #set_first_commandline_argument, #set_namespace, #set_use_colours, #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 = nil, run_already = true) ⇒ SuggestCookbookFor

#

initialize

#


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 37

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  # ======================================================================= #
  # Next, we infer the program name at once.
  # ======================================================================= #
  infer_program_name_from(
    first_argument?
  )
  if block_given?
    yielded = yield
    case yielded
    when :do_not_report
      @report_the_result = false 
    end
  end
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

RBT::Action::Cookbooks::SuggestCookbookFor[]

#


789
790
791
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 789

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

Instance Method Details

#add(i, append_newline = true) ⇒ Object

#

add (add tag)

This method will simply add (aka append) onto the @result variable.

#


175
176
177
178
179
180
181
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 175

def add(i, append_newline = true)
  if append_newline
    i = i.dup if i.frozen?
    i << "\n"
  end
  @result << i
end

#binaries?Boolean

#

binaries?

#

Returns:

  • (Boolean)


118
119
120
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 118

def binaries?
  @binaries
end

#blfs_entry?Boolean

#

blfs_entry?

#

Returns:

  • (Boolean)


278
279
280
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 278

def blfs_entry?
  @dataset_from_the_expanded_cookbooks_directory[:blfs]
end

#configure_base_dir?Boolean

#

configure_base_dir?

#

Returns:

  • (Boolean)


318
319
320
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 318

def configure_base_dir?
  @dataset_from_the_expanded_cookbooks_directory[:configure_base_dir]
end

#configure_options?Boolean

#

configure_options?

#

Returns:

  • (Boolean)


292
293
294
295
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 292

def configure_options?
  @dataset_from_the_expanded_cookbooks_directory and
  @dataset_from_the_expanded_cookbooks_directory[:configure_options]
end

#dataset_from_the_expanded_cookbooks_directory?Boolean Also known as: expanded_dataset?, main_dataset?, expanded_cookbooks?

#

dataset_from_the_expanded_cookbooks_directory?

#

Returns:

  • (Boolean)


125
126
127
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 125

def dataset_from_the_expanded_cookbooks_directory?
  @dataset_from_the_expanded_cookbooks_directory
end

#description?(pad_so_that_the_lines_are_all_equal = true) ⇒ Boolean

#

description?

#

Returns:

  • (Boolean)


300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 300

def description?(pad_so_that_the_lines_are_all_equal = true)
  _ = @dataset_from_the_expanded_cookbooks_directory[:description].to_s
  _ = word_wrap(_, 74).strip
  if pad_so_that_the_lines_are_all_equal
    splitted = _.split("\n").map {|entry|
      unless entry.start_with? '  '
        entry.prepend('  ')
      end
      entry
    }
    _ = splitted.join("\n")
  end
  _.strip
end

#has_blfs_entry?(use_this_key = 'blfs') ⇒ Boolean

#

has_blfs_entry?

#

Returns:

  • (Boolean)


204
205
206
207
208
209
210
211
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 204

def has_blfs_entry?(
    use_this_key = 'blfs'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  expanded_dataset? and
  expanded_dataset?.has_key?(use_this_key) and
 !expanded_dataset?[use_this_key].empty? # ← We only care about non-empty Arrays here.
end

#has_configure_base_directory_entry?Boolean

#

has_configure_base_directory_entry?

#

Returns:

  • (Boolean)


226
227
228
229
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 226

def has_configure_base_directory_entry?
  expanded_dataset? and
  expanded_dataset?.has_key?('configure_base_dir')
end

#has_homepage_entry?(use_this_key = 'homepage') ⇒ Boolean

#

has_homepage_entry?

#

Returns:

  • (Boolean)


216
217
218
219
220
221
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 216

def has_homepage_entry?(
    use_this_key = 'homepage'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  expanded_dataset?.has_key?(use_this_key)
end

#has_required_deps?(use_this_key = 'required_deps_on') ⇒ Boolean

#

has_required_deps?

#

Returns:

  • (Boolean)


193
194
195
196
197
198
199
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 193

def has_required_deps?(
    use_this_key = 'required_deps_on'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  expanded_dataset?.has_key?(use_this_key) and
 !expanded_dataset?[use_this_key].empty?
end

#has_sed_entry?(use_this_key = 'sed') ⇒ Boolean

#

has_sed_entry?

#

Returns:

  • (Boolean)


750
751
752
753
754
755
756
757
758
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 750

def has_sed_entry?(
    use_this_key = 'sed'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  expanded_dataset? and
  expanded_dataset?.has_key?(use_this_key) and
  expanded_dataset?[use_this_key] and
 !expanded_dataset?[use_this_key].empty?
end

#has_url1_entry?(use_this_key = 'url1') ⇒ Boolean

#

has_url1_entry?

#

Returns:

  • (Boolean)


234
235
236
237
238
239
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 234

def has_url1_entry?(
    use_this_key = 'url1'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  expanded_dataset?.has_key?(use_this_key)
end

#has_url2_entry?(use_this_key = 'url2') ⇒ Boolean

#

has_url2_entry?

#

Returns:

  • (Boolean)


244
245
246
247
248
249
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 244

def has_url2_entry?(
    use_this_key = 'url2'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  expanded_dataset?.has_key?(use_this_key)
end

#homepage_entry?Boolean

#

homepage_entry?

#

Returns:

  • (Boolean)


271
272
273
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 271

def homepage_entry?
  @dataset_from_the_expanded_cookbooks_directory[:homepage]
end

#infer_program_name_from(i) ⇒ Object

#

infer_program_name_from

#


148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 148

def infer_program_name_from(i)
  # ======================================================================= #
  # Note that @program_name is not allowed to have a trailing '.yml'
  # component.
  # ======================================================================= #
  @program_name = i.to_s.downcase.delete('-').
                                  delete_suffix('.yml')
  @name_of_the_cookbook_file = "#{@program_name}.yml"
  # ======================================================================= #
  # We have to check whether an expanded cookbook dataset exists. If
  # so then we can infer information from this file.
  # ======================================================================= #
  if expanded_cookbooks_directory_exists?
    this_file = directory_expanded_cookbooks?+@name_of_the_cookbook_file
    if File.exist? this_file
      @dataset_from_the_expanded_cookbooks_directory = load_yaml(
        this_file
      )
    end
  end
end

#libraries?Boolean

#

libraries?

#

Returns:

  • (Boolean)


111
112
113
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 111

def libraries?
  @libraries
end
#

menu (menu tag)

#


668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 668

def menu(
    i = return_commandline_arguments_with_leading_hyphens
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === --help
    #
    # Invocation example:
    #
    #   suggest_cookbook_for glibc --do-not-truncate
    #
    # ===================================================================== #
    when /help$/i
      show_help
      exit
    end
  end
end

#program_name?Boolean Also known as: input?

#

program_name?

#

Returns:

  • (Boolean)


141
142
143
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 141

def program_name?
  @program_name
end

#program_version?Boolean

#

program_version?

#

Returns:

  • (Boolean)


254
255
256
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 254

def program_version?
  @dataset_from_the_expanded_cookbooks_directory[:program_version]
end

#report_something?Boolean

#

report_something?

#

Returns:

  • (Boolean)


134
135
136
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 134

def report_something?
  @report_the_result
end

#report_whether_there_exists_an_expanded_cookbook_dataset_for(i) ⇒ Object

#

report_whether_there_exists_an_expanded_cookbook_dataset_for

#


621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 621

def report_whether_there_exists_an_expanded_cookbook_dataset_for(i)
  i = i.dup
  i << '.yml' unless i.end_with? '.yml'
  _ = directory_expanded_cookbooks?+i
  if report_something?
    if File.exist?(_)
      opne "#{rev}We will additionally make use of the expanded cookbook"
      opne "#{rev}dataset for `#{sfancy(i)}#{rev}`."
    else
      # ===================================================================== #
      # We will report if we are on roebe.
      # ===================================================================== #
      if is_on_roebe?
        opne "#{rev}There is no expanded cookbook dataset for `"\
             "#{sfile(@program_name)}#{rev}`."
        opne 'A new one can be generated via:'
        e
        e "  expand_cookbooks #{sfile(@program_name)}"
        e
      end
    end
  end
end

#required_deps_on?Boolean

#

required_deps_on?

#

Returns:

  • (Boolean)


285
286
287
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 285

def required_deps_on?
  @dataset_from_the_expanded_cookbooks_directory[:required_deps_on]
end

#resetObject

#

reset (reset tag)

#


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 64

def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @dataset_from_the_expanded_cookbooks_directory
  # ======================================================================= #
  @dataset_from_the_expanded_cookbooks_directory = nil
  # ======================================================================= #
  # === @program_name
  # ======================================================================= #
  @program_name = nil
  # ======================================================================= #
  # === @result
  # ======================================================================= #
  @result = ''.dup
  # ======================================================================= #
  # === @report_the_result
  # ======================================================================= #
  @report_the_result = true
  # ======================================================================= #
  # === @libraries
  #
  # We store found libraries in this Array here.
  # ======================================================================= #
  @libraries = []
  # ======================================================================= #
  # === @binaries
  #
  # We store found binaries in this Array here.
  # ======================================================================= #
  @binaries  = []
  # ======================================================================= #
  # === @use_symbols_or_strings_for_the_key
  # ======================================================================= #
  @use_symbols_or_strings_for_the_key = :symbols
end

#result?Boolean

#

result?

#

Returns:

  • (Boolean)


186
187
188
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 186

def result?
  @result
end

#return_licence(use_this_key = 'licence') ⇒ Object

#

return_licence

#


658
659
660
661
662
663
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 658

def return_licence(
    use_this_key = 'licence'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  return expanded_dataset?[use_this_key].to_s
end

#runObject

#

run (run tag)

#


778
779
780
781
782
783
784
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 778

def run
  menu(
    return_commandline_arguments_with_leading_hyphens
  )
  try_to_obtain_information_from_the_corresponding_appdir_subdirectory_of_the_program
  try_to_report if @report_the_result
end

#sanitize_binaries_entriesObject

#

sanitize_binaries_entries

#


593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 593

def sanitize_binaries_entries
  # ======================================================================= #
  # The following regex will get rid of the absolute path entries.
  # ======================================================================= #
  _ = appdir_location_of?(@program_name)
  quoted_regex_for_bin_entries  = Regexp.quote("#{_}/bin/")
  quoted_regex_for_sbin_entries = Regexp.quote("#{_}/sbin/")
  @binaries.flatten!
  @binaries.map! {|binary_file|
    binary_file.sub(quoted_regex_for_bin_entries,  '').
                sub(quoted_regex_for_sbin_entries, '')
  }
end

#sanitize_libraries_entriesObject

#

sanitize_libraries_entries

#


716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 716

def sanitize_libraries_entries
  # ======================================================================= #
  # We must deduct all entries that contain the word 'pkgconfig' from
  # this Array, as the pkgconfig entry will have its own separate
  # entry here.
  # ======================================================================= #
  @libraries.reject! {|line|
    # ===================================================================== #
    # Directories will also be skipped.
    # ===================================================================== #
    line.include? 'pkgconfig' or File.directory?(line) or
    line.end_with?('.dll')
  }
  _ = appdir_location_of?(@program_name)
  # ======================================================================= #
  # Check for broken symlinks.
  # ======================================================================= #
  if File.symlink?(_) and !File.exist?(_)
    opne 'A broken symlink was found at `'+steelblue(_)+'`.'
    opne 'Please fix this manually before this class can continue.'
    exit
  end
  # ======================================================================= #
  # The following regex will get rid of the absolute path entries.
  # ======================================================================= #
  quoted_regex = Regexp.quote("#{_}/lib/")
  @libraries.map! {|library_file|
    library_file.sub(quoted_regex, '')
  }
end

#sed?(use_this_key = 'sed') ⇒ Boolean

#

sed?

#

Returns:

  • (Boolean)


763
764
765
766
767
768
769
770
771
772
773
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 763

def sed?(
    use_this_key = 'sed'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  result = expanded_dataset?[use_this_key].flatten
  if result.is_a? Array
    result = result.join("\n")
  end
  result = result.to_s.tr("\n",' ').squeeze(' ')
  result
end

#short_desc?Boolean

#

short_desc?

This method will only work if the expanded-cookbook dataset exits.

#

Returns:

  • (Boolean)


263
264
265
266
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 263

def short_desc?
  @dataset_from_the_expanded_cookbooks_directory and
  @dataset_from_the_expanded_cookbooks_directory[:short_description]
end

#show_helpObject

#

show_help (help tag)

#


693
694
695
696
697
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 693

def show_help
  e
  e '  --do-not-truncate # do not truncate the result at all'
  e
end

#try_to_obtain_information_from_the_corresponding_appdir_subdirectory_of_the_programObject

#

try_to_obtain_information_from_the_corresponding_appdir_subdirectory_of_the_program

This is the method that will try to obtain as much information as necessary in order to display the result on the commandline.

#


328
329
330
331
332
333
334
335
336
337
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
383
384
385
386
387
388
389
390
391
392
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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 328

def try_to_obtain_information_from_the_corresponding_appdir_subdirectory_of_the_program
  if report_something?
    opne "Next trying to display the guessed content for `"\
         "#{sfile(@name_of_the_cookbook_file)}`."
  end
  report_whether_there_exists_an_expanded_cookbook_dataset_for(
    @program_name
  )
  _ = appdir_location_of?(@program_name)
  is_a_symlink = File.symlink?(_)
  # ======================================================================= #
  # ^^^ This variable may be a String such as "/Programs/Cluttergtk/Current".
  # This may not exist, though, if it is a symlink and has been deleted
  # or not (yet) created. So we will try to do an additional check if we
  # are on roebe - we will check if there is any directory that starts
  # with a number, such as '18.0.2'.
  # ======================================================================= #
  if is_on_roebe? and !File.exist?(_)
    dirname = "#{File.dirname(_)}/"
    subdirectories_in_that_directory = Dir[dirname+'*'].select {|entry|
      File.directory?(entry)
    }
    # ===================================================================== #
    # Must check whether we have found any subdirectories or not:
    # ===================================================================== #
    unless subdirectories_in_that_directory.empty?
      subdirectories_in_that_directory.select! {|entry|
        File.basename(entry).start_with?(/\d+/)
      }
      unless subdirectories_in_that_directory.empty?
        _ = subdirectories_in_that_directory.first # Grab the first entry.
        is_a_symlink = true # This is hackish but we need it to continue, below.
      end
    end
  end
  # ======================================================================= #
  # Obtain a "pointer" towards the main dataset.
  # ======================================================================= #
  main_dataset = main_dataset?
  if File.exist?(_) and is_a_symlink
    # ===================================================================== #
    # Headers are typically .h files, but also .hpp for C++. This
    # explains the next line of code.
    # On 05.12.2019 this was changed - .hpp are not so useful, so let's
    # not include them.
    # ===================================================================== #
    # headers         = Dir["#{_}/include/**/**.{h,hpp}"].sort
    headers         = Dir["#{_}/include/**/**.{h}"].sort
    @libraries      = Dir["#{_}/lib/**/**"].sort
    sanitize_libraries_entries
    @binaries       = Dir["#{_}/bin/**"].sort
    # ===================================================================== #
    # We will also append entries found under sbin/, if this directory
    # exists.
    # ===================================================================== #
    if File.directory? "#{_}/sbin/"
      @binaries       << Dir["#{_}/sbin/**"].sort
    end
    sanitize_binaries_entries
    # ===================================================================== #
    # We first have to add the program name - this one comes ALWAYS on top.
    # ===================================================================== #
    add @program_name+':'
    # ===================================================================== #
    # Next we will consider adding a blfs entry, but this has to be
    # optional because not every program has a registered blfs entry.
    # ===================================================================== #
    if expanded_cookbooks_directory_exists? and
       has_blfs_entry?
      add ' blfs:'
      blfs_entry = blfs_entry?
      blfs_entry = blfs_entry.first if blfs_entry.is_a? Array
      add " - #{blfs_entry}"
    else
      # ===================================================================== #
      # else we will add a stub towards linuxfromscratch.org
      # ===================================================================== #
      add ' # blfs:'
      add ' # - https://www.linuxfromscratch.org/blfs/view/cvs/general/glib2.html'
    end
    # ===================================================================== #
    # Next, consider adding binaries entries, if these exist.
    # ===================================================================== #
    if @binaries.empty?
      add ' # binaries:'
    else
      add ' binaries:'
      quoted_regex = Regexp.quote(_+'/bin/')
      @binaries.each {|this_binary|
        add ' - '+this_binary.sub(quoted_regex, '')
      }
    end
    # ===================================================================== #
    # We have to check whether the expanded cookbooks-dataset also
    # contains an entry called configure_base_dir. If it does we
    # will make use of it.
    # ===================================================================== #
    if expanded_cookbooks_directory_exists? and
       has_configure_base_directory_entry? and
       main_dataset
       add ' configure_base_dir: '+configure_base_dir?
    end
    # ===================================================================== #
    # Next, add the configure options:
    # ===================================================================== #
    add ' configure_options: |'
    if expanded_cookbooks_directory_exists? and
       main_dataset # Must check that we have found something here.
      the_configure_options = configure_options?.dup.to_s
      # ===================================================================== #
      # We can modify/simplify the configure options a bit, if they
      # contain at the least one '--' set.
      # ===================================================================== #
      if the_configure_options.include? '--'
        the_configure_options.gsub!(/--/, "\n  ")
        the_configure_options << "\n"
      end
      add "  #{the_configure_options}" unless the_configure_options.empty?
    end
    # ===================================================================== #
    # Now we will add the short_description tag.
    # ===================================================================== #
    add " short_description: |\n"
    if expanded_cookbooks_directory_exists? and
       main_dataset
      add "  #{short_desc?}\n" if short_desc?
    end
    add " description: |\n"
    if expanded_cookbooks_directory_exists? and
       main_dataset
      add "  #{description?}\n"
    end
    add " extra_information: |\n"
    add ' licence: '+return_licence.to_s
    # ===================================================================== #
    # Next add the url1 entry:
    # ===================================================================== #
    if expanded_cookbooks_directory_exists? and
       main_dataset and
       has_url1_entry?
      add " url1: #{url1?}"
    else
      add ' url1: '
    end
    if expanded_cookbooks_directory_exists? and
       main_dataset and
       has_url2_entry?
      add " url2: #{url2?}"
    else
      add ' url2: '
    end
    if expanded_cookbooks_directory_exists? and
       main_dataset and
       has_homepage_entry?
      add " homepage: #{homepage_entry?}"
    else 
      add ' homepage: '
    end
    # ===================================================================== #
    # === .gir files
    #
    # Next, consider adding .gir files - if they exist.
    # ===================================================================== #
    gir_files = Dir["#{_}/share/gir-1.0/**.{gir}"].sort
    unless gir_files.empty?
      add ' gir_files:'
      gir_files.each {|gir_file|
        gir_file = gir_file.dup if gir_file.frozen?
        gir_file.strip!
        gir_file.sub!("#{_}/share/gir-1.0/", '')
        add " - #{gir_file}"
      }
    end
    # ===================================================================== #
    # === Headers
    #
    # Next, consider adding headers - if they exist.
    # ===================================================================== #
    unless headers.empty?
      add ' symlink_headers: yes'
      add ' headers:'
      quoted_regex = Regexp.quote("#{_}/include/")
      headers.each {|header_file|
        add " - #{header_file.sub(quoted_regex, '')}"
      }
    end
    # ===================================================================== #
    # Next, consider adding the libraries-section:
    # ===================================================================== #
    unless @libraries.empty?
      add ' libraries:'
      @libraries.each {|library_file|
        add ' - '+library_file
      }
    end
    # ===================================================================== #
    # Add the pkg-config .pc files next, if they exist.
    # ===================================================================== #
    pkgconfig_files = Dir["#{_}/lib/pkgconfig/**"].sort.select {|file|
      file.end_with? '.pc' # ← Only use .pc files.
    }
    unless pkgconfig_files.empty?
      add ' symlink_pkgconfig_files: yes'
      add ' pkgconfig_files:'
      quoted_regex = Regexp.quote(_+'/lib/pkgconfig/')
      pkgconfig_files.each {|pkgconfig_file|
        add ' - '+pkgconfig_file.sub(quoted_regex, '')
      }
    end
    # ===================================================================== #
    # Add the .m4 files next, if they exist.
    # ===================================================================== #
    m4_files = Dir["#{_}/share/aclocal/*.m4"].sort.select {|file|
      file.end_with? '.m4' # ← Only use .pc files.
    }
    unless m4_files.empty?
      add ' m4_files:'
      quoted_regex = Regexp.quote(_+'/share/aclocal/')
      m4_files.each {|m4_file|
        add ' - '+m4_file.sub(quoted_regex, '')
      }
    end
    # ===================================================================== #
    # Consider adding sed-instructions if they exist:
    # ===================================================================== #
    if has_sed_entry?
      # =================================================================== #
      # Ok, this program has a sed entry, so show it:'
      # =================================================================== #
      add ' sed:'
      add ' - '+sed?
    end
    # ===================================================================== #
    # Add the prefix variable next.
    # ===================================================================== #
    add ' prefix: t'
    add ' keep_extracted: no'
    add ' use_build_directory: '+
        yes_or_no(
          use_build_directory?.to_s,
          :minimalistic
        )
    add ' required_deps_on:'
    if expanded_cookbooks_directory_exists? and
       main_dataset and
       has_required_deps?
      required_deps_on?.each {|dep|
        add " - #{dep}"
      }
    else
      add ' - '
    end
    # ===================================================================== #
    # Next add a last_update entry, in a format like "18 Dec 2018".
    # ===================================================================== #
    add " last_update: "\
        "#{get_date}"
  else
    opnn; no_file_exists_at(_)
  end
end

#try_to_reportObject

#

try_to_report (report tag)

#


610
611
612
613
614
615
616
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 610

def try_to_report
  if @result.empty?
    # Do nothing in this case.
  else
    e @result
  end
end

#url1?Boolean

#

url1?

#

Returns:

  • (Boolean)


702
703
704
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 702

def url1?
  @dataset_from_the_expanded_cookbooks_directory[:url1]
end

#url2?Boolean

#

url2?

#

Returns:

  • (Boolean)


709
710
711
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 709

def url2?
  @dataset_from_the_expanded_cookbooks_directory[:url2]
end

#use_build_directory?(use_this_key = 'use_build_directory') ⇒ Boolean

#

use_build_directory?

#

Returns:

  • (Boolean)


648
649
650
651
652
653
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 648

def use_build_directory?(
    use_this_key = 'use_build_directory'
  )
  use_this_key = use_this_key.to_sym if use_symbols?
  return expanded_dataset?[use_this_key].to_s
end

#use_symbols?Boolean

#

use_symbols?

#

Returns:

  • (Boolean)


104
105
106
# File 'lib/rbt/actions/individual_actions/cookbooks/suggest_cookbook_for/suggest_cookbook_for.rb', line 104

def use_symbols?
  @use_symbols_or_strings_for_the_key == :symbols
end