rcfiles 1.2.46

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 (101) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +559 -0
  3. data/bin/rcfiles +12 -0
  4. data/bin/rcfiles_run_it +7 -0
  5. data/doc/README.gen +516 -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 +111 -0
  15. data/lib/rcfiles/commandline/commandline.rb +177 -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 +647 -0
  19. data/lib/rcfiles/directory_aliases/toplevel_stored_dataset.rb +177 -0
  20. data/lib/rcfiles/directory_aliases/yaml_file_used_by_class_directory_aliases.rb +67 -0
  21. data/lib/rcfiles/files/file_aliases.rb +78 -0
  22. data/lib/rcfiles/files/file_cd_aliases.rb +85 -0
  23. data/lib/rcfiles/files/file_ls_colours.rb +76 -0
  24. data/lib/rcfiles/files/file_path_variable.rb +74 -0
  25. data/lib/rcfiles/files/file_pkgconfig.rb +74 -0
  26. data/lib/rcfiles/files/file_programs_aliases.rb +68 -0
  27. data/lib/rcfiles/files/file_ps1.rb +80 -0
  28. data/lib/rcfiles/files/file_system_settings.rb +66 -0
  29. data/lib/rcfiles/help/help.rb +46 -0
  30. data/lib/rcfiles/no_colours.rb +13 -0
  31. data/lib/rcfiles/project/project.rb +45 -0
  32. data/lib/rcfiles/rcfiles/README.md +5 -0
  33. data/lib/rcfiles/rcfiles/aliases_rc +20431 -0
  34. data/lib/rcfiles/rcfiles/cd_aliases_rc +14980 -0
  35. data/lib/rcfiles/rcfiles/cflags_rc +9 -0
  36. data/lib/rcfiles/rcfiles/compile_rc +11 -0
  37. data/lib/rcfiles/rcfiles/file_information_rc +16 -0
  38. data/lib/rcfiles/rcfiles/gnome_rc +10 -0
  39. data/lib/rcfiles/rcfiles/kde_rc +17 -0
  40. data/lib/rcfiles/rcfiles/kernel_rc +12 -0
  41. data/lib/rcfiles/rcfiles/lang_rc +9 -0
  42. data/lib/rcfiles/rcfiles/ldflags_rc +8 -0
  43. data/lib/rcfiles/rcfiles/ls_colours_rc +9 -0
  44. data/lib/rcfiles/rcfiles/network_rc +37 -0
  45. data/lib/rcfiles/rcfiles/path_variable_rc +9 -0
  46. data/lib/rcfiles/rcfiles/pkgconfig_rc +9 -0
  47. data/lib/rcfiles/rcfiles/programs_aliases_rc +17571 -0
  48. data/lib/rcfiles/rcfiles/ps1_rc +9 -0
  49. data/lib/rcfiles/rcfiles/special_aliases_rc +8 -0
  50. data/lib/rcfiles/rcfiles/system_rc +13 -0
  51. data/lib/rcfiles/rcfiles/system_settings_rc +192 -0
  52. data/lib/rcfiles/rcfiles/term_rc +9 -0
  53. data/lib/rcfiles/rcfiles/video_rc +24 -0
  54. data/lib/rcfiles/requires/require_the_directory_aliases.rb +7 -0
  55. data/lib/rcfiles/requires/require_the_rcfiles_constants.rb +18 -0
  56. data/lib/rcfiles/requires/require_the_rcfiles_project.rb +67 -0
  57. data/lib/rcfiles/requires/try_to_require_syck_and_psych.rb +18 -0
  58. data/lib/rcfiles/toplevel_methods/autogenerate_rc_file_from_this_yaml_file.rb +102 -0
  59. data/lib/rcfiles/toplevel_methods/change_directory.rb +16 -0
  60. data/lib/rcfiles/toplevel_methods/convert.rb +118 -0
  61. data/lib/rcfiles/toplevel_methods/convert_global_variables_in_the_cd_aliases_file_to_a_standalone_yaml_file.rb +50 -0
  62. data/lib/rcfiles/toplevel_methods/create_windows_cd_aliases_bat_file.rb +51 -0
  63. data/lib/rcfiles/toplevel_methods/e.rb +16 -0
  64. data/lib/rcfiles/toplevel_methods/esystem.rb +19 -0
  65. data/lib/rcfiles/toplevel_methods/generate_yaml_files.rb +148 -0
  66. data/lib/rcfiles/toplevel_methods/infer.rb +83 -0
  67. data/lib/rcfiles/toplevel_methods/is_on_roebe.rb +16 -0
  68. data/lib/rcfiles/toplevel_methods/main_directory.rb +108 -0
  69. data/lib/rcfiles/toplevel_methods/misc.rb +341 -0
  70. data/lib/rcfiles/toplevel_methods/n_registered_aliases_in_total.rb +55 -0
  71. data/lib/rcfiles/toplevel_methods/no_file_exists_at.rb +19 -0
  72. data/lib/rcfiles/toplevel_methods/notifications.rb +35 -0
  73. data/lib/rcfiles/toplevel_methods/rds.rb +16 -0
  74. data/lib/rcfiles/toplevel_methods/remove_newlines.rb +29 -0
  75. data/lib/rcfiles/toplevel_methods/report.rb +53 -0
  76. data/lib/rcfiles/toplevel_methods/return_standard_header.rb +36 -0
  77. data/lib/rcfiles/toplevel_methods/run_it.rb +46 -0
  78. data/lib/rcfiles/toplevel_methods/save_file.rb +27 -0
  79. data/lib/rcfiles/toplevel_methods/use_psych_or_syck.rb +50 -0
  80. data/lib/rcfiles/toplevel_methods/use_quotes.rb +68 -0
  81. data/lib/rcfiles/toplevel_methods/verbosity.rb +28 -0
  82. data/lib/rcfiles/version/version.rb +26 -0
  83. data/lib/rcfiles/yaml/aliases.yml +23069 -0
  84. data/lib/rcfiles/yaml/cd_aliases.yml +15699 -0
  85. data/lib/rcfiles/yaml/global_variables/README.md +3 -0
  86. data/lib/rcfiles/yaml/global_variables/global_variables_extracted_from_the_file_cd_aliases.yml +121 -0
  87. data/lib/rcfiles/yaml/ls_colours.yml +128 -0
  88. data/lib/rcfiles/yaml/path_variable.yml +13 -0
  89. data/lib/rcfiles/yaml/pkgconfig.yml +46 -0
  90. data/lib/rcfiles/yaml/programs_aliases.yml +19203 -0
  91. data/lib/rcfiles/yaml/programs_aliases.yml~ +19086 -0
  92. data/lib/rcfiles/yaml/ps1.yml +82 -0
  93. data/lib/rcfiles/yaml/store_into_this_directory.yml +1 -0
  94. data/lib/rcfiles/yaml/system_settings.yml +526 -0
  95. data/lib/rcfiles/yaml/use_psych_or_syck.yml +1 -0
  96. data/lib/rcfiles.rb +1 -0
  97. data/rcfiles.gemspec +57 -0
  98. data/test/testing_directory_aliases.rb +47 -0
  99. data/test/testing_using_another_path_to_directory_aliases.rb +17 -0
  100. data/test/testing_yaml_to_rcfiles.rb +9 -0
  101. metadata +205 -0
