Class: RBT::Cookbooks::SearchForTags

Inherits:
Base show all
Defined in:
lib/rbt/cookbooks/search_for_tags/search_for_tags.rb

Overview

RBT::Cookbooks::SearchForTags

Constant Summary collapse

USE_XORG_BUFFER =
#

USE_XORG_BUFFER

This constant can be set to automatically set the xorg buffer.

This may be useful sometimes - but it can also be annoying, which is why it is a constant that can be toggled by the user.

#
false
DEFAULT_SEARCH_TAG =
#

DEFAULT_SEARCH_TAG

#
'gnome'
USE_THIS_DELAY =
#

USE_THIS_DELAY

If we open in the editor, we will use this delay.

#
0.45
EXIT_ON_EMPTY_DIRECTORIES =
#

EXIT_ON_EMPTY_DIRECTORIES

Whether to exit on empty directories or whether not.

#
false

Constants inherited from LeanPrototype

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

Instance Method Summary collapse

Methods inherited from Base

#cat, #cd_back_to_the_current_working_directory, #consider_reporting_how_many_programs_are_registered, #cookbook_files?, #copy_recursively, #delete_code_of_conduct?, #determine_appdir_prefix_from_this_input, #directory_validation?, #do_not_show_names, #fast_return_file_size_of_this_program, #file_last_symlinked_program?, #file_programs_version_url, #gem_version, #is_a_64bit_system?, #is_ccache_available?, #is_porg_available?, #is_this_binary_registered?, #is_this_program_included?, #make_command?, #make_install_command?, #new_cookbook_instance_for, #program_exists?, #publish_list_of_all_programs_version, #rcp, registered_binaries?, #remove_symlink, #rename_kde_konsole_tab, #repackage, #report_n_programs, #report_working_directory, #return_compile_time_statistics, #return_n_random_characters, #return_version_of_this_program, #run_make_then_make_install, #sanitize_url1_entry, #set_source_directory, #show_overview_over_available_utility_scripts, #symlink_all_files_from_this_directory_to_that_directory, #system_tags?, #upload_list_of_all_programs_version, #use_yaml_database_for_tags?, #warn_and_exit, #wget

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(search_for = DEFAULT_SEARCH_TAG, run_already = true) ⇒ SearchForTags

#

initialize

#


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 87

def initialize(
    search_for  = DEFAULT_SEARCH_TAG, # This variable is usually an Array.
    run_already = true
  )
  reset
  if search_for.is_a? Array
    if search_for.any? {|entry| entry.start_with? '--' }
      # =================================================================== #
      # Ok, this will be treated as a commandline-instruction then.
      # =================================================================== #
      _ = search_for.select {|inner_entry| inner_entry.start_with? '--' }
      menu(_)
      search_for.reject! {|inner_entry| inner_entry.start_with? '--' }
    end
  end
  set_search_for(search_for)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_quiet
    # ===================================================================== #
    when :be_quiet
      set_be_quiet
    end
  end
  run if run_already
end

Instance Method Details

#also_show_url?Boolean

#

also_show_url?

#

Returns:

  • (Boolean)


359
360
361
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 359

def also_show_url?
  @also_show_url
end

#append_to_buffer(i) ⇒ Object

#

append_to_buffer

#


385
386
387
388
389
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 385

def append_to_buffer(i)
  if use_xorg_buffer?
    @xorg_buffer_string << i
  end
end

#array_of_programs?Boolean Also known as: array_of_programs

#

array_of_programs?

#

Returns:

  • (Boolean)


329
330
331
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 329

def array_of_programs?
  @array_of_programs
end

#calculate_and_display_the_filesize_of(this_file) ⇒ Object

#

calculate_and_display_the_filesize_of

We will calculate the filesize of the given program at hand.

#


252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 252

