totarxz 0.0.6
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 +7 -0
- data/lib/totarxz/totarxz.rb +178 -0
- data/lib/totarxz.rb +1 -0
- data/totarxz.gemspec +46 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba030a83722a44170bb591767ed9d4f8a4b05a68
|
4
|
+
data.tar.gz: 8c2fca0247833e5be2c7abfe03ebbcb41e5406f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f922f79ffa461f01bc5e0143b51133ac8555af6e51a586a6850043f861da1f122f2c9df9cfa224b531a95f52addbb386bd2ec6090ca341780fc00b6366e6d0a7
|
7
|
+
data.tar.gz: 16b8594b0fe8113804980f3bb36d5278e1ef5fe9e7807a575192b9884a31bdbe7bf85969bbcce3272efc3f5c2853c9587311b5522caa9e7e9d69a7f9d1e12dda
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#!/System/Executables/ruby -w
|
2
|
+
# Encoding: ASCII-8BIT
|
3
|
+
# =========================================================================== #
|
4
|
+
# === ToTarXz
|
5
|
+
#
|
6
|
+
# This will just create a .tar.xz package.
|
7
|
+
# =========================================================================== #
|
8
|
+
require 'fileutils'
|
9
|
+
require 'opn'
|
10
|
+
require 'esystem'
|
11
|
+
require 'alias_e'
|
12
|
+
require 'colour_aid'
|
13
|
+
|
14
|
+
class ToTarXz # require 'totarxz'
|
15
|
+
|
16
|
+
include Esystem
|
17
|
+
include ColourAid
|
18
|
+
include AliasE
|
19
|
+
|
20
|
+
attr_accessor :extract_to_this_directory
|
21
|
+
|
22
|
+
BE_SILENT = true # Whether to be silent or no.
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === initialize
|
26
|
+
# ========================================================================= #
|
27
|
+
def initialize(
|
28
|
+
argument,
|
29
|
+
run_already = true,
|
30
|
+
be_silent = BE_SILENT
|
31
|
+
)
|
32
|
+
@be_silent = be_silent # default
|
33
|
+
reset
|
34
|
+
sanitize_data(argument)
|
35
|
+
silence if be_silent # Be silent not before calling sanitize_data().
|
36
|
+
case run_already
|
37
|
+
when 'HELP','help','--help'
|
38
|
+
show_help; exit
|
39
|
+
when 'TODAY','DATE','WITH_DATE'
|
40
|
+
@repackage_archive_to_todays_date = true
|
41
|
+
run_already = true
|
42
|
+
end
|
43
|
+
run if run_already
|
44
|
+
end
|
45
|
+
|
46
|
+
# ========================================================================= #
|
47
|
+
# === reset
|
48
|
+
# ========================================================================= #
|
49
|
+
def reset
|
50
|
+
@repackage_archive_to_todays_date = false
|
51
|
+
@cmd = 'tar cfJv '
|
52
|
+
end
|
53
|
+
|
54
|
+
# ========================================================================= #
|
55
|
+
# === sanitize_data
|
56
|
+
#
|
57
|
+
# Do some sanitization.
|
58
|
+
# ========================================================================= #
|
59
|
+
def sanitize_data(argument)
|
60
|
+
argument = '' if argument.nil?
|
61
|
+
case argument
|
62
|
+
when 'HELP','help','--help'
|
63
|
+
show_help; exit
|
64
|
+
end
|
65
|
+
@extract_to_this_directory = argument.dup # @extract_to_this_directory stores our target.
|
66
|
+
@extract_to_this_directory[-1,1] = '' if @extract_to_this_directory.end_with? '/'
|
67
|
+
if @extract_to_this_directory.include? '/'
|
68
|
+
@archive_filename = @extract_to_this_directory.gsub(/Programs/,'').downcase.gsub(/\//,'-')
|
69
|
+
@archive_filename[0,1] = '' if @archive_filename[0,1] == '-'
|
70
|
+
@archive_filename[0,1] = '' if @archive_filename[0,1] == '-'
|
71
|
+
else
|
72
|
+
@archive_filename = @extract_to_this_directory.dup
|
73
|
+
end
|
74
|
+
@archive_filename << '.tar.xz'
|
75
|
+
end
|
76
|
+
|
77
|
+
# ========================================================================= #
|
78
|
+
# === show_help
|
79
|
+
# ========================================================================= #
|
80
|
+
def show_help
|
81
|
+
e 'To package up with the date, use DATE or TODAY'
|
82
|
+
end
|
83
|
+
|
84
|
+
# ========================================================================= #
|
85
|
+
# === rename?
|
86
|
+
#
|
87
|
+
# Whether we will rename our archive or whether we will not.
|
88
|
+
# ========================================================================= #
|
89
|
+
def rename?
|
90
|
+
@repackage_archive_to_todays_date
|
91
|
+
end
|
92
|
+
|
93
|
+
# ========================================================================= #
|
94
|
+
# === silence
|
95
|
+
# ========================================================================= #
|
96
|
+
def silence
|
97
|
+
@be_silent = true
|
98
|
+
$orig_stdout = $stdout # Be silent.
|
99
|
+
$stdout = File.new('/dev/null', 'w')
|
100
|
+
end
|
101
|
+
|
102
|
+
# ========================================================================= #
|
103
|
+
# === directory=
|
104
|
+
# ========================================================================= #
|
105
|
+
def directory=(i)
|
106
|
+
@extract_to_this_directory = i
|
107
|
+
end
|
108
|
+
|
109
|
+
# ========================================================================= #
|
110
|
+
# === create_tarxz_package
|
111
|
+
# ========================================================================= #
|
112
|
+
def create_tarxz_package
|
113
|
+
if @archive_filename.nil?
|
114
|
+
abort 'Please supply an argument and retry. We could not find any file.'
|
115
|
+
exit
|
116
|
+
end
|
117
|
+
@cmd << " #{@archive_filename} "
|
118
|
+
# @cmd << ' -C '
|
119
|
+
@cmd << @extract_to_this_directory
|
120
|
+
# @cmd << ' 2>&1' if @be_silent
|
121
|
+
esystem(@cmd)
|
122
|
+
# ======================================================================= #
|
123
|
+
# Next, we will apply a mv-action if we repackage to another name.
|
124
|
+
# ======================================================================= #
|
125
|
+
if rename?
|
126
|
+
new_name = File.basename(archive?).gsub(/\.tar\.xz$/, '')+'-'+today?+'.tar.xz'
|
127
|
+
opn; e 'Next renaming the archive to `'+sfancy(new_name)+'`.'
|
128
|
+
mv(archive?, new_name)
|
129
|
+
end
|
130
|
+
$stdout = $orig_stdout if @be_silent # Restore stdout again.
|
131
|
+
end
|
132
|
+
|
133
|
+
# ========================================================================= #
|
134
|
+
# === mv
|
135
|
+
# ========================================================================= #
|
136
|
+
def mv(old, new)
|
137
|
+
FileUtils.mv(old, new)
|
138
|
+
end
|
139
|
+
|
140
|
+
# ========================================================================= #
|
141
|
+
# === today?
|
142
|
+
# ========================================================================= #
|
143
|
+
def today?
|
144
|
+
Time.now.strftime '%d.%m.%Y'
|
145
|
+
end
|
146
|
+
|
147
|
+
# ========================================================================= #
|
148
|
+
# === archive?
|
149
|
+
# ========================================================================= #
|
150
|
+
def archive?
|
151
|
+
@archive_filename
|
152
|
+
end
|
153
|
+
|
154
|
+
# ========================================================================= #
|
155
|
+
# === run
|
156
|
+
# ========================================================================= #
|
157
|
+
def run
|
158
|
+
create_tarxz_package
|
159
|
+
end
|
160
|
+
|
161
|
+
# ========================================================================= #
|
162
|
+
# === ToTarXz[]
|
163
|
+
# ========================================================================= #
|
164
|
+
def self.[](i)
|
165
|
+
ToTarXz.new(i)
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
if __FILE__ == $PROGRAM_NAME
|
171
|
+
if ARGV[1]
|
172
|
+
if ARGV[1].include?('TODAY') or ARGV[1].include?('DATE') # Handle TODAY and DATE differently.
|
173
|
+
ToTarXz.new(ARGV.first, ARGV[1])
|
174
|
+
end
|
175
|
+
else
|
176
|
+
ARGV.each {|entry| ToTarXz.new(entry) }
|
177
|
+
end
|
178
|
+
end # tottarxz GEAS TODAY
|
data/lib/totarxz.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'totarxz/totarxz.rb'
|
data/totarxz.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# Gemspec for Project Totarxz.
|
3
|
+
# =========================================================================== #
|
4
|
+
Gem::Specification.new { |s|
|
5
|
+
|
6
|
+
s.name = 'totarxz'
|
7
|
+
s.version = '0.0.6'
|
8
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
9
|
+
|
10
|
+
s.summary = <<-EOF
|
11
|
+
|
12
|
+
If you have specific suggestions to make this gem more
|
13
|
+
useful for others, please drop me an email at:
|
14
|
+
|
15
|
+
shevegen@gmail.com
|
16
|
+
|
17
|
+
Thank you.
|
18
|
+
|
19
|
+
EOF
|
20
|
+
|
21
|
+
s.description = <<-EOF
|
22
|
+
|
23
|
+
This library is called totarxz.
|
24
|
+
|
25
|
+
EOF
|
26
|
+
|
27
|
+
s.extra_rdoc_files = %w()
|
28
|
+
|
29
|
+
s.authors = ['Robert A. Heiler']
|
30
|
+
s.email = 'shevegen@gmail.com'
|
31
|
+
s.files = Dir['**/*']
|
32
|
+
# s.files << 'README.md'
|
33
|
+
# s.files << 'USAGE.md'
|
34
|
+
s.license = 'GPL 2'
|
35
|
+
s.required_ruby_version = '>= 2.2.3'
|
36
|
+
s.homepage = 'https://github.com/shevegen/totarxz'
|
37
|
+
|
38
|
+
s.rubygems_version = '2.4.8'
|
39
|
+
|
40
|
+
# Dependencies for the project:
|
41
|
+
s.add_dependency 'alias_e'
|
42
|
+
s.add_dependency 'opn'
|
43
|
+
s.add_dependency 'esystem'
|
44
|
+
s.add_dependency 'colour_aid'
|
45
|
+
|
46
|
+
}
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: totarxz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert A. Heiler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: alias_e
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: esystem
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colour_aid
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: |2+
|
70
|
+
|
71
|
+
This library is called totarxz.
|
72
|
+
|
73
|
+
email: shevegen@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- lib/totarxz.rb
|
79
|
+
- lib/totarxz/totarxz.rb
|
80
|
+
- totarxz.gemspec
|
81
|
+
homepage: https://github.com/shevegen/totarxz
|
82
|
+
licenses:
|
83
|
+
- GPL 2
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.2.3
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.4.8
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: 'If you have specific suggestions to make this gem more useful for others,
|
105
|
+
please drop me an email at: shevegen@gmail.com Thank you.'
|
106
|
+
test_files: []
|