universal_pipe_handler 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +461 -0
  3. data/doc/README.gen +417 -0
  4. data/doc/todo/todo_for_the_universal_pipe_handler_project.md +300 -0
  5. data/img/UNIVERSAL_PIPE_HANDLER_LOGO.jpg +0 -0
  6. data/img/pipe_paradise.png +0 -0
  7. data/lib/universal_pipe_handler/base/base.rb +147 -0
  8. data/lib/universal_pipe_handler/cmdlet/cmdlet.rb +287 -0
  9. data/lib/universal_pipe_handler/cmdlets/add.rb +15 -0
  10. data/lib/universal_pipe_handler/cmdlets/add_audio.rb +22 -0
  11. data/lib/universal_pipe_handler/cmdlets/all.rb +37 -0
  12. data/lib/universal_pipe_handler/cmdlets/any.rb +25 -0
  13. data/lib/universal_pipe_handler/cmdlets/ascii_video.rb +30 -0
  14. data/lib/universal_pipe_handler/cmdlets/assign.rb +24 -0
  15. data/lib/universal_pipe_handler/cmdlets/capture_screen.rb +46 -0
  16. data/lib/universal_pipe_handler/cmdlets/colourize.rb +35 -0
  17. data/lib/universal_pipe_handler/cmdlets/convert_to.rb +21 -0
  18. data/lib/universal_pipe_handler/cmdlets/convert_to_images.rb +17 -0
  19. data/lib/universal_pipe_handler/cmdlets/convert_to_mp3.rb +28 -0
  20. data/lib/universal_pipe_handler/cmdlets/convert_to_wav.rb +17 -0
  21. data/lib/universal_pipe_handler/cmdlets/copy_directories.rb +23 -0
  22. data/lib/universal_pipe_handler/cmdlets/count_character.rb +31 -0
  23. data/lib/universal_pipe_handler/cmdlets/count_longest_row.rb +21 -0
  24. data/lib/universal_pipe_handler/cmdlets/crop.rb +26 -0
  25. data/lib/universal_pipe_handler/cmdlets/cut.rb +101 -0
  26. data/lib/universal_pipe_handler/cmdlets/days.rb +41 -0
  27. data/lib/universal_pipe_handler/cmdlets/decolourize.rb +25 -0
  28. data/lib/universal_pipe_handler/cmdlets/download.rb +30 -0
  29. data/lib/universal_pipe_handler/cmdlets/download_torrent.rb +17 -0
  30. data/lib/universal_pipe_handler/cmdlets/duration.rb +34 -0
  31. data/lib/universal_pipe_handler/cmdlets/extract.rb +27 -0
  32. data/lib/universal_pipe_handler/cmdlets/extract_all.rb +23 -0
  33. data/lib/universal_pipe_handler/cmdlets/extract_audio.rb +30 -0
  34. data/lib/universal_pipe_handler/cmdlets/extract_video.rb +18 -0
  35. data/lib/universal_pipe_handler/cmdlets/find_all.rb +40 -0
  36. data/lib/universal_pipe_handler/cmdlets/generate_random_video.rb +29 -0
  37. data/lib/universal_pipe_handler/cmdlets/generate_string.rb +27 -0
  38. data/lib/universal_pipe_handler/cmdlets/get_all_audio_files.rb +33 -0
  39. data/lib/universal_pipe_handler/cmdlets/get_all_files.rb +61 -0
  40. data/lib/universal_pipe_handler/cmdlets/get_all_images.rb +47 -0
  41. data/lib/universal_pipe_handler/cmdlets/get_all_images_including_subdirs.rb +26 -0
  42. data/lib/universal_pipe_handler/cmdlets/get_all_video_files.rb +34 -0
  43. data/lib/universal_pipe_handler/cmdlets/get_last_characters.rb +24 -0
  44. data/lib/universal_pipe_handler/cmdlets/help.rb +36 -0
  45. data/lib/universal_pipe_handler/cmdlets/identify.rb +29 -0
  46. data/lib/universal_pipe_handler/cmdlets/increase_audio.rb +26 -0
  47. data/lib/universal_pipe_handler/cmdlets/install.rb +32 -0
  48. data/lib/universal_pipe_handler/cmdlets/match_regex.rb +24 -0
  49. data/lib/universal_pipe_handler/cmdlets/n_directories.rb +25 -0
  50. data/lib/universal_pipe_handler/cmdlets/n_files.rb +20 -0
  51. data/lib/universal_pipe_handler/cmdlets/n_words.rb +25 -0
  52. data/lib/universal_pipe_handler/cmdlets/number_lines.rb +34 -0
  53. data/lib/universal_pipe_handler/cmdlets/open_in_browser.rb +40 -0
  54. data/lib/universal_pipe_handler/cmdlets/pad_left.rb +20 -0
  55. data/lib/universal_pipe_handler/cmdlets/pad_right.rb +20 -0
  56. data/lib/universal_pipe_handler/cmdlets/play.rb +18 -0
  57. data/lib/universal_pipe_handler/cmdlets/position.rb +21 -0
  58. data/lib/universal_pipe_handler/cmdlets/processes.rb +18 -0
  59. data/lib/universal_pipe_handler/cmdlets/random.rb +21 -0
  60. data/lib/universal_pipe_handler/cmdlets/random_video.rb +23 -0
  61. data/lib/universal_pipe_handler/cmdlets/read_file.rb +44 -0
  62. data/lib/universal_pipe_handler/cmdlets/read_line.rb +31 -0
  63. data/lib/universal_pipe_handler/cmdlets/read_n_lines.rb +38 -0
  64. data/lib/universal_pipe_handler/cmdlets/read_n_lines_inverted.rb +36 -0
  65. data/lib/universal_pipe_handler/cmdlets/remove_audio.rb +22 -0
  66. data/lib/universal_pipe_handler/cmdlets/remove_comments.rb +26 -0
  67. data/lib/universal_pipe_handler/cmdlets/remove_directories.rb +29 -0
  68. data/lib/universal_pipe_handler/cmdlets/remove_html.rb +25 -0
  69. data/lib/universal_pipe_handler/cmdlets/remove_newlines.rb +23 -0
  70. data/lib/universal_pipe_handler/cmdlets/remove_numbers.rb +25 -0
  71. data/lib/universal_pipe_handler/cmdlets/repackage_to.rb +27 -0
  72. data/lib/universal_pipe_handler/cmdlets/replace_underscores.rb +29 -0
  73. data/lib/universal_pipe_handler/cmdlets/resize.rb +39 -0
  74. data/lib/universal_pipe_handler/cmdlets/resize_image.rb +45 -0
  75. data/lib/universal_pipe_handler/cmdlets/reverse.rb +22 -0
  76. data/lib/universal_pipe_handler/cmdlets/screenshot.rb +41 -0
  77. data/lib/universal_pipe_handler/cmdlets/search_torrent.rb +24 -0
  78. data/lib/universal_pipe_handler/cmdlets/seconds.rb +23 -0
  79. data/lib/universal_pipe_handler/cmdlets/select.rb +23 -0
  80. data/lib/universal_pipe_handler/cmdlets/show_lines.rb +31 -0
  81. data/lib/universal_pipe_handler/cmdlets/shuffle.rb +16 -0
  82. data/lib/universal_pipe_handler/cmdlets/shuffle_csv.rb +55 -0
  83. data/lib/universal_pipe_handler/cmdlets/size.rb +21 -0
  84. data/lib/universal_pipe_handler/cmdlets/sort_alphabetical.rb +20 -0
  85. data/lib/universal_pipe_handler/cmdlets/sort_by_date.rb +23 -0
  86. data/lib/universal_pipe_handler/cmdlets/starts_with.rb +25 -0
  87. data/lib/universal_pipe_handler/cmdlets/stat_file.rb +61 -0
  88. data/lib/universal_pipe_handler/cmdlets/to_ascii.rb +38 -0
  89. data/lib/universal_pipe_handler/cmdlets/to_camel_case.rb +38 -0
  90. data/lib/universal_pipe_handler/cmdlets/to_dna.rb +31 -0
  91. data/lib/universal_pipe_handler/cmdlets/to_movie.rb +16 -0
  92. data/lib/universal_pipe_handler/cmdlets/to_pdf.rb +58 -0
  93. data/lib/universal_pipe_handler/cmdlets/translate.rb +36 -0
  94. data/lib/universal_pipe_handler/cmdlets/upload_to.rb +29 -0
  95. data/lib/universal_pipe_handler/cmdlets/word_count.rb +39 -0
  96. data/lib/universal_pipe_handler/cmdlets/word_wrap.rb +26 -0
  97. data/lib/universal_pipe_handler/cmdlets/write_to.rb +51 -0
  98. data/lib/universal_pipe_handler/cmdlets/years.rb +30 -0
  99. data/lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb +193 -0
  100. data/lib/universal_pipe_handler/colours/colourize.rb +112 -0
  101. data/lib/universal_pipe_handler/colours/colours.rb +54 -0
  102. data/lib/universal_pipe_handler/configuration/configuration.rb +18 -0
  103. data/lib/universal_pipe_handler/constants/constants.rb +201 -0
  104. data/lib/universal_pipe_handler/dataset/dataset.rb +14 -0
  105. data/lib/universal_pipe_handler/project/project.rb +36 -0
  106. data/lib/universal_pipe_handler/requires/do_require_the_individual_cmdlet_files.rb +21 -0
  107. data/lib/universal_pipe_handler/requires/require_the_universal_pipe_handler.rb +14 -0
  108. data/lib/universal_pipe_handler/shell/shell.rb +256 -0
  109. data/lib/universal_pipe_handler/toplevel_methods/all_actions.rb +48 -0
  110. data/lib/universal_pipe_handler/toplevel_methods/cmdlet_directory.rb +22 -0
  111. data/lib/universal_pipe_handler/toplevel_methods/e.rb +16 -0
  112. data/lib/universal_pipe_handler/toplevel_methods/misc.rb +54 -0
  113. data/lib/universal_pipe_handler/toplevel_methods/rds.rb +18 -0
  114. data/lib/universal_pipe_handler/toplevel_methods/token.rb +18 -0
  115. data/lib/universal_pipe_handler/version/version.rb +19 -0
  116. data/lib/universal_pipe_handler/yaml/aliases_to_cmdlets.yml +250 -0
  117. data/lib/universal_pipe_handler/yaml/allowed_cmdlets.yml +118 -0
  118. data/lib/universal_pipe_handler/yaml/predefined_methods.yml +15 -0
  119. data/lib/universal_pipe_handler.rb +5 -0
  120. data/test/testing_the_universal_pipe_handler.rb +65 -0
  121. data/test/this_file +46 -0
  122. data/universal_pipe_handler.gemspec +80 -0
  123. metadata +299 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f6af60e80aa79f5d9c8b354bedb14b7449de567acce3118133a8e015f78aae98
