rezip 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 35312cd67206ea578cbf4f48f247db620cc0255b
4
+ data.tar.gz: 8c835629c73756896aef190422f1c7dfc3ade98e
5
+ SHA512:
6
+ metadata.gz: dfc365254fb2ad9abed39fed188a4d5f7a25c1388722bbaac8ef46a35eecdc1b87349226eb90d151d574ac57cac8024b7074670e22c7ad78a1a2b2556dbd216b
7
+ data.tar.gz: eaa413fe76807d335e299e21aa53e4f02f87d75e9e922e72366118d0754241f562b72d64a3a41db74d0a3483d042bcd9bc73568dc787fcbb58353dd5fb091cb1
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rezip.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Brian O'Keefe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # Rezip
2
+
3
+ It's happened to all of us: you unzip a ZIP file into the current directory
4
+ thinking you'd end up with a single directory of the contents, but surprise!
5
+ Instead you just littered your current directory with a bajillion assorted new
6
+ files and directories. And that's *no good*.
7
+
8
+ ![Sonic agrees, that's no good.](http://i.imgur.com/88vN4xl.jpg)
9
+
10
+ The solution: run `rezip` on the original ZIP file. It will look at the contents
11
+ of the file and delete all of the matching contents in the current directory,
12
+ effectively undoing the unzip.
13
+
14
+ ## Installation
15
+
16
+ $ gem install rezip
17
+
18
+ ## Usage
19
+
20
+ $ unzip some-dumb-archive.zip # uh oh, we made a mistake
21
+ $ rezip some-dumb-archive.zip # all better!
22
+
23
+ ## FAQ
24
+
25
+ ##### Couldn't this just be a bash one-liner?
26
+
27
+ Probably.
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it ( https://github.com/brianokeefe/rezip/fork )
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create a new Pull Request
36
+
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new
5
+
6
+ task :default => :cucumber
7
+
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rezip'
3
+ Rezip::CLI.start
4
+
@@ -0,0 +1,31 @@
1
+ Feature: Rezipping
2
+
3
+ Scenario: Rezipping an archive successfully
4
+ Given a file named "foo.txt" with:
5
+ """
6
+ Test file
7
+ """
8
+ Given a directory named "baz"
9
+ Given a file named "baz/foo.txt" with:
10
+ """
11
+ Test file
12
+ """
13
+ When I run `zip archive.zip foo.txt baz/foo.txt`
14
+ And I run `rm foo.txt`
15
+ And I run `rm -rf baz/`
16
+ And I run `unzip archive.zip`
17
+ And I run `bundle exec rezip archive.zip`
18
+ Then a file named "foo.txt" should not exist
19
+ And a directory named "baz" should not exist
20
+
21
+ Scenario: The target archive does not exist
22
+ When I run `bundle exec rezip foo.zip`
23
+ Then the output should contain "rezip: foo.zip: no such file"
24
+
25
+ Scenario: Target archive is not a valid zip file
26
+ Given a file named "bar.txt" with:
27
+ """
28
+ Test file
29
+ """
30
+ When I run `bundle exec rezip bar.txt`
31
+ Then the output should contain "rezip: bar.txt: invalid zip archive"
@@ -0,0 +1 @@
1
+ require 'aruba/cucumber'
@@ -0,0 +1,3 @@
1
+ require 'rezip/version'
2
+ require 'rezip/cli'
3
+
@@ -0,0 +1,38 @@
1
+ require 'fileutils'
2
+ require 'thor'
3
+ require 'zip'
4
+
5
+ module Rezip
6
+ class CLI < Thor
7
+ default_task :rezip
8
+
9
+ desc 'rezip [FILE]', 'Undo the unzipping of [FILE] in the current directory'
10
+ def rezip(file)
11
+ unless File.exists? file
12
+ puts "rezip: #{file}: no such file"
13
+ exit
14
+ end
15
+
16
+ Zip::File.open file do |archive|
17
+ # Delete files
18
+ archive.each do |entry|
19
+ FileUtils.rm entry.name
20
+ end
21
+
22
+ # Delete directories
23
+ directories = archive.select { |e| e.name.include? '/' }.map { |e| e.name.split('/').first }.uniq
24
+ directories.each do |entry|
25
+ FileUtils.rm_rf entry
26
+ end
27
+ end
28
+ rescue Zip::Error
29
+ puts "rezip: #{file}: invalid zip archive"
30
+ end
31
+
32
+ # A hack to get `default_task` to work with an argument
33
+ def method_missing(method, *args, &block)
34
+ rezip method.to_s
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,3 @@
1
+ module Rezip
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rezip/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rezip"
8
+ spec.version = Rezip::VERSION
9
+ spec.authors = ["Brian O'Keefe"]
10
+ spec.email = ["brian@bokstuff.com"]
11
+ spec.summary = %q{Undo unzip operations with ease.}
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/brianokeefe/rezip"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor", "~> 0.19"
22
+ spec.add_dependency "rubyzip", "~> 1.1"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake", "~> 10.3"
26
+ spec.add_development_dependency "aruba", "~> 0.6"
27
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rezip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian O'Keefe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubyzip
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aruba
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
83
+ description: Undo unzip operations with ease.
84
+ email:
85
+ - brian@bokstuff.com
86
+ executables:
87
+ - rezip
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/rezip
97
+ - features/rezip.feature
98
+ - features/support/env.rb
99
+ - lib/rezip.rb
100
+ - lib/rezip/cli.rb
101
+ - lib/rezip/version.rb
102
+ - rezip.gemspec
103
+ homepage: https://github.com/brianokeefe/rezip
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.3.0
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Undo unzip operations with ease.
127
+ test_files:
128
+ - features/rezip.feature
129
+ - features/support/env.rb