roebe 0.5.191 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +89 -41
  3. data/bin/create_my_directories +2 -2
  4. data/bin/{ruby_dhcpcd → dhcpcd_wrapper} +1 -1
  5. data/bin/start_lighty +1 -1
  6. data/doc/README.gen +78 -15
  7. data/doc/core/array.md +24 -23
  8. data/doc/core/gem_and_gemspec.md +12 -11
  9. data/doc/core/hash.md +6 -0
  10. data/doc/core/misc.md +23 -20
  11. data/doc/core/regex.md +1 -1
  12. data/doc/core/stderr.md +16 -0
  13. data/doc/deprecations/deprecations.md +2 -1
  14. data/doc/statistics/statistics.md +1 -0
  15. data/lib/roebe/actions/actions.rb +80 -0
  16. data/lib/roebe/base/colours.rb +52 -19
  17. data/lib/roebe/base/misc.rb +30 -1
  18. data/lib/roebe/base/opnn.rb +7 -0
  19. data/lib/roebe/browser/output_url_then_open_in_browser.rb +18 -15
  20. data/lib/roebe/classes/alltagsgeschichte.rb +1 -1
  21. data/lib/roebe/classes/at.rb +2 -2
  22. data/lib/roebe/classes/auto_rename_file_based_on_its_creation_date.rb +24 -12
  23. data/lib/roebe/classes/books/books.rb +234 -142
  24. data/lib/roebe/classes/books/finished_books/finished_books.rb +10 -3
  25. data/lib/roebe/classes/books/menu.rb +25 -16
  26. data/lib/roebe/classes/books/sanitize_this_book_path/sanitize_this_book_path.rb +0 -1
  27. data/lib/roebe/classes/check_yaml.rb +15 -11
  28. data/lib/roebe/classes/compile_kernel.rb +3 -1
  29. data/lib/roebe/classes/contacts/contacts.rb +104 -0
  30. data/lib/roebe/classes/contacts/gui/universal_widgets/contacts.rb +168 -0
  31. data/lib/roebe/classes/contacts/shared_code.rb +344 -0
  32. data/lib/roebe/classes/copy_kernel_config.rb +5 -3
  33. data/lib/roebe/classes/create_desktop_file.rb +1 -1
  34. data/lib/roebe/classes/create_file_skeleton/constants.rb +1 -1
  35. data/lib/roebe/classes/create_file_skeleton/generate_ruby_string.rb +20 -20
  36. data/lib/roebe/classes/create_file_skeleton/reset.rb +19 -16
  37. data/lib/roebe/classes/create_my_directories.rb +12 -10
  38. data/lib/roebe/classes/dhcpcd/{dhcpcd.rb → dhcpcd_wrapper.rb} +137 -95
  39. data/lib/roebe/classes/dhcpcd/kill_dhcpcd.rb +2 -2
  40. data/lib/roebe/classes/do_install.rb +7 -6
  41. data/lib/roebe/classes/done.rb +1 -1
  42. data/lib/roebe/classes/downcase_extension.rb +4 -4
  43. data/lib/roebe/classes/email.rb +44 -40
  44. data/lib/roebe/classes/enable.rb +1 -1
  45. data/lib/roebe/classes/generate_alsa_conf.rb +4 -4
  46. data/lib/roebe/classes/generate_overview_of_the_locally_available_books.rb +5 -3
  47. data/lib/roebe/classes/github.rb +1 -1
  48. data/lib/roebe/classes/kde/install_this_konsole_theme.rb +1 -1
  49. data/lib/roebe/classes/{handle_lighttpd.rb → lighttpd/lighttpd_wrapper.rb} +55 -47
  50. data/lib/roebe/classes/make_gem.rb +49 -35
  51. data/lib/roebe/classes/mbl.rb +6 -4
  52. data/lib/roebe/classes/readme_generator/readme_generator.rb +597 -1
  53. data/lib/roebe/classes/remove_trailing_newline.rb +82 -0
  54. data/lib/roebe/classes/report_how_many_files_are_in_this_directory.rb +83 -0
  55. data/lib/roebe/classes/rxinitrc/constants.rb +7 -5
  56. data/lib/roebe/classes/rxinitrc/rxinitrc.rb +8 -4
  57. data/lib/roebe/classes/set_background.rb +14 -0
  58. data/lib/roebe/classes/show_ten_aliases.rb +15 -3
  59. data/lib/roebe/classes/simple_boot_script.rb +1 -1
  60. data/lib/roebe/classes/size_of.rb +9 -7
  61. data/lib/roebe/classes/tales_from_the_crypt.rb +1 -1
  62. data/lib/roebe/classes/update.rb +4 -11
  63. data/lib/roebe/classes/upload_to_imgur.rb +64 -35
  64. data/lib/roebe/commandline/misc.rb +28 -28
  65. data/lib/roebe/constants/array_install_these_gem_projects.rb +1 -1
  66. data/lib/roebe/constants/constants.rb +8 -1
  67. data/lib/roebe/constants/emojis.rb +0 -19
  68. data/lib/roebe/constants/file_and_directory_constants.rb +2 -2
  69. data/lib/roebe/constants/misc.rb +10 -2
  70. data/lib/roebe/constants/roebe.rb +2 -0
  71. data/lib/roebe/custom_methods/module.rb +45 -16
  72. data/lib/roebe/fonts/fonts.rb +39 -0
  73. data/lib/roebe/gui/universal_widgets/books/books.rb +232 -0
  74. data/lib/roebe/hello_world/hello_world.rb +0 -0
  75. data/lib/roebe/irb/clean_irbrc +1 -0
  76. data/lib/roebe/math/log10.rb +3 -3
  77. data/lib/roebe/math/the_collatz_problem.rb +104 -0
  78. data/lib/roebe/{toplevel_methods/lighttpd.rb → requires/require_lighttpd.rb} +2 -2
  79. data/lib/roebe/shell/shell/shell.rb +6 -6
  80. data/lib/roebe/shell_scripts/README.md +0 -0
  81. data/lib/roebe/shell_scripts/bashrc +0 -0
  82. data/lib/roebe/shell_scripts/konsole_tabs.sh +6 -0
  83. data/lib/roebe/shell_scripts/lfs/001_binutils_1.sh +10 -2
  84. data/lib/roebe/shell_scripts/lfs/002_gcc_1.sh +33 -3
  85. data/lib/roebe/shell_scripts/lfs/003_linux_1.sh +1 -0
  86. data/lib/roebe/shell_scripts/lfs/004_glibc_1.sh +5 -2
  87. data/lib/roebe/shell_scripts/lfs/005_libstdc++_1.sh +8 -1
  88. data/lib/roebe/shell_scripts/lfs/007_ncurses_2.sh +5 -2
  89. data/lib/roebe/shell_scripts/lfs/020_xz_2.sh +5 -4
  90. data/lib/roebe/shell_scripts/lfs/022_gcc_2.sh +15 -1
  91. data/lib/roebe/shell_scripts/lfs/025_ruby_2.sh +13 -0
  92. data/lib/roebe/shell_scripts/lfs/README.md +0 -0
  93. data/lib/roebe/shell_scripts/lfs/lfs_build_variables.sh +56 -16
  94. data/lib/roebe/toplevel_methods/module_methods.rb +5 -3
  95. data/lib/roebe/toplevel_methods/to_mp3.rb +1 -1
  96. data/lib/roebe/version/version.rb +2 -2
  97. data/lib/roebe/wasm/README.md +7 -0
  98. data/lib/roebe/wasm/enable_simple_puts_output.rb +9 -0
  99. data/lib/roebe/wasm/wasm_examples.html +43 -0
  100. data/lib/roebe/www/LEDS/LEDS.rb +35 -25
  101. data/lib/roebe/www/RNA/RNA.cgi +42 -1
  102. data/lib/roebe/www/algorithms/algorithms.rb +40 -0
  103. data/lib/roebe/www/analytical_chemistry/content.md +6 -0
  104. data/lib/roebe/www/animals/animals.cgi +25 -0
  105. data/lib/roebe/www/bioanalytik/bioanalytik.cgi +90 -0
  106. data/lib/roebe/www/biotechnology/biotechnology.rb +39 -3
  107. data/lib/roebe/www/cellbiology/cellbiology.rb +19 -2
  108. data/lib/roebe/www/chemistry/S/303/244uren_Basen_und_der_pH_Wert/S/303/244uren_Basen_und_der_pH_Wert.cgi +242 -0
  109. data/lib/roebe/www/chemistry/chemistry.rb +10 -258
  110. data/lib/roebe/www/chemistry/css_rules.css +67 -0
  111. data/lib/roebe/www/chemistry/die_quantenzahlen/die_quantenzahlen.cgi +123 -0
  112. data/lib/roebe/www/chemistry/funktionelle_gruppen_in_der_chemie/funktionelle_gruppen_in_der_chemie.cgi +52 -0
  113. data/lib/roebe/www/chrome_and_chromium/chrome_and_chromium.rb +37 -42
  114. data/lib/roebe/www/chromium +1 -0
  115. data/lib/roebe/www/cognitive_biology/cognitive_biology.cgi +18 -3
  116. data/lib/roebe/www/erste_hilfe/erste_hilfe.cgi +215 -62
  117. data/lib/roebe/www/fonts/fonts.cgi +245 -0
  118. data/lib/roebe/www/genomics/genomics.rb +4 -0
  119. data/lib/roebe/www/hardware/computersysteme/computersysteme.rb +117 -102
  120. data/lib/roebe/www/hardware/netzteile/netzteile.cgi +94 -0
  121. data/lib/roebe/www/immunology/immunology.rb +131 -7
  122. data/lib/roebe/www/insekten/insekten.md +27 -0
  123. data/lib/roebe/www/lighttpd/autogenerated_lighttpd.conf +7 -3
  124. data/lib/roebe/www/lighttpd/configuration/index.conf +7 -4
  125. data/lib/roebe/www/lighttpd/lighttpd.rb +6 -6
  126. data/lib/roebe/www/linux/antiX/antiX.rb +7 -4
  127. data/lib/roebe/www/linux/linux.rb +9 -11
  128. data/lib/roebe/www/linux/linuxmint/linuxmint.rb +33 -0
  129. data/lib/roebe/www/linux/slackware/slackware.rb +136 -27
  130. data/lib/roebe/www/linux/void/void.rb +34 -8
  131. data/lib/roebe/www/linux_commands/linux_commands.rb +6 -6
  132. data/lib/roebe/www/lyrics/lyrics.rb +1 -1
  133. data/lib/roebe/www/metabolic_pathways/metabolic_pathways.rb +5 -1
  134. data/lib/roebe/www/microbiology/microbiology.rb +17 -2
  135. data/lib/roebe/www/mikrobielle_physiologie/mikrobielle_physiologie.cgi +1086 -2
  136. data/lib/roebe/www/mitochondria/mitochondria.cgi +16 -2
  137. data/lib/roebe/www/module_www.rb +2 -3
  138. data/lib/roebe/www/neurobiology/neurobiology.rb +20 -3
  139. data/lib/roebe/www/pdf/pdf.rb +13 -0
  140. data/lib/roebe/www/physics/physics.rb +20 -4
  141. data/lib/roebe/www/physiology/physiology.rb +5 -1
  142. data/lib/roebe/www/play_this_video_file/play_this_video_file.cgi +1 -1
  143. data/lib/roebe/www/programming_advice/programming_advice.cgi +36 -0
  144. data/lib/roebe/www/programming_advice/programming_advice.md +358 -0
  145. data/lib/roebe/www/psychologie/psychologie.rb +7 -1
  146. data/lib/roebe/www/science/science.rb +6 -0
  147. data/lib/roebe/www/sex_and_reproduction/sex_and_reproduction.cgi +18 -2
  148. data/lib/roebe/www/statistik/statistik.rb +6 -1
  149. data/lib/roebe/www/structural_biology/structural_biology.cgi +18 -0
  150. data/lib/roebe/www/the_cell_cycle/the_cell_cycle.cgi +27 -0
  151. data/lib/roebe/www/video/video.rb +1 -1
  152. data/lib/roebe/www/virology/virology.rb +12 -1
  153. data/lib/roebe/www/war_in_Ukraine_2022/war_in_Ukraine_2022.rb +70 -28
  154. data/lib/roebe/www/waschmaschinen/waschmaschinen.rb +5 -4
  155. data/lib/roebe/www/xfce/xfce.cgi +5 -4
  156. data/lib/roebe/www/xorg/xorg.rb +3 -202
  157. data/lib/roebe/www/yeast/yeast.rb +4 -2
  158. data/lib/roebe/www/yubiko/yubiko.cgi +49 -0
  159. data/lib/roebe/yaml/{autostart_these_programs.yml → autostart_these_programs/autostart_these_programs.yml} +7 -6
  160. data/lib/roebe/yaml/books/favourite_books.yml +11 -9
  161. data/lib/roebe/yaml/directory_structure.yml +2 -0
  162. data/lib/roebe/yaml/use_this_editor/use_this_editor.yml +1 -0
  163. metadata +39 -20
  164. data/lib/roebe/classes/readme_generator/constants.rb +0 -21
  165. data/lib/roebe/classes/readme_generator/initialize.rb +0 -38
  166. data/lib/roebe/classes/readme_generator/misc.rb +0 -548
  167. data/lib/roebe/classes/readme_generator/reset.rb +0 -28
  168. data/lib/roebe/classes/readme_generator/run.rb +0 -20
  169. data/lib/roebe/shell_scripts/lfs/lfs_variables.sh +0 -31
  170. data/lib/roebe/www/cognitive_biology/cognitive_biology.html +0 -40634
  171. data/lib/roebe/www/mikrobielle_physiologie/mikrobielle_physiologie.rb +0 -1055
  172. data/lib/roebe/www/programming_advice/programming_advice.yml +0 -31
  173. data/lib/roebe/yaml/main_editor.yml +0 -1
