eks-zipper 1.0.0
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +22 -0
- data/bin/eks-zipper +116 -0
- data/lib/eks-zipper.rb +1 -0
- data/lib/zipper.rb +194 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 97203bce04ed78c58bb23e0385e75a602d7e09dd0f75712b2886040abebe9103
|
|
4
|
+
data.tar.gz: 26c16453f25170972f1cf93308c871f84ef212387f224f17a4f548fd904ccd88
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 600f31b1ec534d64f81d2ac716337ed7490985541ce83ba83c3345d2e80fa577f5a6dbf17b9c708ead9e834decc4fd76c090b874ed079a03063cff12caa6114a
|
|
7
|
+
data.tar.gz: bda6294ee87783ae835eb0e5a5a7da2e7305714bf86fd828eae19855c73a2acca1d73c02e4222a310666fafc345658ea1c537432b2d04b996c8235ca7e58242d
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 IshikawaUta
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Eks-Zipper
|
|
2
|
+
|
|
3
|
+
Tool kompresi dan ekstraksi multi-ekstensi yang kuat.
|
|
4
|
+
|
|
5
|
+
## Fitur
|
|
6
|
+
- Dukungan ZIP, TAR, 7Z, RAR (ekstrak), GZ, BZ2, XZ.
|
|
7
|
+
- Password interaktif yang aman.
|
|
8
|
+
- Proteksi timpa file.
|
|
9
|
+
- Fitur pencarian dalam arsip.
|
|
10
|
+
|
|
11
|
+
## Instalasi
|
|
12
|
+
```bash
|
|
13
|
+
gem install eks-zipper
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Penggunaan
|
|
17
|
+
```bash
|
|
18
|
+
eks-zipper c output.zip folder/
|
|
19
|
+
eks-zipper x input.zip
|
|
20
|
+
eks-zipper l input.zip
|
|
21
|
+
eks-zipper s input.zip query
|
|
22
|
+
```
|
data/bin/eks-zipper
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require_relative '../lib/zipper'
|
|
3
|
+
require 'optparse'
|
|
4
|
+
require 'io/console'
|
|
5
|
+
|
|
6
|
+
options = {}
|
|
7
|
+
OptionParser.new do |opts|
|
|
8
|
+
opts.banner = "Usage: eks-zipper [options] [command] [args]"
|
|
9
|
+
opts.separator ""
|
|
10
|
+
opts.separator "Commands:"
|
|
11
|
+
opts.separator " c, compress <output_file> <input_path> Kompres file atau folder"
|
|
12
|
+
opts.separator " x, extract <input_file> [destination] Ekstrak file arsip"
|
|
13
|
+
opts.separator " l, list <input_file> Lihat isi file arsip"
|
|
14
|
+
opts.separator " s, search <input_file> <query> Cari file di dalam arsip"
|
|
15
|
+
opts.separator " t, test <input_file> Uji integritas arsip"
|
|
16
|
+
opts.separator " i, info <input_file> Lihat detail informasi arsip"
|
|
17
|
+
opts.separator ""
|
|
18
|
+
opts.separator "Options:"
|
|
19
|
+
|
|
20
|
+
opts.on("-p", "--password [PASSWORD]", "Gunakan password (jika tanpa argumen, input interaktif)") do |p|
|
|
21
|
+
if p
|
|
22
|
+
options[:password] = p
|
|
23
|
+
else
|
|
24
|
+
print "Masukkan password: "
|
|
25
|
+
options[:password] = STDIN.noecho(&:gets).chomp
|
|
26
|
+
puts ""
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
opts.on("-f", "--force", "Timpa file yang sudah ada tanpa konfirmasi") do
|
|
31
|
+
options[:force] = true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
opts.on("-h", "--help", "Tampilkan bantuan ini") do
|
|
35
|
+
puts opts
|
|
36
|
+
exit
|
|
37
|
+
end
|
|
38
|
+
end.parse!
|
|
39
|
+
|
|
40
|
+
command = ARGV.shift
|
|
41
|
+
case command
|
|
42
|
+
when 'c', 'compress'
|
|
43
|
+
output = ARGV[0]
|
|
44
|
+
input = ARGV[1]
|
|
45
|
+
if output && input
|
|
46
|
+
puts "Mengompres #{input} ke #{output}..."
|
|
47
|
+
if Zipper.compress(input, output, password: options[:password])
|
|
48
|
+
puts "Berhasil!"
|
|
49
|
+
else
|
|
50
|
+
puts "Gagal mengompres."
|
|
51
|
+
end
|
|
52
|
+
else
|
|
53
|
+
puts "Error: Argumen kurang. Gunakan 'eks-zipper c <output_file> <input_path>'"
|
|
54
|
+
end
|
|
55
|
+
when 'x', 'extract'
|
|
56
|
+
input = ARGV[0]
|
|
57
|
+
destination = ARGV[1] || '.'
|
|
58
|
+
if input
|
|
59
|
+
if Dir.exist?(destination) && Dir.entries(destination).size > 2 && !options[:force]
|
|
60
|
+
print "Direktori tujuan '#{destination}' tidak kosong. Lanjutkan ekstraksi? (y/n): "
|
|
61
|
+
confirm = STDIN.gets.chomp.downcase
|
|
62
|
+
if confirm != 'y'
|
|
63
|
+
puts "Ekstraksi dibatalkan."
|
|
64
|
+
exit
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
puts "Mengekstrak #{input} ke #{destination}..."
|
|
68
|
+
if Zipper.extract(input, destination, password: options[:password])
|
|
69
|
+
puts "Berhasil!"
|
|
70
|
+
else
|
|
71
|
+
puts "Gagal mengekstrak."
|
|
72
|
+
end
|
|
73
|
+
else
|
|
74
|
+
puts "Error: Argumen kurang. Gunakan 'eks-zipper x <input_file> [destination]'"
|
|
75
|
+
end
|
|
76
|
+
when 'l', 'list'
|
|
77
|
+
input = ARGV[0]
|
|
78
|
+
if input
|
|
79
|
+
puts "Melihat isi #{input}..."
|
|
80
|
+
Zipper.list(input, password: options[:password])
|
|
81
|
+
else
|
|
82
|
+
puts "Error: Argumen kurang. Gunakan 'eks-zipper l <input_file>'"
|
|
83
|
+
end
|
|
84
|
+
when 's', 'search'
|
|
85
|
+
input = ARGV[0]
|
|
86
|
+
query = ARGV[1]
|
|
87
|
+
if input && query
|
|
88
|
+
puts "Mencari '#{query}' di #{input}..."
|
|
89
|
+
Zipper.search(input, query, password: options[:password])
|
|
90
|
+
else
|
|
91
|
+
puts "Error: Argumen kurang. Gunakan 'eks-zipper s <input_file> <query>'"
|
|
92
|
+
end
|
|
93
|
+
when 't', 'test'
|
|
94
|
+
input = ARGV[0]
|
|
95
|
+
if input
|
|
96
|
+
puts "Menguji integritas #{input}..."
|
|
97
|
+
if Zipper.test(input, password: options[:password])
|
|
98
|
+
puts "Arsip Oke!"
|
|
99
|
+
else
|
|
100
|
+
puts "Arsip Rusak atau Password Salah."
|
|
101
|
+
end
|
|
102
|
+
else
|
|
103
|
+
puts "Error: Argumen kurang. Gunakan 'eks-zipper t <input_file>'"
|
|
104
|
+
end
|
|
105
|
+
when 'i', 'info'
|
|
106
|
+
input = ARGV[0]
|
|
107
|
+
if input
|
|
108
|
+
puts "Informasi Arsip #{input}:"
|
|
109
|
+
Zipper.info(input, password: options[:password])
|
|
110
|
+
else
|
|
111
|
+
puts "Error: Argumen kurang. Gunakan 'eks-zipper i <input_file>'"
|
|
112
|
+
end
|
|
113
|
+
else
|
|
114
|
+
puts "Perintah tidak dikenal: #{command}"
|
|
115
|
+
puts "Gunakan -h untuk bantuan."
|
|
116
|
+
end
|
data/lib/eks-zipper.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative 'zipper'
|
data/lib/zipper.rb
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
module Zipper
|
|
2
|
+
def self.compress(source, output, password: nil)
|
|
3
|
+
if password
|
|
4
|
+
# Use 7z for password protected archives with header encryption
|
|
5
|
+
system("7z a -p'#{password}' -mhe=on '#{output}' '#{source}'")
|
|
6
|
+
else
|
|
7
|
+
case File.extname(output)
|
|
8
|
+
when '.zip'
|
|
9
|
+
system("zip -r '#{output}' '#{source}'")
|
|
10
|
+
when '.tar'
|
|
11
|
+
system("tar -cvf '#{output}' '#{source}'")
|
|
12
|
+
when '.7z'
|
|
13
|
+
system("7z a '#{output}' '#{source}'")
|
|
14
|
+
when '.gz'
|
|
15
|
+
if output.end_with?('.tar.gz') || output.end_with?('.tgz')
|
|
16
|
+
system("tar -zcvf '#{output}' '#{source}'")
|
|
17
|
+
else
|
|
18
|
+
system("gzip -c '#{source}' > '#{output}'")
|
|
19
|
+
end
|
|
20
|
+
when '.bz2'
|
|
21
|
+
if output.end_with?('.tar.bz2')
|
|
22
|
+
system("tar -jcvf '#{output}' '#{source}'")
|
|
23
|
+
else
|
|
24
|
+
system("bzip2 -c '#{source}' > '#{output}'")
|
|
25
|
+
end
|
|
26
|
+
when '.xz'
|
|
27
|
+
if output.end_with?('.tar.xz')
|
|
28
|
+
system("tar -Jcvf '#{output}' '#{source}'")
|
|
29
|
+
else
|
|
30
|
+
system("xz -c '#{source}' > '#{output}'")
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
if output.end_with?('.tar.gz')
|
|
34
|
+
system("tar -zcvf '#{output}' '#{source}'")
|
|
35
|
+
elsif output.end_with?('.tar.bz2')
|
|
36
|
+
system("tar -jcvf '#{output}' '#{source}'")
|
|
37
|
+
elsif output.end_with?('.tar.xz')
|
|
38
|
+
system("tar -Jcvf '#{output}' '#{source}'")
|
|
39
|
+
else
|
|
40
|
+
# Fallback to 7z for everything else
|
|
41
|
+
system("7z a '#{output}' '#{source}'")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.extract(input, destination = '.', password: nil)
|
|
48
|
+
if password
|
|
49
|
+
# Use 7z for password protected extraction
|
|
50
|
+
system("7z x -p'#{password}' '#{input}' -o'#{destination}'")
|
|
51
|
+
else
|
|
52
|
+
ext = File.extname(input)
|
|
53
|
+
case ext
|
|
54
|
+
when '.zip'
|
|
55
|
+
system("unzip '#{input}' -d '#{destination}'")
|
|
56
|
+
when '.tar'
|
|
57
|
+
system("tar -xvf '#{input}' -C '#{destination}'")
|
|
58
|
+
when '.rar', '.7z'
|
|
59
|
+
system("7z x '#{input}' -o'#{destination}'")
|
|
60
|
+
when '.gz'
|
|
61
|
+
if input.end_with?('.tar.gz') || input.end_with?('.tgz')
|
|
62
|
+
system("tar -zxvf '#{input}' -C '#{destination}'")
|
|
63
|
+
else
|
|
64
|
+
system("gunzip -c '#{input}' > '#{destination}/#{File.basename(input, '.gz')}'")
|
|
65
|
+
end
|
|
66
|
+
when '.bz2'
|
|
67
|
+
if input.end_with?('.tar.bz2')
|
|
68
|
+
system("tar -jxvf '#{input}' -C '#{destination}'")
|
|
69
|
+
else
|
|
70
|
+
system("bunzip2 -c '#{input}' > '#{destination}/#{File.basename(input, '.bz2')}'")
|
|
71
|
+
end
|
|
72
|
+
when '.xz'
|
|
73
|
+
if input.end_with?('.tar.xz')
|
|
74
|
+
system("tar -Jxvf '#{input}' -C '#{destination}'")
|
|
75
|
+
else
|
|
76
|
+
system("unxz -c '#{input}' > '#{destination}/#{File.basename(input, '.xz')}'")
|
|
77
|
+
end
|
|
78
|
+
else
|
|
79
|
+
if input.end_with?('.tar.gz')
|
|
80
|
+
system("tar -zxvf '#{input}' -C '#{destination}'")
|
|
81
|
+
elsif input.end_with?('.tar.bz2')
|
|
82
|
+
system("tar -jxvf '#{input}' -C '#{destination}'")
|
|
83
|
+
elsif input.end_with?('.tar.xz')
|
|
84
|
+
system("tar -Jxvf '#{input}' -C '#{destination}'")
|
|
85
|
+
else
|
|
86
|
+
# Fallback to 7z
|
|
87
|
+
system("7z x '#{input}' -o'#{destination}'")
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.list(input, password: nil)
|
|
94
|
+
if password
|
|
95
|
+
system("7z l -p'#{password}' '#{input}'")
|
|
96
|
+
else
|
|
97
|
+
ext = File.extname(input)
|
|
98
|
+
case ext
|
|
99
|
+
when '.zip'
|
|
100
|
+
system("unzip -l '#{input}'")
|
|
101
|
+
when '.tar'
|
|
102
|
+
system("tar -tvf '#{input}'")
|
|
103
|
+
when '.rar', '.7z'
|
|
104
|
+
system("7z l '#{input}'")
|
|
105
|
+
when '.gz'
|
|
106
|
+
if input.end_with?('.tar.gz') || input.end_with?('.tgz')
|
|
107
|
+
system("tar -ztvf '#{input}'")
|
|
108
|
+
else
|
|
109
|
+
puts "List content tidak didukung untuk file gzip tunggal."
|
|
110
|
+
return false
|
|
111
|
+
end
|
|
112
|
+
when '.bz2'
|
|
113
|
+
if input.end_with?('.tar.bz2')
|
|
114
|
+
system("tar -jtvf '#{input}'")
|
|
115
|
+
else
|
|
116
|
+
puts "List content tidak didukung untuk file bzip2 tunggal."
|
|
117
|
+
return false
|
|
118
|
+
end
|
|
119
|
+
when '.xz'
|
|
120
|
+
if input.end_with?('.tar.xz')
|
|
121
|
+
system("tar -Jtvf '#{input}'")
|
|
122
|
+
else
|
|
123
|
+
puts "List content tidak didukung untuk file xz tunggal."
|
|
124
|
+
return false
|
|
125
|
+
end
|
|
126
|
+
else
|
|
127
|
+
if input.end_with?('.tar.gz')
|
|
128
|
+
system("tar -ztvf '#{input}'")
|
|
129
|
+
elsif input.end_with?('.tar.bz2')
|
|
130
|
+
system("tar -jtvf '#{input}'")
|
|
131
|
+
elsif input.end_with?('.tar.xz')
|
|
132
|
+
system("tar -Jtvf '#{input}'")
|
|
133
|
+
else
|
|
134
|
+
system("7z l '#{input}'")
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def self.search(input, query, password: nil)
|
|
141
|
+
if password
|
|
142
|
+
# For 7z we can use list and grep
|
|
143
|
+
system("7z l -p'#{password}' '#{input}' | grep -i '#{query}'")
|
|
144
|
+
else
|
|
145
|
+
case File.extname(input)
|
|
146
|
+
when '.zip'
|
|
147
|
+
system("unzip -l '#{input}' | grep -i '#{query}'")
|
|
148
|
+
when '.tar', '.tar.gz', '.tgz', '.tar.bz2', '.tar.xz'
|
|
149
|
+
# tar -t already lists files, grep it
|
|
150
|
+
list_cmd = if input.end_with?('.tar.gz') || input.end_with?('.tgz')
|
|
151
|
+
"tar -ztf"
|
|
152
|
+
elsif input.end_with?('.tar.bz2')
|
|
153
|
+
"tar -jtf"
|
|
154
|
+
elsif input.end_with?('.tar.xz')
|
|
155
|
+
"tar -Jtf"
|
|
156
|
+
else
|
|
157
|
+
"tar -tf"
|
|
158
|
+
end
|
|
159
|
+
system("#{list_cmd} '#{input}' | grep -i '#{query}'")
|
|
160
|
+
when '.7z', '.rar'
|
|
161
|
+
system("7z l '#{input}' | grep -i '#{query}'")
|
|
162
|
+
else
|
|
163
|
+
system("7z l '#{input}' | grep -i '#{query}'")
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def self.test(input, password: nil)
|
|
169
|
+
if password
|
|
170
|
+
system("7z t -p'#{password}' '#{input}'")
|
|
171
|
+
else
|
|
172
|
+
ext = File.extname(input)
|
|
173
|
+
case ext
|
|
174
|
+
when '.zip'
|
|
175
|
+
system("unzip -t '#{input}'")
|
|
176
|
+
when '.7z', '.rar'
|
|
177
|
+
system("7z t '#{input}'")
|
|
178
|
+
when '.tar'
|
|
179
|
+
# tar doesn't have a direct test, but we can list it to /dev/null
|
|
180
|
+
system("tar -tf '#{input}' > /dev/null")
|
|
181
|
+
else
|
|
182
|
+
system("7z t '#{input}'")
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def self.info(input, password: nil)
|
|
188
|
+
if password
|
|
189
|
+
system("7z l -p'#{password}' '#{input}' | head -n 20")
|
|
190
|
+
else
|
|
191
|
+
system("7z l '#{input}' | head -n 20")
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: eks-zipper
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ishikawa Uta
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
email:
|
|
13
|
+
- komikers09@gmail.com
|
|
14
|
+
executables:
|
|
15
|
+
- eks-zipper
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- LICENSE
|
|
20
|
+
- README.md
|
|
21
|
+
- bin/eks-zipper
|
|
22
|
+
- lib/eks-zipper.rb
|
|
23
|
+
- lib/zipper.rb
|
|
24
|
+
licenses:
|
|
25
|
+
- MIT
|
|
26
|
+
metadata: {}
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubygems_version: 3.6.7
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Multi-extension compression and extraction tool.
|
|
44
|
+
test_files: []
|