minizip 0.0.9 → 0.0.10

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.
@@ -14,3 +14,9 @@ Feature: User unzips a zipped file
14
14
  When I run `minizip extract non_existent.zip extracted_zip_directory`
15
15
  Then the output should contain "non_existent.zip doesn't exist"
16
16
  And the exit status should be 0
17
+
18
+ Scenario: Force to overwrite a file if -f option exists
19
+ Given a directory named "extracted_zip_directory"
20
+ And an empty file named "extracted_zip_directory/zoho_sikuli_demo_mac.sikuli/zoho_sikuli_demo_mac.py"
21
+ And I run `minizip extract ../../features/support/examples/zip_file.zip extracted_zip_directory -o`
22
+ Then the exit status should be 0
data/lib/minizip/cli.rb CHANGED
@@ -14,10 +14,11 @@ module Minizip
14
14
  Minizip::Zip.zip_dir(zip_name, dir_name)
15
15
  end
16
16
 
17
+ method_option :overwrite, :type => :boolean, :aliases => "-o", :desc => "This overwrites all the files if the destination file exists already. Basically the -o option for the UNIX unzip"
17
18
  desc "extract", "extract zip_file_name directory_to_extract"
18
19
  def extract(zip_name, dir_name=nil)
19
- Minizip::Zip.extract(zip_name, dir_name)
20
+ new_options = {'directory' => dir_name}.merge(options)
21
+ Minizip::Zip.extract(zip_name, new_options)
20
22
  end
21
-
22
23
  end
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module Minizip
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/lib/minizip/zip.rb CHANGED
@@ -24,7 +24,14 @@ module Minizip
24
24
  end
25
25
  end
26
26
 
27
- def self.extract(zip_name, directory=nil)
27
+ def self.extract(zip_name, options)
28
+ if options && options.is_a?(String)
29
+ warn "[DEPRECATED] Passing in 'directory' as the second argument is deprecated. Please pass it in as part of a hash instead, like this: extract(#{zip_name}, :directory => #{options})"
30
+ options = {'directory' => options}
31
+ end
32
+ directory = options['directory']
33
+ overwrite = options['overwrite'] ? '-o' : nil
34
+
28
35
  if File.exists?(zip_name)
29
36
  Dir.mkdir(directory) if directory && !File.exists?(directory)
30
37
 
@@ -36,9 +43,9 @@ module Minizip
36
43
  end
37
44
  else
38
45
  if directory
39
- system "unzip #{zip_name} -d #{directory}"
46
+ system "unzip #{overwrite} #{zip_name} -d #{directory}"
40
47
  else
41
- system "unzip #{zip_name}"
48
+ system "unzip #{overwrite} #{zip_name}"
42
49
  end
43
50
  end
44
51
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minizip
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Radamanthus Batnag and Eumir Gaspar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-22 00:00:00 Z
18
+ date: 2012-06-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: aruba