@@ -12,6 +12,7 @@
12
12
  #
13
13
  # =========================================================================== #
14
14
  # require 'roebe/classes/books/books.rb'
15
+ # Roebe::Books.new(ARGV)
15
16
  # =========================================================================== #
16
17
  require 'roebe/base/base.rb'
17
18
 
@@ -56,6 +57,9 @@ class Books < Base # === Roebe::Books
56
57
  set_commandline_arguments(
57
58
  commandline_arguments
58
59
  )
60
+ # ======================================================================= #
61
+ # === Handle blocks given to the method next
62
+ # ======================================================================= #
59
63
  if block_given?
60
64
  yielded = yield
61
65
  case yielded
@@ -93,9 +97,10 @@ class Books < Base # === Roebe::Books
93
97
  # === :store_the_timestamps_into_this_local_file
94
98
  # ======================================================================= #
95
99
  @internal_hash[:store_the_timestamps_into_this_local_file] =
96
- roebe_log_directory?+'stored_timestamps_of_all_opened_pdf_books.yml'
100
+ the_stored_timestamps_of_all_opened_pdf_books_are_where?
97
101
  consider_loading_and_sanitizing_the_timestamps_from_a_local_yaml_file
98
102
  try_to_require_the_open_gem
103
+ try_to_load_the_favourites # Load them at once at startup.
99
104
  end
