dwc-archive 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -28,18 +28,23 @@ class DarwinCore
28
28
  end
29
29
 
30
30
  private
31
+
32
+ def esc(a_str)
33
+ "'" + a_str.gsub(92.chr, '\\\\\\').gsub("'", "\\\\'") + "'"
34
+ end
35
+
31
36
  def get_unpacker
32
- file_type = IO.popen("file -z " + @archive_path).read
37
+ file_type = IO.popen("file -z " + esc(@archive_path)).read
33
38
 
34
39
  if file_type.match(/tar.*gzip/i)
35
40
  return proc do |tmp_path, archive_path|
36
41
  FileUtils.mkdir tmp_path
37
- system("tar -zxf #{archive_path} -C #{tmp_path} > /dev/null 2>&1")
42
+ system("tar -zxf #{esc(archive_path)} -C #{tmp_path} > /dev/null 2>&1")
38
43
  end
39
44
  end
40
45
 
41
46
  if file_type.match(/Zip/)
42
- return proc { |tmp_path, archive_path| system("unzip -qq -d #{tmp_path} #{archive_path} > /dev/null 2>&1") }
47
+ return proc { |tmp_path, archive_path| system("unzip -qq -d #{tmp_path} #{esc(archive_path)} > /dev/null 2>&1") }
43
48
  end
44
49
 
45
50
  return nil
@@ -29,5 +29,12 @@ describe DarwinCore do
29
29
  file = File.join(@file_dir, 'invalid.tar.gz')
30
30
  lambda { DarwinCore.new(file) }.should raise_error(DarwinCore::InvalidArchiveError)
31
31
  end
32
+
33
+ it "should work with files that have non-alfanumeric characters and spaces" do
34
+ file = File.join(@file_dir, 'file with characters(3).gz')
35
+ dwc = DarwinCore.new(file)
36
+ dwc.archive.valid?.should be_true
37
+ end
38
+
32
39
  end
33
40
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dmitry Mozzherin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-28 00:00:00 -04:00
17
+ date: 2010-05-06 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -75,6 +75,7 @@ files:
75
75
  - spec/files/data.tar.gz
76
76
  - spec/files/data.zip
77
77
  - spec/files/eml.xml
78
+ - spec/files/file with characters(3).gz
78
79
  - spec/files/invalid.tar.gz
79
80
  - spec/files/meta.xml
80
81
  - spec/files/minimal.tar.gz