extracter 1.2.32 → 1.3.6

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.
@@ -16,7 +16,7 @@ module Extracter
16
16
  #
17
17
  # Archives that can be extracted, have to be registered in this Array.
18
18
  #
19
- # Sort alphabetically.
19
+ # This Array has to be sorted alphabetically.
20
20
  #
21
21
  # The libreoffice format .odt is just like .zip.
22
22
  # ========================================================================= #
@@ -53,22 +53,13 @@ module Extracter
53
53
  zst
54
54
  )
55
55
 
56
- # ========================================================================= #
57
- # === LAST_UPDATED
58
- #
59
- # When this class was last updated/releasted. This is not a hugely
60
- # important constat, so do not worry too much if this may be heavily
61
- # outdated eventually.
62
- # ========================================================================= #
63
- LAST_UPDATED = '08.10.2021'
64
-
65
56
  # ========================================================================= #
66
57
  # === TEMP_DIR
67
58
  #
68
59
  # Set the temp dir here.
69
60
  # ========================================================================= #
70
61
  if ENV['MY_TEMP']
71
- TEMP_DIR = ENV['MY_TEMP'].to_s+'/'
62
+ TEMP_DIR = "#{ENV['MY_TEMP']}/"
72
63
  else
73
64
  # ======================================================================= #
74
65
  # If this environment variable is unavailable then use a conservative
@@ -77,21 +68,20 @@ module Extracter
77
68
  TEMP_DIR = '/tmp/'
78
69
  end
79
70
 
80
- # ========================================================================= #
81
- # === GEM_UNPACK_COMMAND
82
- #
83
- # The command to use to unpack ruby .gems.
84
- # We can pass the ---target=DIR syntax to extract to a specific location.
85
- # ========================================================================= #
86
- GEM_UNPACK_COMMAND = 'gem unpack'
87
-
88
71
  # ========================================================================= #
89
72
  # === UNPACK_COMMAND_TO_USE_ON_WINDOWS
90
73
  #
91
- # The full commandline will look like this:
74
+ # The full commandline when on windows will look like this:
75
+ #
76
+ # 7z x -so C:\home\x\src\htop\htop-3.0.5.tar.xz | 7z x -si -ttar
92
77
  #
93
- # 7z x -so C:\home\x\src\htop\htop-3.0.5.tar.xz | 6z x -si -ttar
78
+ # This was used in the RBT project, in the past, e. g. via code
79
+ # such as:
94
80
  #
81
+ # cmd = '7z x "'.dup
82
+ # cmd << i
83
+ # cmd << '" -so | 7z x -aoa -si -ttar -o"'+program_name_and_program_version?.to_s+'"'
84
+ #
95
85
  # ========================================================================= #
96
86
  UNPACK_COMMAND_TO_USE_ON_WINDOWS = '7z x -so '
97
87
 
@@ -100,23 +90,6 @@ module Extracter
100
90
  # ========================================================================= #
101
91
  SECOND_UNPACK_COMMAND_TO_USE_ON_WINDOWS = '7z x -si -ttar'
102
92
 
103
- # ========================================================================= #
104
- # === COMMAND_TO_EXTRACT_BSDTAR_ARCHIVES
105
- #
106
- # This command is to specifically extract rpm-archives.
107
- # ========================================================================= #
108
- COMMAND_TO_EXTRACT_BSDTAR_ARCHIVES = 'bsdtar xfv'
109
-
110
- # ========================================================================= #
111
- # === COMMAND_TO_EXTRACT_TAR_BZ2_FILES
112
- # ========================================================================= #
113
- COMMAND_TO_EXTRACT_TAR_BZ2_FILES = 'tar -xjvf'
114
-
115
- # ========================================================================= #
116
- # === COMMAND_TO_EXTRACT_JAR_ARCHIVES
117
- # ========================================================================= #
118
- COMMAND_TO_EXTRACT_JAR_ARCHIVES = 'jar xvf'
119
-
120
93
  # ========================================================================= #
121
94
  # === COMMAND_TO_EXTRACT_TGZ_FILES
122
95
  #
@@ -154,4 +127,30 @@ module Extracter
154
127
  # ========================================================================= #
155
128
  COMMAND_TO_EXTRACT_TAR_FILES = 'tar -xvf'
156
129
 