100
105
 
101
106
  # ========================================================================= #
@@ -135,12 +140,14 @@ class Books < Base # === Roebe::Books
135
140
  # ========================================================================= #
136
141
  # === try_to_load_the_favourites
137
142
  # ========================================================================= #
138
- def try_to_load_the_favourites
139
- into = into?
140
- if File.exist? into
143
+ def try_to_load_the_favourites(
144
+ into = into?
145
+ )
146
+ if into and File.exist?(into)
141
147
  @internal_hash[:favourite_books] = YAML.load_file(into)
142
148
  end
143
149
  end; alias do_load_the_favourites try_to_load_the_favourites # === do_load_the_favourites
150
+ alias reload_the_favourites try_to_load_the_favourites # === reload_the_favourites
144
151
 
145
152
  # ========================================================================= #
146
153
  # === clear
@@ -149,11 +156,19 @@ class Books < Base # === Roebe::Books
149
156
  into = into?
150
157
  )
151
158
  if File.exist? into
152
- opne "#{rev}Now deleting the file #{sfile(into)}#{rev}."
159
+ orev "Now deleting the #{File.extname(into)} file #{sfile(into)}#{rev}."
153
160
  File.delete(into)
154
161
  end
155
162
  end
156
163
 
164
+ # ========================================================================= #
165
+ # === clear_old_books
166
+ # ========================================================================= #
167
+ def clear_old_books
168
+ orev 'Clearing all old books first.'
169
+ clear
170
+ end
171
+
157
172
  # ========================================================================= #
