rcfiles 1.1.1137

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 (97) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +401 -0
  3. data/bin/rcfiles +7 -0
  4. data/bin/rcfiles_run_it +7 -0
  5. data/doc/README.gen +384 -0
  6. data/lib/rcfiles.rb +1 -0
  7. data/lib/rcfiles/class/colours.rb +54 -0
  8. data/lib/rcfiles/class/initialize.rb +66 -0
  9. data/lib/rcfiles/class/misc.rb +299 -0
  10. data/lib/rcfiles/class/rcfiles.rb +31 -0
  11. data/lib/rcfiles/class/reset.rb +26 -0
  12. data/lib/rcfiles/class/run.rb +17 -0
  13. data/lib/rcfiles/colours/colours.rb +107 -0
  14. data/lib/rcfiles/commandline/commandline.rb +170 -0
  15. data/lib/rcfiles/constants/custom_files.rb +80 -0
  16. data/lib/rcfiles/constants/encodings.rb +85 -0
  17. data/lib/rcfiles/constants/misc.rb +75 -0
  18. data/lib/rcfiles/constants/namespace.rb +18 -0
  19. data/lib/rcfiles/expand_cd_aliases/constants.rb +50 -0
  20. data/lib/rcfiles/expand_cd_aliases/expand_cd_aliases.rb +626 -0
  21. data/lib/rcfiles/expand_cd_aliases/run.rb +18 -0
  22. data/lib/rcfiles/files/file_aliases.rb +78 -0
  23. data/lib/rcfiles/files/file_cd_aliases.rb +85 -0
  24. data/lib/rcfiles/files/file_ls_colours.rb +76 -0
  25. data/lib/rcfiles/files/file_path_variable.rb +74 -0
  26. data/lib/rcfiles/files/file_pkgconfig.rb +74 -0
  27. data/lib/rcfiles/files/file_programs_aliases.rb +68 -0
  28. data/lib/rcfiles/files/file_ps1.rb +80 -0
  29. data/lib/rcfiles/files/file_system_settings.rb +66 -0
  30. data/lib/rcfiles/help/help.rb +46 -0
  31. data/lib/rcfiles/no_colours.rb +13 -0
  32. data/lib/rcfiles/project/project.rb +45 -0
  33. data/lib/rcfiles/rcfiles/README.md +5 -0
  34. data/lib/rcfiles/rcfiles/aliases_rc +18526 -0
  35. data/lib/rcfiles/rcfiles/cd_aliases_rc +13313 -0
  36. data/lib/rcfiles/rcfiles/cflags_rc +9 -0
  37. data/lib/rcfiles/rcfiles/compile_rc +11 -0
  38. data/lib/rcfiles/rcfiles/file_information_rc +16 -0
  39. data/lib/rcfiles/rcfiles/german_umlaute_rc +264 -0
  40. data/lib/rcfiles/rcfiles/gnome_rc +10 -0
  41. data/lib/rcfiles/rcfiles/kde_rc +17 -0
  42. data/lib/rcfiles/rcfiles/kernel_rc +12 -0
  43. data/lib/rcfiles/rcfiles/lang_rc +9 -0
  44. data/lib/rcfiles/rcfiles/ldflags_rc +8 -0
  45. data/lib/rcfiles/rcfiles/ls_colours_rc +9 -0
  46. data/lib/rcfiles/rcfiles/network_rc +37 -0
  47. data/lib/rcfiles/rcfiles/path_variable_rc +9 -0
  48. data/lib/rcfiles/rcfiles/pkgconfig_rc +9 -0
  49. data/lib/rcfiles/rcfiles/programs_aliases_rc +15597 -0
  50. data/lib/rcfiles/rcfiles/ps1_rc +9 -0
  51. data/lib/rcfiles/rcfiles/special_aliases_rc +23 -0
  52. data/lib/rcfiles/rcfiles/system_rc +13 -0
  53. data/lib/rcfiles/rcfiles/system_settings_rc +191 -0
  54. data/lib/rcfiles/rcfiles/term_rc +9 -0
  55. data/lib/rcfiles/rcfiles/video_rc +24 -0
  56. data/lib/rcfiles/requires/require_the_expand_cd_aliases.rb +7 -0
  57. data/lib/rcfiles/requires/require_the_rcfiles_constants.rb +21 -0
  58. data/lib/rcfiles/requires/require_the_rcfiles_project.rb +66 -0
  59. data/lib/rcfiles/requires/try_to_require_syck_and_psych.rb +18 -0
  60. data/lib/rcfiles/toplevel_methods/autogenerate_rc_file_from_this_yaml_file.rb +102 -0
  61. data/lib/rcfiles/toplevel_methods/change_directory.rb +16 -0
  62. data/lib/rcfiles/toplevel_methods/convert.rb +118 -0
  63. data/lib/rcfiles/toplevel_methods/create_windows_cd_aliases_bat_file.rb +51 -0
  64. data/lib/rcfiles/toplevel_methods/e.rb +16 -0
  65. data/lib/rcfiles/toplevel_methods/esystem.rb +19 -0
  66. data/lib/rcfiles/toplevel_methods/generate_yaml_files.rb +148 -0
  67. data/lib/rcfiles/toplevel_methods/infer.rb +83 -0
  68. data/lib/rcfiles/toplevel_methods/is_on_roebe.rb +16 -0
  69. data/lib/rcfiles/toplevel_methods/main_directory.rb +108 -0
  70. data/lib/rcfiles/toplevel_methods/misc.rb +304 -0
  71. data/lib/rcfiles/toplevel_methods/n_registered_aliases_in_total.rb +55 -0
  72. data/lib/rcfiles/toplevel_methods/no_file_exists_at.rb +19 -0
  73. data/lib/rcfiles/toplevel_methods/notifications.rb +33 -0
  74. data/lib/rcfiles/toplevel_methods/rds.rb +16 -0
  75. data/lib/rcfiles/toplevel_methods/remove_newlines.rb +29 -0
  76. data/lib/rcfiles/toplevel_methods/report.rb +53 -0
  77. data/lib/rcfiles/toplevel_methods/return_standard_header.rb +36 -0
  78. data/lib/rcfiles/toplevel_methods/run_it.rb +46 -0
  79. data/lib/rcfiles/toplevel_methods/save_file.rb +27 -0
  80. data/lib/rcfiles/toplevel_methods/use_psych_or_syck.rb +50 -0
  81. data/lib/rcfiles/toplevel_methods/use_quotes.rb +68 -0
  82. data/lib/rcfiles/toplevel_methods/verbosity.rb +28 -0
  83. data/lib/rcfiles/version/version.rb +26 -0
  84. data/lib/rcfiles/yaml/aliases.yml +20991 -0
  85. data/lib/rcfiles/yaml/cd_aliases.yml +13970 -0
  86. data/lib/rcfiles/yaml/ls_colours.yml +128 -0
  87. data/lib/rcfiles/yaml/path_variable.yml +12 -0
  88. data/lib/rcfiles/yaml/pkgconfig.yml +46 -0
  89. data/lib/rcfiles/yaml/programs_aliases.yml +17081 -0
  90. data/lib/rcfiles/yaml/ps1.yml +82 -0
  91. data/lib/rcfiles/yaml/store_into_this_directory.yml +1 -0
  92. data/lib/rcfiles/yaml/system_settings.yml +513 -0
  93. data/lib/rcfiles/yaml/use_psych_or_syck.yml +1 -0
  94. data/rcfiles.gemspec +56 -0
  95. data/test/testing_expand_cd_aliases.rb +47 -0
  96. data/test/testing_yaml_to_rcfiles.rb +9 -0
  97. metadata +201 -0
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/is_on_roebe.rb'
6
+ # =========================================================================== #
7
+ module Rcfiles
8
+
9
+ # ========================================================================= #
10
+ # === Rcfiles.is_on_roebe?
11
+ # ========================================================================= #
12
+ def self.is_on_roebe?
13
+ ENV['IS_ROEBE'].to_s == '1'
14
+ end
15
+
16
+ end
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # The purpose of the file is to designate our main target directory -
6
+ # that is, the directory in which we will store the rc-generated files.
7
+ # =========================================================================== #
8
+ # require 'rcfiles/toplevel_methods/main_directory.rb'
9
+ # Rcfiles.main_directory?
10
+ # =========================================================================== #
11
+ require 'rcfiles/constants/misc.rb'
12
+ require 'rcfiles/toplevel_methods/e.rb'
13
+ require 'rcfiles/toplevel_methods/no_file_exists_at.rb'
14
+ require 'rcfiles/toplevel_methods/save_file.rb'
15
+
16
+ module Rcfiles
17
+
18
+ # ========================================================================= #
19
+ # === @store_into_this_directory
20
+ # ========================================================================= #
21
+ @store_into_this_directory = nil
22
+
23
+ # ========================================================================= #
24
+ # === Rcfiles.main_directory?
25
+ #
26
+ # This method will return e. g. "/AUTOGENERATED/".
27
+ #
28
+ # Note that you can modify this value, via the method stored in this
29
+ # file here, called Rcfiles.set_store_into_this_directory().
30
+ # ========================================================================= #
31
+ def self.main_directory?(
32
+ i = FILE_STORE_INTO_THIS_DIRECTORY
33
+ )
34
+ # ======================================================================= #
35
+ # The toplevel instance variable @store_into_this_directory will
36
+ # have priority. (Ideally this should be the only way how to
37
+ # query which directory is the current main one.)
38
+ # ======================================================================= #
39
+ if @store_into_this_directory
40
+ return @store_into_this_directory
41
+ elsif File.exist? i
42
+ result = YAML.load_file(i)
43
+ if result == false
44
+ result = CREATE_RCFILES_WHERE
45
+ end
46
+ result = result.to_s.chomp
47
+ return result
48
+ else
49
+ no_file_exists_at(i)
50
+ end
51
+ end; self.instance_eval { alias store_at? main_directory? } # === Rcfiles.store_at?
52
+ self.instance_eval { alias main_dir? main_directory? } # === Rcfiles.main_dir?
53
+
54
+ # ========================================================================= #
55
+ # === Rcfiles.store_at=
56
+ # ========================================================================= #
57
+ def self.store_at=(i)
58
+ unless i.end_with? '/'
59
+ i = i.dup if i.frozen?
60
+ i << '/'
61
+ end
62
+ @store_into_this_directory = i
63
+ end; self.instance_eval { alias store_at store_at= } # === Rcfiles.store_at
64
+
65
+ # ========================================================================= #
66
+ # === Rcfiles.set_store_into_this_directory
67
+ #
68
+ # If the second argument to this method is true then we will also
69
+ # save this information into a local file.
70
+ # ========================================================================= #
71
+ def self.set_store_into_this_directory(
72
+ i = :pwd,
73
+ save_into_file = true
74
+ )
75
+ case i
76
+ when 'pwd',
77
+ 'Dir.pwd',
78
+ :pwd
79
+ i = Dir.pwd
80
+ end
81
+ i << '/' unless i.end_with? '/'
82
+ self.store_at = i
83
+ what = i
84
+ into = FILE_STORE_INTO_THIS_DIRECTORY
85
+ if save_into_file
86
+ e "We will store into the directory `#{sdir(what.to_s)}` from now on."
87
+ e "This will be saved into the file `#{sfile(into)}`."
88
+ write_what_into(what, into)
89
+ end
90
+ # ======================================================================= #
91
+ # Also save it on my home system.
92
+ # ======================================================================= #
93
+ this_dir =
94
+ "#{RUBY_SRC_DIR_AT_HOME}rcfiles/lib/rcfiles/yaml/"
95
+ if (ENV['IS_ROEBE'].to_s == '1') and
96
+ File.directory?(this_dir) and
97
+ save_into_file
98
+ into = "#{this_dir}store_into_this_directory.yml" # <- Save into this file here.
99
+ e "And also into the file `#{sfile(into)}`."
100
+ write_what_into(what, into)
101
+ end
102
+ end; self.instance_eval { alias set_main_directory set_store_into_this_directory } # === Rcfiles.set_main_directory
103
+ self.instance_eval { alias set_path set_store_into_this_directory } # === Rcfiles.set_path
104
+ self.instance_eval { alias set_store_here set_store_into_this_directory } # === Rcfiles.set_store_here
105
+ self.instance_eval { alias set_store_into set_store_into_this_directory } # === Rcfiles.set_store_into
106
+ self.instance_eval { alias base_dir= set_store_into_this_directory } # === Rcfiles.base_dir=
107
+
108
+ end
@@ -0,0 +1,304 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/toplevel_methods/misc.rb'
6
+ # =========================================================================== #
7
+ require 'fileutils'
8
+ require 'rcfiles/project/project.rb'
9
+ require 'rcfiles/files/file_aliases.rb'
10
+ require 'rcfiles/files/file_cd_aliases.rb'
11
+ require 'rcfiles/files/file_programs_aliases.rb'
12
+ require 'rcfiles/files/file_system_settings.rb'
13
+ require 'rcfiles/files/file_pkgconfig.rb'
14
+ require 'rcfiles/files/file_ls_colours.rb'
15
+ require 'rcfiles/files/file_path_variable.rb'
16
+ require 'rcfiles/files/file_ps1.rb'
17
+ require 'rcfiles/constants/custom_files.rb'
18
+ # =========================================================================== #
19
+ # Add the colours next:
20
+ # =========================================================================== #
21
+ require 'rcfiles/colours/colours.rb'
22
+ # =========================================================================== #
23
+ # Next, require the toplevel-methods of the rcfiles project:
24
+ # =========================================================================== #
25
+ require 'rcfiles/toplevel_methods/change_directory.rb'
26
+ require 'rcfiles/toplevel_methods/convert.rb'
27
+ require 'rcfiles/toplevel_methods/e.rb'
28
+ require 'rcfiles/toplevel_methods/is_on_roebe.rb'
29
+ require 'rcfiles/toplevel_methods/main_directory.rb'
30
+ require 'rcfiles/toplevel_methods/no_file_exists_at.rb'
31
+ require 'rcfiles/toplevel_methods/return_standard_header.rb'
32
+ require 'rcfiles/toplevel_methods/verbosity.rb'
33
+
34
+ module Rcfiles
35
+
36
+ # ========================================================================= #
37
+ # === Rcfiles::ARRAY_MAIN_ALIASES_FILE
38
+ # ========================================================================= #
39
+ ARRAY_MAIN_ALIASES_FILE = [
40
+ file_cd_aliases?,
41
+ file_aliases?,
42
+ file_programs_aliases?,
43
+ file_system_settings?
44
+ ]
45
+
46
+ # ========================================================================= #
47
+ # === Rcfiles.run_default_action
48
+ #
49
+ # If the argument to this method is true then we will also install
50
+ # the rcfiles project.
51
+ # ========================================================================= #
52
+ def self.run_default_action(
53
+ also_install_the_rcfiles_project = is_on_roebe?
54
+ )
55
+ # ======================================================================= #
56
+ # If we are on roebe then we will also run rinstall2 first.
57
+ # ======================================================================= #
58
+ if also_install_the_rcfiles_project
59
+ install_the_rcfiles_project
60
+ end
61
+ generate_the_most_important_rcfiles
62
+ end
63
+
64
+ # ========================================================================= #
65
+ # === Rcfiles.install_the_rcfiles_project
66
+ #
67
+ # This method is evidently only useful on my home system.
68
+ # ========================================================================= #
69
+ def self.install_the_rcfiles_project
70
+ target = ENV['USERS'].to_s.dup
71
+ target = '/home' if target.nil? or target.empty?
72
+ cd target+'/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rcfiles/'
73
+ begin
74
+ require 'roebe/toplevel_methods/rinstall2.rb'
75
+ Roebe.rinstall2
76
+ rescue LoadError; end
77
+ end
78
+
79
+ # ========================================================================= #
80
+ # === Rcfiles.do_use_custom_rcfiles_home_directory_as_target
81
+ #
82
+ # This presently uses a hardcoded path.
83
+ #
84
+ # In the long run this method ought to become more flexible.
85
+ # ========================================================================= #
86
+ def self.do_use_custom_rcfiles_home_directory_as_target
87
+ @store_into_this_directory =
88
+ '/home/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rcfiles/lib/rcfiles/rcfiles/'
89
+ end
90
+
91
+ # ========================================================================= #
92
+ # === Rcfiles.generate_custom_roebe_rcfiles
93
+ #
94
+ # The following method is mostly useful only on my home system, as there
95
+ # are some .yml files that are not distributed with this project, mostly
96
+ # because other people will not really benefit from these custom
97
+ # definitions, whereas they might benefit from e. g. the cd-aliases
98
+ # or shortcuts (aliased names) to programs, such as "gi" for "gimp"
99
+ # and so forth.
100
+ # ========================================================================= #
101
+ def self.generate_custom_roebe_rcfiles(
102
+ hash = HASH_CUSTOM_FILES,
103
+ be_verbose = ::Rcfiles.be_verbose?
104
+ )
105
+ case be_verbose
106
+ when :be_quiet, :be_silent
107
+ be_verbose = false
108
+ end
109
+ e "Next generating #{teal('custom roebe rcfiles')}:" if be_verbose
110
+ hash.each_pair {|path_to_the_yaml_file, type_to_use|
111
+ unless File.exist? path_to_the_yaml_file
112
+ # =================================================================== #
113
+ # The file does not exist, but it may exist in the main directory
114
+ # where these .yml files are typically stored on my home system.
115
+ # =================================================================== #
116
+ target = "#{LINUX_YAML_BASE_DIRECTORY}#{path_to_the_yaml_file}"
117
+ if File.exist? target
118
+ path_to_the_yaml_file = target
119
+ end
120
+ end
121
+ # ===================================================================== #
122
+ # Now we can begin to autogenerate the new rc-file, if the file exists:
123
+ # ===================================================================== #
124
+ _ = path_to_the_yaml_file
125
+ if File.exist? _
126
+ require 'yaml'
127
+ require 'rcfiles/toplevel_methods/convert.rb'
128
+ case type_to_use
129
+ # =================================================================== #
130
+ # === :export
131
+ #
132
+ # Handle files that must use export= settings next.
133
+ # =================================================================== #
134
+ when :export
135
+ new_dataset = convert_this_hash_to_export_file(
136
+ YAML.load_file(path_to_the_yaml_file)
137
+ )
138
+ # =================================================================== #
139
+ # Handle files that must use alias settings next:
140
+ # =================================================================== #
141
+ when :aliases
142
+ new_dataset = convert_this_hash_to_alias_file(
143
+ YAML.load_file(path_to_the_yaml_file)
144
+ )
145
+ end
146
+ into = main_directory?+
147
+ File.basename(path_to_the_yaml_file).sub(/\.yml$/,'')+'_rc'
148
+ new_dataset.prepend(
149
+ standard_header?(into)
150
+ )
151
+ write_what_into(new_dataset, into)
152
+ e "Storing into the file `#{sfile(into)}`." if be_verbose
153
+ else
154
+ no_file_exists_at(_) if be_verbose
155
+ end
156
+ }
157
+ end
158
+
159
+ # ========================================================================= #
160
+ # === generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
161
+ # ========================================================================= #
162
+ def self.generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
163
+ generate_cd_aliases_rcfile
164
+ generate_aliases_rcfile
165
+ generate_programs_aliases_rcfile
166
+ generate_system_settings_rcfile
167
+ generate_pkgconfig_rcfile
168
+ generate_ls_colours_rcfile
169
+ generate_path_variable_rcfile
170
+ generate_ps1_rcfile
171
+ end
172
+
173
+ # ========================================================================= #
174
+ # === Rcfiles.generate_the_most_important_rcfiles
175
+ #
176
+ # Presently, the main rc-files are:
177
+ #
178
+ # (1) cd-aliases rcfile
179
+ # (2) aliases rcfile
180
+ # (3) programs aliases rcfile
181
+ # (4) system settings rcfile
182
+ # (5) pkgconfig rcfile
183
+ # (6) ls_colours rcfile
184
+ # (7) path variable rcfile
185
+ #
186
+ # Keep in mind that the method may also be invoked in these ways:
187
+ #
188
+ # Rcfiles.run { :disable_colours }
189
+ # Rcfiles.run { :be_quiet }
190
+ #
191
+ # ========================================================================= #
192
+ def self.generate_the_most_important_rcfiles(
193
+ generate_which_files = :all,
194
+ &block
195
+ )
196
+ be_verbose = true
197
+ if block_given?
198
+ yielded = yield
199
+ case yielded
200
+ when :be_quiet
201
+ be_verbose = false
202
+ ::Rcfiles.set_be_verbose(false)
203
+ when :disable_colours
204
+ disable_colours
205
+ end
206
+ end
207
+ case generate_which_files
208
+ when :all,
209
+ :default
210
+ generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
211
+ if is_on_roebe?
212
+ # =================================================================== #
213
+ # First generate roeberia on my home system:
214
+ # =================================================================== #
215
+ if is_on_roebe? and File.exist?(FILE_ROEBERIA_SETTINGS)
216
+ into = main_directory?+'roeberia_settings_rc'
217
+ if be_verbose
218
+ e 'Also generating the rc-file from '+
219
+ sfile(FILE_ROEBERIA_SETTINGS)+' into `'+sfile(into)+'` next.'
220
+ end
221
+ what = convert_this_hash_to_export_file(
222
+ YAML.load_file(FILE_ROEBERIA_SETTINGS)
223
+ )
224
+ write_what_into(what, into)
225
+ end
226
+ # =================================================================== #
227
+ # The following subsection is entered only on "roebe-systems",
228
+ # aka my home-systems. Other users do not really need this
229
+ # subsection at all.
230
+ # =================================================================== #
231
+ generate_custom_roebe_rcfiles
232
+ # =================================================================== #
233
+ # Designate another directory as the main target directory:
234
+ # =================================================================== #
235
+ do_use_custom_rcfiles_home_directory_as_target
236
+ generate_the_main_rcfiles_without_the_custom_roebe_rcfiles
237
+ generate_custom_roebe_rcfiles
238
+ @store_into_this_directory = nil
239
+ end
240
+ else
241
+ case generate_which_files
242
+ when :cd_aliases
243
+ generate_cd_aliases_rcfile(&block)
244
+ end
245
+ end
246
+ end; self.instance_eval { alias [] generate_the_most_important_rcfiles } # === Rcfiles[]
247
+ self.instance_eval { alias generate_files generate_the_most_important_rcfiles } # === Rcfiles.generate_files
248
+ self.instance_eval { alias run generate_the_most_important_rcfiles } # === Rcfiles.run
249
+ self.instance_eval { alias new generate_the_most_important_rcfiles } # === Rcfiles.new
250
+
251
+ # ========================================================================= #
252
+ # === Rcfiles.copy_rcfiles_to_the_current_directory
253
+ #
254
+ # This method can be used to quickly copy the rc-files into a
255
+ # (local) directory. It is especially important when some
256
+ # error prevents the user from being able to autogenerate
257
+ # these rc-files.
258
+ # ========================================================================= #
259
+ def self.copy_rcfiles_to_the_current_directory
260
+ target = "#{project_base_dir?}rcfiles/*rc"
261
+ e "Trying to copy the rc-files from #{sdir(target)}"
262
+ e 'into the current directory next:'
263
+ available_files = Dir[target]
264
+ available_files.each {|this_file|
265
+ if File.exist?(this_file) and
266
+ File.file?(this_file) and
267
+ this_file.end_with?('_rc')
268
+ target = (
269
+ Dir.pwd+'/'+File.basename(this_file)
270
+ ).squeeze '/'
271
+ e "Copying `#{sfile(this_file)}` to the current working directory next:"
272
+ FileUtils.cp(this_file, target)
273
+ end
274
+ }
275
+ end; self.instance_eval { alias copy_the_rcfiles copy_rcfiles_to_the_current_directory } # === Rcfiles.copy_the_rcfiles
276
+ self.instance_eval { alias copy_rcfiles copy_rcfiles_to_the_current_directory } # === Rcfiles.copy_rcfiles
277
+
278
+ # =========================================================================== #
279
+ # === Rcfiles.aliases?
280
+ #
281
+ # This method will return all aliases, as a Hash.
282
+ # =========================================================================== #
283
+ def self.aliases?
284
+ hash = {}
285
+ _ = file_aliases?
286
+ if File.exist? _
287
+ hash.merge!(YAML.load_file(_))
288
+ end
289
+ _ = file_cd_aliases?
290
+ if File.exist? _
291
+ hash.merge!(YAML.load_file(_))
292
+ end
293
+ _ = file_programs_aliases?
294
+ if File.exist? _
295
+ hash.merge!(YAML.load_file(_))
296
+ end
297
+ return hash
298
+ end
299
+
300
+ end
301
+
302
+ if __FILE__ == $PROGRAM_NAME
303
+ pp Rcfiles.aliases?.keys.size
304
+ 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