def calculate_and_display_the_filesize_of(this_file)
  this_file = this_file.dup.map {|entry|
    source_directory?+
      File.basename(entry.split(':').first).sub(/\.yml$/,'')+
      '/'
  }
  total_size = 0
  this_file.each {|entry|
    entries = Dir[entry+'*']
    if entries.size == 0
      # =================================================================== #
      # Report empty directories, but only if the entry "do_not_download"
      # was not set.
      # =================================================================== #
      program = File.basename(entry).downcase
      _ = action(:SanitizeCookbook, program) { :fast }
      unless _.do_not_download?
        if File.directory? entry # Only report it if it exists.
          opne 'We found an empty directory here, at `'+sdir(entry)+'`.'
        end
      end
      exit if EXIT_ON_EMPTY_DIRECTORIES
    end
    if entries.first
      total_size += File.size(entries.first) if File.exist? entries.first
    end
  }
  total_filesize = ( total_size.to_f/1024/1024 ).round(2).to_s
  if be_verbose?
    result = "#{rev}#{N}The total filesize is #{sfancy(total_size.to_s)} "\
             "#{rev}bytes. (This is #{simp(total_filesize)}#{rev} MB)"
    e result
  end
end

#display_every_tag(also_show_the_specific_tags = true) ⇒ Object

#

display_every_tag

This method will show every available tag.

If the argument also_show_the_specific_tags is set to true then we will also show the specific tag.

To invoke this, do:

tags ALL
#


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
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 412

def display_every_tag(
    also_show_the_specific_tags = true
  )
  array = [] # This array will keep our results.
  all_programs = available_programs?
  all_programs.each {|program|
    opne "#{rev}Checking on the program `#{sfancy(program)}#{rev}` next:"
    begin
      _ = action(:SanitizeCookbook, program) { :fast }
    rescue Exception => error
      opnn; pp error
      opne program
    end
    if _
      begin
        if _.has_tags?
          e 'Yes, it has tags.'
          array << [ program, _.return_tags ] if also_show_the_specific_tags
        else # Else, it has no tags.
          # e 'No, it has no tags.'
          array << [ program, '']
        end
      rescue Exception; end
    else
      owarn "We did not find anything about `#{simp(program)}#{swarn('`.')}"
      owarn 'This is considered a fatal error for now, thus exiting.'
      exit
    end
  }
  # ======================================================================= #
  # Now report that array:
  # ======================================================================= #
  opne "#{rev}Next reporting these results:"
  array.sort_by {|key, value| value }.each {|key,value|
    value = skyblue(value) if Object.const_defined? :Colours
    e ("#{key}: ").ljust(left_padding?)+value
  }
end

#do_not_show_the_indexObject

#

do_not_show_the_index

#


345
346
347
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 345

def do_not_show_the_index
  @show_index = false
end

#left_padding?Boolean

#

left_padding?

#

Returns:

  • (Boolean)


352
353
354
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 352

def left_padding?
  28
end
#

menu (menu tag)

#


184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
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
244
245
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 184

def menu(
    i = search_for?
  )
  if i.is_a? Array
    i.map! {|entry| menu(entry) }
    set_search_for(i)
  else
    case i # case tag
    # ===================================================================== #
    # === search_for_tags OPEN_ALL
    # ===================================================================== #
    when /^OPEN$/i,
         /^-?-?open(-|_| )?all$/i,
         /^-?-?open(-|_| )?in(-|_| )?editor/i # stag mate --open-in-editor
      @also_open_every_entry_in_the_editor = true
      i = nil
    # ===================================================================== #
    # === search_for_tags WITH_URL
    # ===================================================================== #
    when 'WITH_URL',
         'WURL',
         'USE_URL',
         /WITH/,
         /URL/,
         /^-?-?with(-|_| )?url$/i
      @also_show_url = true
      i = nil # Remove it.
    # ===================================================================== #
    # === search_for_tags --available
    # ===================================================================== #
    when /^-?-?available$/i
      show_available_tags
      exit
    # ===================================================================== #
    # === search_for_tags --no-index
    # ===================================================================== #
    when /^-?-?do(-|_)?not(-|_)?show(-|_)?the(-|_)?index$/,
         /^-?-?no(-|_)?index$/i,
         /^-?-?no(-|_)?numbers/i,
         'NO_NUMBERING','-nix'
      do_not_show_the_index
    # ===================================================================== #
    # === search_for_tags --help
    # ===================================================================== #
    when 'HELP',/-?-?help/,'?'
      show_help
      exit
    # ===================================================================== #
    # === search_for_tags xfce --be_verbose
    # ===================================================================== #
    when /^--be(-|_)?verbose$/
      set_be_verbose
    # ===================================================================== #
    # === search_for_tags ALL
    # ===================================================================== #
    when 'ALL','EVERYTHING'
      display_every_tag
      exit
    end
    i # return it here.
  end