4
+ data.tar.gz: 4848d62822693a8f5cf6415b2fdab6189775118138b2b6938bdc9efe146e0a56
5
+ SHA512:
6
+ metadata.gz: 756037546326b34cab67b8e95b4edd13639102e69138ecfdc192b33d9f79af7c88a324b783daaca279fa9484d4843342f1412c47f8134fe8dddf8066ab3ad1ae
7
+ data.tar.gz: 12cf59e4e48341aad5bdc5b05efff13d44df53496e55c4064f72a59a93a6f74c9c24d3a5c320855f7301b95a42fd82a6a0da57b4a849e091800c1ebc49755962
data/README.md ADDED
@@ -0,0 +1,461 @@
1
+ [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/universal_pipe_handler.svg)](https://badge.fury.io/rb/universal_pipe_handler)
4
+
5
+ This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">03.07.2022</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">22:08:42</span> o'clock.
6
+ [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
7
+
8
+ # The Universal Pipe Handler Project
9
+
10
+ Handling Pipes - via Ruby
11
+
12
+ <i>„Because one pipe can rule them all ...“</i>
13
+
14
+ <img src="https://i.imgur.com/c7lFded.jpg" style="margin: 1em">
15
+
16
+ ## Description
17
+
18
+ This project aims to implement pipes, in ruby. The idea here is to be able
19
+ to use a fully OOP-centric implementation of pipes, rather than "merely"
20
+ a simulation of UNIX/Linux pipes as such. Thus, the project attempts to
21
+ include ideas from other projects, such as the powershell on Windows.
22
+ It also attempts to include ideas gained from projects such
23
+ as Avisynth/VirtualDub, which was a really useful project when it
24
+ came to <b>applying filters</b> to image, video and audio files.
25
+
26
+ The actual implementation of the project may be split up into separate
27
+ projects, but will be unified within the Universal Pipe Handler (UPH).
28
+
29
+ The general input-output follows this simple schematic:
30
+
31
+ <img src="https://i.imgur.com/Mp9y6ZY.png" style="margin: 1em">
32
+
33
+ ## How to require the project
34
+
35
+ Use this to require the project:
36
+
37
+ require 'universal_pipe_handler'
38
+
39
+ ## Usage examples
40
+
41
+ This subsection will try to show various usage examples that should be
42
+ guaranteed to work, provided that you have installed various other
43
+ projects (gems). For instance, for multimedia-related actions you
44
+ will require the gem called <b>multimedia_paradise</b>.
45
+
46
+ Extract audio from a .mp4 file:
47
+
48
+ foobar.mp4 | extract_audio
49
+ foobar.mp4 | extract audio # both variants must work
50
+
51
+ Extract audio from a .mp4 file and convert it into a .wav file:
52
+
53
+ foobar.mp4 | extract audio | convert into .wav file
54
+ foobar.mp4 | extract audio | convert_into_wav_file
55
+ foobar.mp4 | extract audio | to_wav
56
+ foobar.mp4 | extract audio | towav
57
+ foobar.mp4 | extract audio | 2wav
58
+ foobar.mp4 | extract_audio | 2wav
59
+
60
+ Camelcase all files in the current working directory:
61
+
62
+ ls | camel_case
63
+ ls | camel case
64
+ ls | camelCase
65
+ ls | camel
66
+
67
+ ## The unimportant history of this project
68
+
69
+ I initially started this project back in <b>2007</b> or so, under another name -
70
+ the Hermes pipe. The idea here was that Hermes, from the Greek mythology,
71
+ would deliver messages to others. In German the name is "Götterbote".
72
+
73
+ After the Hermes pipe I created the Solar pipe, then the Master Pipe,
74
+ then PipeHandler and eventually renamed the project to
75
+ **PipeParadise**. Then it was idle for about 5 years or so, until
76
+ <b>June 2022</b>. Quite a lot of history here, eh?
77
+
78
+ Most of my more successful projects end up with the string
79
+ *paradise*, such as **ftp_paradise** and so forth.
80
+
81
+ I will most likely stick to the name <b>universal pipe handler</b>,
82
+ but who knows really. I thought I'd stick with **PipeParadise** as
83
+ a name as well, largely because many of my other ruby-based
84
+ projects have the suffix *paradise*, but then I changed my
85
+ mind again. So who knows.
86
+
87
+ Why so many rewrites, aside from the various name changes, though?
88
+
89
+ The Hermes pipe ended up being way too hard to maintain, so I
90
+ thought about *simplifying** it and using a better, simpler concept,
91
+ including a full specification of the behaviour. This part is
92
+ very important: I wanted to **document what is available**, so
93
+ that if I need to rewrite anything in the future again, one day, I
94
+ can just refer to that specification and continue from there.
95
+
96
+ Thus, this is one goal of the universal pipe handler: to really
97
+ specify what it can do, at all times.
98
+
99
+ ## Current status of the Universal Pipe Handler project
100
+
101
+ The current status of the Universal Pipe Handler project is not
102
+ complete at all, but it is still better than the prior status
103
+ quo, which had no specification at all whatsoever.
104
+
105
+ ## Definition and Specification for the Universal Pipe Handler
106
+
107
+ This subsection will contain some definitions and specifications
108
+ for the universal pipe handler project.
109
+
110
+ The definition of a **cmdlet**, short for <b>Commandlet</b>. An
111
+ alternative name for a <b>cmdlet</b> would be a <b>command
112
+ snippet</b>.
113
+
114
+ A **cmdlet**, as far as the universal pipe handler project is
115
+ concerned, is everything before and after a pipe token
116
+ (the <b>|</b> token). The pipe must be able to interprete
117
+ these cmdlets.
118
+
119
+ If you look at the above example again:
120
+
121
+ foobar.mp4 | extract_audio | to_wav
122
+
123
+ Then you can see two | pipe tokens, and a total of three
124
+ individual **cmdlets**.
125
+
126
+ Let's look at another example:
127
+
128
+ ls | nl | remove comments from mp3 files
129
+
130
+ This would list all entries from the correct working directory,
131
+ number them (from 1 to n), then remove all comments from mp3
132
+ files found, and finally display the result to the user.
133
+
134
+ Thus, in this case you have three individual <b>cmdlets</b>:
135
+
136
+ ls
137
+ nl
138
+ remove comments from mp3 files
139
+
140
+ So everything before and after any individual '|' token
141
+ is an individual "cmdlet". The primary objective for
142
+ the universal pipe handler is to interprete and evaluate
143
+ the cmdlet correctly.
144
+
145
+ We also have to store data that has to be exchanged between
146
+ the individual command-snippets. This data will be
147
+ stored in a toplevel variable called @dataset.
148
+
149
+ If there is an unknown instruction given, that is, an unknown
150
+ cmdlet, then this must be reported to the user. Then the pipe
151
+ will either exit (and thus terminate) or continue nonetheless,
152
+ depending on the behaviour used for this pipe instruction.
153
+
154
+ ## Individual cmdlets described
155
+
156
+ This subsection will describe individual cmdlets. Ideally
157
+ **every** cmdlet should be described, so that we can
158
+ evaluate the behaviour and check it against the main
159
+ specification.
160
+
161
+ Note that each individual cmdlet **must** be registered
162
+ in the Array that is stored in the file called
163
+ <b>allowed_cmdlets.yml</b>.
164
+
165
+ Keep the following list sorted alphabetically.
166
+
167
+ <b>add_audio</b>: This cmdlet attempts to add an audio to a
168
+ video file. It also supports shortcuts via **BeautifulUrl**.
169
+
170
+ <b>all</b>: This is a general wrapper towards doing an action on "all"
171
+ files or directories. It allows you to pattern-match towards a
172
+ specific pattern. For instance, if you do "all rb files" then
173
+ we will fetch all .rb files of a given directory.
174
+
175
+ <b>all_images_from</b>: this cmdlet will obtain all images from
176
+ a subdirectory. It also responds to :symbols, such as in the
177
+ following example: <b>all_images_from :njoy_dir</b>. The symbols
178
+ specify from where something should be read.
179
+
180
+ <b>any</b>: This is a commandlet for convenience. For instance, if you
181
+ do "any avi" then we will fetch any avi file (randomly). This can be
182
+ used in pipes like: "any mp3 | stat" to report the size of that
183
+ file. Not too terribly useful, unless you want to quickly test
184
+ something.
185
+
186
+ <b>ascii_video</b>: This commandlet allows the user to play a video,
187
+ in mplayer, as ASCII Art, using the <b>aalib library</b>.
188
+
189
+ <b>assign</b>: this cmdlet allows the user to assign to
190
+ a specific file. Is the default for the first pipe
191
+ processing task, to allow the user to operate with
192
+ existing local files.
193
+
194
+ <b>copy_directories</b>: will copy all directories found within
195
+ a directory into another target.
196
+
197
+ <b>colourize</b>: This little cmdlet allows the user to colourize
198
+ string input in any way they see fit. Right now it is a bit
199
+ limited though, you have to extend it as you use that.
200
+
201
+ <b>crop</b>: Crop can be used to crop (make it smaller) any
202
+ given image or a video, such as from 1024px to 800px.
203
+
204
+ <b>cut</b>: cut audio ... like cut 30%. This would take from the beginning at
205
+ 0% up to 30% of the audio file. We start from the left side by default, which
206
+ is where audio and video files are normally started. If you provide a
207
+ negative number here, like -30%, then we instead count from 100% to the
208
+ left, in other words, -30% would mean 70% up to 100%. To recapitulate, if
209
+ you use -30%, we start from the right side instead. (This allows you to
210
+ clip away only the last part of an audio file.)
211
+
212
+ Here are two examples to highlight this:
213
+ assign foo.mp3 | cut -30%
214
+ ^^^ cut away the last 30% of the audio file.
215
+ assign foo.mp3 | cut -30
216
+ ^^^ cut away the last 30 seconds of the audio file.
217
+
218
+ Note though that the general action "cut" could also mean to "cut this
219
+ video file", so since December 2011 we assume that cutting a video file
220
+ means that we want to just cut away some parts of it.
221
+
222
+ You can also use percentages, such as "30%-80%". This will start
223
+ cutting at 30% and proceed up to 80% of the file length.
224
+
225
+ <b>decolourize</b>: this cmdlet get rid of colours from a
226
+ <b>video</b> file specifically.
227
+
228
+ <b>download</b>: Like wget, this allows the user to download
229
+ something. This uses a pure ruby solution, so the user
230
+ is independent of <b>wget</b> actually.
231
+
232
+ <b>extract</b>: this is a meta instruction. Applied on video
233
+ data, it will try to extract the audio and the video
234
+ separately. Applied to an archive, such as a .zip file,
235
+ it will extract said archive.
236
+
237
+ <b>extract_all</b>: this cmdlet allows the user to
238
+ extract all packages in a given location.
239
+
240
+ <b>find_all</b>: this cmdlet allows the user to find a
241
+ substring. <b>Grep</b> is an alias to this, so this is
242
+ mostly a simulation of <b>grep</b>.
243
+
244
+ <b>generate_string</b>: this cmdlet allows us to generate a string,
245
+ in particular a random string.
246
+
247
+ <b>get_all_files</b>: This commandlet will obtain all files
248
+ of a given directory. It should equal the UNIX command
249
+ "ls", more or less.
250
+
251
+ <b>get_last_characters</b>: How many characters we can get from a
252
+ string or a file.
253
+
254
+ <b>help?</b>: lists all available commands that are supported
255
+ by the <b>universal pipe handler</b>.
256
+
257
+ <b>identify</b>: This cmdlet can be used to identify a
258
+ multimedia component, be it audio or video related data.
259
+
260
+ <b>install</b>: We try to install something with this cmdlet.
261
+ This can be used like in "install | htop" to install htop.
262
+ The latter will make use of the <b>rbt</b> project.
263
+
264
+ <b>match_regex</b>: This cmdlet allows the user to match to
265
+ regexes found in a given file.
266
+
267
+ <b>n_words</b>: report how many words are in a given file, or
268
+ somewhere else.
269
+
270
+ <b>play</b>: use this cmdlet to play an audio or a video
271
+ file. Some aliases exist to this, i.e. <b>play_video_file</b>.
272
+
273
+ <b>random line</b>: fetch a random line from a file. This
274
+ is usually done to show (display) that line.
275
+
276
+ <b>read_file</b>: This cmdlet will read the content of a file, similar
277
+ to the unix "cat" command. If you use a <b>:</b> then we will use
278
+ BeautifyUrl here. This allows us to access registered files more
279
+ readily using symbols as shortcuts. Specific example for this
280
+ functionality: <b>read_file :pc</b>
281
+
282
+ <b>read_line</b>: Read a specific line in a file. Like "read_line 9"
283
+ allows you to read the ninth line. (Show line number x). Note that
284
+ the keyword "last" will fetch the last line of a file.
285
+
286
+ <b>remove_audio</b>: This action attempts to remove the audio found
287
+ in a video container or somewhere else. It will then create a new
288
+ file, for instance called output.avi
289
+
290
+ <b>remove_comments</b>: this commandlet will remove comments from a
291
+ file. The default comment specifier is the '#' character. Anything
292
+ after that token will be removed, including that token itself.
293
+
294
+ <b>remove_directories</b>: removes all directories. Use with
295
+ care. Note that <b>/</b> will never be assumed to be a
296
+ valid directory for removal via this functionality.
297
+
298
+ <b>remove_html</b>: This cmdlet will remove all <html> tags found
299
+ in a given String. It can be used to "sanitize" a downloaded
300
+ .html page, for instance, if the user needs the raw text.
301
+
302
+ <b>remove_newlines</b>: This cmdlet will simply remove newlines.
303
+ In pure ruby code, this would be equal to .delete("\n").
304
+ <b>strip_newlines</b> is an alias to this cmdlet.
305
+
306
+ <b>repackage_to</b>: allows us to fill in the @result into a
307
+ method and repackage that. A typical example for this may be
308
+ <b>repackage_to .tar.xz</b>.
309
+
310
+ <b>resize_image</b>: This cmdlet allows the user to resize a given
311
+ image. Right now, resize is an alias to resize_image but in the
312
+ future we may wish to use resize on videos as well.
313
+
314
+ <b>search</b>: the search-cmdlet is primarily used to search
315
+ for torrents that can be downloaded, since as of June 2011.
316
+ However had, it may be extended eventually towards a more
317
+ comprehensible search-functionality.
318
+
319
+ <b>shuffle_csv</b>: This commandlet can be used to shuffle CSV
320
+ values. shuffle_csv 1,5,6 means that the entries at 5 and 6 will
321
+ become right next to 1. It thus reoganizes the entries in a
322
+ csv file.
323
+
324
+ Specific Example:
325
+
326
+ assign /Depot/j/test.csv | shuffle_csv 1,5,6 | save_as /Depot/j/output.csv
327
+
328
+ <b>starts_with?</b>: This queries whether a line starts with
329
+ a specific substring or not. If yes, then we add it.
330
+
331
+ <b>this_dir</b>: This is not a commandlet-action as such,
332
+ but a special alias. It is expanded into "assign Dir.pwd"
333
+ for the most part (or, more accurately, into the method
334
+ return_pwd, which is more or less equal to Dir.pwd, but
335
+ with a trailing <b>/</b>).
336
+
337
+ <b>to_camel_case</b>: This will camelCase the given input.
338
+ If a list of files is passed then this will be applied
339
+ onto each file. Thus, use with caution.
340
+
341
+ <b>to_pdf</b>: This cmdlet can be used to create a .pdf
342
+ file.
343
+
344
+ <b>word_count</b>: This will simply count the word frequency of a
345
+ file or all files in a given directory. In case a directory is
346
+ provided here, the current behaviour is to find all files in
347
+ that given directory and count the words found therein, in all
348
+ of these files.
349
+
350
+ <b>word_wrap</b>: wraps words after <n characters>. word_wrap
351
+ 76 would wrap after 76 characters. Aliases like wrap at
352
+ exist, with wrap at 30 wrapping at every 30th character.
353
+
354
+ ## How to use several cmdlets
355
+
356
+ You can combine these cmdlets like in the following manner:
357
+
358
+ handler = UniversalPipeHandler.new 'assign foo.avi | filter huffyman | save to /Depot/bla.avi'
359
+
360
+ This will run the passed cmdlets - first assign to foo.avi, then run
361
+ through a <b>huffyman filter</b>, and then save the result of
362
+ that into a new file. The whole line is called a <b>pipe</b>.
363
+
364
+ Rather than UniversalPipeHandler.new() you could also use the slightly
365
+ shorter UniversalPipeHandler[] method call.
366
+
367
+ ## class UniversalPipeHandler::CmdletsHandler
368
+
369
+ This class will handle individual cmdlets. Individual cmdlets
370
+ will, in turn, be handled by <b>class UniversalPipeHandler::Cmdlet</b>,
371
+ so <b>class UniversalPipeHandler::CmdletsHandler</b> is the kind of
372
+ cmdlet-"controller".
373
+
374
+ ## Readline support
375
+
376
+ The universal_pipe_handler should be able to make use of Readline,
377
+ in particular upon completion of all registered cmdlets. This
378
+ should also work with aliases towards cmdlets.
379
+
380
+ Readline can be used for <b>tab completion</b>. The current
381
+ behaviour is to tab-complete on every available cmdlet
382
+ snippet, including the aliases to it. This should allow the
383
+ user to complete individual instructions towards a cmdlet.
384
+
385
+ ## The variable @result
386
+
387
+ Data that is processed between two different cmdlets is always
388
+ stored in the toplevel instance variable @result. Access to
389
+ this toplevel instance variable should occur via the method
390
+ <b>.result?</b>.
391
+
392
+ ## Compatibility to Avisynth
393
+
394
+ Avisynth was a really interesting program that would allow the
395
+ user to do various video-related manipulations in a pipe-oriented
396
+ manner. You could do numerous things with it, including overlaying
397
+ commercial ads on a TV show with some ad-hoc bar that would
398
+ censor it away, programmatically. This focus on using avisynth
399
+ like a **script** was what really was nifty. I am trying to
400
+ add support for this into the **universal pipe handler**
401
+ from the get go, via ffmpeg, but who knows how far I'll get
402
+ with this.
403
+
404
+ The following subsection shall show some examples how avisynth
405
+ could be used:
406
+
407
+ # Add a subtitle
408
+ AviSource("foobar.avi")
409
+ Subtitle("Hello World!", size=56, align=5)
410
+
411
+ # Flip the video vertically
412
+ DirectShowSource('foobar.avi')
413
+ FlipVertical
414
+
415
+ # resize the dimensions of the video frame to 320x240
416
+ LanczosResize(320, 240)
417
+
418
+ # fade-in the first 15 frames from black
419
+ FadeIn(15)
420
+
421
+
422
+ ## Contact information and mandatory 2FA coming up in 2022
423
+
424
+ If your creative mind has ideas and specific suggestions to make this gem
425
+ more useful in general, feel free to drop me an email at any time, via:
426
+
427
+ shevy@inbox.lt
428
+
429
+ Before that email I used an email account at Google gmail, but in **2021** I
430
+ decided to slowly abandon gmail for various reasons. In order to limit this
431
+ explanation here, allow me to just briefly state that I do not feel as if I
432
+ want to promote any Google service anymore, for various reasons.
433
+
434
+ Do keep in mind that responding to emails may take some time, depending on
435
+ the amount of work I may have at that moment.
436
+
437
+ In 2022 rubygems.org decided to make 2FA mandatory for every gem owner:
438
+ see https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
439
+
440
+ As I can not use 2FA, for reasons I will skip explaining here (see
441
+ various github issue discussions in the past), this effectively means that
442
+ Betty Li and others who run the show at rubygems.org will perma-ban me
443
+ from using rubygems as a developer.
444
+
445
+ As I disagree with that decision completely, this will mean that all my
446
+ gems will be removed from rubygems.org prior to that sunset date, e. g.
447
+ before they permanently lock me out from the code that I used
448
+ to maintain. It is pointless to want to discuss this with them anymore -
449
+ they have made up their minds and decided that you can only use
450
+ the code if 2FA is in place, even though the code itself works just
451
+ fine. If you don't use 2FA you are effectively locked out from your
452
+ own code; I consider this a malicious attack. See also how they limited
453
+ discussions to people with mandatory 2FA on the ruby-bugtracker, thus
454
+ banning everyone permanently without 2FA:
455
+
456
+ https://bugs.ruby-lang.org/issues/18800
457
+
458
+ Guess it may indeed be time to finally abandon ruby - not because
459
+ ruby is a bad language, but there are people now in charge who
460
+ really should not be part of ruby in the first place.
461
+