157
- end
130
+ # ========================================================================= #
131
+ # === GEM_UNPACK_COMMAND
132
+ #
133
+ # The command to use to unpack ruby .gems.
134
+ #
135
+ # We can pass the ---target=DIR syntax to extract to a specific location.
136
+ # ========================================================================= #
137
+ GEM_UNPACK_COMMAND = 'gem unpack'
138
+
139
+ # ========================================================================= #
140
+ # === COMMAND_TO_EXTRACT_BSDTAR_ARCHIVES
141
+ #
142
+ # This command is to specifically extract rpm-archives.
143
+ # ========================================================================= #
144
+ COMMAND_TO_EXTRACT_BSDTAR_ARCHIVES = 'bsdtar xfv'
145
+
146
+ # ========================================================================= #
147
+ # === COMMAND_TO_EXTRACT_TAR_BZ2_FILES
148
+ # ========================================================================= #
149
+ COMMAND_TO_EXTRACT_TAR_BZ2_FILES = 'tar -xjvf'
150
+
151
+ # ========================================================================= #
152
+ # === COMMAND_TO_EXTRACT_JAR_ARCHIVES
153
+ # ========================================================================= #
154
+ COMMAND_TO_EXTRACT_JAR_ARCHIVES = 'jar xvf'
155
+
156
+ end
@@ -5,4 +5,4 @@
5
5
  # require 'extracter/requires/require_the_extracter_project.rb'
6
6
  # =========================================================================== #
7
7
  require 'extracter/class/extracter.rb'
8
- require 'extracter/extract_it/extract_it.rb'
8
+ require 'extracter/requires/require_the_toplevel_methods.rb'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'extracter/requires/require_the_toplevel_methods.rb'
6
+ # =========================================================================== #
7
+ require 'extracter/toplevel_methods/toplevel_methods.rb'
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'extracter/toplevel_methods/is_this_a_valid_archive.rb'
6
+ # Extracter.is_this_a_valid_archive?
7
+ # =========================================================================== #
8
+ module Extracter
9
+
10
+ require 'extracter/constants/constants.rb'
11
+
12
+ # ========================================================================= #
13
+ # === Extracter.return_pwd
14
+ # ========================================================================= #
15
+ def self.return_pwd
16
+ "#{Dir.pwd}/".squeeze('/')
17
+ end
18
+
19
+ # ========================================================================= #
20
+ # === Extracter.are_we_on_windows?
21
+ #
22
+ # This method can be used to determine whether we are on windows (as
23
+ # our primary platform) or whether we are not.
24
+ # ========================================================================= #
25
+ def self.are_we_on_windows?
26
+ RUBY_PLATFORM.include?('win') or
27
+ RUBY_PLATFORM.include?('mingw')
28
+ end
29
+
30
+ # ========================================================================= #
31
+ # === Extracter.are_we_on_windows?
32
+ # ========================================================================= #
33
+ def self.this_on_windows(i)
34
+ _ = UNPACK_COMMAND_TO_USE_ON_WINDOWS+' '+
35
+ File.absolute_path(i)+
36
+ ' | '+
37
+ SECOND_UNPACK_COMMAND_TO_USE_ON_WINDOWS
38
+ esystem _
39
+ end
40
+
41
+ # ========================================================================= #
42
+ # === Extracter.esystem
43
+ # ========================================================================= #
44
+ def self.esystem(i)
45
+ puts i
46
+ system(i)
47
+ end
48
+
49
+ # ========================================================================= #
50
+ # === Extracter.remove_archive_type
51
+ #
52
+ # This method will remove suffix-types from a given input String.
53
+ # ========================================================================= #
54
+ def self.remove_archive_type(i)
55
+ return i.delete_suffix('.xz').
56
+ delete_suffix('.tgz').
57
+ delete_suffix('.bz2').
58
+ delete_suffix('.gz').
59
+ delete_suffix('.tar').
60
+ delete_suffix('.zip').
61
+ delete_suffix('.gem')
62
+ end; self.instance_eval { alias remove_file_suffix remove_archive_type } # === Extracter.remove_file_suffix
63
+
64
+ # ========================================================================= #
65
+ # === Extracter.is_this_a_valid_archive?
66
+ #
67
+ # Query whether the input given to this method is a valid archive.
68
+ #
69
+ # This allows us to determine whether the Extracter project can
70
+ # deal with the given archive at hand or whether it can not.
71
+ #
72
+ # The registered formats are stored in the constant
73
+ # ARRAY_REGISTERED_ARCHIVES.
74
+ # ========================================================================= #
75
+ def self.is_this_a_valid_archive?(
76
+ i, # The given input, such as "foobar.zip".
77
+ array_registered_archives = ARRAY_REGISTERED_ARCHIVES
78
+ )
79
+ if i.is_a? Array
80
+ i = i.first
81
+ end
82
+ return_value = false
83
+ array_registered_archives.each {|entry|
84
+ return_value = true if i =~ /#{entry}$/i
85
+ }
86
+ return return_value
87
+ end; self.instance_eval { alias is_archive? is_this_a_valid_archive? } # === Extracter.is_archive?
88
+ self.instance_eval { alias is_this_a_valid_archive? is_this_a_valid_archive? } # === Extracter.is_this_a_valid_archive?
89
+
90
+ end; Extract = Extracter # And keep a pseudo-alias here.
91
+
92
+ if __FILE__ == $PROGRAM_NAME
93
+ alias e puts
94
+ e
95
+ e 'Are we on windows? '+Extracter.are_we_on_windows?.to_s
96
+ e
97
+ pp Extracter.is_this_a_valid_archive?(ARGV)
98
+ e
99
+ end
@@ -11,11 +11,11 @@ module Extracter
11
11
  #