158
173
  # === return_the_dataset_containing_all_favourite_books
159
174
  # ========================================================================= #
@@ -169,8 +184,8 @@ class Books < Base # === Roebe::Books
169
184
  )
170
185
  if File.exist? into
171
186
  dataset = YAML.load_file(into)
172
- opne "Next loading from #{sfile(into)} #{rev}a total of "\
173
- "#{steelblue(dataset.size)} #{rev}.pdf files."
187
+ ogrey "Next loading from #{sfile(into)} #{grey}a total of "\
188
+ "#{steelblue(dataset.size)} #{grey}.pdf files.#{rev}"
174
189
  dataset.each {|this_file|
175
190
  open_this_pdf_file(this_file)
176
191
  }
@@ -181,16 +196,6 @@ class Books < Base # === Roebe::Books
181
196
  alias open_the_pdf_files open_the_favourites # === open_the_pdf_files
182
197
  alias do_query_open open_the_favourites # === do_query_open
183
198
 
184
- # ========================================================================= #
185
- # === favourite_books?
186
- # ========================================================================= #
187
- def favourite_books?
188
- @internal_hash[:favourite_books]
189
- end; alias favourites? favourite_books? # === favourites?
190
- alias favourite_books favourite_books? # === favourite_books
191
- alias all_favourites? favourite_books? # === all_favourites?
192
- alias available_books? favourite_books? # === available_books?
193
-
194
199
  # ========================================================================= #
195
200
  # === current_favourite_books?
196
201
  #
@@ -240,9 +245,9 @@ class Books < Base # === Roebe::Books
240
245
  )
241
246
  what = YAML.dump(use_these_favourites)
242
247
  into = into?
243
- opne grey("Storing the current .pdf favourites (")+
244
- lightblue("#{use_these_favourites.size} entries")+
245
- grey(')')
248
+ ogrey "Storing the current .pdf favourites ("+
249
+ lightblue("#{use_these_favourites.size} entries")+
250
+ grey(')')
246
251
  opne grey('into `')+
247
252
  sfile(into)+
248
253
  grey('`.')
@@ -293,13 +298,6 @@ class Books < Base # === Roebe::Books
293
298
  end
294
299
  end
295
300
 
296
- # ========================================================================= #
297
- # === into?
298
- # ========================================================================= #
299
- def into?
300
- "#{log_dir?}roebe/favourite_books.yml"
301
- end; alias yaml_location? into? # === yaml_location?
302
-
303
301
  # ========================================================================= #
304
302
  # === show_help (help tag)
305
303
  # ========================================================================= #
@@ -313,7 +311,7 @@ class Books < Base # === Roebe::Books
313
311
  eparse ' books --open=2 # open only the .pdf file at entry #2'
314
312
  eparse ' books --real # show the real path to the .pdf files'
315
313
  eparse ' books --reopen # reopen all .pdf files that are '\
316
- 'registered'
314
+ 'registered; --open-all is an alias to this'
317
315
  eparse ' books --store # store the favourites'
318
316
  eparse ' books --restore # restore the default from the '+
319
317
  steelblue('.yml')+
@@ -323,9 +321,9 @@ class Books < Base # === Roebe::Books
323
321
  ::Colours::Eparse.colour_right(
324
322
  'do this after a fresh computer installation)')
325
323
  eparse ' books --first=1 # remove the first page of the '\
326
- 'book stored at the given position'
324
+ 'book stored at the given position'
327
325
  eparse ' books --remove_entry=2 # remove the second entry from the '\
328
- 'list of favourites'
326
+ 'list of favourites'
329
327
  eparse ' books --exchange=6,1 # exchange entry at position 1 '\
330
328
  'with position 6'
331
329
  eparse ' books --add-this-to-that-entry=*pdf,4 # add a new .pdf file '\
@@ -342,6 +340,9 @@ class Books < Base # === Roebe::Books
342
340
  be_verbose = true,
343
341
  &block
344
342
  )
343
+ # ======================================================================= #
344
+ # === Handle blocks first
345
+ # ======================================================================= #
345
346
  if block_given?
346
347
  yielded = yield
347
348
  case yielded
@@ -362,13 +363,13 @@ class Books < Base # === Roebe::Books
362
363
  unless @internal_hash[:favourite_books].include? i
363
364
  if File.exist? i
364
365
  if be_verbose
365
- opne "Adding the file"
366
- opne "#{sfancy(i)} #{rev}to the favourites."
366
+ ogrey 'Adding the file'
367
+ orev "#{sfancy(i)} #{grey}to the favourites."
367
368
  end
368
369
  @internal_hash[:favourite_books] << i
369
370
  store_the_favourites
370
371
  else
371
- opne "No file exists at #{sfile(i)}."
372
+ opnn; no_file_exists_at(i)
372
373
  end
373
374
  end
374
375
  end; alias add add_to_the_favourites # === add
