Class: Roebe::ReadmeGenerator
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/classes/readme_generator/readme_generator.rb
Overview
Constant Summary
collapse
- FILE_DOC_README_GEN =
'doc/README.gen'
- NAME_OF_THE_FILE_THAT_IS_AUTOGENERATED =
#
NAME_OF_THE_FILE_THAT_IS_AUTOGENERATED
#
'README.md'
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === Roebe::ReadmeGenerator[] ========================================================================= #.
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, #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(input_gen_file = FILE_DOC_README_GEN, run_already = true) ⇒ ReadmeGenerator
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 37
def initialize(
input_gen_file = FILE_DOC_README_GEN,
run_already = true
)
reset
set_input_gen_file(input_gen_file)
if block_given?
yielded = yield
case yielded
when :do_not_open_in_the_browser
@internal_hash[:open_in_browser] = false
end
end
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
#
Roebe::ReadmeGenerator[]
#
599
600
601
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 599
def self.[](i = ARGV)
new(i)
end
|
Instance Method Details
#add(i = '') ⇒ Object
279
280
281
282
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 279
def add(i = '')
i = i.join(N) if i.is_a? Array
@_ << "#{i}#{N}"
end
|
#add_badge ⇒ Object
Also known as:
add_ruby_badge
#
add_badge (badge tag)
This will add the two main badges that I usually use in ruby projects.
The first badge, to the left, is a link to the distribution called GoboLinux; the second badge, to the right of it, is a link to the official ruby-lang site.
Note that since as of August 2019, a third badge will be shown - the badge that tags the gem-version onto the markdown file. This badge is special in that we need to attach the name of the project at hand.
#
298
299
300
301
302
303
304
305
306
307
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 298
def add_badge
homepage2 = 'https://www.ruby-lang.org/en/'.dup
name_of_the_project = return_name_of_the_project
add_gobolinux_badge
@_ << "[![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](#{homepage2})#{N}"
@_ << '[![Gem Version](https://badge.fury.io/rb/'+name_of_the_project+'.svg)](https://badge.fury.io/rb/'+name_of_the_project+')'+N
end
|
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 539
def add_contact_information
@_ << "
## Contact information and mandatory 2FA (no longer) coming up in 2022 / 2023
If your creative mind has ideas and specific suggestions to make this gem
more useful in general, feel free to drop me an email at any time, via:
[email protected]
Before that email I used an email account at Google gmail, but in **2021** I
decided to slowly abandon gmail, for various reasons. In order to limit the
explanation here, allow me to just briefly state that I do not feel as if I
want to promote any Google service anymore when the user becomes the end
product (such as via data collection by upstream services, including other
proxy-services). My feeling is that this is a hugely flawed business model
to begin with, and I no longer wish to support this in any way, even if
only indirectly so, such as by using services of companies that try to
promote this flawed model.
In regards to responding to emails: please keep in mind that responding
may take some time, depending on the amount of work I may have at that
moment. So it is not that emails are ignored; it is more that I have not
(yet) found the time to read and reply. This means there may be a delay
of days, weeks and in some instances also months. There is, unfortunately,
not much I can do when I need to prioritise my time investment, but I try
to consider <b>all</b> feedback as an opportunity to improve my projects
nonetheless.
In <b>2022</b> rubygems.org decided to make 2FA mandatory for every
gem owner eventually:
see
https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
However had, that has been reverted again, so I decided to shorten
this paragraph. Mandatory 2FA may exclude users who do not have a
smartphone device or other means to 'identify'. I do not feel it is
a fair assumption by others to be made that non-identified people may
not contribute code, which is why I reject it. Mandatory 2FA would mean
an end to all my projects on rubygems.org, so let's hope it will never
happen. (Keep in mind that I refer to mandatory 2FA; I have no qualms
for people who use 2FA on their own, but this carrot-and-stick strategy
by those who control the rubygems infrastructure is a very bad one to
pursue.
"
end
|
#add_contextfree_art_disclaimer ⇒ Object
#
add_contextfree_art_disclaimer
#
501
502
503
504
505
506
507
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 501
def add_contextfree_art_disclaimer
@_ << "(The <b>above image</b> was <b>partially autogenerated</b> "\
"using <b>cfdg rules</b>. See this fine project here for "\
"more information pertaining to the <b>autogeneration</b> of "\
"such - or similar - images: "\
"**https://www.contextfreeart.org/gallery/**)\n"
end
|
321
322
323
324
325
326
327
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 321
def add_environment_information_properly_formatted_array
require 'environment_information/constants/constants.rb'
EnvironmentInformation.tracked_components?.each {|entry|
@_ << " #{entry}\n"
}
@_ << "\n"
end
|
#add_gobolinux_badge(homepage = 'https://www.gobolinux.org/') ⇒ Object
Also known as:
add_gobolinux_logo
312
313
314
315
316
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 312
def add_gobolinux_badge(
homepage = 'https://www.gobolinux.org/'
)
@_ << "[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](#{homepage})#{N}"
end
|
#add_licence_is_MIT ⇒ Object
Also known as:
use_the_mit_licence
#
add_licence_is_MIT (MIT tag)
This will add the MIT licence to the readme.
#
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 514
def add_licence_is_MIT
@_ << "
## Licence
The licence for this gem is the MIT licence.
Basically the most important part of the MIT licence is that, aside
from you being able to use the project as you see fit, is the no
warranty disclaimer to avoid any potential misuse from the use
of the software at hand.
You can read up on this licence here:
https://opensource.org/licenses/MIT
The usual copyright assignment is:
Copyright #{current_year?} Robert Heiler
"
end
|
#add_string_showing_the_last_updated_programs ⇒ Object
#
add_string_showing_the_last_updated_programs
Note that we will modify this String by replacing all newlines via HTML
tags.
#
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 245
def add_string_showing_the_last_updated_programs
require 'rbt/toplevel_methods/toplevel_methods.rb'
begin
add(
RBT.return_string_showing_the_last_updated_programs.
gsub("\n","<br>\n")
)
rescue Exception => error
pp error
end
if is_on_roebe?
begin
require 'rbt/toplevel_methods/files_and_directories_related_methods.rb'
rescue LoadError => error; pp error; end
this_file = "#{RBT.log_dir?}these_programs_were_updated_copy.yml"
if File.exist? this_file
remove_file(this_file)
this_file = "/home/x/programming/ruby/src/rbt/lib/rbt/yaml/these_programs_were_updated_copy.yml"
if File.exist?(this_file)
remove_file(this_file)
end
else
e rev+'Can not remove file '+sfile(this_file)+
rev+' because it does not exist.'
end
end
end
|
#add_text_for_the_donate_macro ⇒ Object
#
add_text_for_the_donate_macro
This is the text that will be added for the donation-macro in a README.gen file.
#
139
140
141
142
143
144
145
146
147
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 139
def add_text_for_the_donate_macro
add('Currently this project does not accept donations, but')
add('in the future this may be subject to change, including')
add('more information in how folks could support the project,')
add('if they would like to.')
add
add('Of course **documentation**, **patches**, **bug fixes** and so')
add('forth are **always** appreciated.')
end
|
#add_time_stamp ⇒ Object
#
add_time_stamp
Add information to the README when this gem was last updated.
#
334
335
336
337
338
339
340
341
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 334
def add_time_stamp
add(
"\nThis gem was <b>last updated</b> on the "\
"<span style=\"color: darkblue; font-weight: bold\">#{dd_mm_yyyy}</span> "\
"(dd.mm.yyyy notation), at "\
"<span style=\"color: steelblue; font-weight: bold\">#{hh_mm_ss}</span> o'clock."
)
end
|
#generate_html_file_via_kramdown ⇒ Object
#
generate_html_file_via_kramdown
#
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 213
def generate_html_file_via_kramdown
store_here = '/Depot/Information/foobar.html'
if File.exist? main_file?
_ = "kramdown #{main_file?} > #{store_here}"
esystem _
if File.exist? store_here
open_in_browser(store_here) if open_in_browser?
end
else
opne "No file exists at #{sfile(main_file?)}#{rev} "\
"- thus, kramdown can not be used."
if is_on_roebe?
opne 'This is a problem on my home system, as I tend to generate'
opne 'readme files. Hence, we will now exit, and hope that the'
opne 'problem will be corrected by roebe.'
end
end
end
|
108
109
110
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 108
def input_gen_file?
@input_gen_file
end
|
#open_in_browser(i) ⇒ Object
152
153
154
155
156
157
158
159
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 152
def open_in_browser(i)
if File.exist?(i) and !(File.size(i) == 0)
Open.in_browser(i) if Object.const_defined? :Open
else
opne "No file exists at `#{sfile(i)}` - or "\
"has a file size larger than 0."
end
end
|
#open_in_browser? ⇒ Boolean
235
236
237
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 235
def open_in_browser?
@internal_hash[:open_in_browser]
end
|
#read_dataset_from_gen_file ⇒ Object
#
read_dataset_from_gen_file
#
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 346
def read_dataset_from_gen_file
_ = gen_file?
if File.exist? _
readlines_with_proper_encoding(_).each {|line|
line.chomp!
case line when /^MACRO read_file_as_pre_tag (.+)$/,
/^INCLUDE_THIS_FILE (.+)$/,
/^EMBED_THIS_FILE (.+)$/,
/^READ_AND_DISPLAY_THIS_FILE (.+)$/,
/^DISPLAY_THIS_FILE (.+)$/
this_file = $1.to_s.dup
try_to_embed_this_file(this_file)
when /^RUBY_BADGE_AND_TIME_STAMP$/i,
/^DEFAULT_HEADER$/i
add_ruby_badge add_time_stamp
when /ADD(_|-)?CONTEXTFREE(_|-)?ART(_|-)?DISCLAIMER$/
add_contextfree_art_disclaimer
when /^ADD_TIME_STAMP$/,
/^ADD_LAST_UPDATE$/,
/^ADD_MAIN_TIMESTAMP$/,
/^ADD_LAST_UPDATED_WHEN$/
add_time_stamp
when /LICENCE_?IS_?MIT/,
/USE_?THE_?MIT_?LICENCE/
add_licence_is_MIT
when /ADD_?CONTACT_?INFORMATION/,
/ADD_?CONTACT_?DETAILS/,
/ADD_?EMAIL/,
/ADD_?MY_?EMAIL/,
/CONTACT_?INFORMATION/
add_contact_information
when /^ADD_GOBOLINUX_LINK$/,
/^GOBOLINUX_IS_AWESOME$/
add_gobolinux_badge
when /^ADD_RUBY_LOGO_AND_TIMESTAMP$/,
/^MY_MAIN_HEADER$/,
/^ADD_DEFAULT_HEADER$/
add_badge
add_time_stamp
when 'ADD_BADGE',
'DEFAULT_RUBY_HEADER',
'ADD_RUBY_HEADER',
'ADD_RUBY_BADGE',
/ADD_?RUBY_?BADGES/,
/ADD_?GOBOLINUX_?AND_?RUBY_?HEADER/,
/ADD_?DEFAULT_?HEADER/,
/RUBY_?HEADER/,
/ADD_?RUBY_?HEAD/,
/GOBOLINUX_?IS_?GREAT/,
/ADD(_|-)?MAIN(_|-)?HEADER/i
add_badge
when /^INSERT_THE_LAST_UPDATED_PROGRAMS_HERE$/
add_string_showing_the_last_updated_programs
when /^MACRO read_file (.+)$/,
/^INCLUDE_FILE (.+)$/,
/^embed_this_file (.+)$/
this_file = $1.to_s.dup
try_to_add_the_content_of_this_file(this_file)
when /^DONATE_MACRO$/
add_text_for_the_donate_macro
when /^ADD_?ENVIRONMENT_?INFORMATION_?PROPERLY_?FORMATTED_?ARRAY$/i
add_environment_information_properly_formatted_array
when /^MACRO RBT\.(.+)$/
require 'rbt' if RBT.respond_to? $1.to_s.to_sym
result = RBT.send($1.to_s.to_sym)
if result.is_a? Array result = result.map {|entry| entry.prepend(' ') }.join(N)
end
add(result) else
e 'RBT does not respond to '+$1.to_s.to_sym.to_s+'().'
end
else
add(line)
end
}
else
opne "No file called #{sfile(_)} could be found."
end
end
|
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 62
def reset
super()
infer_the_namespace
try_to_require_the_open_gem
@internal_hash[:open_in_browser] = true
@_ = ''.dup
end
|
#return_name_of_the_project ⇒ Object
#
return_name_of_the_project
This method will return the name of the project at hand. Note that this functionality depends on guessing the directory name, so we need to have cd-ed to the correct directory prior to making use of this method here.
#
179
180
181
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 179
def return_name_of_the_project
File.basename(Dir.pwd)
end
|
590
591
592
593
594
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 590
def run
read_dataset_from_gen_file
store_the_string
generate_html_file_via_kramdown
end
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 86
def set_input_gen_file(
i = FILE_DOC_README_GEN
)
i = i.first if i.is_a? Array
i = i.to_s.dup
if i.empty?
i = FILE_DOC_README_GEN
end
if File.exist?('README.gen') and !File.exist?(i)
i = 'README.gen'
end
@input_gen_file = i
end
|
#store_the_string ⇒ Object
164
165
166
167
168
169
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 164
def store_the_string
what = @_
into = main_file?
opne 'Storing the dataset into the file `'+sfile(into)+'`.'
write_what_into(what, into)
end
|
#try_to_add_the_content_of_this_file(this_file) ⇒ Object
#
try_to_add_the_content_of_this_file
This method will try to add the file-content of an existing file, into the newly generated README.md file.
#
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 189
def try_to_add_the_content_of_this_file(this_file)
if File.exist? this_file
opne "Reading in the content of the file `#{sfile(this_file)}`."
add(File.read(this_file))
else
e
opne crimson("No file called #{sfile(this_file)} exists.")
e
if is_on_roebe?
e 'Please fix the above error first.'
esystem "zenity --list --column='#{this_file}'"
end
end
end
|
#try_to_embed_this_file(this_file) ⇒ Object
#
try_to_embed_this_file
#
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/roebe/classes/readme_generator/readme_generator.rb', line 115
def try_to_embed_this_file(this_file)
this_file = File.absolute_path(this_file)
if File.exist? this_file
opne "Reading in the content of the file `#{sfile(this_file)}`."
add(
N+'<pre>'+N+File.read(this_file)+N+'</pre>'+N
)
else
opne "No file called #{sfile(this_file)} exists."
end
end
|