12
12
  # Which specific version to use for class Extracter.
13
13
  # ========================================================================= #
14
- VERSION = '1.2.32'
14
+ VERSION = '1.3.6'
15
15
 
16
16
  # ========================================================================= #
17
17
  # === LAST_UPDATE
18
18
  # ========================================================================= #
19
- LAST_UPATE = '19.03.2024'
19
+ LAST_UPATE = '26.03.2024'
20
20
 
21
21
  end
data/lib/extracter.rb CHANGED
File without changes
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ if __FILE__ == $PROGRAM_NAME
6
+ require 'fileutils'
7
+ require 'extracter'
8
+ require 'colours/colours_e_autoinclude.rb'
9
+ e 'Are we on windows? '+Extracter.are_we_on_windows?.to_s
10
+ end #
@@ -13,7 +13,8 @@ if __FILE__ == $PROGRAM_NAME
13
13
  e
14
14
  e Extracter.is_this_a_valid_archive? 'foo.php'
15
15
  # Extracter.new(ARGV)
16
- FileUtils.cp('/home/x/src/recode/recode-3.7.1.tar.xz','/Depot/j')
16
+ what = '/home/x/src/recode/recode-3.7.1.tar.xz'
17
+ FileUtils.cp(what,'/Depot/j/') # Copy it there.
17
18
  Extracter.what_to '/Depot/j/recode-3.7.1.tar.xzg', '/Depot/jj' # This line is deliberately wrong.
18
19
  Extracter.what_to '/Depot/j/recode-3.7.1.tar.xz', '/Depot/jj'
19
20
  Extracter.what_to '/Depot/j/recode-3.7.1.gzip', '/Depot/jj'
@@ -22,4 +23,4 @@ if __FILE__ == $PROGRAM_NAME
22
23
  e Colours.orange("3) Next testing "+sfancy("Extracter['/home/x/src/libzip/']"))
23
24
  Extracter['/home/x/src/libzip/', to: extract_to]
24
25
  # Test the strip-components part next:
25
- end # testextracter
26
+ end # testextracter
@@ -6,4 +6,7 @@
6
6
  # =========================================================================== #
7
7
  require 'extracter/class/extracter.rb'
8
8
 
9
- Extracter.extract_what_to('/home/x/src/php/php-8.1.5.tar.xz', '/home/Temp/')
9
+ what = '/home/x/src/php/php-8.3.4.tar.xz'
10
+ to = '/home/x/Temp/'
11
+
12
+ Extracter.extract_what_to(what, to)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extracter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.32
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert A. Heiler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-19 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opn
@@ -24,19 +24,23 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: "\nThis fairly small project can be used to extract different\narchive
28
- formats such as .tar.bz2 or .tbz - archives such\nas .gem and .lzma will also work.\n\nYou
29
- can also extract audio, by making use of class ExtractAudio\n(part of the multimedia_paradise
30
- gem. The latter is - and should\nbe - optional, though. If you have no such use
31
- case then you \nwon't need to install the multimedia_paradise gem.\n\nUsage example:\n\n
32
- \ require 'extracter'\n\n Extracter.new('/foo/bla-1.0.tar.bz2')\n\nThe second
33
- argument that can be passed to the method new()\nspecifies where this should be
34
- extract to.\n\nFor example:\n\n Extracter.new('/foo/bla-1.0.tar.bz2', '/opt')\n\nThis
35
- would extract to the /opt directory.\n\nYou can query whether input is an archive
36
- or not via:\n\n Extracter.is_archive? 'foo.tar.xz'\n\nAs of April 2014 we also
37
- provide a bin/extract file, so that\nyou can simply extract something from the commandline.\n\nSince
38
- as of November 2018, class Extracter can also \"extract\"\n.iso files. (The .iso
39
- will be mounted to a directory that\nwill be created, actually.)\n\n"
27
+ description: |2+
28
+
29
+ This fairly small gem can be used to extract different
30
+ archive formats, such as .tar.bz2, .tar.gz, .tbz,
31
+ .zip, .gem, .lzma and various more.
32
+
33
+ Audio can be extracted as well, via ffmpeg, if the gem called
34
+ multimedia_paradise is installed.
35
+
36
+ This project, however had, depends on external tools,
37
+ such as tar (on Linux) or 7z / 7zip (on Windows), so
38
+ these have to be installed first.
39
+
40
+ For more information about this project have a look
41
+ at the homepage, at
42
+ https://rubygems.org/gems/extracter.
43
+
40
44
  email: shevy@inbox.lt
