rcfiles 1.3.47

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

Potentially problematic release.


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

Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +562 -0
  3. data/bin/rcfiles +12 -0
  4. data/bin/rcfiles_run_it +7 -0
  5. data/doc/README.gen +515 -0
  6. data/img/LOGO_FOR_THE_RCFILES_PROJECT.png +0 -0
  7. data/lib/rcfiles/aggregate_all_rcfiles/aggregate_all_rcfiles.rb +137 -0
  8. data/lib/rcfiles/class/colours.rb +54 -0
  9. data/lib/rcfiles/class/initialize.rb +66 -0
  10. data/lib/rcfiles/class/misc.rb +300 -0
  11. data/lib/rcfiles/class/rcfiles.rb +31 -0
  12. data/lib/rcfiles/class/reset.rb +26 -0
  13. data/lib/rcfiles/class/run.rb +17 -0
  14. data/lib/rcfiles/colours/colours.rb +137 -0
  15. data/lib/rcfiles/commandline/commandline.rb +190 -0
  16. data/lib/rcfiles/constants/constants.rb +253 -0
  17. data/lib/rcfiles/directory_aliases/README.md +2 -0
  18. data/lib/rcfiles/directory_aliases/directory_aliases.rb +868 -0
  19. data/lib/rcfiles/files/file_aliases.rb +78 -0
  20. data/lib/rcfiles/files/file_cd_aliases.rb +85 -0
  21. data/lib/rcfiles/files/file_ls_colours.rb +76 -0
  22. data/lib/rcfiles/files/file_path_variable.rb +74 -0
  23. data/lib/rcfiles/files/file_pkgconfig.rb +74 -0
  24. data/lib/rcfiles/files/file_programs_aliases.rb +68 -0
  25. data/lib/rcfiles/files/file_ps1.rb +80 -0
  26. data/lib/rcfiles/files/file_system_settings.rb +75 -0
  27. data/lib/rcfiles/help/help.rb +48 -0
  28. data/lib/rcfiles/no_colours.rb +13 -0
  29. data/lib/rcfiles/project/project.rb +45 -0
  30. data/lib/rcfiles/rcfiles/README.md +5 -0
  31. data/lib/rcfiles/rcfiles/aliases_rc +24986 -0
  32. data/lib/rcfiles/rcfiles/cd_aliases_rc +17016 -0
  33. data/lib/rcfiles/rcfiles/cflags_rc +9 -0
  34. data/lib/rcfiles/rcfiles/compile_rc +11 -0
  35. data/lib/rcfiles/rcfiles/file_information_rc +16 -0
  36. data/lib/rcfiles/rcfiles/gnome_rc +10 -0
  37. data/lib/rcfiles/rcfiles/kde_rc +17 -0
  38. data/lib/rcfiles/rcfiles/kernel_rc +12 -0
  39. data/lib/rcfiles/rcfiles/lang_rc +9 -0
  40. data/lib/rcfiles/rcfiles/ldflags_rc +8 -0
  41. data/lib/rcfiles/rcfiles/ls_colours_rc +9 -0
  42. data/lib/rcfiles/rcfiles/network_rc +37 -0
  43. data/lib/rcfiles/rcfiles/path_variable_rc +9 -0
  44. data/lib/rcfiles/rcfiles/pkgconfig_rc +9 -0
  45. data/lib/rcfiles/rcfiles/programs_aliases_rc +18989 -0
  46. data/lib/rcfiles/rcfiles/ps1_rc +9 -0
  47. data/lib/rcfiles/rcfiles/special_aliases_rc +8 -0
  48. data/lib/rcfiles/rcfiles/system_rc +13 -0
  49. data/lib/rcfiles/rcfiles/system_settings_rc +192 -0
  50. data/lib/rcfiles/rcfiles/term_rc +9 -0
  51. data/lib/rcfiles/rcfiles/video_rc +24 -0
  52. data/lib/rcfiles/requires/require_the_directory_aliases.rb +7 -0
  53. data/lib/rcfiles/requires/require_the_rcfiles_constants.rb +18 -0
  54. data/lib/rcfiles/requires/require_the_rcfiles_project.rb +67 -0
  55. data/lib/rcfiles/requires/try_to_require_syck_and_psych.rb +18 -0
  56. data/lib/rcfiles/toplevel_methods/autogenerate_rc_file_from_this_yaml_file.rb +102 -0
  57. data/lib/rcfiles/toplevel_methods/change_directory.rb +16 -0
  58. data/lib/rcfiles/toplevel_methods/convert.rb +118 -0
  59. data/lib/rcfiles/toplevel_methods/convert_global_variables_in_the_cd_aliases_file_to_a_standalone_yaml_file.rb +50 -0
  60. data/lib/rcfiles/toplevel_methods/create_windows_cd_aliases_bat_file.rb +51 -0
  61. data/lib/rcfiles/toplevel_methods/e.rb +16 -0
  62. data/lib/rcfiles/toplevel_methods/esystem.rb +19 -0
  63. data/lib/rcfiles/toplevel_methods/generate_yaml_files.rb +148 -0
  64. data/lib/rcfiles/toplevel_methods/infer.rb +83 -0
  65. data/lib/rcfiles/toplevel_methods/is_on_roebe.rb +16 -0
  66. data/lib/rcfiles/toplevel_methods/main_directory.rb +108 -0
  67. data/lib/rcfiles/toplevel_methods/misc.rb +343 -0
  68. data/lib/rcfiles/toplevel_methods/n_registered_aliases_in_total.rb +55 -0
  69. data/lib/rcfiles/toplevel_methods/no_file_exists_at.rb +19 -0
  70. data/lib/rcfiles/toplevel_methods/notifications.rb +35 -0
  71. data/lib/rcfiles/toplevel_methods/rds.rb +16 -0
  72. data/lib/rcfiles/toplevel_methods/remove_newlines.rb +29 -0
  73. data/lib/rcfiles/toplevel_methods/report.rb +53 -0
  74. data/lib/rcfiles/toplevel_methods/return_standard_header.rb +36 -0
  75. data/lib/rcfiles/toplevel_methods/run_it.rb +46 -0
  76. data/lib/rcfiles/toplevel_methods/save_file.rb +27 -0
  77. data/lib/rcfiles/toplevel_methods/use_psych_or_syck.rb +50 -0
  78. data/lib/rcfiles/toplevel_methods/use_quotes.rb +68 -0
  79. data/lib/rcfiles/toplevel_methods/verbosity.rb +28 -0
  80. data/lib/rcfiles/version/version.rb +26 -0
  81. data/lib/rcfiles/yaml/aliases.yml +27882 -0
  82. data/lib/rcfiles/yaml/cd_aliases.yml +17818 -0
  83. data/lib/rcfiles/yaml/global_variables/README.md +3 -0
  84. data/lib/rcfiles/yaml/global_variables/global_variables_extracted_from_the_file_cd_aliases.yml +125 -0
  85. data/lib/rcfiles/yaml/ls_colours.yml +128 -0
  86. data/lib/rcfiles/yaml/path_variable.yml +15 -0
  87. data/lib/rcfiles/yaml/pkgconfig.yml +46 -0
  88. data/lib/rcfiles/yaml/programs_aliases.yml +20690 -0
  89. data/lib/rcfiles/yaml/ps1.yml +82 -0
  90. data/lib/rcfiles/yaml/store_into_this_directory.yml +1 -0
  91. data/lib/rcfiles/yaml/system_settings.yml +526 -0
  92. data/lib/rcfiles/yaml/use_psych_or_syck.yml +1 -0
  93. data/lib/rcfiles.rb +1 -0
  94. data/rcfiles.gemspec +57 -0
  95. data/test/testing_directory_aliases.rb +62 -0
  96. data/test/testing_using_another_path_to_directory_aliases.rb +17 -0
  97. data/test/testing_yaml_to_rcfiles.rb +9 -0
  98. metadata +202 -0
