roebe 0.5.120 → 0.5.121

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of roebe might be problematic. Click here for more details.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +57 -34
  3. data/doc/README.gen +56 -33
  4. data/doc/add_ons_for_ruby/fxruby.md +14 -0
  5. data/doc/add_ons_for_ruby/prawn.md +12 -0
  6. data/doc/sinatra_tutorial/sinatra_tutorial.rb +52 -22
  7. data/lib/roebe/base/colours.rb +59 -50
  8. data/lib/roebe/classes/create_file_skeleton/generate_ruby_string.rb +1 -0
  9. data/lib/roebe/classes/current_monitor_resolution.rb +27 -9
  10. data/lib/roebe/classes/do_install.rb +1 -9
  11. data/lib/roebe/classes/done.rb +1 -9
  12. data/lib/roebe/classes/done_and_open.rb +2 -13
  13. data/lib/roebe/classes/email.rb +36 -26
  14. data/lib/roebe/classes/find_out_version_of.rb +1 -5
  15. data/lib/roebe/classes/find_static_libraries.rb +1 -18
  16. data/lib/roebe/classes/fluxbox/generate_fluxbox_apps_file.rb +1 -9
  17. data/lib/roebe/classes/generate_fstab_file/generate_fstab_file.rb +1 -9
  18. data/lib/roebe/classes/generate_master_shell_script.rb +1 -13
  19. data/lib/roebe/classes/generate_system_values.rb +1 -9
  20. data/lib/roebe/classes/get_dependencies.rb +1 -9
  21. data/lib/roebe/classes/good_night.rb +1 -5
  22. data/lib/roebe/classes/google_url_cleaner.rb +1 -9
  23. data/lib/roebe/classes/grant_superuser_rights.rb +0 -5
  24. data/lib/roebe/classes/run/run.rb +130 -105
  25. data/lib/roebe/classes/symlink_files_from_that_directory_to_the_current_directory/symlink_files_from_that_directory_to_the_current_directory.rb +10 -1
  26. data/lib/roebe/classes/time/current_time_in_singapore.rb +1 -5
  27. data/lib/roebe/classes/umlaut_converter.rb +1 -1
  28. data/lib/roebe/classes/use_jruby.rb +68 -0
  29. data/lib/roebe/documentation/prawn.md +0 -11
  30. data/lib/roebe/gui/gtk3/shell/misc.rb +94 -0
  31. data/lib/roebe/gui/gtk3/shell/shell.rb +690 -10
  32. data/lib/roebe/gui/libui/shell/shell.rb +107 -0
  33. data/lib/roebe/gui/shared_code/shell/shell_module.rb +0 -601
  34. data/lib/roebe/pdf/README.md +1 -0
  35. data/lib/roebe/pdf/prawn/all_in_one_showcasing_prawn.rb +160 -0
  36. data/lib/roebe/requires/require_the_run_class.rb +7 -0
  37. data/lib/roebe/shell/shell/class_methods.rb +25 -0
  38. data/lib/roebe/shell/shell/core/browser.rb +4 -1
  39. data/lib/roebe/shell/shell/core/cat.rb +34 -28
  40. data/lib/roebe/shell/shell/core/disable.rb +12 -1
  41. data/lib/roebe/shell/shell/core/esystem.rb +10 -1
  42. data/lib/roebe/shell/shell/core/help.rb +24 -21
  43. data/lib/roebe/shell/shell/core/queries.rb +7 -7
  44. data/lib/roebe/shell/shell/core/set.rb +15 -0
  45. data/lib/roebe/shell/shell/core/show_display_feedback_and_report.rb +11 -7
  46. data/lib/roebe/shell/shell/core/stat.rb +4 -1
  47. data/lib/roebe/shell/shell/menu.rb +231 -173
  48. data/lib/roebe/shell/shell/shell.rb +77 -77
  49. data/lib/roebe/toplevel_methods/unicode/popular_unicode_symbols.rb +9 -0
  50. data/lib/roebe/version/version.rb +2 -2
  51. data/lib/roebe/www/cancer/cancer.rb +10 -5
  52. data/lib/roebe/www/cellbiology/cellbiology.rb +4 -0
  53. data/lib/roebe/www/covid19/covid19.rb +32 -6
  54. data/lib/roebe/www/developmental_biology/developmental_biology.rb +16 -4
  55. data/lib/roebe/www/genomics/genomics.rb +27 -3
  56. data/lib/roebe/www/hardware/computersysteme/computersysteme.rb +25 -13
  57. data/lib/roebe/www/libreoffice/libreoffice.rb +22 -5
  58. data/lib/roebe/www/lighttpd/autogenerated_lighttpd.conf +1 -1
  59. data/lib/roebe/www/lighttpd/configuration/redirects.conf +1 -1
  60. data/lib/roebe/www/links/links.rb +1 -1
  61. data/lib/roebe/www/mathematics/mathematics.rb +48 -24
  62. data/lib/roebe/www/neurobiology/neurobiology.rb +13 -3
  63. data/lib/roebe/www/virology/virology.rb +81 -58
  64. data/lib/roebe/www/weechat/weechat.cgi +1 -1
  65. data/lib/roebe/www/weechat/weechat.rb +4 -5
  66. data/lib/roebe/www/wlan/wlan.rb +9 -3
  67. metadata +12 -7
  68. data/lib/roebe/classes/monitor_resolution.rb +0 -95
  69. data/lib/roebe/gui/gtk2/shell/shell.rb +0 -37
  70. data/lib/roebe/gui/shared_code/shell/connect_skeleton.rb +0 -53
  71. data/lib/roebe/gui/shared_code/shell/constants.rb +0 -82
@@ -0,0 +1 @@
1
+ pdf-specific code may reside in this directory.
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === AllInOneShowcasingPrawn
6
+ #
7
+ # Usage examples:
8
+ # AllInOneShowcasingPrawn.new
9
+ # =========================================================================== #
10
+ require 'opn'
11
+ require 'prawn'
12
+ require 'beautiful_url'
13
+
14
+ class AllInOneShowcasingPrawn # require 'all_in_one_showcasing_prawn'; AllInOneShowcasingPrawn.new
15
+
16
+ # require 'prawn/table'
17
+ require 'pdf_paradise/prawn_addons/prawn_addons.rb'
18
+
19
+ require 'colours'
20
+ include Colours
21
+
22
+ require 'esystem'
23
+ include Esystem
24
+
25
+ THIS_PDF_FILE = '/hello.pdf'
26
+
27
+ # ========================================================================= #
28
+ # === MAIN_PDF
29
+ # ========================================================================= #
30
+ MAIN_PDF = '/home/x/programming/ruby/src/roebe/lib/roebe/yaml/main_pdf.yml'
31
+
32
+ # ========================================================================= #
33
+ # Colour-related constants - these are currently wrong.
34
+ # ========================================================================= #
35
+ SLATEBLUE = '6A5ACD'
36
+ CRIMSON = 'DC143C'
37
+ RED = 'FF0000'
38
+
39
+ # ========================================================================= #
40
+ # === initialize
41
+ # ========================================================================= #
42
+ def initialize(
43
+ run_already = true
44
+ )
45
+ reset
46
+ run if run_already
47
+ end
48
+
49
+ # ========================================================================= #
50
+ # === reset
51
+ # ========================================================================= #
52
+ def reset
53
+ @pdf_file = THIS_PDF_FILE
54
+ end
55
+
56
+ # ========================================================================= #
57
+ # === report_what_we_will_do
58
+ # ========================================================================= #
59
+ def report_what_we_will_do
60
+ opn; e 'Now generating file `'+sfile(pdf_file?)+
61
+ '` (Filesize: '+simp(File.size(pdf_file?).to_s)+' Bytes).'
62
+ end
63
+
64
+ # ========================================================================= #
65
+ # === AllInOneShowcasingPrawn.return_random_image
66
+ # ========================================================================= #
67
+ def self.return_random_image # Right now we just return a hardcoded entry.
68
+ '/home/x/data/images/NJOY/Torrie_Wilson.jpg'
69
+ end
70
+
71
+ # ========================================================================= #
72
+ # === generate_the_pdf_document
73
+ # ========================================================================= #
74
+ def generate_the_pdf_document(
75
+ path_to_image = '/home/x/data/images/NJOY/Susanne_01.jpg'
76
+ )
77
+ Prawn::Document.generate(pdf_file?, page_size: 'A4') {
78
+ font 'Times-Roman'
79
+ text 'Hello Prawn!'
80
+ # pdf.image(path_to_dir, :width => 197, :height => 91)
81
+ image path_to_image
82
+ draw_text 'Hello World 1', :at => [200,720], :size => 32
83
+ draw_text 'Hello World 2', :at => [400,920], :size => 28
84
+ text 'Ruby in Red', :color => 'FF0000'
85
+ text 'Ruby in Red', :color => '#FF0000'
86
+ text 'Test', :align => :center, :color => SLATEBLUE
87
+ text 'Test', :align => :center, :color => CRIMSON
88
+ text 'Test', :align => :center, :color => RED
89
+ indent(20) { text('yo') }
90
+ indent(50) { text('yo') }
91
+ start_new_page
92
+ text 'Test', :align => :center, :color => RED
93
+ text 'Test', :align => :center, :color => RED
94
+ move_down 70
95
+ text 'Test', :align => :center, :color => RED
96
+ text_box 'Your Text Here', :align => :right
97
+ add_page
98
+ text_box 'Your Text Here', :align => :right
99
+ image( AllInOneShowcasingPrawn.return_random_image, :width => 100, :height => 100 )
100
+ add_page :layout => :portrait
101
+ text_box 'Your Text Here', :align => :right
102
+ bounding_box [100, 600], :width => 200 do
103
+ move_down 15
104
+ text 'the rain in spain ' * 5
105
+ move_down 15
106
+ stroke {
107
+ line bounds.top_left, bounds.top_right
108
+ line bounds.bottom_left, bounds.bottom_right
109
+ }
110
+ end
111
+ }
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === consider_deleting_old_pdf_file
116
+ # ========================================================================= #
117
+ def consider_deleting_old_pdf_file
118
+ File.delete(pdf_file?) if File.exist? pdf_file?
119
+ end
120
+
121
+ # ========================================================================= #
122
+ # === open_in_pdf_viewer
123
+ # ========================================================================= #
124
+ def open_in_pdf_viewer
125
+ esystem use_this_pdf_viewer+' '+@pdf_file+' &' if File.exist? pdf_file?
126
+ end
127
+
128
+ # ========================================================================= #
129
+ # === use_this_pdf_viewer
130
+ # ========================================================================= #
131
+ def use_this_pdf_viewer
132
+ _ = 'okular'
133
+ if File.exist? MAIN_PDF
134
+ _ = File.read(MAIN_PDF).chomp
135
+ end
136
+ return _
137
+ end
138
+
139
+ # ========================================================================= #
140
+ # === pdf_file?
141
+ # ========================================================================= #
142
+ def pdf_file?
143
+ @pdf_file
144
+ end
145
+
146
+ # ========================================================================= #
147
+ # === run (run tag)
148
+ # ========================================================================= #
149
+ def run
150
+ consider_deleting_old_pdf_file
151
+ generate_the_pdf_document
152
+ report_what_we_will_do
153
+ open_in_pdf_viewer
154
+ end
155
+
156
+ end
157
+
158
+ if __FILE__ == $PROGRAM_NAME
159
+ AllInOneShowcasingPrawn.new
160
+ end # pdftest
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'roebe/requires/require_the_run_class.rb'
6
+ # =========================================================================== #
7
+ require 'roebe/classes/run/run.rb'
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'roebe/shell/shell/class_methods.rb'
6
+ # =========================================================================== #
7
+ require 'roebe/base/base.rb'
8
+
9
+ module Roebe
10
+
11
+ class Shell < Base # === Roebe::Shell
12
+
13
+ # ========================================================================= #
14
+ # === Roebe::Shell.file_menu
15
+ # ========================================================================= #
16
+ def self.file_menu
17
+ Roebe.project_base_directory?+'shell/shell/menu.rb'
18
+ end
19
+
20
+ end; end
21
+
22
+ if __FILE__ == $PROGRAM_NAME
23
+ puts Roebe::Shell.file_menu
24
+ puts File.exist?(Roebe::Shell.file_menu)
25
+ end
@@ -79,6 +79,9 @@ class Shell < Base # === Roebe::Shell
79
79
  end