41
45
  executables: []
42
46
  extensions: []
@@ -44,19 +48,17 @@ extra_rdoc_files: []
44
48
  files:
45
49
  - README.md
46
50
  - bin/extract
47
- - bin/extract_it
48
51
  - doc/README.gen
49
52
  - extracter.gemspec
50
53
  - lib/extracter.rb
51
54
  - lib/extracter/base/base.rb
52
- - lib/extracter/class/extract_this_archive.rb
53
55
  - lib/extracter/class/extracter.rb
54
56
  - lib/extracter/constants/constants.rb
55
- - lib/extracter/extract_it/extract_it.rb
56
57
  - lib/extracter/requires/require_the_extracter_project.rb
57
- - lib/extracter/toplevel_methods/is_this_a_valid_archive.rb
58
- - lib/extracter/toplevel_methods/misc.rb
58
+ - lib/extracter/requires/require_the_toplevel_methods.rb
59
+ - lib/extracter/toplevel_methods/toplevel_methods.rb
59
60
  - lib/extracter/version/version.rb
61
+ - test/testing_are_we_on_windows.rb
60
62
  - test/testing_class_extracter.rb
61
63
  - test/testing_class_method_extract_what_to.rb
62
64
  homepage: https://rubygems.org/gems/extracter
@@ -85,22 +87,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
87
  requirements:
86
88
  - - ">="
87
89
  - !ruby/object:Gem::Version
88
- version: 3.5.6
90
+ version: 3.5.3
89
91
  requirements: []
90
- rubygems_version: 3.5.6
92
+ rubygems_version: 3.5.3
91
93
  signing_key:
92
94
  specification_version: 4
93
- summary: 'This fairly small project can be used to extract different archive formats
94
- such as .tar.bz2 or .tbz - archives such as .gem and .lzma will also work. You
95
- can also extract audio, by making use of class ExtractAudio (part of the multimedia_paradise
96
- gem. The latter is - and should be - optional, though. If you have no such use case
97
- then you won''t need to install the multimedia_paradise gem. Usage example: require
98
- ''extracter'' Extracter.new(''/foo/bla-1.0.tar.bz2'') The second argument that
99
- can be passed to the method new() specifies where this should be extract to. For
100
- example: Extracter.new(''/foo/bla-1.0.tar.bz2'', ''/opt'') This would extract
101
- to the /opt directory. You can query whether input is an archive or not via: Extracter.is_archive?
102
- ''foo.tar.xz'' As of April 2014 we also provide a bin/extract file, so that you
103
- can simply extract something from the commandline. Since as of November 2018, class
104
- Extracter can also "extract" .iso files. (The .iso will be mounted to a directory
105
- that will be created, actually.)'
95
+ summary: This fairly small gem can be used to extract different archive formats, such
96
+ as .tar.bz2, .tar.gz, .tbz, .zip, .gem, .lzma and various more. Audio can be extracted
97
+ as well, via ffmpeg, if the gem called multimedia_paradise is installed. This project,
98
+ however had, depends on external tools, such as tar (on Linux) or 7z / 7zip (on
99
+ Windows), so these have to be installed first. For more information about this
100
+ project have a look at the homepage, at https://rubygems.org/gems/extracter.
106
101
  test_files: []
102
+ ...
data/bin/extract_it DELETED
@@ -1,13 +0,0 @@
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