end

#perform_the_searchObject

#

This method will perform the actual search.

We will search through our programs via grep.

#


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
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 550

def perform_the_search
  array_with_the_results = [] # We store the results here.
  # ======================================================================= #
  # The advantage of the yaml database is that it is faster.
  #
  # The disadvantage is that the yaml database must be manually updated.
  #
  # You can do so via file registered_tags.rb or as alias:
  #
  #   regtag
  #
  # ======================================================================= #
  if use_yaml_database_for_tags?
    if be_verbose?
      opne "The #{slateblue('yaml-database')} #{rev}at"
      e
      e "  #{sfile(RBT.file_registered_tags?)}"
      e
      opne 'will be queried for the registered tags.'
    end
    _ = search_term?
    _ = _.first if _.is_a? Array
    if RBT.all_tags?.include? _
      array_with_the_results << RBT.all_tags?[_]
    end
  # ======================================================================= #
  # === Use grep
  # ======================================================================= #
  else # else we use grep.
    if be_verbose?
      opne 'The command grep will be used to perform this search.'
    end
    # ===================================================================== #
    # Next, we have an array stored in @search_for_these_tags since
    # April 2014. We will search for "tags: SEARCH_TERM_HERE".
    # ===================================================================== #
    search_for?.each {|this_tag|
      # =================================================================== #
      # Why do we use grep here and thus depend on it? Simply. Grep is
      # super-fast.
      # =================================================================== #
      _ = 'grep --ignore-case -r "^ tags: '+this_tag+'" '+individual_cookbooks_directory?+'*'
      e _ if be_verbose?
      _ = `#{_}`.split(N)
      _ = _.map {|entry|
        splitted = entry.split(': tags:')
        File.basename(splitted.first).gsub(/\.yml/,'')
      }
      # =================================================================== #
      # Now that we sanitized that temp dataset, we can add it to
      # our array.
      # =================================================================== #
      array_with_the_results << _
    }
  end
  # ======================================================================= #
  # Next, as there may be multiple search tags, we may have to display
  # only the conjoint tags. We will do so next, by using the &
  # intersection operator of ruby.
  # ======================================================================= #
  if array_with_the_results.size > 1
    array_with_the_results = array_with_the_results.first & array_with_the_results[1]
  end
  array_with_the_results.flatten!
  @array_of_programs = array_with_the_results
  unless array_with_the_results.empty?
    if be_verbose?
      e; opne rev+'The results for programs with the tag(s): `'+
              sfancy(search_for?.join(' '))+rev+'` are:'+
              N+N
    end
    # ===================================================================== #
    # Show either with or without index.
    # ===================================================================== #
    array_with_the_results.each_with_index {|the_name, index|
      index = (index+1).to_s
      index = ('%4s' % index)+') '
      the_name = ('%-25s' % the_name.strip) if also_show_url?
      if use_xorg_buffer?
        append_to_buffer(index) if @show_index
        append_to_buffer(the_name)
      end
      _ = ''.dup
      _ << sfancy(index) if @show_index
      _ << "#{rev}#{the_name}" # Composite index and program-name.
      if also_show_url?
        the_url = url?(the_name)
        the_url = '   '+('%58s' % the_url)
        the_url = the_url.strip
        if use_xorg_buffer?
          append_to_buffer(the_url)
        end
        _ << simp(the_url)
      end
      if use_xorg_buffer?
        append_to_buffer(N) # Prepare the xorg-buffer string.
      end
      @result = _
      e _ if be_verbose?
      if @also_open_every_entry_in_the_editor
        this_file = return_location_to_this_programs_yaml_file(the_name)
        if File.exist? this_file
          if be_verbose?
            e 'Next opening '+sfile(this_file)+' after a '+
              "delay of #{simp(USE_THIS_DELAY.to_s)} seconds."
          end
          open_in_editor(this_file)
          sleep USE_THIS_DELAY
        end
      end
    }
    if array_with_the_results.size > 1
      calculate_and_display_the_filesize_of(array_with_the_results)
    end
    store_results_into_file # Store these results.
  else # Else we did not find any results.
    if be_verbose?
      opne "#{rev}Not found any tag-result for search entry `"\
           "#{sfancy(search_for?.first)}#{rev}`."
    end
  end
  set_the_xorg_buffer