80
80
  end
81
81
 
82
+ begin
83
+ require 'open'
84
+ rescue LoadError; end
82
85
  # ========================================================================= #
83
86
  # === open_in_browser (browser tag)
84
87
  #
@@ -209,7 +212,7 @@ class Shell < Base # === Roebe::Shell
209
212
  # _ << ' &' # This line is not absolutely required.
210
213
  # end
211
214
  # esystem(_)
212
- if Object.const_defined? :Open
215
+ if Object.const_defined?(:Open)
213
216
  if is_on_roebe?
214
217
  i = prettify_this_url(i)
215
218
  end
@@ -75,8 +75,37 @@ class Shell < Base # === Roebe::Shell
75
75
  # ===================================================================== #
76
76
  this_file = convert_global_env(this_file) if this_file.include? '$'
77
77
  if File.file? this_file
78
- result = ::Roebe.get_file_content(this_file)
78
+ # =================================================================== #
79
+ # Obtain the file content of the target file next:
80
+ # =================================================================== #
81
+ result = Roebe.get_file_content(this_file)
79
82
  result = result.join if result.is_a? Array
83
+ extname = File.extname(this_file).delete('.')
84
+ # =================================================================== #
85
+ # Enter the following only if we may use colours, among other checks.
86
+ # =================================================================== #
87
+ if use_colours? and use_coderay? and defined?(CodeRay)
88
+ case extname # Won't have leading '.'
89
+ # ================================================================= #
90
+ # === cgi, rb
91
+ # ================================================================= #
92
+ when 'cgi',
93
+ 'rb'
94
+ result = CodeRay.scan(result, :ruby).term
95
+ # ================================================================= #
96
+ # === py
97
+ #
98
+ # This entry point is specifically for python files (aka .py).
99
+ # ================================================================= #
100
+ when 'py'
101
+ result = CodeRay.scan(result, :python).term
102
+ # ================================================================= #
103
+ # === php, xml
104
+ # ================================================================= #
105
+ when 'php','xml'
106
+ result = CodeRay.scan(result, extname.to_sym).term
107
+ end
108
+ end
80
109
  e result
