totarxz 0.0.19

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of totarxz might be problematic. Click here for more details.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aba9ef3ccbb5b0bbeacc472d6e49975f78f492099ea1d135644fc65a82c49ca1
4
+ data.tar.gz: 3363f5e533f957159cc6ae672ddb28be4cb2479ee2558965529a1b284b47528d
5
+ SHA512:
6
+ metadata.gz: 06c09b4a38dbd7783ab73132812e268f5b4722e0fdc023d1ba6d050855371c0e60cba01339b8bd7421dc1fda06b7f732ed6e6895a9d83b4c012ffa7435dc38ea
7
+ data.tar.gz: 0bd68d0f7fa1d7898448d64f751a69265294fefd4b2e51ebdd32fa64649bf38c1bd413b6c3c79dfa422e3794b4032c3bac8a24243ab63e51025638e446281352
data/bin/totarxz ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'totarxz/totarxz.rb'
6
+
7
+ ToTarXz.new(ARGV) { :be_silent }
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'totarxz/constants.rb'
6
+ # =========================================================================== #
7
+ class ToTarXz # === Totarxz.new
8
+
9
+ # ========================================================================= #
10
+ # === TAR_XZ_EXTENSION
11
+ # ========================================================================= #
12
+ TAR_XZ_EXTENSION = '.tar.xz'
13
+
14
+ # ========================================================================= #
15
+ # === TAR_BZ2_EXTENSION
16
+ # ========================================================================= #
17
+ TAR_BZ2_EXTENSION = '.tar.bz2'
18
+
19
+ # ========================================================================= #
20
+ # === BE_VERBOSE
21
+ #
22
+ # Whether to be verbose by default or whether we will not be verbose.
23
+ # ========================================================================= #
24
+ BE_VERBOSE = true
25
+
26
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'fileutils'
6
+ require 'opn'
7
+ require 'colours'
@@ -0,0 +1,342 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ToTarXz
6
+ #
7
+ # This class will essentially just create a .tar.xz package.
8
+ #
9
+ # The normal command for this is on Linux is:
10
+ #
11
+ # tar cfJ <archive.tar.xz> <files>
12
+ # tar cfJ rbt-04.09.2015.tar.xz rbt-04.09.2015/
13
+ #
14
+ # =========================================================================== #
15
+ # require 'totarxz/totarxz.rb'
16
+ # =========================================================================== #
17
+ require 'totarxz/requires/base_requires.rb'
18
+ require 'totarxz/version/version.rb'
19
+ require 'totarxz/constants.rb'
20
+
21
+ class ToTarXz # === Totarxz.new
22
+
23
+ include Colours
24
+
25
+ # ========================================================================= #
26
+ # === initialize
27
+ #
28
+ # The first argument is the target to become a .tar.xz archive.
29
+ # ========================================================================= #
30
+ def initialize(
31
+ package_this_target = nil,
32
+ be_verbose = BE_VERBOSE,
33
+ run_already = true,
34
+ &block
35
+ )
36
+ @be_verbose = be_verbose # default
37
+ reset # This must come after @be_verbose was set.
38
+ be_verbose if be_verbose # Be silent not before calling sanitize_data().
39
+ set_package_this_target(
40
+ package_this_target
41
+ )
42
+ case run_already
43
+ # ======================================================================= #
44
+ # === --help
45
+ # ======================================================================= #
46
+ when /^-?-?help$/i
47
+ show_help_then_exit
48
+ # ======================================================================= #
49
+ # === --date
50
+ # ======================================================================= #
51
+ when /^-?-?date$/,
52
+ 'TODAY','DATE','WITH_DATE'
53
+ @repackage_archive_to_todays_date = true
54
+ run_already = true
55
+ end
56
+ # ======================================================================= #
57
+ # === Handle blocks next
58
+ #
59
+ # Intercept blocks here. Handle :be_verbose as argument, but also
60
+ # certain keys in a Hash, since as of June 2020.
61
+ # ======================================================================= #
62
+ if block_given?
63
+ yielded = yield
64
+ case yielded
65
+ when :be_silent
66
+ @be_verbose = false
67
+ when :be_verbose
68
+ @be_verbose = true
69
+ else
70
+ if yielded.is_a? Hash
71
+ # ================================================================= #
72
+ # === :use_this_archive_name => "htop-2.2.0"
73
+ # ================================================================= #
74
+ if yielded.has_key? :use_this_archive_name
75
+ set_tar_xz_name(yielded.delete(:use_this_archive_name))
76
+ end
77
+ end
78
+ end
79
+ end
80
+ run if run_already
81
+ end
82
+
83
+ # ========================================================================= #
84
+ # === reset (reset tag)
85
+ # ========================================================================= #
86
+ def reset
87
+ if @be_verbose
88
+ @cmd = 'tar cJvf ' # v stands for verbosity here.
89
+ else
90
+ @cmd = 'tar cJf ' # v stands for verbosity here.
91
+ end
92
+ # ======================================================================= #
93
+ # === @cmd
94
+ # ======================================================================= #
95
+ @cmd = @cmd.dup
96
+ # ======================================================================= #
97
+ # === @archive_type
98
+ # ======================================================================= #
99
+ @archive_type = '.tar.xz'
100
+ # ======================================================================= #
101
+ # === @repackage_archive_to_todays_date
102
+ # ======================================================================= #
103
+ @repackage_archive_to_todays_date = false
104
+ # ======================================================================= #
105
+ # === @orig_stdout
106
+ # ======================================================================= #
107
+ @orig_stdout = nil
108
+ end
109
+
110
+ # ========================================================================= #
111
+ # === be_silent?
112
+ # ========================================================================= #
113
+ def be_silent?
114
+ !@be_verbose
115
+ end
116
+
117
+ # ========================================================================= #
118
+ # === be_verbose?
119
+ # ========================================================================= #
120
+ def be_verbose?
121
+ @be_verbose
122
+ end
123
+
124
+ # ========================================================================= #
125
+ # === show_help
126
+ # ========================================================================= #
127
+ def show_help
128
+ e 'To package up with the date, use DATE or TODAY.'
129
+ end
130
+
131
+ # ========================================================================= #
132
+ # === show_help_then_exit
133
+ # ========================================================================= #
134
+ def show_help_then_exit
135
+ show_help
136
+ exit
137
+ end
138
+
139
+ # ========================================================================= #
140
+ # === abort_then_exit
141
+ # ========================================================================= #
142
+ def abort_then_exit
143
+ abort "class ToTarXz: No file was provided or could be found. Please \n"\
144
+ "supply a valid argument (an existing file) and try again."
145
+ exit
146
+ end
147
+
148
+ # ========================================================================= #
149
+ # === set_package_this_target
150
+ #
151
+ # This method will be called from within initialize().
152
+ # ========================================================================= #
153
+ def set_package_this_target(
154
+ i = nil
155
+ )
156
+ if i.is_a? Array and !i.empty?
157
+ i = i.join(' ').strip
158
+ end
159
+ if i and i.end_with?('*')
160
+ # In this case continue.
161
+ elsif i.nil? or !File.exist?(i.to_s)
162
+ abort_then_exit
163
+ end
164
+ case i
165
+ # ======================================================================= #
166
+ # === --help
167
+ # ======================================================================= #
168
+ when /^-?-?help$/i
169
+ show_help_then_exit
170
+ end
171
+ i = i.to_s.dup
172
+ unless i.end_with? '*'
173
+ i << '/' unless i.end_with? '/'
174
+ end
175
+ i.gsub!(/\.tar\.xz$/, '') if i.include? '.tar.xz'
176
+ i.gsub!(/\.tar\.bz2$/, '') if i.include? '.tar.bt2'
177
+ @package_this_target = i
178
+ # ======================================================================= #
179
+ # Now we can determine the .tar.xz name.
180
+ # ======================================================================= #
181
+ determine_tar_xz_name
182
+ end; alias set_archive_filename set_package_this_target # === set_archive_filename
183
+ alias directory= set_package_this_target # === directory=
184
+ alias extract_to_this_directory= set_package_this_target # === extract_to_this_directory=
185
+
186
+ # ========================================================================= #
187
+ # === silence
188
+ # ========================================================================= #
189
+ def silence
190
+ @be_verbose = false
191
+ @orig_stdout = $stdout # Be silent.
192
+ $stdout = File.new('/dev/null', 'w')
193
+ end
194
+
195
+ # ========================================================================= #
196
+ # === extract_to_this_directory?
197
+ # ========================================================================= #
198
+ def extract_to_this_directory?
199
+ @tar_xz_name
200
+ end; alias directory? extract_to_this_directory? # === directory?
201
+ alias dir? extract_to_this_directory? # === dir?
202
+ alias tar_xz_name? extract_to_this_directory? # === tar_xz_name?
203
+ alias archive_location? extract_to_this_directory? # === archive_location?
204
+
205
+ # ========================================================================= #
206
+ # === location?
207
+ # ========================================================================= #
208
+ def location?
209
+ determine_tar_xz_name # Yes, we will determine anew.
210
+ end
211
+
212
+ # ========================================================================= #
213
+ # === package_this_target?
214
+ # ========================================================================= #
215
+ def package_this_target?
216
+ @package_this_target
217
+ end; alias input? package_this_target? # === input?
218
+ alias archive_filename? package_this_target? # === archive_filename?
219
+ alias archive? package_this_target? # === archive?
220
+
221
+ # ========================================================================= #
222
+ # === mv
223
+ # ========================================================================= #
224
+ def mv(old, new)
225
+ FileUtils.mv(old, new)
226
+ end
227
+
228
+ # ========================================================================= #
229
+ # === today?
230
+ # ========================================================================= #
231
+ def today?
232
+ Time.now.strftime '%d.%m.%Y'
233
+ end
234
+
235
+ # ========================================================================= #
236
+ # === set_cmd
237
+ # ========================================================================= #
238
+ def set_cmd(i)
239
+ unless i.end_with? ' '
240
+ i = i.dup if i.frozen?
241
+ i << ' '
242
+ end
243
+ @cmd = i
244
+ end
245
+
246
+ # ========================================================================= #
247
+ # === run_cmd
248
+ # ========================================================================= #
249
+ def run_cmd
250
+ e @cmd
251
+ system @cmd
252
+ # ======================================================================= #
253
+ # Next, we will apply a mv-action if we repackage to another name.
254
+ # ======================================================================= #
255
+ if rename?
256
+ new_name = File.basename(archive?).sub(/\.tar\.xz$/, '')+'-'+
257
+ today?+@archive_type
258
+ opn; e 'Next renaming the archive to `'+sfancy(new_name)+'`.'
259
+ mv(archive?, new_name)
260
+ end
261
+ $stdout = @orig_stdout unless be_verbose? # Restore stdout again.
262
+ end; alias create_tarxz_package run_cmd # === create_tarxz
263
+
264
+ # ========================================================================= #
265
+ # === create_tarxz_package
266
+ # ========================================================================= #
267
+ def create_tarxz_package
268
+ build_cmd_string
269
+ run_cmd
270
+ end
271
+
272
+ # ========================================================================= #
273
+ # === rename?
274
+ #
275
+ # Whether we will rename our archive or whether we will not.
276
+ # ========================================================================= #
277
+ def rename?
278
+ @repackage_archive_to_todays_date
279
+ end
280
+
281
+ # ========================================================================= #
282
+ # === determine_tar_xz_name
283
+ #
284
+ # Note that this method will always append .tar.xz to the name. This
285
+ # is fine for .tar.xz archives but not for .tar.bz2 archives.
286
+ # ========================================================================= #
287
+ def determine_tar_xz_name(
288
+ i = input?.delete('/')+
289
+ TAR_XZ_EXTENSION
290
+ )
291
+ @tar_xz_name = i
292
+ end
293
+
294
+ # ========================================================================= #
295
+ # === set_tar_xz_name
296
+ # ========================================================================= #
297
+ def set_tar_xz_name(i)
298
+ if i.frozen?
299
+ i = i.dup
300
+ end
301
+ i << TAR_XZ_EXTENSION unless i.end_with? TAR_XZ_EXTENSION
302
+ @tar_xz_name = i
303
+ end
304
+
305
+ # ========================================================================= #
306
+ # === build_cmd_string
307
+ # ========================================================================= #
308
+ def build_cmd_string
309
+ @cmd << @tar_xz_name << ' ' << input? # Simply append.
310
+ end
311
+
312
+ # ========================================================================= #
313
+ # === run (run tag)
314
+ # ========================================================================= #
315
+ def run
316
+ create_tarxz_package
317
+ end
318
+
319
+ # ========================================================================= #
320
+ # === ToTarXz[]
321
+ # ========================================================================= #
322
+ def self.[](i)
323
+ new(i)
324
+ end
325
+
326
+ end
327
+
328
+ if __FILE__ == $PROGRAM_NAME
329
+ require 'opn'
330
+ require 'colours/colours_e_autoinclude.rb'
331
+ if ARGV[1]
332
+ if ARGV[1].include?('TODAY') or ARGV[1].include?('DATE') # Handle TODAY and DATE differently.
333
+ ToTarXz.new(ARGV.first, ARGV[1])
334
+ end
335
+ else
336
+ ARGV.each {|entry|
337
+ _ = ToTarXz.new(entry) { :be_silent }
338
+ Opn.opn(namespace: ToTarXz.to_s)
339
+ puts 'You can now find everything at: '+simp(_.archive_location?)
340
+ }
341
+ end
342
+ end # tottarxz GEAS TODAY
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'totarxz/version/version.rb'
6
+ # =========================================================================== #
7
+ class ToTarXz
8
+
9
+ # ========================================================================= #
10
+ # === ToTarXz
11
+ # ========================================================================= #
12
+ VERSION = '0.0.19'
13
+
14
+ end
data/lib/totarxz.rb ADDED
@@ -0,0 +1 @@
1
+ require 'totarxz/totarxz.rb'
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'fileutils'
6
+ require 'cliner'
7
+ require 'totarxz'
8
+ require 'colours/colours_e_autoinclude.rb'
9
+ require 'extracter'
10
+
11
+ e "Now testing #{sfancy('class ToTarXz')}."
12
+ htop = '/Users/x/SRC/htop/htop-1.0.3.tar.xz'
13
+ target_dir = '/Depot/jjjj/'
14
+ FileUtils.cp(htop, target_dir)
15
+ Dir.chdir(target_dir)
16
+ target = target_dir+File.basename(htop)
17
+ e 'First extracting '+target+'.'
18
+ _ = Extracter.new target, Dir.pwd
19
+ pp Dir['*']
20
+ cliner
21
+ e sfancy(_.extracted_to?)
22
+ File.delete(target) # Kill the old archive.
23
+ e 'Now packaging up this here:'
24
+ e ' '+sfancy(target)
25
+ location = ToTarXz[target].location?
26
+ e 'It can now be found here:'
27
+ e
28
+ e ' '+sfancy(location)
29
+ e
data/totarxz.gemspec ADDED
@@ -0,0 +1,52 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project Totarxz.
3
+ # =========================================================================== #
4
+ require 'totarxz/version/version.rb'
5
+
6
+ Gem::Specification.new { |s|
7
+
8
+ s.name = 'totarxz'
9
+ s.version = ToTarXz::VERSION
10
+ s.date = Time.now.strftime('%Y-%m-%d')
11
+
12
+ s.summary = <<-EOF
13
+
14
+ This library is called totarxz. It will create a .tar.xz
15
+ file from the given input at hand.
16
+
17
+ If you have specific suggestions to make this gem more
18
+ useful for others, please drop me an email at:
19
+
20
+ shevegen@gmail.com
21
+
22
+ Thank you.
23
+
24
+ EOF
25
+
26
+ s.description = <<-EOF
27
+
28
+ This library is called totarxz. It will create a .tar.xz
29
+ file from the given input at hand.
30
+
31
+ EOF
32
+
33
+ s.extra_rdoc_files = %w()
34
+
35
+ s.authors = ['Robert A. Heiler']
36
+ s.email = 'shevegen@gmail.com'
37
+ s.files = Dir['**/*']
38
+ s.license = 'GPL-2.0'
39
+ s.executables = Dir['bin/*'].map { |f| File.basename(f) }
40
+ s.homepage = 'https://rubygems.org/gems/totarxz'
41
+
42
+ s.required_ruby_version = '>= '+RUBY_VERSION
43
+ s.required_rubygems_version = '>= '+Gem::VERSION
44
+ s.rubygems_version = '>= '+Gem::VERSION
45
+
46
+ # ========================================================================= #
47
+ # Dependencies for the project:
48
+ # ========================================================================= #
49
+ s.add_dependency 'colours'
50
+ s.add_dependency 'opn'
51
+
52
+ }
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: totarxz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.19
5
+ platform: ruby
6
+ authors:
7
+ - Robert A. Heiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colours
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: opn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |2+
42
+
43
+ This library is called totarxz. It will create a .tar.xz
44
+ file from the given input at hand.
45
+
46
+ email: shevegen@gmail.com
47
+ executables:
48
+ - totarxz
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - bin/totarxz
53
+ - lib/totarxz.rb
54
+ - lib/totarxz/constants.rb
55
+ - lib/totarxz/requires/base_requires.rb
56
+ - lib/totarxz/totarxz.rb
57
+ - lib/totarxz/version/version.rb
58
+ - test/testing_totarxz.rb
59
+ - totarxz.gemspec
60
+ homepage: https://rubygems.org/gems/totarxz
61
+ licenses:
62
+ - GPL-2.0
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.7.1
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 3.1.3
78
+ requirements: []
79
+ rubygems_version: 3.1.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: 'This library is called totarxz. It will create a .tar.xz file from the given
83
+ input at hand. If you have specific suggestions to make this gem more useful for
84
+ others, please drop me an email at: shevegen@gmail.com Thank you.'
85
+ test_files: []
86
+ ...