end

#reassign_this_input_to_that_registered_entry(original_input, i) ⇒ Object

#

reassign_this_input_to_that_registered_entry

#


677
678
679
680
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 677

def reassign_this_input_to_that_registered_entry(original_input, i)
  opne "#{rev}Reassigning input `#{simp(original_input)} #{rev}to "\
       "the registered entry `#{simp(i)}#{rev}`."
end

#resetObject

#

reset (reset tag)

#


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
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 122

def reset
  super()
  infer_the_namespace
  try_to_require_the_xorg_buffer
  # ======================================================================= #
  # === @use_xorg_buffer
  # ======================================================================= #
  @use_xorg_buffer = USE_XORG_BUFFER
  # ======================================================================= #
  # === @xorg_buffer_string
  # ======================================================================= #
  @xorg_buffer_string = ''.dup
  # ======================================================================= #
  # === @show_index
  # ======================================================================= #
  @show_index = true
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  set_be_verbose # Just to make sure that we will be verbose here.
  # ======================================================================= #
  # === @also_show_url
  #
  # If true then we will also show the URL.
  # ======================================================================= #
  @also_show_url = false
  # ======================================================================= #
  # === @also_open_every_entry_in_the_editor
  # ======================================================================= #
  @also_open_every_entry_in_the_editor = false
  # ======================================================================= #
  # === @array_of_programs
  # ======================================================================= #
  @array_of_programs = []
end

#runObject

#

run (run tag)

#


701
702
703
704
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 701

def run
  check_against_menu # Check against the menu first.
  perform_the_search # We use grep to find the tags.
end

#search_for?Boolean Also known as: commandline?, search_term?

#

search_for?

#

Returns:

  • (Boolean)


394
395
396
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 394

def search_for?
  @search_for
end

#set_search_for(i = nil) ⇒ Object

#

set_search_for

#


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
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 454

def set_search_for(i = nil)
  i = DEFAULT_SEARCH_TAG if i.nil?
  if i.is_a? Array and i.empty?
    i = [DEFAULT_SEARCH_TAG] # Fill up empty arrays in this case.
  end
  if i.is_a? Symbol
    i = i.to_s
  end
  if i.is_a? String
    i = i.strip # Get rid of whitespace.
    # ===================================================================== #
    # Next, sanitize some common misspellings.
    # ===================================================================== #
    if i.include? ' ' # If it includes internal ' '.
      i = i.split(' ') # Then we turn it into an Array.
    end
  end
  if i.is_a? Array # Next handle Arrays here.
    i.compact! # Remove nil entries as these can arise when we passed input through menu().
    i.map! {|entry|
      if entry.include? '-' # '-' characters are useless - they are not part of a tag.
        entry = entry.dup if entry.frozen?
        entry.delete!('-')
      end
      entry
    }
    original_input = i.first
    # ===================================================================== #
    # === Sanitize operations
    #
    # Perform some sanitize-operations next, out of user-convenience.
    #
    # Input such as 'kde_apps' will become substituted towards the
    # longer variant called 'kde_application'.
    # ===================================================================== #
    case i.first # case tag
    # ===================================================================== #
    # === kde_application
    # ===================================================================== #
    when 'kdeapp',
         'kdeapplicates',
         'kdeapplications',
         'kde_applications',
         'kde_apps',
         /kdeapps/i
      i = 'kde_application'
      reassign_this_input_to_that_registered_entry(original_input, i)
    # ===================================================================== #
    # === xorg
    # ===================================================================== #
    when 'x11'
      i = 'xorg'
      opne 'Reassigning input `'+simp(original_input)+rev+
           " to `#{simp(i)} as we should have more"
      opne 'tags registered that way.'
    # ===================================================================== #
    # === game
    # ===================================================================== #
    when 'games'
      opne 'Need to correct `'+simp(original_input)+'` to `'+
            simp('game')+'` tag.'
      i = 'game'
    # ===================================================================== #
    # === windowmanager
    # ===================================================================== #
    when 'WM',
         'wm',
         'windowsmanager'
      i = 'windowmanager'
      reassign_this_input_to_that_registered_entry(original_input, i)
    # ===================================================================== #
    # === programming_language
    # ===================================================================== #
    when 'programming_languages'
      i = 'programming_language'
      reassign_this_input_to_that_registered_entry(original_input, i)
    # ===================================================================== #
    # === scanning
    # ===================================================================== #
    when 'scanning'
      i = 'scanner'
    end
  end
  i.flatten! if i.is_a? Array
  i = [i] unless i.is_a? Array
  i.compact!
  @search_for = i # Must be an Array.