81
110
  else
82
111
  e 'File at '+sfile(this_file)+' does not exist.'
@@ -86,7 +115,7 @@ class Shell < Base # === Roebe::Shell
86
115
  alias display_file cat # === display_file
87
116
  # alias cat get_file_content # Since Nov 2011 cat is no longer a 1:1 alias.
88
117
 
89
- def cat2
118
+ def cat2_DEPRECATED
90
119
  if i.is_a? Array
91
120
  # ===================================================================== #
92
121
  # === Handle redirections next
@@ -126,30 +155,7 @@ class Shell < Base # === Roebe::Shell
126
155
  # Ok, first check if the file exists.
127
156
  # ===================================================================== #
128
157
  if File.exist? i
129
- # ================================================================= #
130
- # Enter the following only if we may use colours.
131
- # ================================================================= #
132
- if use_colours?
133
- extname = File.extname(i).to_s[1..-1]
134
- case extname # Won't have leading '.'
135
- # =============================================================== #
136
- # === cgi, rb
137
- # =============================================================== #
138
- when 'cgi',
139
- 'rb'
140
- result = CodeRay.scan(result, :ruby).term
141
- # =============================================================== #
142
- # === py
143
- # =============================================================== #
144
- when 'py' # To test this, do: cat $PROGL/PYTHON/SRC/GAMES/GODMODE/arena.py
145
- result = CodeRay.scan(result, :python).term
146
- # =============================================================== #
147
- # === php, xml
148
- # =============================================================== #
149
- when 'php','xml'
150
- result = CodeRay.scan(result, extname.to_sym).term
151
- end if defined?(CodeRay) and use_coderay?
152
- end
158
+ # CHECK FOR CODERAY 111
153
159
  # ================================================================= #