@@ -385,9 +386,25 @@ class Books < Base # === Roebe::Books
385
386
  YAML.load_file(i).each {|entry|
386
387
  open_this_pdf_file(entry)
387
388
  }
389
+ else
390
+ no_file_exists_at(i)
388
391
  end
389
392
  end
390
393
 
394
+ # ========================================================================= #
395
+ # === do_custom_reopen (custom tag)
396
+ #
397
+ # This is only for my home system.
398
+ # ========================================================================= #
399
+ def do_custom_reopen
400
+ clear_old_books
401
+ add('/home/x/books/BASICS_Erste_Hilfe_by_Tobias_Matreitz_2013/BASICS_Erste_Hilfe_by_Tobias_Matreitz_2013.pdf')
402
+ add('/home/x/studium/UNI_WIEN/300078_Hominidenevolution/Alle_Folien_Hominidenevolution_2023W.pdf')
403
+ add('/home/x/books/The_Pragmatic_Programmer_20th_Anniversary_Edition_by_David_Thomas_Andrew_Hunt_2020/The_Pragmatic_Programmer_20th_Anniversary_Edition_by_David_Thomas_Andrew_Hunt_2020.pdf')
404
+ store_the_favourites
405
+ open_the_favourites
406
+ end
407
+
391
408
  # ========================================================================= #
392
409
  # === exchange_these_two_positions
393
410
  #
@@ -438,6 +455,15 @@ class Books < Base # === Roebe::Books
438
455
  end
439
456
  end
440
457
 
458
+ # ========================================================================= #
459
+ # === remove_the_first_page_of_this_target
460
+ # ========================================================================= #
461
+ def remove_the_first_page_of_this_target(
462
+ target_pdf_file
463
+ )
464
+ ::PdfParadise.remove_first_page_of_this_pdf_file(target_pdf_file) { :be_quiet }
465
+ end
466
+
441
467
  # ========================================================================= #
442
468
  # === show_these_books
443
469
  #
@@ -447,111 +473,6 @@ class Books < Base # === Roebe::Books
447
473
  show_the_favourites(nil, i)
448
474
  end
449
475
 
450
- # ========================================================================= #
451
- # === show_the_favourites
452
- #
453
- # This method will show all favourite books.
454
- # ========================================================================= #
455
- def show_the_favourites(
456
- optional_arguments = nil, # or :full_path
457
- _ = favourite_books?
458
- )
459
- n_favourite_books = _.size
460
- if _.empty?
461
- opne tomato('No .pdf books are available for the current library.')
462
- opne tomato("Normally these would be found at the following location:")
463
- e
464
- e " #{sfile(yaml_location?)}"
465
- e
466
- if is_on_roebe?
467
- e "#{rev}You can also use:"
468
- e
469
- e ' books --restore'
470
- e
471
- e 'To copy the old books.' # In fact, we will do this now, anyway.'
472
- e
473
- # do_restore_the_original_yaml_file
474
- end
475
- else
476
- n_pdf_pages_in_total = 0
477
- e "#{rev}#{grey('The following ')}#{royalblue(_.size)} #{rev}"\
478
- "#{grey('books are stored as favourites:')}"
479
- e
480
- if SHOW_HOW_MANY_PAGES_ARE_IN_THAT_PDF_FILE
481
- e skyblue('-'*80)
482
- end
483
- # ===================================================================== #
484
- # Iterate over all entries next:
485
- # ===================================================================== #
486
- _.each_with_index {|this_book, index| index += 1
487
- absolute_path = File.absolute_path(this_book)
488
- if @internal_hash[:hash_store_the_timestamps].has_key?(absolute_path)
489
- else # else must create a new entry.
490
- @internal_hash[:hash_store_the_timestamps][absolute_path] = []
491
- # ================================================================= #
492
- # First add when it was last modified:
493
- # ================================================================= #
494
- if File.exist? absolute_path
495
- @internal_hash[:hash_store_the_timestamps][absolute_path] <<
496
- File.mtime(absolute_path)
497
- end
498
- end
499
- if SHOW_HOW_MANY_PAGES_ARE_IN_THAT_PDF_FILE
500
- current_array = @internal_hash[:hash_store_the_timestamps][absolute_path]
501
- if current_array.size > 1 # In this case we assume a page.
502
- first = current_array.first # n pages in this pdf file.
503
- if first.is_a?(String) # Do nothing in this case.
504
- else
505
- # =============================================================== #
506
- # Here, we must compare the File.mtime data.
507
- # =============================================================== #
508
- if File.exist? absolute_path
509
- modification = File.mtime(absolute_path) - first
510
- end
511
- if modification and modification > 1
512
- n_pages = ::PdfParadise.n_pages_in_this_pdf_file(this_book) { :be_quiet }
513
- else
514
- n_pages = current_array.last
515
- end
516
- end
517
- else
518
- n_pages = ::PdfParadise.n_pages_in_this_pdf_file(this_book) { :be_quiet }
519
- @internal_hash[:hash_store_the_timestamps][absolute_path] << n_pages
520
- end
521
- end
522
- n_pdf_pages_in_total += n_pages.to_i
523
- case optional_arguments
524
- # =================================================================== #
525
- # === :full_path
526
- # =================================================================== #
527
- when :full_path
528
- else
529
- this_book = File.basename(this_book)
530
- end
531
- result = ''.dup
532
- result << ' ' if (n_favourite_books > 9) and (index < 10)
533
- result << "#{green('(')}"\
534
- "#{steelblue(index)}"\
535
- "#{green(')')} "\
536
- "#{sfancy(this_book)}".dup
537
- result << lightsteelblue(
538
- " (#{n_pages} pages)"
539
- ) if SHOW_HOW_MANY_PAGES_ARE_IN_THAT_PDF_FILE
540
- result.prepend(' ')
541
- e result
542
- }
543
- if SHOW_HOW_MANY_PAGES_ARE_IN_THAT_PDF_FILE
544
- e skyblue('-'*80)
545
- e royalblue(
546
- (n_pdf_pages_in_total.to_s+' pages in total').
547
- rjust(66)
548
- )
549
- end
550
- e
551
- end
552
- store_the_timestamps_into_a_local_yaml_file
553
- end; alias do_query_favourites show_the_favourites # === do_query_favourites
554
-
555
476
  # ========================================================================= #
