Class: Roebe::FindExpandedAlias
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/classes/find_expanded_alias.rb
Overview
Constant Summary
collapse
- DEFAULT_RUN_STATE =
true
- FILE_PROGRAMS_ALIASES =
#
FILE_PROGRAMS_ALIASES
This is hardcoded.
#
"#{HOME_DIRECTORY_OF_USER_X}programming/ruby/src/rcfiles/lib/rcfiles/yaml/"\
"programs_aliases.yml"
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Class Method Summary
collapse
-
.[](i) ⇒ Object
# === Roebe::FindExpandedAlias[] ========================================================================= #.
-
.has_key?(i) ⇒ Boolean
# === Roebe::FindExpandedAlias.has_key? ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_this_onto_that_file, #append_what_into, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #show_help, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow
#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments
Constructor Details
#initialize(i = nil, run_already = DEFAULT_RUN_STATE) ⇒ FindExpandedAlias
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 42
def initialize(
i = nil,
run_already = DEFAULT_RUN_STATE
)
reset
set_search_for_this_alias(i)
case run_already
when :be_silent,
:be_quiet
@be_verbose = false run_already = DEFAULT_RUN_STATE end
if block_given?
yielded = yield
case yielded
when :be_quiet
@be_verbose = false
end
end
run if run_already
end
|
Class Method Details
#
Roebe::FindExpandedAlias[]
#
.has_key?(i) ⇒ Boolean
#
Roebe::FindExpandedAlias.has_key?
#
167
168
169
170
171
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 167
def self.has_key?(i)
_ = new(i, :do_not_run_yet)
_.be_silent
return _.has_key?
end
|
Instance Method Details
#be_silent ⇒ Object
160
161
162
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 160
def be_silent
@be_verbose = false
end
|
#be_verbose? ⇒ Boolean
137
138
139
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 137
def be_verbose?
@be_verbose
end
|
#check_if_we_have_this_key(i = @search_for_this_alias) ⇒ Object
#
check_if_we_have_this_key
#
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 176
def check_if_we_have_this_key(
i = @search_for_this_alias
)
if has_key? i
if be_verbose?
opne "#{rev}Yes, we have an alias called #{sfancy(i)}."
end
set_points_at(i)
really_points_at = really_points_at?(i)
unless really_points_at == points_at?
@points_at = really_points_at
end
if be_verbose?
opne "It points at `#{simp(points_at?)}`."
unless really_points_at == points_at?
opne 'It effectively points at `'+simp(really_points_at?)+'`.'
end
end
else
if be_verbose?
opne 'No, we do not have this key.'
end
end
end
|
#does_include? ⇒ Boolean
#
has_key?
Tell us whether we have a key or whether we don’t.
#
does_include?
155
156
157
158
159
160
161
162
163
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 155
def has_key?(
i = @search_for_this_alias
)
if @programs_aliases.respond_to? :has_key?
return @programs_aliases.has_key?(i)
else
return false
end
end
|
#file_programs_aliases? ⇒ Boolean
#
file_programs_aliases?
#
70
71
72
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 70
def file_programs_aliases?
FILE_PROGRAMS_ALIASES
end
|
#has_key?(i = @search_for_this_alias) ⇒ Boolean
#
has_key?
Tell us whether we have a key or whether we don’t.
#
146
147
148
149
150
151
152
153
154
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 146
def has_key?(
i = @search_for_this_alias
)
if @programs_aliases.respond_to? :has_key?
return @programs_aliases.has_key?(i)
else
return false
end
end
|
#is_included? ⇒ Boolean
#
has_key?
Tell us whether we have a key or whether we don’t.
#
is_included?
154
155
156
157
158
159
160
161
162
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 154
def has_key?(
i = @search_for_this_alias
)
if @programs_aliases.respond_to? :has_key?
return @programs_aliases.has_key?(i)
else
return false
end
end
|
#points_at? ⇒ Boolean
Also known as:
points_at, result?, result
204
205
206
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 204
def points_at?
@points_at
end
|
#really_points_at?(i) ⇒ Boolean
Also known as:
[]
#
really_points_at?
Where the alias really points to. This means we will also remove trailling ‘ &’ parts.
#
216
217
218
219
220
221
222
223
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 216
def really_points_at?(i)
_ = convert_global_env(@programs_aliases[i]) if @programs_aliases.has_key? i
_ = convert_global_env(@programs_aliases[_]) if @programs_aliases.has_key? _
_ = convert_global_env(@programs_aliases[_]) if @programs_aliases.has_key? _
_ = convert_global_env(@programs_aliases[_]) if @programs_aliases.has_key? _
_[-2,2] = '' if _.end_with? ' &'
return _
end
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 77
def reset
infer_the_namespace
@points_at = nil
_ = file_programs_aliases?
if File.exist? _
@programs_aliases = YAML.load_file(_)
else
if is_on_roebe?
opne 'No file was found at '+sfile(_)+'.'
end
@programs_aliases = nil
end
@be_verbose = true
@number_of_redirections = 0 end
|
228
229
230
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 228
def run
check_if_we_have_this_key
end
|
#set_points_at(i) ⇒ Object
#
set_points_at
Since as of March 2021 we will remove trailing ‘ &’.
#
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 113
def set_points_at(i)
i = i.dup if i.frozen?
if @programs_aliases.has_key? i
@number_of_redirections += 1
end
result = @programs_aliases[i]
if @programs_aliases.has_key? result
@number_of_redirections += 1
result = @programs_aliases[result]
end
result = convert_global_env(result) if result.include? '$'
@points_at = result
end
|
#set_search_for_this_alias(i = '') ⇒ Object
#
set_search_for_this_alias
#
102
103
104
105
106
|
# File 'lib/roebe/classes/find_expanded_alias.rb', line 102
def set_search_for_this_alias(i = '')
i = i.first if i.is_a? Array
i = i.to_s
@search_for_this_alias = i
end
|