Class: Roebe::Browser
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/browser/menu.rb,
lib/roebe/browser/misc.rb,
lib/roebe/browser/reset.rb,
lib/roebe/browser/constants.rb
Overview
Constant Summary
collapse
- NAMESPACE =
inspect
- FILE_BROWSER =
"#{Roebe.project_yaml_dir?}browser.yml"
_
Constants inherited
from Base
Roebe::Base::COLOURS, Roebe::Base::HOME_DIRECTORY_OF_USER_X, Roebe::Base::N
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #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, #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(commandline_arguments = nil, run_already = true) ⇒ Browser
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/roebe/browser/misc.rb', line 14
def initialize(
commandline_arguments = nil,
run_already = true
)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
243
244
245
|
# File 'lib/roebe/browser/misc.rb', line 243
def self.[](i = '')
new(i)
end
|
.e(i = '') ⇒ Object
236
237
238
|
# File 'lib/roebe/browser/misc.rb', line 236
def self.e(i = '')
puts i
end
|
.permanently_use_this_browser(location_to_the_binary = '/usr/bin/firefox', into = FILE_BROWSER) ⇒ Object
#
Roebe::Browser.permanently_use_this_browser
This method can be used to permanently set the location to a browser.
#
.return_remote_homepage_of_this_lecture(i) ⇒ Object
#
Roebe::Browser.return_remote_homepage_of_this_lecture
#
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
# File 'lib/roebe/browser/misc.rb', line 313
def self.return_remote_homepage_of_this_lecture(i)
if i.is_a? Array
i = i.first
end
if Object.const_defined?(:Studium) and
Studium.respond_to?(:return_homepage_for)
result = Studium.return_homepage_for(i)
if i == result
if Object.const_defined? :BeautifulUrl
i = BeautifulUrl[i] { :array_if_possible }
end
else
i = result
end
i = i.first if i.is_a? Array
end
i
end
|
229
230
231
|
# File 'lib/roebe/browser/misc.rb', line 229
def self.rev
::Roebe.rev
end
|
222
223
224
|
# File 'lib/roebe/browser/misc.rb', line 222
def self.sfile(i)
::Roebe.sfile(i)
end
|
Instance Method Details
#considering_opening_this_remote_url(i) ⇒ Object
Also known as:
consider_opening_url_in_the_browser
#
considering_opening_this_remote_url
This is the method that will set the URL to use; and then open this in the browser as well.
#
273
274
275
276
277
278
279
280
281
282
283
284
|
# File 'lib/roebe/browser/misc.rb', line 273
def considering_opening_this_remote_url(i)
set_url(i)
_ = url?
if @be_verbose
e "#{rev}Next opening #{steelblue(_)} in the browser."
end
cmd = @path_to_the_browser+' '+url?.to_s+' '+@optional_argument.to_s
esystem cmd.strip
end
|
#generate_tab_completions ⇒ Object
#
generate_tab_completions
To trigger this method, do:
browser.rb tabcompletions
#
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/roebe/browser/misc.rb', line 160
def generate_tab_completions
require 'case_parser'
begin
require 'generate_shell_completion'
rescue LoadError; end
array = CaseParser.parse(MENU)
_ = GenerateShellCompletion::GenerateShellCompletion.new(nil, :dont_run_yet)
_.set_name_of_the_shell_function 'beautiful_menu'
if array.empty?
opne 'The array is empty at line `'+__LINE__.to_s+'`.'
end
_.set_dataset(array) _.set_name "#{HOME_DIRECTORY_OF_USER_X}DATA/PROGRAMMING_LANGUAGES/RUBY/src/"\
"roebe/lib/roebe/shell_scripts/completion_for_rf.sh"
_.set_aliases 'rf'
_.run
end
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/roebe/browser/menu.rb', line 14
def (
i = commandline_arguments?
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i
when /^-?-?browser\??$/i
show_which_browser_is_in_use
when /^-?-?browser=(.+)$/i,
/^-?-?set=(.+)$/i
permanently_use_this_browser($1.to_s.dup)
when /^-?-?help$/i,
'--help?'
show_help
exit
when 'LAST'
i = `xsel -o`.to_s.chomp
when /^-?-?file\??$/
e sfile(FILE_BROWSER)
exit
when /^HERE$/i,
/^-?-?pwd$/i if return_pwd.include? 'studium'
i = File.basename(return_pwd)
if i.include?('_') and (i =~ /^\d+/)
i.tr!('_',' ')
i.delete!('.')
regex_for_numbers = /^(\d+-?\d*)/ i.gsub!(regex_for_numbers, '')
i.strip!
considering_opening_this_remote_url(i)
end
end
when /^-?-?completion$/i,
/^-?-?complete$/i,
/^-?-?gentab$/i,
/^-?-?generate(_|-)?tab(_|-)?completions$/i,
/^-?-?generate(_|-)?tab$/i,
/^-?-?generate(_|-)?completions?$/i,
/^-?-?tabcompletions$/i,
/^-?-?TAB$/i
generate_tab_completions
else
considering_opening_this_remote_url(i)
end
end
end
|
#permanently_use_this_browser(i) ⇒ Object
#
permanently_use_this_browser
#
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/roebe/browser/reset.rb', line 14
def reset
super()
infer_the_namespace
@path_to_the_browser = File.read(FILE_BROWSER)
@name_of_the_browser = nil
@optional_argument = nil
@use_this_url = nil
@be_verbose = false
end
|
#return_remote_homepage_of_this_lecture(i) ⇒ Object
#
return_remote_homepage_of_this_lecture
#
208
209
210
|
# File 'lib/roebe/browser/misc.rb', line 208
def run
end
|
#set_name(i = :palemoon) ⇒ Object
46
47
48
|
# File 'lib/roebe/browser/misc.rb', line 46
def set_name(i = :palemoon)
@name_of_the_browser = i.to_sym
end
|
#set_path_to_the_browser(i) ⇒ Object
#
set_path_to_the_browser
#
263
264
265
|
# File 'lib/roebe/browser/misc.rb', line 263
def set_path_to_the_browser(i)
@path_to_the_browser = i
end
|
#set_use_this_url(i = '') ⇒ Object
Also known as:
set_url
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/roebe/browser/misc.rb', line 63
def set_use_this_url(i = '')
if i.is_a?(Symbol) and is_on_roebe?
i = BeautifulUrl.sanitize_this_input(i)
end
if i.is_a? Array
if i[1]
@optional_argument = i[1..-1]
end
i = i[0]
end
i = i.dup if i.frozen?
if i.respond_to?(:include?)
if i.include?('.cgi')
i.tr!(' ','#') if i.include? ' '
else
i.tr!(' ','_') if i.include? ' '
end
else
i = i.to_s
end
i.gsub!(/_-_/,'_') if i.include? '_-_'
i.gsub!(/-_/,'_') if i.include? '-_'
i.delete!(N)
i.rstrip!
i.chop! if i.end_with? '~'
i.rstrip!
i.chop! if i.end_with? '_' and i.count('_') > 1
i.delete!('()') if i.include? '('
if i.end_with?('.cgi') and
i.include?(HOME_DIRECTORY_OF_USER_X)
use_this_regex = /#{Regexp.quote("#{HOME_DIRECTORY_OF_USER_X}")}/
i.sub!(use_this_regex, 'http://localhost/')
end
unless i.include?('htt') or i.include?(HOME_DIRECTORY_OF_USER_X)
i.downcase! end
old_input = i.dup
i = return_remote_homepage_of_this_lecture(i)
if is_on_roebe? and (old_input == i)
i = BeautifulUrl[i]
end
if is_on_roebe? and i.end_with?('.cgi') and i.include?(HOME_DIRECTORY_OF_USER_X)
use_this_regex = /#{Regexp.quote("#{HOME_DIRECTORY_OF_USER_X}")}/
i.sub!(use_this_regex, 'http://localhost/')
end
unless i.start_with? '"'
i = '"'+i+'"'
end
@use_this_url = i
end
|
#show_help ⇒ Object
#
show_help (help tag)
Invocation example:
browser --help
#
33
34
35
36
37
38
39
40
41
|
# File 'lib/roebe/browser/misc.rb', line 33
def show_help
e
e ' browser --set=firefox # set the path to firefox'
e
end
|
#show_which_browser_is_in_use(_ = @path_to_the_browser) ⇒ Object
#
show_which_browser_is_in_use
This method will show which browser is in use.
Normally we will store which browser is in use in this file:
roebe/yaml/browser.yml
#
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/roebe/browser/misc.rb', line 188
def show_which_browser_is_in_use(
_ = @path_to_the_browser
)
if File.exist? _
e
opnn
e "The browser that will be used is:#{N}#{N}"
if _.end_with? '.yml'
_ = File.read(_)
end
e sfile(_)
e
else
opnn; no_file_exists_at(_)
end
end
|
#use_this_url? ⇒ Boolean
Also known as:
url?
148
149
150
|
# File 'lib/roebe/browser/misc.rb', line 148
def use_this_url?
@use_this_url
end
|