556
477
  # === restore_the_original_yaml_file
557
478
  #
@@ -562,7 +483,11 @@ class Books < Base # === Roebe::Books
562
483
  new_target = '/home/x/Temp/roebe/favourite_books.yml'
563
484
  mkdir(File.dirname(new_target))
564
485
  original_file = "#{project_base_dir?}yaml/books/favourite_books.yml"
565
- opnn; copy_file(original_file, new_target) { :be_verbose }
486
+ if File.exist? original_file
487
+ opnn; copy_file(original_file, new_target) { :be_verbose }
488
+ else
489
+ opnn; no_file_exists_at(original_file)
490
+ end
566
491
  end; alias do_restore_the_original_yaml_file restore_the_original_yaml_file # === do_restore_the_original_yaml_file
567
492
 
568
493
  # ========================================================================= #
@@ -737,7 +662,9 @@ class Books < Base # === Roebe::Books
737
662
  # ========================================================================= #
738
663
  # === remove_the_first_page_of_this_book_and_then_considering_showing_the_favourites
739
664
  # ========================================================================= #
740
- def remove_the_first_page_of_this_book_and_then_considering_showing_the_favourites(i)
665
+ def remove_the_first_page_of_this_book_and_then_considering_showing_the_favourites(
666
+ i
667
+ )
741
668
  remove_the_first_page_of_this_book(i)
742
669
  if is_on_roebe?
743
670
  e # Let's also show a newline here.
@@ -770,11 +697,176 @@ class Books < Base # === Roebe::Books
770
697
  }
771
698
  end; alias open_in_pdf_viewer open_this_pdf_file # === open_in_pdf_viewer
772
699
 
