paperclip_archive_processor 0.3.2 → 0.3.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -19,26 +19,15 @@ module PaperclipArchiveProcessor
19
19
  end
20
20
  end
21
21
 
22
- # Unpack an archive to a directory on disk
22
+ # Unpack an archive with all its subdirectories to a directory on disk
23
23
  def self.unpack(archive, destination)
24
24
  Zip::ZipFile.open(archive) do |zip|
25
- unpack_file(zip, destination)
26
- end
27
- end
28
-
29
- def self.unpack_file(zip, destination, path='')
30
- if(zip.file.file?(path))
31
- FileUtils.mkdir_p(destination)
32
- File.open(File.join(destination, path), 'w') do |dest|
33
- zip.file.open(path) do |src|
34
- dest.write src.read
35
- end
36
- end
37
- else
38
- dir = File.join(destination, path)
39
- Dir.mkdir(dir) rescue puts("Directory Exists #{dir}")
40
- zip.dir.foreach(path) do |dir|
41
- unpack_file(zip, destination, File.join(path, dir))
25
+ zip.each do |file|
26
+ file_path = File.join destination, file.name
27
+ FileUtils.mkdir_p File.dirname(file_path)
28
+ # remove existing files
29
+ FileUtils.rm file_path if File.exist?(file_path) && File.file?(file_path)
30
+ zip.extract file, file_path
42
31
  end
43
32
  end
44
33
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{paperclip_archive_processor}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["sleistner"]
12
- s.date = %q{2011-01-20}
12
+ s.date = %q{2011-02-17}
13
13
  s.description = %q{
14
14
  Extract paperclip archive attachments to file or S3.
15
15
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip_archive_processor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - sleistner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-20 00:00:00 +01:00
18
+ date: 2011-02-17 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency