extracter 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of extracter might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +79 -0
- data/USAGE.md +22 -0
- data/bin/extract +7 -0
- data/bin/extract_it +15 -0
- data/doc/README.gen +62 -0
- data/extracter.gemspec +111 -0
- data/lib/extracter/class_methods.rb +143 -0
- data/lib/extracter/colours.rb +126 -0
- data/lib/extracter/constants/constants.rb +97 -0
- data/lib/extracter/do_extract_what_to.rb +290 -0
- data/lib/extracter/extract_it/extract_it.rb +236 -0
- data/lib/extracter/extracter.rb +66 -0
- data/lib/extracter/help.rb +34 -0
- data/lib/extracter/initialize.rb +90 -0
- data/lib/extracter/misc.rb +430 -0
- data/lib/extracter/opn.rb +47 -0
- data/lib/extracter/reset.rb +66 -0
- data/lib/extracter/version/version.rb +18 -0
- data/lib/extracter.rb +6 -0
- data/test/testing_class_extracter.rb +24 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '08cb29351e0a11e0572ce5113de128ee7106bb78a9ec53ea0b5f48964b810d97'
|
4
|
+
data.tar.gz: 9aeee95c0f46885d5fc407568b25bf52b69da00de0c8f59fbfb0c47ec1c7b2a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb79fc46f6c26ca7ca8ae073ab9069ea3a7bf4d2062cf3d832248641549d9236a6088b7231d9956d9ca8e3da499d598f5ebdc100fcbd07bc61326bcbdc3d7eff
|
7
|
+
data.tar.gz: da3a14d78de711eb0154a5020845897c30a8879ca27d8edf96e25bc49cf26e0b3f54a9556101a664e5b27f100f7bb042982954bb4cc4f7c44a7260f5317fec29
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
|
2
|
+
[![forthebadge](http://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/extracter.svg)](https://badge.fury.io/rb/extracter)
|
4
|
+
|
5
|
+
# Extracter
|
6
|
+
|
7
|
+
## Scope of Extracter
|
8
|
+
|
9
|
+
The scope (and goals) for **class Extracter** are really simple: throw any archive
|
10
|
+
format at it, and the class will try to **extract** it.
|
11
|
+
|
12
|
+
It can be used on the commandline as well.
|
13
|
+
|
14
|
+
## How to find out whether a given file is a valid archive
|
15
|
+
|
16
|
+
You can find out whether given input xyz is a valid archive by issuing
|
17
|
+
the following toplevel-method:
|
18
|
+
|
19
|
+
Extracter.is_this_a_valid_archive?(path)
|
20
|
+
|
21
|
+
This will return either true or false.
|
22
|
+
|
23
|
+
## How to extract an archive through class Extracter, in pure ruby
|
24
|
+
|
25
|
+
You can use the following method to extract an archive, into a specific
|
26
|
+
target location:
|
27
|
+
|
28
|
+
Extracter.extract_what_to('foo-1.0.tar.xz', '/tmp')
|
29
|
+
|
30
|
+
The first argument is the local path to an archive. The second
|
31
|
+
argument specifies the **target**, usually the target directory.
|
32
|
+
|
33
|
+
## Colour support
|
34
|
+
|
35
|
+
If the **Colours** gem (**gem install colours**) is available then colour
|
36
|
+
support is possible for **class Extracter**. For the class, the instance
|
37
|
+
variable **@use_colours** determines this. If you do not want to have
|
38
|
+
colours then you can disable this, e. g. through the method call
|
39
|
+
**.disable_colours** to give one example for doing so.
|
40
|
+
|
41
|
+
## What archives and files can be extracted?
|
42
|
+
|
43
|
+
class Extracter can extract .tar.xz, .tar.bz, .tar.gz, tar.Z,
|
44
|
+
.zip and numerous more file formats. This requires that tools such
|
45
|
+
as **tar** or **gzip** or **xz** are installed and available on the
|
46
|
+
target computer-machine.
|
47
|
+
|
48
|
+
It can also extract audio-files if ffmpeg is installed and the
|
49
|
+
multimedia_paradise project is available (**gem install multimedia_paradise**),
|
50
|
+
as well as squashfs files (typically .img files). In the latter case,
|
51
|
+
such an .img file will be mounted in the current directory.
|
52
|
+
|
53
|
+
Support for extracting .jar files has been added in **May 2020**.
|
54
|
+
|
55
|
+
## class Extracter::ExtractIt
|
56
|
+
|
57
|
+
class Extracter::ExtractIt was a standalone .gem (named **extract_it**),
|
58
|
+
but since as of September 2020 it is now part of "module Extracter".
|
59
|
+
|
60
|
+
Basically this class is is a wrapper over the class Extracter,
|
61
|
+
which will extract archives in general. The extraction step
|
62
|
+
will go into the current working directory.
|
63
|
+
|
64
|
+
|
65
|
+
## Contact information
|
66
|
+
|
67
|
+
If your creative mind has ideas and specific suggestions to make this
|
68
|
+
gem more useful in general, feel free to drop me an email at any
|
69
|
+
time, via:
|
70
|
+
|
71
|
+
shevegen@gmail.com
|
72
|
+
|
73
|
+
(Do keep in mind that responding to emails may take some time, depending
|
74
|
+
on the amount of work I may have at that moment, due to reallife. I will,
|
75
|
+
however had, read feedback. Patches and code changes are welcome too
|
76
|
+
of course, as long as they are in the spirit of the project at
|
77
|
+
hand, e. g. fitting to the general theme.)
|
78
|
+
|
79
|
+
Thank you.
|
data/USAGE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
= Usage of Library
|
2
|
+
|
3
|
+
== Requiring it
|
4
|
+
|
5
|
+
require 'extracter'
|
6
|
+
|
7
|
+
== Using it in a project
|
8
|
+
|
9
|
+
_ = Extracter.extract_what_to('foobar-1.0.tar.bz2', '/tmp/')
|
10
|
+
|
11
|
+
# You can also use the .new variant, which goes
|
12
|
+
# like so::
|
13
|
+
|
14
|
+
_ = Extracter.new('foo.gz', '/tmp', false) # Yes, you can extract .gz files.
|
15
|
+
_.run
|
16
|
+
|
17
|
+
# The argument false means "do not yet run". You have to
|
18
|
+
# invoke the .run method in that case.
|
19
|
+
|
20
|
+
# The second argument to the above method is the target
|
21
|
+
# location, the directory where we will extract our
|
22
|
+
# archive to.
|
data/bin/extract
ADDED
data/bin/extract_it
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
require 'extracter/extract_it/extract_it.rb'
|
6
|
+
|
7
|
+
if __FILE__ == $PROGRAM_NAME
|
8
|
+
_ = Extracter::ExtractIt.new(ARGV, false)
|
9
|
+
if ARGV[1]
|
10
|
+
_.show_commands_used
|
11
|
+
else
|
12
|
+
_.be_silent
|
13
|
+
end
|
14
|
+
_.run
|
15
|
+
end # extractit
|
data/doc/README.gen
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
ADD_RUBY_BADGE
|
2
|
+
|
3
|
+
# Extracter
|
4
|
+
|
5
|
+
## Scope of Extracter
|
6
|
+
|
7
|
+
The scope (and goals) for **class Extracter** are really simple: throw any archive
|
8
|
+
format at it, and the class will try to **extract** it.
|
9
|
+
|
10
|
+
It can be used on the commandline as well.
|
11
|
+
|
12
|
+
## How to find out whether a given file is a valid archive
|
13
|
+
|
14
|
+
You can find out whether given input xyz is a valid archive by issuing
|
15
|
+
the following toplevel-method:
|
16
|
+
|
17
|
+
Extracter.is_this_a_valid_archive?(path)
|
18
|
+
|
19
|
+
This will return either true or false.
|
20
|
+
|
21
|
+
## How to extract an archive through class Extracter, in pure ruby
|
22
|
+
|
23
|
+
You can use the following method to extract an archive, into a specific
|
24
|
+
target location:
|
25
|
+
|
26
|
+
Extracter.extract_what_to('foo-1.0.tar.xz', '/tmp')
|
27
|
+
|
28
|
+
The first argument is the local path to an archive. The second
|
29
|
+
argument specifies the **target**, usually the target directory.
|
30
|
+
|
31
|
+
## Colour support
|
32
|
+
|
33
|
+
If the **Colours** gem (**gem install colours**) is available then colour
|
34
|
+
support is possible for **class Extracter**. For the class, the instance
|
35
|
+
variable **@use_colours** determines this. If you do not want to have
|
36
|
+
colours then you can disable this, e. g. through the method call
|
37
|
+
**.disable_colours** to give one example for doing so.
|
38
|
+
|
39
|
+
## What archives and files can be extracted?
|
40
|
+
|
41
|
+
class Extracter can extract .tar.xz, .tar.bz, .tar.gz, tar.Z,
|
42
|
+
.zip and numerous more file formats. This requires that tools such
|
43
|
+
as **tar** or **gzip** or **xz** are installed and available on the
|
44
|
+
target computer-machine.
|
45
|
+
|
46
|
+
It can also extract audio-files if ffmpeg is installed and the
|
47
|
+
multimedia_paradise project is available (**gem install multimedia_paradise**),
|
48
|
+
as well as squashfs files (typically .img files). In the latter case,
|
49
|
+
such an .img file will be mounted in the current directory.
|
50
|
+
|
51
|
+
Support for extracting .jar files has been added in **May 2020**.
|
52
|
+
|
53
|
+
## class Extracter::ExtractIt
|
54
|
+
|
55
|
+
class Extracter::ExtractIt was a standalone .gem (named **extract_it**),
|
56
|
+
but since as of September 2020 it is now part of "module Extracter".
|
57
|
+
|
58
|
+
Basically this class is is a wrapper over the class Extracter,
|
59
|
+
which will extract archives in general. The extraction step
|
60
|
+
will go into the current working directory.
|
61
|
+
|
62
|
+
ADD_CONTACT_INFORMATION
|
data/extracter.gemspec
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# Gemspec for Project Extracter.
|
3
|
+
# =========================================================================== #
|
4
|
+
require 'extracter/version/version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new { |s|
|
7
|
+
|
8
|
+
s.name = 'extracter'
|
9
|
+
s.version = Extracter::Extracter::VERSION
|
10
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
11
|
+
|
12
|
+
DESCRIPTION = <<-EOF
|
13
|
+
|
14
|
+
This fairly small class/library can be used to extract different archive
|
15
|
+
formats such as .tar.bz2 or .tbz - archives such as .gem and .lzma
|
16
|
+
will also work.
|
17
|
+
|
18
|
+
You can also extract audio, by making use of class ExtractAudio. The
|
19
|
+
latter is - and should be - optional though.
|
20
|
+
|
21
|
+
Usage example:
|
22
|
+
|
23
|
+
require 'extracter'
|
24
|
+
|
25
|
+
Extracter.new('/foo/bla-1.0.tar.bz2')
|
26
|
+
|
27
|
+
The second argument that can be passed to the method new()
|
28
|
+
specifies where we should extract to, example:
|
29
|
+
|
30
|
+
Extracter.new('/foo/bla-1.0.tar.bz2', '/opt')
|
31
|
+
|
32
|
+
This would extract to the /opt directory.
|
33
|
+
|
34
|
+
You can query whether input is an archive or not via:
|
35
|
+
|
36
|
+
Extracter.is_archive? 'foo.tar.xz'
|
37
|
+
|
38
|
+
As of April 2014 we also provide a bin/extract file, so that
|
39
|
+
you can simply extract something from the commandline.
|
40
|
+
|
41
|
+
Since as of November 2018, class Extracter can also "extract"
|
42
|
+
.iso files. (The .iso will be mounted to a directory that
|
43
|
+
will be created, actually.)
|
44
|
+
|
45
|
+
If you have a specific suggestion to make this gem more useful
|
46
|
+
for others, please drop me an email at:
|
47
|
+
|
48
|
+
shevegen@gmail.com
|
49
|
+
|
50
|
+
Thank you.
|
51
|
+
|
52
|
+
EOF
|
53
|
+
|
54
|
+
s.summary = DESCRIPTION
|
55
|
+
s.description = DESCRIPTION
|
56
|
+
|
57
|
+
s.authors = ['Robert A. Heiler']
|
58
|
+
s.email = 'shevegen@gmail.com'
|
59
|
+
s.files = Dir['**/*']
|
60
|
+
s.files << 'USAGE.md'
|
61
|
+
s.licenses = 'GPL-2.0'
|
62
|
+
s.homepage = 'http://rubygems.org/gems/extracter'
|
63
|
+
|
64
|
+
# ========================================================================= #
|
65
|
+
# Show this when a user installs the DiamondShell.
|
66
|
+
# ========================================================================= #
|
67
|
+
s.post_install_message = <<-EOF
|
68
|
+
|
69
|
+
class Extracter can be used to extract archives, such as .tar.gz or
|
70
|
+
.zip.
|
71
|
+
|
72
|
+
If you need some help, you can invoke bin/extract via:
|
73
|
+
|
74
|
+
extract --help
|
75
|
+
|
76
|
+
In general, the syntax for extract is kept simple. Just pass in the
|
77
|
+
archive that has to be extracted as the first argument to
|
78
|
+
extract ( bin/extract) , and class Extracter will try to extract
|
79
|
+
it, if it is a registered archive format.
|
80
|
+
|
81
|
+
In ruby code, you may be able to use class Extracter in this manner:
|
82
|
+
|
83
|
+
require 'extracter'
|
84
|
+
Extracter[file_path_here]
|
85
|
+
|
86
|
+
or
|
87
|
+
|
88
|
+
require 'extracter'
|
89
|
+
Extracter.new(file_path_here)
|
90
|
+
|
91
|
+
Specific example:
|
92
|
+
|
93
|
+
require 'extracter'
|
94
|
+
Extracter.new('htop-2.2.0.tar.xz')
|
95
|
+
|
96
|
+
See the --help option.
|
97
|
+
|
98
|
+
EOF
|
99
|
+
|
100
|
+
s.required_ruby_version = '>= '+RUBY_VERSION
|
101
|
+
s.required_rubygems_version = '>= '+Gem::VERSION
|
102
|
+
s.rubygems_version = '>= '+Gem::VERSION
|
103
|
+
|
104
|
+
# ========================================================================= #
|
105
|
+
# Specify the dependencies for this gem:
|
106
|
+
# ========================================================================= #
|
107
|
+
s.add_dependency 'colours'
|
108
|
+
s.add_dependency 'opn'
|
109
|
+
s.add_dependency 'remove_file_suffix'
|
110
|
+
|
111
|
+
}
|
@@ -0,0 +1,143 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
module Extracter
|
6
|
+
|
7
|
+
class Extracter
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === Extracter::Extracter.is_this_a_valid_archive?
|
11
|
+
#
|
12
|
+
# Query whether the input is a valid archive.
|
13
|
+
#
|
14
|
+
# The registered formats are stored in the constant
|
15
|
+
# ARRAY_REGISTERED_ARCHIVES.
|
16
|
+
# ========================================================================= #
|
17
|
+
def self.is_this_a_valid_archive?(i)
|
18
|
+
return_value = false
|
19
|
+
ARRAY_REGISTERED_ARCHIVES.each {|entry|
|
20
|
+
return_value = true if i =~ /#{entry}$/
|
21
|
+
}
|
22
|
+
return return_value
|
23
|
+
end; self.instance_eval { alias is_archive? is_this_a_valid_archive? } # === Extracter.is_archive?
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === Extracter.extract_what_to
|
27
|
+
#
|
28
|
+
# This method provides a convenient API to extract something to a
|
29
|
+
# specified directory, as a class method. It defaults to the
|
30
|
+
# current working directory, as that is by far the most convenient
|
31
|
+
# way to extract a source tarball/archive.
|
32
|
+
#
|
33
|
+
# Useage example goes like this:
|
34
|
+
#
|
35
|
+
# Extracter.extract_what_to('foo-1.0.tar.xz', '/tmp')
|
36
|
+
#
|
37
|
+
# ========================================================================= #
|
38
|
+
def self.extract_what_to(
|
39
|
+
what,
|
40
|
+
to = Dir.pwd, # <- This can also be a Hash.
|
41
|
+
optional_be_silent = false
|
42
|
+
)
|
43
|
+
_ = Extracter.new(what, to, :do_not_run_yet)
|
44
|
+
if to.is_a? Hash
|
45
|
+
# ===================================================================== #
|
46
|
+
# === :prepend_this_namespace
|
47
|
+
# ===================================================================== #
|
48
|
+
if to.has_key? :prepend_this_namespace
|
49
|
+
prefix_with_this = to.delete(:prepend_this_namespace) # Get rid of it from the Hash as well.
|
50
|
+
_.prefix_namespace_with(
|
51
|
+
prefix_with_this
|
52
|
+
)
|
53
|
+
end
|
54
|
+
# ===================================================================== #
|
55
|
+
# === :to
|
56
|
+
# ===================================================================== #
|
57
|
+
if to.has_key? :to
|
58
|
+
to = to.delete(:to)
|
59
|
+
end
|
60
|
+
# ===================================================================== #
|
61
|
+
# === :verbosity
|
62
|
+
#
|
63
|
+
# Handle how verbose we shall be.
|
64
|
+
# ===================================================================== #
|
65
|
+
if to.has_key? :verbosity
|
66
|
+
_.set_verbosity(
|
67
|
+
to.delete(:verbosity)
|
68
|
+
)
|
69
|
+
end
|
70
|
+
# ===================================================================== #
|
71
|
+
# === :use_colours
|
72
|
+
# ===================================================================== #
|
73
|
+
if to.has_key? :use_colours
|
74
|
+
_.set_use_colours(to[:use_colours])
|
75
|
+
end
|
76
|
+
# ===================================================================== #
|
77
|
+
# === :pad_opn_with_n_tokens
|
78
|
+
# ===================================================================== #
|
79
|
+
if to.has_key? :pad_opn_with_n_tokens
|
80
|
+
_.set_pad_opn_with_n_tokens(to[:pad_opn_with_n_tokens])
|
81
|
+
end
|
82
|
+
# ===================================================================== #
|
83
|
+
# === :use_opn
|
84
|
+
# ===================================================================== #
|
85
|
+
if to.has_key? :use_opn
|
86
|
+
_.set_use_opn(to[:use_opn])
|
87
|
+
end
|
88
|
+
end
|
89
|
+
if optional_be_silent
|
90
|
+
_.be_silent
|
91
|
+
else
|
92
|
+
_.be_verbose
|
93
|
+
end
|
94
|
+
# ======================================================================= #
|
95
|
+
# === Handle blocks next
|
96
|
+
# ======================================================================= #
|
97
|
+
if block_given?
|
98
|
+
yielded = yield
|
99
|
+
case yielded
|
100
|
+
when :show_the_full_name_of_the_archive
|
101
|
+
_.do_show_the_full_name_of_the_archive
|
102
|
+
end
|
103
|
+
end
|
104
|
+
_.run
|
105
|
+
end; self.instance_eval { alias extract_this extract_what_to } # === Extracter.extract_this
|
106
|
+
self.instance_eval { alias what_to extract_what_to } # === Extracter.what_to
|
107
|
+
self.instance_eval { alias extract extract_what_to } # === Extracter.extract
|
108
|
+
|
109
|
+
# ========================================================================= #
|
110
|
+
# === Extracter::Extracter[]
|
111
|
+
# ========================================================================= #
|
112
|
+
def self.[](i, where_to = Dir.pwd)
|
113
|
+
new(i, where_to)
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
# =========================================================================== #
|
119
|
+
# === Extracter.is_this_a_valid_archive?
|
120
|
+
# =========================================================================== #
|
121
|
+
def self.is_this_a_valid_archive?(i)
|
122
|
+
::Extracter::Extracter.is_this_a_valid_archive?(i)
|
123
|
+
end
|
124
|
+
|
125
|
+
# =========================================================================== #
|
126
|
+
# === Extracter.extract_what_to
|
127
|
+
# =========================================================================== #
|
128
|
+
def self.extract_what_to(
|
129
|
+
what = 'foo-1.0.tar.xz',
|
130
|
+
to = '/tmp',
|
131
|
+
optional_be_silent = false
|
132
|
+
)
|
133
|
+
::Extracter.extract_what_to(what, to, optional_be_silent)
|
134
|
+
end
|
135
|
+
|
136
|
+
# =========================================================================== #
|
137
|
+
# === Extracter[]
|
138
|
+
# =========================================================================== #
|
139
|
+
def self.[](i, where_to = Dir.pwd)
|
140
|
+
::Extracter::Extracter.new(i, where_to)
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
module Extracter
|
6
|
+
|
7
|
+
class Extracter
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'colours'
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === use_colours?
|
15
|
+
#
|
16
|
+
# Determine whether we will use colours in class Extracter.
|
17
|
+
# ========================================================================= #
|
18
|
+
def use_colours?
|
19
|
+
@use_colours
|
20
|
+
end
|
21
|
+
|
22
|
+
# ========================================================================= #
|
23
|
+
# === set_use_colours
|
24
|
+
# ========================================================================= #
|
25
|
+
def set_use_colours(i)
|
26
|
+
# ======================================================================= #
|
27
|
+
# We must also sync this towards our main Hash, for opn(). The next
|
28
|
+
# line of code achieves precisely that.
|
29
|
+
# ======================================================================= #
|
30
|
+
@use_this_opn_hash.update(use_colours: i)
|
31
|
+
@use_colours = i
|
32
|
+
end
|
33
|
+
|
34
|
+
# ========================================================================= #
|
35
|
+
# === disable_colours
|
36
|
+
#
|
37
|
+
# Use this method if you want to disable colour-support of this class.
|
38
|
+
# ========================================================================= #
|
39
|
+
def disable_colours
|
40
|
+
@use_colours = false
|
41
|
+
@colour_to_use_for_directories = ''.dup
|
42
|
+
end
|
43
|
+
|
44
|
+
# ========================================================================= #
|
45
|
+
# === enable_colours
|
46
|
+
# ========================================================================= #
|
47
|
+
def enable_colours
|
48
|
+
@use_colours = true
|
49
|
+
@colour_to_use_for_directories = cyan?
|
50
|
+
end
|
51
|
+
|
52
|
+
# ========================================================================= #
|
53
|
+
# === set_colour_for_directories
|
54
|
+
#
|
55
|
+
# Set the colour for directories to use.
|
56
|
+
# ========================================================================= #
|
57
|
+
def set_colour_for_directories(i)
|
58
|
+
@colour_to_use_for_directories = Colours.beautify(i)
|
59
|
+
end
|
60
|
+
|
61
|
+
# ========================================================================= #
|
62
|
+
# === colour_to_use_for_directories?
|
63
|
+
# ========================================================================= #
|
64
|
+
def colour_to_use_for_directories?
|
65
|
+
if @use_colours
|
66
|
+
@colour_to_use_for_directories
|
67
|
+
else
|
68
|
+
''
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# ========================================================================= #
|
73
|
+
# === cyan
|
74
|
+
# ========================================================================= #
|
75
|
+
def cyan?
|
76
|
+
if @use_colours
|
77
|
+
Colours::CYAN
|
78
|
+
else
|
79
|
+
''
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# ========================================================================= #
|
84
|
+
# === ewarn
|
85
|
+
# ========================================================================= #
|
86
|
+
def ewarn(i = '')
|
87
|
+
if use_colours?
|
88
|
+
e Colours.swarn(i)
|
89
|
+
else
|
90
|
+
e i
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# ========================================================================= #
|
95
|
+
# === simp
|
96
|
+
# ========================================================================= #
|
97
|
+
def simp(i = '')
|
98
|
+
return Colours.simp(i) if @use_colours
|
99
|
+
return i
|
100
|
+
end
|
101
|
+
|
102
|
+
# ========================================================================= #
|
103
|
+
# === sfile
|
104
|
+
# ========================================================================= #
|
105
|
+
def sfile(i = '')
|
106
|
+
return Colours.sfancy(i) if @use_colours
|
107
|
+
return i
|
108
|
+
end
|
109
|
+
|
110
|
+
# ========================================================================= #
|
111
|
+
# === sfancy
|
112
|
+
# ========================================================================= #
|
113
|
+
def sfancy(i = '')
|
114
|
+
return Colours.sfancy(i) if @use_colours
|
115
|
+
return i
|
116
|
+
end
|
117
|
+
|
118
|
+
# ========================================================================= #
|
119
|
+
# === sdir
|
120
|
+
# ========================================================================= #
|
121
|
+
def sdir(i = '')
|
122
|
+
return Colours.sdir(i) if @use_colours
|
123
|
+
return i
|
124
|
+
end
|
125
|
+
|
126
|
+
end; end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
module Extracter
|
6
|
+
|
7
|
+
class Extracter
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === NAMESPACE
|
11
|
+
# ========================================================================= #
|
12
|
+
NAMESPACE = inspect
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === N
|
16
|
+
# ========================================================================= #
|
17
|
+
N = "\n"
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === LAST_UPDATED
|
21
|
+
#
|
22
|
+
# When this class was last updated/releasted. This is not a hugely
|
23
|
+
# important constat, so do not worry too much if this may be
|
24
|
+
# heavily outdated eventually.
|
25
|
+
# ========================================================================= #
|
26
|
+
LAST_UPDATED = '14 Jun 2020'
|
27
|
+
|
28
|
+
# ========================================================================= #
|
29
|
+
# === TEMP_DIR
|
30
|
+
#
|
31
|
+
# Set the temp dir here.
|
32
|
+
# ========================================================================= #
|
33
|
+
if ENV['MY_TEMP']
|
34
|
+
TEMP_DIR = ENV['MY_TEMP'].to_s+'/'
|
35
|
+
else
|
36
|
+
# ======================================================================= #
|
37
|
+
# If this environment variable is unavailable then use a conservative
|
38
|
+
# default value.
|
39
|
+
# ======================================================================= #
|
40
|
+
TEMP_DIR = '/tmp/'
|
41
|
+
end
|
42
|
+
|
43
|
+
# ========================================================================= #
|
44
|
+
# === SHOW_ONLY_THE_SHORT_NAME_OF_THE_ARCHIVE
|
45
|
+
#
|
46
|
+
# If this constant is set to true then we will only show the shortened
|
47
|
+
# name of the archive in question by default.
|
48
|
+
# ========================================================================= #
|
49
|
+
SHOW_ONLY_THE_SHORT_NAME_OF_THE_ARCHIVE = true
|
50
|
+
|
51
|
+
# ========================================================================= #
|
52
|
+
# === GEM_UNPACK_COMMAND
|
53
|
+
#
|
54
|
+
# The command to use to unpack ruby .gems.
|
55
|
+
# We can pass the ---target=DIR syntax to extract to a specific location.
|
56
|
+
# ========================================================================= #
|
57
|
+
GEM_UNPACK_COMMAND = 'gem unpack'
|
58
|
+
|
59
|
+
# ========================================================================= #
|
60
|
+
# === ARRAY_REGISTERED_ARCHIVES
|
61
|
+
#
|
62
|
+
# Archives that can be extracted, have to be registered in this Array.
|
63
|
+
#
|
64
|
+
# Sort alphabetically.
|
65
|
+
#
|
66
|
+
# The libreoffice format .odt is just like .zip.
|
67
|
+
# ========================================================================= #
|
68
|
+
ARRAY_REGISTERED_ARCHIVES = %w(
|
69
|
+
7z
|
70
|
+
bin
|
71
|
+
bz2
|
72
|
+
deb
|
73
|
+
gem
|
74
|
+
gz
|
75
|
+
img
|
76
|
+
iso
|
77
|
+
jar
|
78
|
+
lz
|
79
|
+
lzma
|
80
|
+
odt
|
81
|
+
mp4
|
82
|
+
rar
|
83
|
+
rpm
|
84
|
+
squashfs
|
85
|
+
sxz
|
86
|
+
tar
|
87
|
+
taz
|
88
|
+
tgz
|
89
|
+
txz
|
90
|
+
xpi
|
91
|
+
xz
|
92
|
+
zip
|
93
|
+
Z
|
94
|
+
zst
|
95
|
+
)
|
96
|
+
|
97
|
+
end; end
|