154
160
  # Next, we scan for HTTP Links if possible.
155
161
  # All discovered HTTP-like links will be registered.
@@ -168,9 +174,9 @@ class Shell < Base # === Roebe::Shell
168
174
  if result.nil?
169
175
  e "Empty file at #{sfile(i.to_s)} (no file content)."
170
176
  else
171
- # =============================================================== #
177
+ # ================================================================= #
172
178
  # Show the result next. This constitutes the "cat-functionality".
173
- # =============================================================== #
179
+ # ================================================================= #
174
180
  e result, :do_not_parse_this
175
181
  end
176
182
  # ================================================================= #
@@ -19,8 +19,19 @@ class Shell < Base # === Roebe::Shell
19
19
  # ========================================================================= #
20
20
  def disable_colours(
21
21
  also_save_config = true,
22
- be_verbose = true
22
+ be_verbose = true,
23
+ &block
23
24
  )
25
+ if block_given?
26
+ yielded = yield
27
+ case yielded
28
+ # ===================================================================== #
29
+ # === :be_quiet
30
+ # ===================================================================== #
31
+ when :be_quiet
32
+ be_verbose = false
33
+ end
34
+ end
24
35
  case be_verbose
25
36
  # ======================================================================= #
26
37
  # === :be_quiet
@@ -97,7 +97,7 @@ class Shell < Base # === Roebe::Shell
97
97
  # Next, delegate towards IO.popen. In the past we used system()
98
98
  # instead. We will still show the command that will be run.
99
99
  # ===================================================================== #
100
- e orchid(cmd_to_run)
100
+ ecolsystem(cmd_to_run)
101
101
  begin