700
+ # ========================================================================= #
701
+ # === inform_the_user_how_to_restore_the_books
702
+ # ========================================================================= #
703
+ def inform_the_user_how_to_restore_the_books
704
+ e "#{rev}You can also use:"
705
+ e
706
+ e ' books --restore'
707
+ e
708
+ e 'To copy the old books.' # In fact, we will do this now, anyway.'
709
+ e
710
+ # do_restore_the_original_yaml_file
711
+ end
712
+
713
+ # ========================================================================= #
714
+ # === elegantly_show_all_favourites
715
+ #
716
+ #
717
+ # This method will show all favourite books.
718
+ #
719
+ # This method, rewritten in January 2024, will make use of unicode
720
+ # horizontal bars, and also show more information than the old
721
+ # method did.
722
+ # ========================================================================= #
723
+ def elegantly_show_all_favourites(
724
+ optional_arguments = nil, # or :full_path
725
+ _ = favourite_books?
726
+ )
727
+ n_favourite_books = _.size
728
+ if _.empty? # No books were found.
729
+ opne tomato('No .pdf books are available for the current library.')
730
+ opne tomato("Normally these would be found at the following location:")
731
+ e
732
+ e " #{sfile(yaml_location?)}"
733
+ e
734
+ if is_on_roebe?
735
+ inform_the_user_how_to_restore_the_books
736
+ end
737
+ else
738
+ n_pdf_pages_in_total = 0
739
+ unicode_horizontal_bar = EmojiParadise.unicode_horizontal_bar
740
+ e "#{rev}#{grey('The following ')}#{royalblue(_.size)} #{rev}"\
741
+ "#{grey('books are stored as favourites:')}"
742
+ e
743
+ e olivedrab(' Index | Title'\
744
+ ' '\
745
+ '| n pages')
746
+ if SHOW_HOW_MANY_PAGES_ARE_IN_THAT_PDF_FILE
747
+ e olivedrab(unicode_horizontal_bar * 108)
748
+ end
749
+ # ===================================================================== #
750
+ # Iterate over all entries next:
751
+ # ===================================================================== #
752
+ _.each_with_index {|this_book, index| index += 1
753
+ absolute_path = File.absolute_path(this_book)
754
+ if @internal_hash[:hash_store_the_timestamps].has_key?(absolute_path)
755
+ else # else must create a new entry.
756
+ @internal_hash[:hash_store_the_timestamps][absolute_path] = []
757
+ # ================================================================= #
758
+ # First add when it was last modified:
759
+ # ================================================================= #
760
+ if File.exist? absolute_path
761
+ @internal_hash[:hash_store_the_timestamps][absolute_path] <<
762
+ File.mtime(absolute_path)
763
+ end
764
+ end
765
+ if SHOW_HOW_MANY_PAGES_ARE_IN_THAT_PDF_FILE
766
+ current_array = @internal_hash[:hash_store_the_timestamps][absolute_path]
767
+ if current_array.size > 1 # In this case we assume a page.
768
+ first = current_array.first # n pages in this pdf file.
769
+ if first.is_a?(String) # Do nothing in this case.
770
+ else
771
+ # =============================================================== #
772
+ # Here, we must compare the File.mtime data.
773
+ # =============================================================== #
774
+ if File.exist? absolute_path
775
+ modification = File.mtime(absolute_path) - first
776
+ end
777
+ begin
778
+ if modification and modification > 1
779
+ n_pages = ::PdfParadise.n_pages_in_this_pdf_file(this_book) { :be_quiet }
780
+ else
781
+ n_pages = current_array.last
782
+ end
783
+ rescue ArgumentError => error
784
+ pp error
785
+ e sfile(yaml_file?)
786
+ e sfile(the_stored_timestamps_of_all_opened_pdf_books_are_where?)
787
+ end
788
+ end
789
+ else
790
+ n_pages = ::PdfParadise.n_pages_in_this_pdf_file(this_book) { :be_quiet }
791
+ @internal_hash[:hash_store_the_timestamps][absolute_path] << n_pages
792
+ end
793
+ end
794
+ n_pdf_pages_in_total += n_pages.to_i
795
+ case optional_arguments
796
+ # =================================================================== #
797
+ # === :full_path
798
+ # =================================================================== #
799
+ when :full_path
800
+ else
801
+ this_book = File.basename(this_book)
802
+ end
803
+ result = ' '.dup
804
+ result << ' ' if (n_favourite_books > 9) and (index < 10)
805
+ result << "#{green('(')}"\
806
+ "#{steelblue(index)}"\
807
+ "#{green(')')} #{olivedrab('|')} "\
808
+ "#{sfancy(this_book.ljust(86, ' '))}".dup
809
+ if SHOW_HOW_MANY_PAGES_ARE_IN_THAT_PDF_FILE
810
+ result << olivedrab(' |')+lightsteelblue(
811
+ " #{n_pages.to_s.rjust(3,' ')} pages"
812
+ )
813
+ end
814
+ result.prepend(' ')
815
+ e result # Display the result.
816
+ }
817
+ if SHOW_HOW_MANY_PAGES_ARE_IN_THAT_PDF_FILE
818
+ e olivedrab(unicode_horizontal_bar * 108)
819
+ e royalblue(
820
+ (n_pdf_pages_in_total.to_s+' pages in total').
821
+ rjust(108)
822
+ )
823
+ end
824
+ e
825
+ store_the_timestamps_into_a_local_yaml_file
826
+ end
827
+ end; alias do_query_favourites elegantly_show_all_favourites # === do_query_favourites
828
+ alias show_the_favourites elegantly_show_all_favourites # === do_query_favourites
829
+
830
+ # ========================================================================= #
831
+ # === into?
832
+ # ========================================================================= #
833
+ def into?
834
+ "#{log_dir?}roebe/favourite_books.yml"
835
+ end; alias yaml_location? into? # === yaml_location?
836
+ alias yaml_file? into? # === yaml_file?
837
+
838
+ # ========================================================================= #
839
+ # === the_stored_timestamps_of_all_opened_pdf_books_are_where?
840
+ # ========================================================================= #
841
+ def the_stored_timestamps_of_all_opened_pdf_books_are_where?
842
+ roebe_log_directory?+'stored_timestamps_of_all_opened_pdf_books.yml'
843
+ end
844
+
845
+ # ========================================================================= #
846
+ # === favourite_books?
847
+ #
848
+ # Query-method over @internal_hash[:favourite_books], to return the
849
+ # Array keeping track of the favourite books.
850
+ # ========================================================================= #
851
+ def favourite_books?
852
+ @internal_hash[:favourite_books]
853
+ end; alias favourites? favourite_books? # === favourites?
854
+ alias favourite_books favourite_books? # === favourite_books
855
+ alias all_favourites? favourite_books? # === all_favourites?
856
+ alias available_books? favourite_books? # === available_books?
857
+
858
+ # ========================================================================= #
859
+ # === empty_favourites?
860
+ # ========================================================================= #
861
+ def empty_favourites?
862
+ favourites?.empty?
863
+ end; alias no_favourites? empty_favourites? # === no_favourites?
864
+
773
865
  # ========================================================================= #
774
866
  # === run (run tag)
775
867
  # ========================================================================= #
776
868
  def run
777
- try_to_load_the_favourites
869
+ try_to_load_the_favourites if no_favourites?
778
870
  menu
779
871
  end
780
872
 
@@ -782,4 +874,4 @@ end; end
782
874
 
783
875
  if __FILE__ == $PROGRAM_NAME
784
876
  Roebe::Books.new(ARGV)
785
- end # books
877
+ end # books
@@ -14,6 +14,10 @@ module Roebe
14
14
 
15
15
  class FinishedBooks < ::Roebe::Base # === Roebe::FinishedBooks
16
16
 
17
+ begin
18
+ require 'emoji_paradise'
19
+ rescue LoadError; end
20
+
17
21
  # ========================================================================= #
18
22
  # === FILE_FINISHED_BOOKS
19
23
  # ========================================================================= #
@@ -90,15 +94,18 @@ class FinishedBooks < ::Roebe::Base # === Roebe::FinishedBooks
90
94
  line.include? '--------'
91
95
  }
92
96
  analyse_the_years_from_this_dataset(dataset)