@@ -0,0 +1,341 @@
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); e "Next generating #{teal('custom roebe rcfiles')}:"
97
+ end
98
+ hash.each_pair {|path_to_the_yaml_file, type_to_use|
99
+ unless File.exist? path_to_the_yaml_file
100
+ # =================================================================== #
101
+ # The file does not exist, but it may exist in the main directory
102
+ # where these .yml files are typically stored on my home system.
103
+ # =================================================================== #
104
+ target = "#{LINUX_YAML_BASE_DIRECTORY}#{path_to_the_yaml_file}"
105
+ if File.exist? target
106
+ path_to_the_yaml_file = target
107
+ end
108
+ end
109
+ # ===================================================================== #
110
+ # Now we can begin to autogenerate the new rc-file, if the file exists:
111
+ # ===================================================================== #
112
+ _ = path_to_the_yaml_file
113
+ if File.exist? _
114
+ require 'yaml'
115
+ require 'rcfiles/toplevel_methods/convert.rb'
116
+ case type_to_use
117
+ # =================================================================== #
118
+ # === :export
119
+ #
120
+ # Handle files that must use export= settings next.
121
+ # =================================================================== #
122
+ when :export
123
+ new_dataset = convert_this_hash_to_export_file(
124
+ YAML.load_file(path_to_the_yaml_file)
125
+ )
126
+ # =================================================================== #
127
+ # Handle files that must use alias settings next:
128
+ # =================================================================== #
129
+ when :aliases
130
+ new_dataset = convert_this_hash_to_alias_file(
131
+ YAML.load_file(path_to_the_yaml_file)
132
+ )
133
+ end
134
+ into = main_directory?+
135
+ File.basename(path_to_the_yaml_file).sub(/\.yml$/,'')+'_rc'
136
+ new_dataset.prepend(
137
+ standard_header?(into)
138
+ )
139
+ write_what_into(new_dataset, into)
140
+ if be_verbose
141
+ opn(namespace: NAMESPACE); e "Storing into the file `#{sfile(into)}`."
142
+ end
143
+ else
144
+ no_file_exists_at(_) if be_verbose
145
+ end
146
+ }
147
+ return hash.keys.map {|entry|
148
+ File.basename(entry).delete_suffix('.yml').to_sym
149
+ }
150
+ end
151
+
152
+ # ========================================================================= #
153
+ # === generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
154
+ # ========================================================================= #
155
+ def self.generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
156
+ generate_system_settings_rcfile
157
+ generate_cd_aliases_rcfile
158
+ generate_aliases_rcfile
159
+ generate_programs_aliases_rcfile
160
+ generate_pkgconfig_rcfile
161
+ generate_ls_colours_rcfile
162
+ generate_path_variable_rcfile
163
+ generate_ps1_rcfile
164
+ return [
165
+ :system_settings,
166
+ :cd_aliases,
167
+ :aliases,
168
+ :programs_aliases,
169
+ :pkgconfig,
170
+ :ls_colours,
171
+ :path_variable,
172
+ :ps1
173
+ ]
174
+ end
175
+
176
+ # ========================================================================= #
177
+ # === Rcfiles.copy_rcfiles_to_the_current_directory
178
+ #
179
+ # This method can be used to quickly copy the rc-files into a
180
+ # (local) directory. It is especially important when some
181
+ # error prevents the user from being able to autogenerate
182
+ # these rc-files.
183
+ # ========================================================================= #
184
+ def self.copy_rcfiles_to_the_current_directory
185
+ target = "#{project_base_dir?}rcfiles/*rc"
186
+ e "Trying to copy the rc-files from #{sdir(target)}"
187
+ e 'into the current directory next:'
188
+ available_files = Dir[target]
189
+ available_files.each {|this_file|
190
+ if File.exist?(this_file) and
191
+ File.file?(this_file) and
192
+ this_file.end_with?('_rc')
193
+ target = (
194
+ Dir.pwd+'/'+File.basename(this_file)
195
+ ).squeeze '/'
196
+ e "Copying `#{sfile(this_file)}` to the current working directory next:"
197
+ FileUtils.cp(this_file, target)
198
+ end
199
+ }
200
+ end; self.instance_eval { alias copy_the_rcfiles copy_rcfiles_to_the_current_directory } # === Rcfiles.copy_the_rcfiles
201
+ self.instance_eval { alias copy_rcfiles copy_rcfiles_to_the_current_directory } # === Rcfiles.copy_rcfiles
202
+
203
+ # =========================================================================== #
204
+ # === Rcfiles.aliases?
205
+ #
206
+ # This method will return all aliases, as a Hash.
207
+ # =========================================================================== #
208
+ def self.aliases?
209
+ hash = {}
210
+ _ = file_aliases?
211
+ if File.exist? _
212
+ hash.merge!(YAML.load_file(_))
213
+ end
214
+ _ = file_cd_aliases?
215
+ if File.exist? _
216
+ hash.merge!(YAML.load_file(_))
217
+ end
218
+ _ = file_programs_aliases?
219
+ if File.exist? _
220
+ hash.merge!(YAML.load_file(_))
221
+ end
222
+ return hash
223
+ end
224
+
225
+ # ========================================================================= #
226
+ # === Rcfiles.install_the_rcfiles_project
227
+ #
228
+ # This method is evidently only useful on my home system.
229
+ # ========================================================================= #
230
+ def self.install_the_rcfiles_project
231
+ target = ENV['USERS'].to_s.dup
232
+ target = '/home' if target.nil? or target.empty?
233
+ cd target+'/x/programming/ruby/src/rcfiles/'
234
+ begin
235
+ require 'roebe/toplevel_methods/rinstall2.rb'
236
+ Roebe.rinstall2
237
+ rescue LoadError; end
238
+ end
239
+
240
+ # ========================================================================= #
241
+ # === Rcfiles.generate_the_most_important_rcfiles
242
+ #
243
+ # Presently, the main rc-files are:
244
+ #
245
+ # (1) cd-aliases rcfile
246
+ # (2) aliases rcfile
247
+ # (3) programs aliases rcfile
248
+ # (4) system settings rcfile
249
+ # (5) pkgconfig rcfile
250
+ # (6) ls_colours rcfile
251
+ # (7) path variable rcfile
252
+ #
253
+ # Keep in mind that the method may also be invoked in these ways:
254
+ #
255
+ # Rcfiles.run { :disable_colours }
256
+ # Rcfiles.run { :be_quiet }
257
+ #
258
+ # ========================================================================= #
259
+ def self.generate_the_most_important_rcfiles(
260
+ generate_which_files = :all,
261
+ &block
262
+ )
263
+ be_verbose = true
264
+ if block_given?
265
+ yielded = yield
266
+ case yielded
267
+ when :be_quiet
268
+ be_verbose = false
269
+ ::Rcfiles.set_be_verbose(false)
270
+ when :disable_colours
271
+ disable_colours
272
+ end
273
+ end
274
+ case generate_which_files
275
+ # ======================================================================= #
276
+ # === :all
277
+ # ======================================================================= #
278
+ when :all,
279
+ :default
280
+ array = generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
281
+ if is_on_roebe?
282
+ # =================================================================== #
283
+ # Next generate roeberia on my home system:
284
+ # =================================================================== #
285
+ if is_on_roebe? and File.exist?(FILE_ROEBERIA_SETTINGS)
286
+ into = main_directory?+'roeberia_settings_rc'
287
+ if be_verbose
288
+ opn(namespace: NAMESPACE)
289
+ e 'Also generating the rc-file from '+
290
+ sfile(FILE_ROEBERIA_SETTINGS)+' into `'+sfile(into)+'` next.'
291
+ end
292
+ what = convert_this_hash_to_export_file(
293
+ YAML.load_file(FILE_ROEBERIA_SETTINGS)
294
+ )
295
+ write_what_into(what, into)
296
+ array.insert(1, :roeberia_settings) # Must be at the second position.
297
+ end
298
+ # =================================================================== #
299
+ # The following subsection is entered only on "roebe-systems",
300
+ # aka my home-systems. Other users do not really need this
301
+ # subsection at all.
302
+ # =================================================================== #
303
+ array << generate_custom_roebe_rcfiles
304
+ array.flatten!
305
+ # =================================================================== #
306
+ # Next create a new master.sh file.
307
+ # =================================================================== #
308
+ into = ::Rcfiles.main_dir?+'source_all_the_rc_files.sh'
309
+ what = ''.dup
310
+ array.each {|entry|
311
+ what << "source "+::Rcfiles.main_dir?+"#{entry}_rc\n"
312
+ }
313
+ opn(namespace: NAMESPACE); e 'Storing into the file `'+sfile(into)+'`.'
314
+ write_what_into(what, into)
315
+ # =================================================================== #
316
+ # Designate another directory as the main target directory:
317
+ # =================================================================== #
318
+ do_use_custom_rcfiles_home_directory_as_target
319
+ generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
320
+ generate_custom_roebe_rcfiles
321
+ @store_into_this_directory = nil
322
+ end
323
+ else
324
+ case generate_which_files
325
+ # ===================================================================== #
326
+ # === :cd_aliases
327
+ # ===================================================================== #
328
+ when :cd_aliases
329
+ generate_cd_aliases_rcfile(&block)
330
+ end
331
+ end
332
+ end; self.instance_eval { alias [] generate_the_most_important_rcfiles } # === Rcfiles[]
333
+ self.instance_eval { alias generate_files generate_the_most_important_rcfiles } # === Rcfiles.generate_files
334
+ self.instance_eval { alias run generate_the_most_important_rcfiles } # === Rcfiles.run
335
+ self.instance_eval { alias new generate_the_most_important_rcfiles } # === Rcfiles.new
336
+
337
+ end
338
+
339
+ if __FILE__ == $PROGRAM_NAME
340
+ pp Rcfiles.aliases?.keys.size
341
+ 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)}`, 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