102
102
  io_object = IO.popen(cmd_to_run, :err => [:child, :out]).each { |line|
103
103
  ee line # Output here.
@@ -119,4 +119,13 @@ class Shell < Base # === Roebe::Shell
119
119
  end
120
120
  end
121
121
 
122
+ # ========================================================================= #
123
+ # === ecolsystem
124
+ #
125
+ # This method can be used to colourize a system command.
126
+ # ========================================================================= #
127
+ def ecolsystem(cmd_to_run = 'ls')
128
+ e orchid(cmd_to_run)
129
+ end
130
+
122
131
  end; end
@@ -277,27 +277,6 @@ ROEBE_SUBSECTION
277
277
  register_this_help_option
278
278
  end
279
279
 
280
- # ========================================================================= #
281
- # === show_help_options_intro
282
- #
283
- # This method will show the generic header for the available help options
284
- # of the Roebe::Shell.
285
- # ========================================================================= #
286
- def show_help_options_intro
287
- e N+'============================================= '+
288
- yel('Roebe::Shell Help Options')+rev+N
289
- e 'Shortcuts are available for most inbuilt-commands.'
290
- e " (Note: You can omit the _ and ? in all shortcuts, if you want to.)#{N}"
291
- e 'For a more complete explanation, with all available options, please '\
292
- 'refer to'
293
- e 'the Roebe::Shell tutorial, which can be found here:'
294
- e
295
- e mediumseagreen(' https://www.rubydoc.info/gems/roebe')
296
- e
297
- e "The following inbuilt #{pink('help options')} are documented:"
298
- e
299
- end
300
-
301
280
  # ========================================================================= #
302
281
  # === return_sanitized_help_menu
303
282
  # ========================================================================= #
@@ -445,4 +424,28 @@ ROEBE_SUBSECTION
445
424
  Roebe::Shell.return_help_menu
446
425
  end
447
426
 
427
+ # ========================================================================= #
428
+ # === show_help_options_intro
429
+ #
430
+ # This method will show the generic header for the available help options
431
+ # of the Roebe::Shell.
432
+ # ========================================================================= #
433
+ def show_help_options_intro
434
+ e N+'============================================= '+
435
+ yel('Roebe::Shell Help Options', use_colours?)+
436
+ rev+N
437
+ e 'Shortcuts are available for most inbuilt-commands.'
438
+ e " (Note: You can omit the _ and ? in all shortcuts, if you want to.)#{N}"
439
+ e 'For a more complete explanation, with all available options, please '\
440
+ 'refer to'
441
+ e 'the Roebe::Shell tutorial, which can be found here:'
442
+ e
443
+ e mediumseagreen(' https://www.rubydoc.info/gems/roebe', use_colours?)
444
+ e
445
+ e "The following inbuilt "+
446
+ pink('help options', use_colours?)+
447
+ " are documented:"
448
+ e
449
+ end
450
+
448
451
  end; end
@@ -10,6 +10,13 @@ module Roebe
10
10
 
11
11
  class Shell < Base # === Roebe::Shell
12
12
 
13
+ # ========================================================================= #
14
+ # === last_result?
15
+ # ========================================================================= #
16
+ def last_result?
17
+ @internal_hash[:last_result]
18
+ end
19
+
13
20
  # ========================================================================= #
14
21
  # === open_in_background?
15
22
  # ========================================================================= #
@@ -140,13 +147,6 @@ class Shell < Base # === Roebe::Shell
140
147
  config? and config?.autoconvert_numbers
141
148
  end
142
149
 
143
- # ========================================================================= #
144
- # === last_result?
145
- # ========================================================================= #
146
- def last_result?
147
- @internal_hash[:last_result]
148
- end
149
-
150
150
  # ========================================================================= #
151
151
  # === hash_file_positions?
152
152
  # ========================================================================= #
@@ -12,6 +12,21 @@ module Roebe
12
12
 
13
13
  class Shell < Base # === Roebe::Shell
14
14
 
15
+ # ========================================================================= #
16
+ # === clear_last_result
17
+ # ========================================================================= #
18
+ def clear_last_result
19
+ @internal_hash[:last_result].clear # This should work, as it is a String.
20
+ end
21
+
22
+ # ========================================================================= #
23
+ # === set_last_result
24
+ # ========================================================================= #
25
+ def set_last_result(i)
26
+ @internal_hash[:last_result] = i
27
+ return @internal_hash[:last_result]
28
+ end; alias set_result set_last_result # === set_result
29
+
15
30
  # ========================================================================= #
16
31
  # === set_shall_we_try_to_use_readline_for_the_user_input
17
32
  # ========================================================================= #
@@ -54,6 +54,16 @@ class Shell < Base # === Roebe::Shell
54
54
  end
55
55
  end
56
56
 
57
+ # ========================================================================= #
58
+ # === report_return_date
59
+ # ========================================================================= #
60
+ def report_return_date
61
+ _ = return_date
62
+ e simp(_)
63
+ set_result(_)
64
+ return _
65
+ end
66
+
57
67
  # ========================================================================= #
58
68
  # === show_configuration (config tag)
59
69
  #
@@ -207,6 +217,7 @@ class Shell < Base # === Roebe::Shell
207
217
  _.run
208
218
  # _.display # This is no longer necessary as of May 2022.
209
219
  end
220
+ set_result(_.result?) if _.result?
210
221
  end; alias display_directory_content show_directory_content # === display_directory_content
211
222
 
212
223
  # ========================================================================= #
@@ -384,13 +395,6 @@ class Shell < Base # === Roebe::Shell
384
395
  alias show_setpoints show_jumpers # === show_setpoints
385
396
  alias setpoints? show_jumpers # === setpoints?
386
397
 
387
- # ========================================================================= #
388
- # === report_return_date
389
- # ========================================================================= #
390
- def report_return_date
391
- e simp(return_date)
392
- end
393
-
394
398
  # ========================================================================= #
395
399
  # === show_modules
396
400
  #
@@ -35,7 +35,10 @@ class Shell < Base # === Roebe::Shell
35
35
  end
36
36
  if File.exist? this_file
37
37
  if Object.const_defined? :StatFile
38
- StatFile.new(this_file) # bl $RSRC/stat_file/lib/stat_file/stat_file.rb
38
+ stat_file = StatFile.new(this_file) # bl $RSRC/stat_file/lib/stat_file/stat_file.rb
39
+ set_result(
40
+ stat_file.text?
41
+ ) # This ^^^ is done specifically to support GUIs.
39
42
  else
40
43
  e 'The class StatFile is not available. Please install the gem called '\
41
44
  'stat_file.'