93
- e steelblue('Book collection:')
97
+ e steelblue(
98
+ 'Book collection:'.ljust(33)+
99
+ EmojiParadise.book_emoji?
100
+ )
101
+ e
102
+ report_the_yearly_statistics
94
103
  e
95
104
  e lightblue(' n books were read already:'.ljust(30))+
96
105
  gold(dataset.size.to_s.rjust(5))
97
106
  e lightblue(' Total number of pages read:'.ljust(30))+
98
107
  gold(return_n_pages_read(dataset).to_s)
99
108
  e
100
- report_the_yearly_statistics
101
- e
102
109
  else
103
110
  no_file_exists_at(_)
104
111
  end
@@ -29,6 +29,28 @@ class Books < ::Roebe::Base # === Roebe::Books
29
29
  else
30
30
  case i # case tag
31
31
  # ===================================================================== #
32
+ # === books --custom-reopen
33
+ # ===================================================================== #
34
+ when /^-?-?custom(-|_)?reopen/i,
35
+ /^-?-?do(-|_)?custom(-|_)?reopen/i
36
+ do_custom_reopen
37
+ exit
38
+ # ===================================================================== #
39
+ # === books --clear
40
+ # ===================================================================== #
41
+ when /^-?-?clear$/i,
42
+ /^-?-?reset$/i
43
+ clear
44
+ exit
45
+ # ===================================================================== #
46
+ # === books --reopen
47
+ # ===================================================================== #
48
+ when /^-?-?reopen/i,
49
+ /^-?-?restore/i,
50
+ /^-?-?open(-|_)?all/i
51
+ do_reopen_all_tracked_pdf_files
52
+ exit
53
+ # ===================================================================== #
32
54
  # === books 10
33
55
  # ===================================================================== #
34
56
  when /^\d+$/ # Input is only numbers.
@@ -68,13 +90,6 @@ class Books < ::Roebe::Base # === Roebe::Books
68
90
  remove_entry_at_position(position)
69
91
  show_the_favourites
70
92
  # ===================================================================== #
71
- # === books --clear
72
- # ===================================================================== #
73
- when /^-?-?clear$/i,
74
- /^-?-?reset$/i
75
- clear
76
- exit
77
- # ===================================================================== #
78
93
  # === books --add=
79
94
  #
80
95
  # This entry point combines adding the .pdf file to the favourites,
@@ -85,7 +100,8 @@ class Books < ::Roebe::Base # === Roebe::Books
85
100
  # books --add=foobar.pdf
86
101
  #
87
102
  # ===================================================================== #
88
- when /^-?-?add=(.+)$/i
103
+ when /^-?-?add=(.+)$/i,
104
+ /^-?-?open=(.+)$/i
89
105
  _ = $1.to_s.dup
90
106
  add_this_pdf_file(_)
91
107
  open_this_pdf_file(_)
@@ -171,13 +187,6 @@ class Books < ::Roebe::Base # === Roebe::Books
171
187
  renew_the_timestamps
172
188
  exit
173
189
  # ===================================================================== #
174
- # === books --reopen
175
- # ===================================================================== #
176
- when /^-?-?reopen/i,
177
- /^-?-?restore/i
178
- do_reopen_all_tracked_pdf_files
179
- exit
180
- # ===================================================================== #
181
190
  # === books --exchange=6,1
182
191
  #
183
192
  # This entry point allows the user to exchange two positions
@@ -267,4 +276,4 @@ class Books < ::Roebe::Base # === Roebe::Books
267
276
  end
268
277
  end
269
278
 
270
- end; end
279
+ end; end
@@ -16,7 +16,6 @@ module Roebe
16
16
 
17
17
  class SanitizeThisBookPath < ::Roebe::Base # === Roebe::SanitizeThisBookPath
18
18
 
19
- require 'pdf_paradise/toplevel_methods/automatic_pdf_title.rb'
20
19
  require 'pdf_paradise/utility_scripts/automatic_pdf_title.rb'
21
20
 
22
21
  # ========================================================================= #
@@ -44,23 +44,27 @@ class CheckYaml < Base # === Roebe::CheckYaml
44
44
  # ========================================================================= #
45
45
  def run
46
46
  _ = first_argument?
47
- if File.exist? _
48
- begin
49
- _dataset = YAML.load_file(_)
50
- e "#{rev}All appears to be fine with the file `#{sfile(_)}`."
51
- rescue Exception => error
52
- e sfile(_)
53
- pp error
54
- end
47
+ if _.nil?
48
+ opne "#{rev}Please supply the path to a locally existing .yml file."
55
49
  else
56
- no_file_exists_at(_)
50
+ if File.exist? _
51
+ begin
52
+ _dataset = YAML.load_file(_)
53
+ e "#{rev}All appears to be fine with the file `#{sfile(_)}#{rev}`."
54
+ rescue Exception => error
55
+ e sfile(_)
56
+ pp error
57
+ end
58
+ else
59
+ no_file_exists_at(_)
60
+ end
57
61
  end
58
62
  end
59
63
 
60
64
  # ========================================================================= #
61
65
  # === Roebe::CheckYaml[]
62
66
  # ========================================================================= #
63
- def self.[](i = '')
67
+ def self.[](i = ARGV)
64
68
  new(i)
65
69
  end
66
70
 
@@ -68,4 +72,4 @@ end; end
68
72
 
69
73
  if __FILE__ == $PROGRAM_NAME
70
74
  Roebe::CheckYaml.new(ARGV)
71
- end # check_yaml
75
+ end # checkyaml