@@ -0,0 +1,343 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/misc.rb'
6
+ # =========================================================================== #
7
+ module Rcfiles
8
+
9
+ require 'fileutils'
10
+ require 'rcfiles/project/project.rb'
11
+ require 'rcfiles/files/file_aliases.rb'
12
+ require 'rcfiles/files/file_cd_aliases.rb'
13
+ require 'rcfiles/files/file_programs_aliases.rb'
14
+ require 'rcfiles/files/file_system_settings.rb'
15
+ require 'rcfiles/files/file_pkgconfig.rb'
16
+ require 'rcfiles/files/file_ls_colours.rb'
17
+ require 'rcfiles/files/file_path_variable.rb'
18
+ require 'rcfiles/files/file_ps1.rb'
19
+ require 'rcfiles/constants/constants.rb'
20
+ # ========================================================================= #
21
+ # Add the colours next:
22
+ # ========================================================================= #
23
+ require 'rcfiles/colours/colours.rb'
24
+
25
+ # ========================================================================= #
26
+ # Next, require the toplevel-methods of the rcfiles project:
27
+ # ========================================================================= #
28
+ require 'rcfiles/toplevel_methods/change_directory.rb'
29
+ require 'rcfiles/toplevel_methods/convert.rb'
30
+ require 'rcfiles/toplevel_methods/e.rb'
31
+ require 'rcfiles/toplevel_methods/is_on_roebe.rb'
32
+ require 'rcfiles/toplevel_methods/main_directory.rb'
33
+ require 'rcfiles/toplevel_methods/no_file_exists_at.rb'
34
+ require 'rcfiles/toplevel_methods/return_standard_header.rb'
35
+ require 'rcfiles/toplevel_methods/verbosity.rb'
36
+
37
+ # ========================================================================= #
38
+ # === Rcfiles::ARRAY_MAIN_ALIASES_FILE
39
+ # ========================================================================= #
40
+ ARRAY_MAIN_ALIASES_FILE = [
41
+ file_cd_aliases?,
42
+ file_aliases?,
43
+ file_programs_aliases?,
44
+ file_system_settings?
45
+ ]
46
+
47
+ # ========================================================================= #
48
+ # === Rcfiles.do_use_custom_rcfiles_home_directory_as_target
49
+ #
50
+ # This presently uses a hardcoded path.
51
+ #
52
+ # In the long run this method ought to become more flexible.
53
+ # ========================================================================= #
54
+ def self.do_use_custom_rcfiles_home_directory_as_target
55
+ @store_into_this_directory =
56
+ RUBY_SRC_DIR_AT_HOME+'rcfiles/lib/rcfiles/rcfiles/'
57
+ end
58
+
59
+ # ========================================================================= #
60
+ # === Rcfiles.run_default_action
61
+ #
62
+ # If the argument to this method is true then we will also install
63
+ # the rcfiles project.
64
+ # ========================================================================= #
65
+ def self.run_default_action(
66
+ also_install_the_rcfiles_project = is_on_roebe?
67
+ )
68
+ # ======================================================================= #
69
+ # If we are on roebe then we will also run rinstall2 first.
70
+ # ======================================================================= #
71
+ if also_install_the_rcfiles_project
72
+ install_the_rcfiles_project
73
+ end
74
+ generate_the_most_important_rcfiles
75
+ end
76
+
77
+ # ========================================================================= #
78
+ # === Rcfiles.generate_custom_roebe_rcfiles
79
+ #
80
+ # The following method is mostly useful only on my home system, as there
81
+ # are some .yml files that are not distributed with this project, mostly
82
+ # because other people will not really benefit from these custom
83
+ # definitions, whereas they might benefit from e. g. the cd-aliases
84
+ # or shortcuts (aliased names) to programs, such as "gi" for "gimp"
85
+ # and so forth.
86
+ # ========================================================================= #
87
+ def self.generate_custom_roebe_rcfiles(
88
+ hash = HASH_CUSTOM_FILES,
89
+ be_verbose = ::Rcfiles.be_verbose?
90
+ )
91
+ case be_verbose
92
+ when :be_quiet, :be_silent
93
+ be_verbose = false
94
+ end
95
+ if be_verbose
96
+ opn(namespace: NAMESPACE)
97
+ e "#{rev}Next generating #{teal('custom roebe rcfiles')}#{rev}:"
98
+ end
99
+ hash.each_pair {|path_to_the_yaml_file, type_to_use|
100
+ unless File.exist? path_to_the_yaml_file
101
+ # =================================================================== #
102
+ # The file does not exist, but it may exist in the main directory
103
+ # where these .yml files are typically stored on my home system.
104
+ # =================================================================== #
105
+ target = "#{LINUX_YAML_BASE_DIRECTORY}#{path_to_the_yaml_file}"
106
+ if File.exist? target
107
+ path_to_the_yaml_file = target
108
+ end
109
+ end
110
+ # ===================================================================== #
111
+ # Now we can begin to autogenerate the new rc-file, if the file exists:
112
+ # ===================================================================== #
113
+ _ = path_to_the_yaml_file
114
+ if File.exist? _
115
+ require 'yaml'
116
+ require 'rcfiles/toplevel_methods/convert.rb'
117
+ case type_to_use
118
+ # =================================================================== #
119
+ # === :export
120
+ #
121
+ # Handle files that must use export= settings next.
122
+ # =================================================================== #
123
+ when :export
124
+ new_dataset = convert_this_hash_to_export_file(
125
+ YAML.load_file(path_to_the_yaml_file)
126
+ )
127
+ # =================================================================== #
128
+ # Handle files that must use alias settings next:
129
+ # =================================================================== #
130
+ when :aliases
131
+ new_dataset = convert_this_hash_to_alias_file(
132
+ YAML.load_file(path_to_the_yaml_file)
133
+ )
134
+ end
135
+ into = main_directory?+
136
+ File.basename(path_to_the_yaml_file).sub(/\.yml$/,'')+'_rc'
137
+ new_dataset.prepend(
138
+ standard_header?(into)
139
+ )
140
+ write_what_into(new_dataset, into)
141
+ if be_verbose
142
+ opn(namespace: NAMESPACE); e "Storing into the file `#{sfile(into)}`."
143
+ end
144
+ else
145
+ no_file_exists_at(_) if be_verbose
146
+ end
147
+ }
148
+ return hash.keys.map {|entry|
149
+ File.basename(entry).delete_suffix('.yml').to_sym
150
+ }
151
+ end
152
+
153
+ # ========================================================================= #
154
+ # === generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
155
+ # ========================================================================= #
156
+ def self.generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
157
+ generate_system_settings_rcfile
158
+ generate_cd_aliases_rcfile
159
+ generate_aliases_rcfile
160
+ generate_programs_aliases_rcfile
161
+ generate_pkgconfig_rcfile
162
+ generate_ls_colours_rcfile
163
+ generate_path_variable_rcfile
164
+ generate_ps1_rcfile
165
+ return [
166
+ :system_settings,
167
+ :cd_aliases,
168
+ :aliases,
169
+ :programs_aliases,
170
+ :pkgconfig,
171
+ :ls_colours,
172
+ :path_variable,
173
+ :ps1
174
+ ]
175
+ end
176
+
177
+ # ========================================================================= #
178
+ # === Rcfiles.copy_rcfiles_to_the_current_directory
179
+ #
180
+ # This method can be used to quickly copy the rc-files into a
181
+ # (local) directory. It is especially important when some
182
+ # error prevents the user from being able to autogenerate
183
+ # these rc-files.
184
+ # ========================================================================= #
185
+ def self.copy_rcfiles_to_the_current_directory
186
+ target = "#{project_base_dir?}rcfiles/*rc"
187
+ e "Trying to copy the rc-files from #{sdir(target)}"
188
+ e 'into the current directory next:'
189
+ available_files = Dir[target]
190
+ available_files.each {|this_file|
191
+ if File.exist?(this_file) and
192
+ File.file?(this_file) and
193
+ this_file.end_with?('_rc')
194
+ target = (
195
+ Dir.pwd+'/'+File.basename(this_file)
196
+ ).squeeze '/'
197
+ e "Copying `#{sfile(this_file)}` to the current working directory next:"
198
+ FileUtils.cp(this_file, target)
199
+ end
200
+ }
201
+ end; self.instance_eval { alias copy_the_rcfiles copy_rcfiles_to_the_current_directory } # === Rcfiles.copy_the_rcfiles
202
+ self.instance_eval { alias copy_rcfiles copy_rcfiles_to_the_current_directory } # === Rcfiles.copy_rcfiles
203
+
204
+ # =========================================================================== #
205
+ # === Rcfiles.aliases?
206
+ #
207
+ # This method will return all aliases, as a Hash.
208
+ # =========================================================================== #
209
+ def self.aliases?
210
+ hash = {}
211
+ _ = file_aliases?
212
+ if File.exist? _
213
+ hash.merge!(YAML.load_file(_))
214
+ end
215
+ _ = file_cd_aliases?
216
+ if File.exist? _
217
+ hash.merge!(YAML.load_file(_))
218
+ end
219
+ _ = file_programs_aliases?
220
+ if File.exist? _
221
+ hash.merge!(YAML.load_file(_))
222
+ end
223
+ return hash
224
+ end
225
+
226
+ # ========================================================================= #
227
+ # === Rcfiles.install_the_rcfiles_project
228
+ #
229
+ # This method is evidently only useful on my home system.
230
+ # ========================================================================= #
231
+ def self.install_the_rcfiles_project
232
+ target = ENV['USERS'].to_s.dup
233
+ target = '/home' if target.nil? or target.empty?
234
+ cd target+'/x/programming/ruby/src/rcfiles/'
235
+ begin
236
+ require 'roebe/toplevel_methods/rinstall2.rb'
237
+ Roebe.rinstall2
238
+ rescue LoadError; end
239
+ end
240
+
241
+ # ========================================================================= #
242
+ # === Rcfiles.generate_the_most_important_rcfiles
243
+ #
244
+ # Presently, the main rc-files are:
245
+ #
246
+ # (1) cd-aliases rcfile
247
+ # (2) aliases rcfile
248
+ # (3) programs aliases rcfile
249
+ # (4) system settings rcfile
250
+ # (5) pkgconfig rcfile
251
+ # (6) ls_colours rcfile
252
+ # (7) path variable rcfile
253
+ #
254
+ # Keep in mind that the method may also be invoked in these ways:
255
+ #
256
+ # Rcfiles.run { :disable_colours }
257
+ # Rcfiles.run { :be_quiet }
258
+ #
259
+ # ========================================================================= #
260
+ def self.generate_the_most_important_rcfiles(
261
+ generate_which_files = :all,
262
+ &block
263
+ )
264
+ be_verbose = true
265
+ if block_given?
266
+ yielded = yield
267
+ case yielded
268
+ when :be_quiet
269
+ be_verbose = false
270
+ ::Rcfiles.set_be_verbose(false)
271
+ when :disable_colours
272
+ disable_colours
273
+ end
274
+ end
275
+ case generate_which_files
276
+ # ======================================================================= #
277
+ # === :all
278
+ # ======================================================================= #
279
+ when :all,
280
+ :default
281
+ array = generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
282
+ if is_on_roebe?
283
+ # =================================================================== #
284
+ # Next generate roeberia on my home system:
285
+ # =================================================================== #
286
+ if is_on_roebe? and File.exist?(FILE_ROEBERIA_SETTINGS)
287
+ into = main_directory?+'roeberia_settings_rc'
288
+ if be_verbose
289
+ opn(namespace: NAMESPACE)
290
+ e "#{rev}Also generating the rc-file from "\
291
+ "#{sfile(FILE_ROEBERIA_SETTINGS)} #{rev}into "\
292
+ "`#{sfile(into)}#{rev}` next."
293
+ end
294
+ what = convert_this_hash_to_export_file(
295
+ YAML.load_file(FILE_ROEBERIA_SETTINGS)
296
+ )
297
+ write_what_into(what, into)
298
+ array.insert(1, :roeberia_settings) # Must be at the second position.
299
+ end
300
+ # =================================================================== #
301
+ # The following subsection is entered only on "roebe-systems",
302
+ # aka my home-systems. Other users do not really need this
303
+ # subsection at all.
304
+ # =================================================================== #
305
+ array << generate_custom_roebe_rcfiles
306
+ array.flatten!
307
+ # =================================================================== #
308
+ # Next create a new master.sh file.
309
+ # =================================================================== #
310
+ into = ::Rcfiles.main_dir?+'source_all_the_rc_files.sh'
311
+ what = ''.dup
312
+ array.each {|entry|
313
+ what << "source "+::Rcfiles.main_dir?+"#{entry}_rc\n"
314
+ }
315
+ opn(namespace: NAMESPACE); e 'Storing into the file `'+sfile(into)+'`.'
316
+ write_what_into(what, into)
317
+ # =================================================================== #
318
+ # Designate another directory as the main target directory:
319
+ # =================================================================== #
320
+ do_use_custom_rcfiles_home_directory_as_target
321
+ generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
322
+ generate_custom_roebe_rcfiles
323
+ @store_into_this_directory = nil
324
+ end
325
+ else
326
+ case generate_which_files
327
+ # ===================================================================== #
328
+ # === :cd_aliases
329
+ # ===================================================================== #
330
+ when :cd_aliases
331
+ generate_cd_aliases_rcfile(&block)
332
+ end
333
+ end
334
+ end; self.instance_eval { alias [] generate_the_most_important_rcfiles } # === Rcfiles[]
335
+ self.instance_eval { alias generate_files generate_the_most_important_rcfiles } # === Rcfiles.generate_files
336
+ self.instance_eval { alias run generate_the_most_important_rcfiles } # === Rcfiles.run
337
+ self.instance_eval { alias new generate_the_most_important_rcfiles } # === Rcfiles.new
338
+
339
+ end
340
+
341
+ if __FILE__ == $PROGRAM_NAME
342
+ pp Rcfiles.aliases?.keys.size
343
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/n_registered_aliases_in_total.rb'
6
+ # Rcfiles.n_registered_aliases_in_total?
7
+ # =========================================================================== #
8
+ # require 'rcfiles/toplevel_methods/n_registered_aliases_in_total.rb'
9
+ # =========================================================================== #
10
+ require 'rcfiles/files/file_aliases.rb'
11
+ require 'rcfiles/files/file_cd_aliases.rb'
12
+ require 'rcfiles/files/file_programs_aliases.rb'
13
+
14
+ module Rcfiles
15
+
16
+ # ========================================================================= #
17
+ # === Rcfiles.n_registered_aliases_in_total?
18
+ #
19
+ # This method will return, as a Number, how many aliases are registered
20
+ # in total in this project.
21
+ #
22
+ # We will only consider three files for the purpose of this method:
23
+ #
24
+ # aliases.yml
25
+ # cd_aliases.yml
26
+ # programs_aliases.yml
27
+ #
28
+ # ========================================================================= #
29
+ def self.n_registered_aliases_in_total?
30
+ require 'yaml'
31
+ # ======================================================================= #
32
+ # We will store into the variable n_aliases how many entries are
33
+ # registered in total.
34
+ # ======================================================================= #
35
+ n_aliases = 0
36
+ _ = file_aliases?
37
+ if File.exist? _
38
+ n_aliases += YAML.load_file(_).keys.size # === aliases.yml
39
+ end
40
+ _ = file_cd_aliases?
41
+ if File.exist? _
42
+ n_aliases += YAML.load_file(_).keys.size # === cd_aliases.yml
43
+ end
44
+ _ = file_programs_aliases?
45
+ if File.exist? _
46
+ n_aliases += YAML.load_file(_).keys.size # === programs_aliases.yml
47
+ end
48
+ n_aliases
49
+ end
50
+
51
+ end
52
+
53
+ if __FILE__ == $PROGRAM_NAME
54
+ puts Rcfiles.n_registered_aliases_in_total?
55
+ end # n_registered_aliases_in_total
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/no_file_exists_at.rb'
6
+ # =========================================================================== #
7
+ require 'rcfiles/colours/colours.rb'
8
+ require 'rcfiles/toplevel_methods/e.rb'
9
+
10
+ module Rcfiles
11
+
12
+ # ========================================================================= #
13
+ # === Rcfiles.no_file_exists_at
14
+ # ========================================================================= #
15
+ def self.no_file_exists_at(i)
16
+ e "No file exists at `#{sfile(i)}`."
17
+ end
18
+
19
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # The purpose of this file is to bundle code that can be used to notify
6
+ # the user, for example, when a file is generated. Before this file was
7
+ # created there was a lot of redundancy in different files; now we have
8
+ # unified this under this new .rb file here (November 2019:
9
+ # =========================================================================== #
10
+ # require 'rcfiles/toplevel_methods/notifications.rb'
11
+ # =========================================================================== #
12
+ module Rcfiles
13
+
14
+ require 'yaml'
15
+
16
+ require 'rcfiles/colours/colours.rb'
17
+ require 'rcfiles/toplevel_methods/main_directory.rb'
18
+ require 'rcfiles/toplevel_methods/no_file_exists_at.rb'
19
+ require 'rcfiles/toplevel_methods/return_standard_header.rb'
20
+
21
+ # ========================================================================= #
22
+ # === Rcfiles.notify_the_user_that_this_file_will_be_generated_from_that_existing_file
23
+ #
24
+ # This method only notifies the user. It does not generate any file on
25
+ # its own.
26
+ # ========================================================================= #
27
+ def self.notify_the_user_that_this_file_will_be_generated_from_that_existing_file(
28
+ this_file,
29
+ that_existing_file
30
+ )
31
+ opn(namespace: NAMESPACE); e "#{rev}Now generating `#{sfile(this_file)}#{rev}`, from "
32
+ opn(namespace: NAMESPACE); e "#{sfile(that_existing_file)}."
33
+ end
34
+
35
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/rds.rb'
6
+ # =========================================================================== #
7
+ module Rcfiles
8
+
9
+ # ========================================================================= #
10
+ # === Rcfiles.rds
11
+ # ========================================================================= #
12
+ def self.rds(i)
13
+ i.squeeze('/')
14
+ end
15
+
16
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/remove_newlines.rb'
6
+ # =========================================================================== #
7
+ module Rcfiles
8
+
9
+ # ========================================================================= #
10
+ # === Rcfiles.remove_newlines
11
+ #
12
+ # This method will remove all newlines of the given input. The given
13
+ # input is the first argument to this method.
14
+ #
15
+ # The optional second input to this method can be used to also ensure
16
+ # that a proper encoding is used.
17
+ # ========================================================================= #
18
+ def self.remove_newlines(
19
+ i,
20
+ ensure_this_encoding = nil # 'ISO-8859-1' # <- or nil.
21
+ )
22
+ if ensure_this_encoding
23
+ i = i.force_encoding(ensure_this_encoding)
24
+ end
25
+ i.delete!("\n") if i.include?("\n")
26
+ return i
27
+ end
28
+
29
+ end
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/report.rb'
6
+ # =========================================================================== #
7
+ module Rcfiles
8
+
9
+ require 'rcfiles/toplevel_methods/e.rb'
10
+ require 'rcfiles/toplevel_methods/main_directory.rb'
11
+ require 'rcfiles/toplevel_methods/misc.rb'
12
+ require 'rcfiles/colours/colours.rb'
13
+ require 'rcfiles/files/file_aliases.rb'
14
+ require 'rcfiles/files/file_cd_aliases.rb'
15
+ require 'rcfiles/files/file_programs_aliases.rb'
16
+
17
+ # ========================================================================= #
18
+ # === Rcfiles.report
19
+ #
20
+ # This method will report some information about where the Rcfiles
21
+ # will collect information.
22
+ # ========================================================================= #
23
+ def self.report
24
+ e 'The main directory is at:'
25
+ e
26
+ e " #{sdir(main_directory?)}"
27
+ unless File.directory? main_directory?
28
+ e 'This directory could, however had, NOT be found.'
29
+ end
30
+ e
31
+ e 'The three main .yml aliases paths are:'
32
+ e
33
+ e ' file aliases: '+sfile(file_aliases?)
34
+ unless File.exist? file_aliases?
35
+ e 'This file could not be found.'
36
+ end
37
+ e ' file cd aliases: '+sfile(file_cd_aliases?)
38
+ unless File.exist? file_cd_aliases?
39
+ e 'This file could not be found.'
40
+ end
41
+ e ' file programs aliases: '+sfile(file_programs_aliases?)
42
+ unless File.exist? file_programs_aliases?
43
+ e 'This file could not be found.'
44
+ end
45
+ e
46
+ end
47
+
48
+ end
49
+
50
+
51
+ if __FILE__ == $PROGRAM_NAME
52
+ Rcfiles.report
53
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/return_standard_header.rb'
6
+ # Rcfiles.return_standard_header('cd_aliases_rc')
7
+ # =========================================================================== #
8
+ module Rcfiles
9
+
10
+ # ========================================================================== #
11
+ # === Rcfiles.return_standard_header
12
+ #
13
+ # This adds a standard header to our RC-File in question.
14
+ #
15
+ # The first input argument to this method should be the name of the
16
+ # rc-file at hand.
17
+ # ========================================================================== #
18
+ def self.return_standard_header(
19
+ which_file = '',
20
+ current_date = Time.now.strftime('%d.%m.%Y')
21
+ )
22
+ _ = <<-EOF
23
+ # =========================================================================== #
24
+ # This file was automatically generated at: #{current_date}
25
+ #
26
+ # The filename is:
27
+ #
28
+ # #{which_file}
29
+ #
30
+ # =========================================================================== #
31
+ EOF
32
+ return _
33
+ end; self.instance_eval { alias add_header return_standard_header } # === Rcfiles.add_header
34
+ self.instance_eval { alias standard_header? return_standard_header } # === Rcfiles.standard_header?
35
+
36
+ end
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # The method in this file here is mostly a convenience-method.
6
+ #
7
+ # It will leverage the old setup.rb file to install a project written in
8
+ # ruby. Of course "gem" is the more modern way to go about this, but
9
+ # sometimes, due to various reasons, you may want to use setup.rb
10
+ # instead, which explains why this file here has been created.
11
+ # =========================================================================== #
12
+ # require 'rcfiles/toplevel_methods/run_it.rb'
13
+ # =========================================================================== #
14
+ module Rcfiles
15
+
16
+ # ========================================================================= #
17
+ # === Rcfiles.run_it
18
+ # ========================================================================= #
19
+ def self.run_it(
20
+ optional_arguments = ARGV
21
+ )
22
+ require 'rcfiles/requires/require_the_rcfiles_project.rb'
23
+ require 'convert_global_env'
24
+ Dir.chdir(ConvertGlobalEnv['$RSRC/rcfiles/']) # cd to it.
25
+ begin
26
+ require 'roebe/toplevel_methods/setup.rb'
27
+ Roebe.copy_setup_file_to_pwd
28
+ rescue LoadError
29
+ puts 'Could not load the file roebe/toplevel_methods/setup.rb'
30
+ end
31
+ if File.exist? 'setup.rb'
32
+ system 'ruby setup.rb --quiet config'
33
+ system 'ruby setup.rb --quiet setup'
34
+ system 'ruby setup.rb --quiet install'
35
+ File.delete('setup.rb') if File.exist? 'setup.rb'
36
+ File.delete('InstalledFiles') if File.exist? 'InstalledFiles'
37
+ File.delete('.config') if File.exist? '.config'
38
+ ::Rcfiles[] { yield if block_given? }
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ if __FILE__ == $PROGRAM_NAME
45
+ Rcfiles.run_it(ARGV)
46
+ end # rcfile_run_it
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/save_file.rb'
6
+ # Rcfiles.write_what_into
7
+ # =========================================================================== #
8
+ module Rcfiles
9
+
10
+ require 'fileutils'
11
+
12
+ # ========================================================================= #
13
+ # === Rcfiles.write_what_into
14
+ #
15
+ # This method can be used to save data into a file.
16
+ # ========================================================================= #
17
+ def self.write_what_into(
18
+ what = '',
19
+ into = ''
20
+ )
21
+ unless File.directory? File.dirname(into)
22
+ FileUtils.mkdir_p(File.dirname(into))
23
+ end
24
+ File.open(into, 'w') { |file| file.write(what) }
25
+ end
26
+
27
+ end