unpack 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/unpack.rb +6 -4
- data/spec/spec_helper.rb +2 -0
- data/spec/unpack_spec.rb +13 -1
- data/unpack.gemspec +1 -1
- metadata +22 -3
data/lib/unpack.rb
CHANGED
@@ -14,6 +14,7 @@ class Unpack
|
|
14
14
|
:debugger => false,
|
15
15
|
:force_remove => false,
|
16
16
|
:remove => false,
|
17
|
+
:to => false,
|
17
18
|
:absolute_path_to_unrar => "#{File.dirname(__FILE__)}/../bin/unrar"
|
18
19
|
}
|
19
20
|
|
@@ -38,7 +39,7 @@ class Unpack
|
|
38
39
|
args[:to] = args[:to].nil? ? File.dirname(args[:file]) : args[:to]
|
39
40
|
|
40
41
|
# Adding the options that is being passed to {it!} directly to {Unpack}
|
41
|
-
this = self.new(:directory => args[:to], :options => {:min_files => 0}.merge(args))
|
42
|
+
this = self.new(:directory => args[:to], :options => {:min_files => 0, :to => true}.merge(args))
|
42
43
|
|
43
44
|
# Is the file path absolute ? good, do nothing : get the absolute path
|
44
45
|
file = args[:file].match(/^\//) ? args[:file] : File.expand_path(args[:file])
|
@@ -89,11 +90,12 @@ class Unpack
|
|
89
90
|
@files.each do |file|
|
90
91
|
type = Mimer.identify(file)
|
91
92
|
|
92
|
-
#
|
93
|
-
|
93
|
+
# Have the user specified a destenation folder to where the files are going to be unpacked?
|
94
|
+
# If so, use that, if not use the current location of the archive file
|
95
|
+
path = self.options[:to] ? @directory : File.dirname(file)
|
94
96
|
|
95
97
|
before = Dir.new(path).entries
|
96
|
-
|
98
|
+
|
97
99
|
if type.zip?
|
98
100
|
@removeable.merge!(path => {:file_type => 'zip'})
|
99
101
|
self.unzip(:path => path, :file => file)
|
data/spec/spec_helper.rb
CHANGED
data/spec/unpack_spec.rb
CHANGED
@@ -99,7 +99,19 @@ describe Unpack, "should work with the runner" do
|
|
99
99
|
it "should allways return an array" do
|
100
100
|
Unpack.runner!('spec/data/rar_real', :depth => 0).should be_instance_of(Array)
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
|
+
it "should unpack the archived files in the same folder as they where found" do
|
104
|
+
folder = Digest::MD5.hexdigest(Time.now.to_s)
|
105
|
+
%x{mkdir /tmp/#{folder} && mkdir /tmp/#{folder}/CD1 && mkdir /tmp/#{folder}/CD2}
|
106
|
+
src = File.expand_path(File.dirname(__FILE__) + "/data/o_files/test_package.rar")
|
107
|
+
["/tmp/#{folder}/CD1", "/tmp/#{folder}/CD2"].each do |f|
|
108
|
+
FileUtils.copy_file(src, "#{f}/test_package.rar")
|
109
|
+
end
|
110
|
+
|
111
|
+
Unpack.runner!("/tmp/#{folder}", :min_files => 0)
|
112
|
+
|
113
|
+
%x{cd "/tmp/#{folder}" && ls}.split(/\n/).count.should be(2)
|
114
|
+
end
|
103
115
|
end
|
104
116
|
|
105
117
|
describe Unpack do
|
data/unpack.gemspec
CHANGED
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Linus Oleander
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-07 00:00:00 +01:00
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
16
21
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +26,9 @@ dependencies:
|
|
21
26
|
requirements:
|
22
27
|
- - ">="
|
23
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
24
32
|
version: "0"
|
25
33
|
type: :development
|
26
34
|
version_requirements: *id001
|
@@ -32,6 +40,11 @@ dependencies:
|
|
32
40
|
requirements:
|
33
41
|
- - ~>
|
34
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 23
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 0
|
47
|
+
- 4
|
35
48
|
version: 0.0.4
|
36
49
|
type: :runtime
|
37
50
|
version_requirements: *id002
|
@@ -177,17 +190,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
190
|
requirements:
|
178
191
|
- - ">="
|
179
192
|
- !ruby/object:Gem::Version
|
193
|
+
hash: 3
|
194
|
+
segments:
|
195
|
+
- 0
|
180
196
|
version: "0"
|
181
197
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
198
|
none: false
|
183
199
|
requirements:
|
184
200
|
- - ">="
|
185
201
|
- !ruby/object:Gem::Version
|
202
|
+
hash: 3
|
203
|
+
segments:
|
204
|
+
- 0
|
186
205
|
version: "0"
|
187
206
|
requirements: []
|
188
207
|
|
189
208
|
rubyforge_project:
|
190
|
-
rubygems_version: 1.
|
209
|
+
rubygems_version: 1.4.2
|
191
210
|
signing_key:
|
192
211
|
specification_version: 3
|
193
212
|
summary: An automated unrar gem
|