extracter 1.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e45b6d80b96923bfd8bd5e73c3f6e65ad98e4346eabadfca63a24b74dbedf1fa
4
+ data.tar.gz: dc7b8883262c5f605eba796f10b9bb3956a66d0889d59140ce6ce02f318f922b
5
+ SHA512:
6
+ metadata.gz: 726275b6eb718a9fcb8f8c1f1a03f9358cfbdfe1b3074e5bfecd5dba77dc9bb712ed6574f6f18fb8e87802e5c8fbb5d75b4679bfbbddb44425c1aebe41dee82b
7
+ data.tar.gz: dec795cfdff6ad71a6352537d775ad0fe4d4ef8f03567c869bb26f45a8de368f6c99632763e49df153e6c8787008b095e1c8b4408f308bbcb3735d14b86f1077
data/README.md ADDED
@@ -0,0 +1,210 @@
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/extracter.svg)](https://badge.fury.io/rb/extracter)
4
+
5
+ # Extracter
6
+
7
+ ## The primary goal of the extracter gem
8
+
9
+ This gem can help the user if said user wants to **extract a given
10
+ archive**.
11
+
12
+ ## Scope of Extracter
13
+
14
+ The scope (and goals) for **class Extracter** are really simple: throw
15
+ any archive format at it, and the class will try to **extract** it.
16
+
17
+ It can be used on the commandline as well, via **bin/extracter**.
18
+
19
+ Note that in order to extract a given archive, some programs must
20
+ be available still. On linux this tends to be **tar**, **bzip2**,
21
+ **xz** and **gzip**. On windows it is recommended to use **7-zip**.
22
+
23
+ ## How to find out whether a given file is a valid archive
24
+
25
+ You can find out whether a given input **xyz** is a valid archive by
26
+ issuing the following toplevel-method:
27
+
28
+ Extracter.is_this_a_valid_archive?(path)
29
+
30
+ This will return either true or false. In <b>August 2022</b> the
31
+ code was adapted slightly to return true no matter if the
32
+ file extension is upcased or lowercased. In other words: a
33
+ file called <b>foobar.zip</b> will work fine, as will the same
34
+ file but this time called <b>foobar.ZIP</b>. I had the latter issue
35
+ when I downloaded a BIOS Firmware update in August 2022 - the
36
+ file was .ZIP and Extracter did not work. So that was a tiny
37
+ bug in the extracter gem - it really should work on .ZIP
38
+ files just fine as well, since these are simply .zip files
39
+ anyway.
40
+
41
+ Keep in mind that not all archive formats have been added so far,
42
+ so this will return false even if it should instead return true.
43
+
44
+ More support for archive formats will be added whenever possible,
45
+ as time permits.
46
+
47
+ ## How to extract an archive through class Extracter, in pure ruby
48
+
49
+ You can use the following method to extract an archive, in ruby,
50
+ into a specific target location on the given computer system:
51
+
52
+ Extracter.extract_what_to('foo-1.0.tar.xz', '/tmp')
53
+
54
+ The first argument is the local path to an archive. The second
55
+ argument simply specifies the **target**, usually the target
56
+ directory. Can't get any simpler than that!
57
+
58
+ ## Colour support
59
+
60
+ If the **Colours** gem (**gem install colours**) is available then colour
61
+ support is possible for **class Extracter::Extracter**.
62
+
63
+ For class Extracter::Extracter, whether colours are supported is
64
+ determined via the method called **.colours?**. If true then colours
65
+ will be used - at the least it will be tried.
66
+
67
+ If you do not want to have colours, for whatever the reason or use case,
68
+ then you can disable this, e. g. through the method call
69
+ **.disable_colours** specifically, to give one example for doing so.
70
+
71
+ ## class Extracter::ExtractIt
72
+
73
+ **class Extracter::ExtractIt** was a standalone .gem (named **extract_it**),
74
+ but since as of **September 2020** it is now part of "module Extracter".
75
+
76
+ Basically this class is is a wrapper over the class Extracter, which will
77
+ extract archives in general. The extraction step will go into the current
78
+ working directory.
79
+
80
+ ## What archives and files can be extracted?
81
+
82
+ **class Extracter** can extract .tar.xz, .tar.bz, .tar.gz, tar.Z,
83
+ .zip and numerous other file formats. This requires that tools
84
+ such as **tar** or **gzip** or **xz** are installed and available
85
+ on the target computer-machine, as we will simply use ruby to
86
+ shell out to these other programs. Ruby is the ultimate 'glue'
87
+ language after all.
88
+
89
+ This class can also **extract audio-files** if ffmpeg is installed and
90
+ the multimedia_paradise project is available (**gem install
91
+ multimedia_paradise**), as well as squashfs files (typically
92
+ .img files). In the latter case, such an .img file will be mounted
93
+ in the current directory. You could then simply copy the content,
94
+ to have a 'full' archive situation (mounting means read-only by
95
+ deafult in this regard, hence why the copy-operation has to be
96
+ done).
97
+
98
+ Support for extracting **.jar files** - used by Java - has been
99
+ added in **May 2020**.
100
+
101
+ Support for 'extracting' .pdf files has been added in **January 2021**.
102
+ This depends on **poppler**, and it is not really an extraction; we
103
+ simply convert the file to a .txt (text) file. For this functionality
104
+ the **pdf_paradise** project has to be available.
105
+
106
+ Support for extracting archives on windows via 7zip has been added
107
+ in **August 2021**. This was done because I had problems with 'tar'
108
+ on windows; using 7zip bypassed these problems, and I needed to
109
+ be able to extract archives on windows easily.
110
+
111
+ ## Usage example:
112
+
113
+ _ = Extracter.extract_what_to('foobar-1.0.tar.bz2', '/tmp/')
114
+
115
+ You can also use the .new variant, which goes like so::
116
+
117
+ _ = Extracter.new('foo.gz', '/tmp', false) # Yes, you can extract .gz files.
118
+ _.run
119
+
120
+ The argument false means "do not yet run". You have to invoke
121
+ the .run method in that case.
122
+
123
+ The second argument to the above method is the target location,
124
+ the directory where we will extract our archive to.
125
+
126
+ ## strip components
127
+
128
+ Say that we have a path such as **/home/x/htop/htop-3.0.5.tar.xz**. You
129
+ want to extract it, say, into **/tmp/**.
130
+
131
+ Normally this would create the following directory:
132
+
133
+ /tmp/htop-3.0.5/
134
+
135
+ In most cases this is what the user wants; at the least I expect this
136
+ if an archive is correctly tarred up, such as a **.tar.xz** file.
137
+
138
+ But there are use cases where this is not the case so. For instance,
139
+ say that you already did creat such a directory, cd-ed into it and
140
+ now just want to extract right **into** this directory. Then you
141
+ don't want to end up with:
142
+
143
+ /tmp/htop-3.0.5/htop-3.0.5/
144
+
145
+ **tar** allows us to avoid this, by using the commandline flag
146
+ called **--strip-components=1**.
147
+
148
+ In **October 2021** I needed this for the rbt-project. Since the
149
+ old class Extracter did not support it, and the code was very messy,
150
+ I ended up re-writing the project. It should now be better -
151
+ at the least cleaner than it once was. And support for the above
152
+ is possible as well now; even with a specific method call
153
+ (which is **.strip_components()**).
154
+
155
+ ## Extracter.remove_archive_type
156
+
157
+ If you have a use case where you would like to remove the file
158
+ suffix from an archive, such as turning
159
+ "https://rubygems.org/rubygems/rubygems-3.3.14.tgz" into
160
+ "rubygems-3.3.14" exactly, then you can use
161
+ Extracter.remove_archive_type() for this.
162
+
163
+ Example follows:
164
+
165
+ Extracter.remove_archive_type(File.basename("https://rubygems.org/rubygems/rubygems-3.3.14.tgz")) # => "rubygems-3.3.14"
166
+
167
+
168
+ ## Contact information and mandatory 2FA (no longer) coming up in 2022 / 2023
169
+
170
+ If your creative mind has ideas and specific suggestions to make this gem
171
+ more useful in general, feel free to drop me an email at any time, via:
172
+
173
+ shevy@inbox.lt
174
+
175
+ Before that email I used an email account at Google gmail, but in **2021** I
176
+ decided to slowly abandon gmail, for various reasons. In order to limit the
177
+ explanation here, allow me to just briefly state that I do not feel as if I
178
+ want to promote any Google service anymore when the user becomes the end
179
+ product (such as via data collection by upstream services, including other
180
+ proxy-services). My feeling is that this is a hugely flawed business model
181
+ to begin with, and I no longer wish to support this in any way, even if
182
+ only indirectly so, such as by using services of companies that try to
183
+ promote this flawed model.
184
+
185
+ In regards to responding to emails: please keep in mind that responding
186
+ may take some time, depending on the amount of work I may have at that
187
+ moment. So it is not that emails are ignored; it is more that I have not
188
+ (yet) found the time to read and reply. This means there may be a delay
189
+ of days, weeks and in some instances also months. There is, unfortunately,
190
+ not much I can do when I need to prioritise my time investment, but I try
191
+ to consider <b>all</b> feedback as an opportunity to improve my projects
192
+ nonetheless.
193
+
194
+ In <b>2022</b> rubygems.org decided to make 2FA mandatory for every
195
+ gem owner eventually:
196
+
197
+ see
198
+ https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
199
+
200
+ However had, that has been reverted again, so I decided to shorten
201
+ this paragraph. Mandatory 2FA may exclude users who do not have a
202
+ smartphone device or other means to 'identify'. I do not feel it is
203
+ a fair assumption by others to be made that non-identified people may
204
+ not contribute code, which is why I reject it. Mandatory 2FA would mean
205
+ an end to all my projects on rubygems.org, so let's hope it will never
206
+ happen. (Keep in mind that I refer to mandatory 2FA; I have no qualms
207
+ for people who use 2FA on their own, but this carrot-and-stick strategy
208
+ by those who control the rubygems infrastructure is a very bad one to
209
+ pursue.
210
+
data/bin/extract ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'extracter'
6
+
7
+ Extracter.what_to(ARGV, Dir.pwd)
data/bin/extract_it ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'extracter/requires/require_the_extracter_project.rb'
6
+
7
+ _ = Extracter.extract_it(ARGV, false)
8
+ if ARGV[1]
9
+ _.show_commands_used
10
+ else
11
+ _.be_silent
12
+ end
13
+ _.run # extractit
data/doc/README.gen ADDED
@@ -0,0 +1,165 @@
1
+ ADD_RUBY_BADGE
2
+
3
+ # Extracter
4
+
5
+ ## The primary goal of the extracter gem
6
+
7
+ This gem can help the user if said user wants to **extract a given
8
+ archive**.
9
+
10
+ ## Scope of Extracter
11
+
12
+ The scope (and goals) for **class Extracter** are really simple: throw
13
+ any archive format at it, and the class will try to **extract** it.
14
+
15
+ It can be used on the commandline as well, via **bin/extracter**.
16
+
17
+ Note that in order to extract a given archive, some programs must
18
+ be available still. On linux this tends to be **tar**, **bzip2**,
19
+ **xz** and **gzip**. On windows it is recommended to use **7-zip**.
20
+
21
+ ## How to find out whether a given file is a valid archive
22
+
23
+ You can find out whether a given input **xyz** is a valid archive by
24
+ issuing the following toplevel-method:
25
+
26
+ Extracter.is_this_a_valid_archive?(path)
27
+
28
+ This will return either true or false. In <b>August 2022</b> the
29
+ code was adapted slightly to return true no matter if the
30
+ file extension is upcased or lowercased. In other words: a
31
+ file called <b>foobar.zip</b> will work fine, as will the same
32
+ file but this time called <b>foobar.ZIP</b>. I had the latter issue
33
+ when I downloaded a BIOS Firmware update in August 2022 - the
34
+ file was .ZIP and Extracter did not work. So that was a tiny
35
+ bug in the extracter gem - it really should work on .ZIP
36
+ files just fine as well, since these are simply .zip files
37
+ anyway.
38
+
39
+ Keep in mind that not all archive formats have been added so far,
40
+ so this will return false even if it should instead return true.
41
+
42
+ More support for archive formats will be added whenever possible,
43
+ as time permits.
44
+
45
+ ## How to extract an archive through class Extracter, in pure ruby
46
+
47
+ You can use the following method to extract an archive, in ruby,
48
+ into a specific target location on the given computer system:
49
+
50
+ Extracter.extract_what_to('foo-1.0.tar.xz', '/tmp')
51
+
52
+ The first argument is the local path to an archive. The second
53
+ argument simply specifies the **target**, usually the target
54
+ directory. Can't get any simpler than that!
55
+
56
+ ## Colour support
57
+
58
+ If the **Colours** gem (**gem install colours**) is available then colour
59
+ support is possible for **class Extracter::Extracter**.
60
+
61
+ For class Extracter::Extracter, whether colours are supported is
62
+ determined via the method called **.colours?**. If true then colours
63
+ will be used - at the least it will be tried.
64
+
65
+ If you do not want to have colours, for whatever the reason or use case,
66
+ then you can disable this, e. g. through the method call
67
+ **.disable_colours** specifically, to give one example for doing so.
68
+
69
+ ## class Extracter::ExtractIt
70
+
71
+ **class Extracter::ExtractIt** was a standalone .gem (named **extract_it**),
72
+ but since as of **September 2020** it is now part of "module Extracter".
73
+
74
+ Basically this class is is a wrapper over the class Extracter, which will
75
+ extract archives in general. The extraction step will go into the current
76
+ working directory.
77
+
78
+ ## What archives and files can be extracted?
79
+
80
+ **class Extracter** can extract .tar.xz, .tar.bz, .tar.gz, tar.Z,
81
+ .zip and numerous other file formats. This requires that tools
82
+ such as **tar** or **gzip** or **xz** are installed and available
83
+ on the target computer-machine, as we will simply use ruby to
84
+ shell out to these other programs. Ruby is the ultimate 'glue'
85
+ language after all.
86
+
87
+ This class can also **extract audio-files** if ffmpeg is installed and
88
+ the multimedia_paradise project is available (**gem install
89
+ multimedia_paradise**), as well as squashfs files (typically
90
+ .img files). In the latter case, such an .img file will be mounted
91
+ in the current directory. You could then simply copy the content,
92
+ to have a 'full' archive situation (mounting means read-only by
93
+ deafult in this regard, hence why the copy-operation has to be
94
+ done).
95
+
96
+ Support for extracting **.jar files** - used by Java - has been
97
+ added in **May 2020**.
98
+
99
+ Support for 'extracting' .pdf files has been added in **January 2021**.
100
+ This depends on **poppler**, and it is not really an extraction; we
101
+ simply convert the file to a .txt (text) file. For this functionality
102
+ the **pdf_paradise** project has to be available.
103
+
104
+ Support for extracting archives on windows via 7zip has been added
105
+ in **August 2021**. This was done because I had problems with 'tar'
106
+ on windows; using 7zip bypassed these problems, and I needed to
107
+ be able to extract archives on windows easily.
108
+
109
+ ## Usage example:
110
+
111
+ _ = Extracter.extract_what_to('foobar-1.0.tar.bz2', '/tmp/')
112
+
113
+ You can also use the .new variant, which goes like so::
114
+
115
+ _ = Extracter.new('foo.gz', '/tmp', false) # Yes, you can extract .gz files.
116
+ _.run
117
+
118
+ The argument false means "do not yet run". You have to invoke
119
+ the .run method in that case.
120
+
121
+ The second argument to the above method is the target location,
122
+ the directory where we will extract our archive to.
123
+
124
+ ## strip components
125
+
126
+ Say that we have a path such as **/home/x/htop/htop-3.0.5.tar.xz**. You
127
+ want to extract it, say, into **/tmp/**.
128
+
129
+ Normally this would create the following directory:
130
+
131
+ /tmp/htop-3.0.5/
132
+
133
+ In most cases this is what the user wants; at the least I expect this
134
+ if an archive is correctly tarred up, such as a **.tar.xz** file.
135
+
136
+ But there are use cases where this is not the case so. For instance,
137
+ say that you already did creat such a directory, cd-ed into it and
138
+ now just want to extract right **into** this directory. Then you
139
+ don't want to end up with:
140
+
141
+ /tmp/htop-3.0.5/htop-3.0.5/
142
+
143
+ **tar** allows us to avoid this, by using the commandline flag
144
+ called **--strip-components=1**.
145
+
146
+ In **October 2021** I needed this for the rbt-project. Since the
147
+ old class Extracter did not support it, and the code was very messy,
148
+ I ended up re-writing the project. It should now be better -
149
+ at the least cleaner than it once was. And support for the above
150
+ is possible as well now; even with a specific method call
151
+ (which is **.strip_components()**).
152
+
153
+ ## Extracter.remove_archive_type
154
+
155
+ If you have a use case where you would like to remove the file
156
+ suffix from an archive, such as turning
157
+ "https://rubygems.org/rubygems/rubygems-3.3.14.tgz" into
158
+ "rubygems-3.3.14" exactly, then you can use
159
+ Extracter.remove_archive_type() for this.
160
+
161
+ Example follows:
162
+
163
+ Extracter.remove_archive_type(File.basename("https://rubygems.org/rubygems/rubygems-3.3.14.tgz")) # => "rubygems-3.3.14"
164
+
165
+ ADD_CONTACT_INFORMATION
data/extracter.gemspec ADDED
@@ -0,0 +1,109 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project Extracter.
3
+ # =========================================================================== #
4
+ require 'extracter/version/version.rb'
5
+ begin
6
+ # require 'roebe'
7
+ require 'roebe/toplevel_methods/misc.rb'
8
+ rescue LoadError; end
9
+
10
+ Gem::Specification.new { |s|
11
+
12
+ s.name = 'extracter'
13
+ s.version = Extracter::VERSION
14
+ s.date = Time.now.strftime('%Y-%m-%d')
15
+
16
+ DESCRIPTION = <<-EOF
17
+
18
+ This fairly small project can be used to extract different
19
+ archive formats such as .tar.bz2 or .tbz - archives such
20
+ as .gem and .lzma will also work.
21
+
22
+ You can also extract audio, by making use of class ExtractAudio
23
+ (part of the multimedia_paradise gem. The latter is - and should
24
+ be - optional, though. If you have no such use case then you
25
+ won't need to install the multimedia_paradise gem.
26
+
27
+ Usage example:
28
+
29
+ require 'extracter'
30
+
31
+ Extracter.new('/foo/bla-1.0.tar.bz2')
32
+
33
+ The second argument that can be passed to the method new()
34
+ specifies where this should be extract to.
35
+
36
+ For example:
37
+
38
+ Extracter.new('/foo/bla-1.0.tar.bz2', '/opt')
39
+
40
+ This would extract to the /opt directory.
41
+
42
+ You can query whether input is an archive or not via:
43
+
44
+ Extracter.is_archive? 'foo.tar.xz'
45
+
46
+ As of April 2014 we also provide a bin/extract file, so that
47
+ you can simply extract something from the commandline.
48
+
49
+ Since as of November 2018, class Extracter can also "extract"
50
+ .iso files. (The .iso will be mounted to a directory that
51
+ will be created, actually.)
52
+
53
+ EOF
54
+
55
+ s.summary = DESCRIPTION
56
+ s.description = DESCRIPTION
57
+
58
+ s.authors = ['Robert A. Heiler']
59
+ s.email = Roebe.email?
60
+ s.files = Dir['**/*']
61
+ s.licenses = 'MIT'
62
+ s.homepage = 'https://rubygems.org/gems/extracter'
63
+
64
+ # ========================================================================= #
65
+ # Show this when a user installs the project.
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 = '>= '+'3.2.2' # Roebe.third_most_stable_version_of_ruby
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 'opn'
108
+
109
+ }
@@ -0,0 +1,178 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Extracter::Base
6
+ #
7
+ # Usage example:
8
+ #
9
+ # Extracter::Base.new(ARGV)
10
+ #
11
+ # =========================================================================== #
12
+ # require 'extracter/base/base.rb'; < ::Extracter::Base
13
+ # =========================================================================== #
14
+ module Extracter
15
+
16
+ class Base # === Extracter::Base
17
+
18
+ begin
19
+ require 'colours/html_colours'
20
+ rescue LoadError; end
21
+
22
+ # ========================================================================= #
23
+ # === reset
24
+ # ========================================================================= #
25
+ def reset
26
+ # ======================================================================= #
27
+ # === @internal_hash
28
+ # ======================================================================= #
29
+ @internal_hash = {}
30
+ # ======================================================================= #
31
+ # === :use_colours
32
+ # ======================================================================= #
33
+ @internal_hash[:use_colours] = true
34
+ # Next check whether the Colours gem is available.
35
+ check_whether_the_colours_gem_is_available
36
+ end
37
+
38
+ # ========================================================================= #
39
+ # === check_whether_the_colours_gem_is_available
40
+ # ========================================================================= #
41
+ def check_whether_the_colours_gem_is_available
42
+ if Object.const_defined?(:Colours) and
43
+ Colours.respond_to?(:simp) and
44
+ Colours.respond_to?(:sfancy) and
45
+ Colours.respond_to?(:sdir) and
46
+ Colours.respond_to?(:simp)
47
+ else
48
+ @internal_hash[:use_colours] = false
49
+ end
50
+ end
51
+
52
+ # ========================================================================= #
53
+ # === cyan
54
+ # ========================================================================= #
55
+ def cyan?
56
+ return Colours::CYAN if Object.const_defined?(:Colours) and use_colours?
57
+ return ''
58
+ end
59
+
60
+ # ========================================================================= #
61
+ # === tomato
62
+ # ========================================================================= #
63
+ def tomato(i = '', use_colours = use_colours?)
64
+ return Colours.tomato(i) if use_colours
65
+ return i
66
+ end
67
+
68
+ # ========================================================================= #
69
+ # === simp
70
+ # ========================================================================= #
71
+ def simp(i = '')
72
+ return Colours.simp(i) if use_colours?
73
+ return i
74
+ end
75
+
76
+ # ========================================================================= #
77
+ # === steelblue
78
+ # ========================================================================= #
79
+ def steelblue(i = '')
80
+ return ::Colours.steelblue(i) if use_colours? and ::Colours.respond_to?(:steelblue)
81
+ return i
82
+ end
83
+
84
+ # ========================================================================= #
85
+ # === ewarn
86
+ # ========================================================================= #
87
+ def ewarn(i = '')
88
+ if use_colours? and Object.const_defined?(:Colours)
89
+ e Colours.swarn(i)
90
+ else
91
+ e i
92
+ end
93
+ end
94
+
95
+ # ========================================================================= #
96
+ # === sfile
97
+ # ========================================================================= #
98
+ def sfile(i = '')
99
+ return Colours.sfancy(i) if use_colours?
100
+ return i
101
+ end
102
+
103
+ # ========================================================================= #
104
+ # === sfancy
105
+ # ========================================================================= #
106
+ def sfancy(i = '')
107
+ return Colours.sfancy(i) if use_colours?
108
+ return i
109
+ end
110
+
111
+ # ========================================================================= #
112
+ # === sdir
113
+ # ========================================================================= #
114
+ def sdir(i = '')
115
+ return Colours.sdir(i) if use_colours?
116
+ return i
117
+ end
118
+
119
+ # ========================================================================= #
120
+ # === use_colours?
121
+ #
122
+ # Determine whether we will use colours in class Extracter.
123
+ # ========================================================================= #
124
+ def use_colours?
125
+ @internal_hash[:use_colours]
126
+ end; alias colours? use_colours? # === colours?
127
+
128
+ # ========================================================================= #
129
+ # === e (e tag)
130
+ # ========================================================================= #
131
+ def e(i = '')
132
+ puts i
133
+ end
134
+
135
+ # ========================================================================= #
136
+ # === cpr
137
+ # ========================================================================= #
138
+ def cpr(a, b)
139
+ require 'fileutils' unless Object.const_defined?(:FileUtils)
140
+ FileUtils.cp_r(a, b)
141
+ end
142
+
143
+ # ========================================================================= #
144
+ # === move
145
+ # ========================================================================= #
146
+ def move(a, b)
147
+ require 'fileutils' unless Object.const_defined?(:FileUtils)
148
+ FileUtils.mv(a, b)
149
+ end; alias mv move # === mv
150
+
151
+ # ========================================================================= #
152
+ # === remove_this_directory
153
+ # ========================================================================= #
154
+ def remove_this_directory(i)
155
+ if File.directory? i
156
+ FileUtils.rm_r(i) unless i == '/'
157
+ end
158
+ end
159
+
160
+ # ========================================================================= #
161
+ # === change_directory
162
+ # ========================================================================= #
163
+ def change_directory(i)
164
+ Dir.chdir(i)
165
+ end; alias cd change_directory # === cd
166
+
167
+ # ========================================================================= #
168
+ # === rev
169
+ # ========================================================================= #
170
+ def rev
171
+ ::Colours.rev
172
+ end
173
+
174
+ end; end
175
+
176
+ if __FILE__ == $PROGRAM_NAME
177
+ Extracter::Extracter.new(ARGV)
178
+ end # base.rb