end

#set_the_xorg_buffer(i = @xorg_buffer_string) ⇒ Object

#

set_the_xorg_buffer

#


309
310
311
312
313
314
315
316
317
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 309

def set_the_xorg_buffer(
    i = @xorg_buffer_string
  )
  if use_xorg_buffer?
    unless i.empty?
      set_xorg_buffer(i)
    end
  end
end

#show_available_tags(use_this_path = RBT.file_allowed_tags) ⇒ Object

#

show_available_tags

Simply delegate towards Cookbooks.show_available_tags.

Invocation example:

searchfortags --show-available-tags
#


692
693
694
695
696
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 692

def show_available_tags(
    use_this_path = RBT.file_allowed_tags
  )
  opnn; RBT.show_available_tags(use_this_path, :do_not_report_the_namespace)
end

#show_helpObject

#

show_help

Invoke this method like so:

tags --help
#


166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 166

def show_help # help tag
  e 'The following options are available for class '+
    steelblue('RBT::Cookbooks::SearchForTags')+':'
  e
  eparse '  OPEN_ALL         # open all entries in the editor'
  eparse '  WITH_URL         # also show the URL'
  eparse '  NO_INDEX         # do not show the leading numbers '\
         'when listing the tags'
  eparse '  ALL              # display every tag'
  eparse '  --available      # show which tags are available'
  eparse '  --open-in-editor # batch-open all files with that '\
         'tag in the main editor'
  e
end

#store_results_into_fileObject

#

store_results_into_file

#


373
374
375
376
377
378
379
380
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 373

def store_results_into_file
  this_file = store_into_this_directory?+'these_tags'
  if be_verbose?
    e # A spacer here is in order.
    opne "Now storing these results into the file `#{sfile(this_file)}`."
  end
  save_file(@xorg_buffer_string, this_file)
end

#string?Boolean Also known as: string, result?

#

string?

#

Returns:

  • (Boolean)


336
337
338
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 336

def string?
  @xorg_buffer_string
end

#url?(i) ⇒ Boolean

#

url?

Return the URL of a program. The method perform_the_search() will display it.

#

Returns:

  • (Boolean)


293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 293

def url?(i)
  i = i.to_s.dup
  _ = "#{cookbooks_directory?}"\
      "#{File.basename(i).split(' ').first.delete(':')}".dup
  _ << '.yml' unless _.end_with? '.yml'
  if File.exist? _ # We directly load this file.
    i = YAML.load_file(_)
    i = i[i.keys.first]['url1'].to_s
  else # File does not exist here. Should not happen.
  end
  return i
end

#use_xorg_buffer?Boolean

#

use_xorg_buffer?

#

Returns:

  • (Boolean)


322
323
324
# File 'lib/rbt/cookbooks/search_for_tags/search_for_tags.rb', line 322

def use_xorg_buffer?
  @use_xorg_buffer
end