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
@@ -0,0 +1,300 @@
1
+ # =========================================================================== #
2
+ # This file lists which functions should be included or added into
3
+ # the PipeParadise project.
4
+ # =========================================================================== #
5
+
6
+ (1) add action:
7
+
8
+ exchange_character_in_filename (or another name)
9
+
10
+ assign file THIS_FILE | replace o with a
11
+
12
+ ^^^ will result in faa.txt
13
+
14
+ ---------------------------------------------------------------
15
+ (2) go through and see if we use many of my modern software
16
+ components already; also check if we can reshuffle .csv
17
+ files
18
+
19
+ shuffle_tab 5 6
20
+ ^^^ should exchange these
21
+ ---------------------------------------------------------------
22
+ (3) add this:
23
+
24
+ burn iso *pdf | xmessage done
25
+
26
+ # the above burns the pdf, and then when done, shows a
27
+ # message to the user.
28
+ ---------------------------------------------------------------
29
+ (4) all action-requires should be bundled into a
30
+ single .rb file, so that we can avoid
31
+ requiring it more than once, like
32
+ file_duration
33
+
34
+ ---------------------------------------------------------------
35
+ (5) continually look at
36
+ https://github.com/cantino/huginn
37
+ and learn from it
38
+
39
+ ---------------------------------------------------------------
40
+ (6) cat $RUBY_TOOLS/return_random_image.rb | nl | colourize | nl
41
+
42
+ ^^^ Irgendwas ist mit colourize falsch. Der output den man
43
+ bekommt, der scheint auf einmal keine Newlines mehr zu haben.
44
+
45
+ ----------------------------------------------------------------------------------------------------
46
+ (7)
47
+ - assign foo.avi | add_audio blablabla/mp3 # <--- the same as above...
48
+ ---------------------------------------------------------------
49
+ (8)
50
+ - assign foo.avi | convert to animated gif
51
+
52
+ ^^^ should work. also | convert to image
53
+ somehow the ... command sucks.
54
+
55
+ -----------------------------------------------------------------------------------------------------
56
+ (11) read file bla | create foobar.rtf
57
+
58
+ ^^^ this triggers the binding of ruby rtf stuff.
59
+
60
+
61
+ -----------------------------------------------------------------------------------------------------
62
+ (11) any avi | increase audio delay 3ms
63
+
64
+ assign avi | decrease audio delay 3ms
65
+
66
+ assign any avi | increase audio delay 3ms
67
+
68
+ ^^^ use any avi, then increase its audio delay by 3 ms.
69
+
70
+ -----------------------------------------------------------------------------------------------------
71
+ (11) assign bloodsport.avi | duration 155 - 255 | extract_audio_to /tmp/stored_here.mp3
72
+ ^^^ This is in seconds
73
+
74
+ Das hier soll das bloodsport avi assigned, von der sekunden zahl hinspringen und
75
+ den audio teil rausholen. Synonym sollte auch dies hier gehen:
76
+
77
+ assign bloodsport.avi | at 00:45:02 | for 20 seconds | extract_audio | save to /tmp/stored_here.mp3
78
+
79
+ Das macht das selbe. UND danach das ganze natürlich dokumentieren.
80
+
81
+
82
+
83
+ -----------------------------------------------------------------------------------------------------
84
+
85
+
86
+ read this_file | starts_with? X
87
+
88
+ read this_file | starts_with? pqr
89
+
90
+ cat LINUX.cgi | egrep '^A' | sort | uniq | wc -l
91
+
92
+ read file foo.txt | starts_with? X | sort | uniq | word_count # print longest line
93
+
94
+ This counts the number of unique lines in the text file that
95
+ begin with X. The great thing is that it's quite readable.
96
+ You can read the data left to right.
97
+
98
+ alias egrep starts_with?
99
+
100
+ IMPLEMENT:
101
+ starts_with?
102
+
103
+
104
+ -----------------------------------------------------------------------------------------------------
105
+
106
+
107
+ match_regex
108
+
109
+
110
+
111
+ - Video und Audio Processing sollte funktionieren wie mit Avisynth.
112
+
113
+ open foo.avi | increase audio 2% | duration 5%..50% | crop video 300x150 | filter huffyman | save_to /x.avi | upload_to default
114
+
115
+
116
+
117
+
118
+
119
+ find_all "hier kommt die condition..."
120
+ find_all scripts
121
+
122
+
123
+ - find_all "hier kommt die condition..." | remove <--- die wird reingepiped.
124
+ ^^^ das hier wurde schon realisiert ^^^ das hier verstehe ich nicht ... was will ich da entfernen???
125
+ und funzt mehr oder weniger.
126
+
127
+
128
+
129
+ - assign audio_song | cut 30% # or cut 0-30, 30% defaults from start to 30% of lenght
130
+ - assign audio_song | cut -30% # reverse.
131
+
132
+
133
+ - we also want to have the ability to use system() for unix things when the command was not registered.
134
+ but perhaps make this a toggleable setting.
135
+
136
+
137
+
138
+ - automatically create an animated gif somehow... with several images
139
+
140
+
141
+ - Eine lose Idee: Wenn eine action nichts gscheites rausgibt ... das dem user sagen
142
+
143
+
144
+
145
+ - grep # to grep for a specific string.
146
+
147
+ cat foo | grep blablabla
148
+
149
+ -> alias search_for, searchfor, sfor
150
+
151
+
152
+
153
+
154
+ - | repackage to squashfs
155
+ ^^^ this shit did not work!
156
+
157
+
158
+
159
+ - ein allgemeiner fokus is das wir image-dateien manipulieren können, z.bsp
160
+
161
+ rasterize (sollte ein raster machen auf ein image)
162
+ rasterize: -> image_rasterize
163
+
164
+ Das scheint ziemlich schwer zu sein...
165
+
166
+
167
+
168
+
169
+
170
+ >>> [1, 2, 3, 4, 5] | add
171
+ 15
172
+
173
+ >>> [5, 4, 3, 2, 1] | sort
174
+ [1, 2, 3, 4, 5]
175
+
176
+ [1, 2, 3, 4, 5]
177
+
178
+ The base class of Pipe is kept simple (7 lines of python) and
179
+ is usable as a decorator permitting you to create new
180
+ 'pipeable' functions easily. The module provides ~30
181
+ prepared pipes functions like 'where', 'group_by',
182
+ 'sort', 'take_while'
183
+ A pipeable
184
+ function takes an iterable (tuple, list, generator)
185
+ and yields to be itself an iterator, so
186
+ pipeable function can be piped together.
187
+
188
+
189
+
190
+ - [1, 2, 3, 4, 5] | select even
191
+ - [1, 2, 3, 4, 5] | select odd
192
+ select all even or odd numbers.
193
+ without []
194
+
195
+
196
+ [1, 2, 3, 4, 5] | add
197
+ [1, 2, 3, 4, 5] . add
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+ ---------------------------------------------------------------
208
+
209
+ master_pipe.assign_data = blablabla
210
+
211
+ We need a way to assign data before the master pipe starts
212
+ its actions. This is the default action! First action always!
213
+
214
+ assign data |
215
+
216
+ will always be the first thing that happens!!!
217
+
218
+ Can be nil.
219
+
220
+
221
+ ---------------------------------------------------------------
222
+
223
+
224
+ flip left right (flip a video left-right)
225
+
226
+
227
+ ---------------------------------------------------------------
228
+
229
+ - find . -name '*.rb' | xargs wc -l
230
+
231
+ ^^^ das muss auch gehen...
232
+
233
+
234
+
235
+
236
+
237
+ ---------------------------------------------------------------
238
+
239
+ - implement:
240
+
241
+ "upload to youtube"
242
+
243
+
244
+
245
+ ---------------------------------------------------------------
246
+
247
+
248
+ http://www.sean-crist.com/personal/pages/visual_pipes/
249
+
250
+ ^^^ ensure that the master pipe can use this too.
251
+
252
+
253
+ ---------------------------------------------------------------
254
+ Austesten ob "married with bloopers" rausschneiden kann.
255
+ Dazu brauchen wir eine Testdatei, bla.avi.
256
+
257
+ assign bla.avi | video_cut 30s | save #APPEND#_modified
258
+
259
+
260
+ assign bla.avi | video_cut 20-1630s | save #APPEND#_modified
261
+
262
+ Beides sollte funktionieren.
263
+
264
+ ---------------------------------------------------------------
265
+
266
+ die conversions aus dem multimedia_project hinzufügen
267
+
268
+ ---------------------------------------------------------------
269
+
270
+
271
+ <bradland> shevy: regarding audio, when removing duration,
272
+ trucate is a good term. when altering amplitude, attenuate/amplify would be the terms used.
273
+
274
+ <bradland> cool
275
+ <bradland> when designing your API, think of duration as its own entity
276
+ <bradland> most editing is done using markers, referred to as in & out
277
+ <bradland> once markers ar eset, you perform an operation
278
+ <bradland> it's a nice set of abstractions for designing and api
279
+
280
+
281
+ - add a way to install stuff
282
+
283
+ ---------------------------------------------------------------
284
+
285
+ merge video #
286
+ We need a simple way to append new videos to an existing
287
+ video, so that we can chain together different videos,
288
+ automatically, without having to worry about encoding
289
+ and such.
290
+
291
+
292
+ ---------------------------------------------------------------
293
+
294
+ - enable or verify that this works:
295
+
296
+ download https://www.youtube.com/watch?v=UZr75lLiE6k
297
+ we will use youtube-dl for now.
298
+
299
+ - add rblanks as well to the list of commands that can
300
+ be done.
Binary file
Binary file
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === UniversalPipeHandler::Base
6
+ #
7
+ # Usage example:
8
+ #
9
+ # UniversalPipeHandler::Base.new(ARGV)
10
+ #
11
+ # =========================================================================== #
12
+ # require 'universal_pipe_handler/base/base.rb'
13
+ # < Base
14
+ # =========================================================================== #
15
+ module UniversalPipeHandler
16
+
17
+ class Base # === UniversalPipeHandler::Base
18
+
19
+ require 'universal_pipe_handler/colours/colours.rb' # Mandatory.
20
+ include Colours
21
+
22
+ require 'fileutils'
23
+
24
+ require 'universal_pipe_handler/toplevel_methods/all_actions.rb'
25
+
26
+ # ========================================================================= #
27
+ # === NAMESPACE
28
+ # ========================================================================= #
29
+ NAMESPACE = inspect
30
+
31
+ # ========================================================================= #
32
+ # === initialize
33
+ # ========================================================================= #
34
+ def initialize(
35
+ commandline_arguments = nil,
36
+ run_already = true
37
+ )
38
+ reset
39
+ set_commandline_arguments(
40
+ commandline_arguments
41
+ )
42
+ run if run_already
43
+ end
44
+
45
+ # ========================================================================= #
46
+ # === reset (reset tag)
47
+ # ========================================================================= #
48
+ def reset
49
+ # ======================================================================= #
50
+ # === @namespace
51
+ # ======================================================================= #
52
+ @namespace = NAMESPACE
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === set_commandline_arguments
57
+ # ========================================================================= #
58
+ def set_commandline_arguments(i = '')
59
+ i = [i].flatten.compact
60
+ @commandline_arguments = i
61
+ end
62
+
63
+ # ========================================================================= #
64
+ # === commandline_arguments?
65
+ # ========================================================================= #
66
+ def commandline_arguments?
67
+ @commandline_arguments
68
+ end
69
+
70
+ # ========================================================================= #
71
+ # === first_argument?
72
+ # ========================================================================= #
73
+ def first_argument?
74
+ @commandline_arguments.first
75
+ end; alias first? first_argument? # === first?
76
+
77
+ # ========================================================================= #
78
+ # === allowed_actions?
79
+ #
80
+ # Return every allowed action. This will not be needed by every
81
+ # subclass, so perhaps this may have to be changed at one point
82
+ # in time.
83
+ # ========================================================================= #
84
+ def allowed_actions?
85
+ ::UniversalPipeHandler.all_actions?
86
+ end; alias registered_actions? allowed_actions? # === registered_actions?
87
+
88
+ # ========================================================================= #
89
+ # === copy
90
+ # ========================================================================= #
91
+ def copy(from, to)
92
+ FileUtils.copy(from, to)
93
+ end
94
+
95
+ # ========================================================================== #
96
+ # === remove_quotes
97
+ # ========================================================================== #
98
+ def remove_quotes(i)
99
+ i.delete('"')
100
+ end
101
+
102
+ # ========================================================================= #
103
+ # === mkdir
104
+ # ========================================================================= #
105
+ def mkdir(i)
106
+ FileUtils.mkdir_p(i)
107
+ end
108
+
109
+ # ========================================================================= #
110
+ # === chdir
111
+ # ========================================================================= #
112
+ def chdir(i)
113
+ FileUtils.chdir(i)
114
+ end; alias cd chdir # === cd
115
+
116
+ # ========================================================================= #
117
+ # === register_sigint
118
+ # ========================================================================= #
119
+ def register_sigint
120
+ Signal.trap('SIGINT') { exit }
121
+ end
122
+
123
+ # ========================================================================= #
124
+ # === run (run tag)
125
+ # ========================================================================= #
126
+ def run
127
+ end
128
+
129
+ # ========================================================================= #
130
+ # === return_pwd
131
+ # ========================================================================= #
132
+ def return_pwd
133
+ "#{Dir.pwd}/".squeeze('')
134
+ end
135
+
136
+ # ========================================================================= #
137
+ # === UniversalPipeHandler::Base[]
138
+ # ========================================================================= #
139
+ def self.[](i = '')
140
+ new(i)
141
+ end
142
+
143
+ end; end
144
+
145
+ if __FILE__ == $PROGRAM_NAME
146
+ UniversalPipeHandler::Base.new(ARGV)
147
+ end # base.rb