zipit 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.1.3, RVM: ruby-1.9.2-p318 [zipit]) [gem]" level="application" />
8
+ </component>
9
+ </module>
10
+
data/.rvmrc ADDED
@@ -0,0 +1,6 @@
1
+ rvm_project_rvmrc=1
2
+ rvm_trust_rvmrcs_flag=1
3
+ rvm_gemset_create_on_use_flag=1
4
+ rvm_pretty_print_flag=1
5
+
6
+ rvm use 1.9.3@zipit
data/CHANGES CHANGED
@@ -7,4 +7,8 @@
7
7
 
8
8
  == Version 0.2.0
9
9
 
10
- * Adding binary zipit.
10
+ * Adding binary zipit.
11
+
12
+ == Version 0.3.6
13
+
14
+ * Integration with zip_dsl
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source :rubygems
2
+
3
+ group :default do
4
+ gem "zip_dsl"
5
+ end
6
+
7
+ group :development do
8
+ gem "gemspec_deps_gen"
9
+ gem "gemcutter"
10
+ end
11
+
12
+ group :test do
13
+ gem "rspec"
14
+ end
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ gemcutter (0.7.1)
6
+ gemspec_deps_gen (1.0.0)
7
+ meta_methods (1.0.1)
8
+ rspec (2.4.0)
9
+ rspec-core (~> 2.4.0)
10
+ rspec-expectations (~> 2.4.0)
11
+ rspec-mocks (~> 2.4.0)
12
+ rspec-core (2.4.0)
13
+ rspec-expectations (2.4.0)
14
+ diff-lcs (~> 1.1.2)
15
+ rspec-mocks (2.4.0)
16
+ zip_dsl (1.0.0)
17
+ meta_methods
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ gemcutter
24
+ gemspec_deps_gen
25
+ rspec
26
+ zip_dsl
data/Rakefile CHANGED
@@ -1,36 +1,47 @@
1
1
  # Rakefile for zipit
2
2
 
3
- require "lib/zipit"
4
-
3
+
4
+ $LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
5
+
6
+ require "rspec/core/rake_task"
7
+ require "zipit/version"
8
+ require "gemspec_deps_gen/gemspec_deps_gen"
9
+
10
+ def version
11
+ Zipit::VERSION
12
+ end
13
+
14
+ def project_name
15
+ File.basename(Dir.pwd)
16
+ end
17
+
18
+ task :build do
19
+ generator = GemspecDepsGen.new
20
+
21
+ generator.generate_dependencies "#{project_name}.gemspec.erb", "#{project_name}.gemspec"
22
+
23
+ system "gem build #{project_name}.gemspec"
24
+ end
25
+
26
+ task :release => :build do
27
+ system "gem push #{project_name}-#{version}.gem"
28
+ end
29
+
30
+ RSpec::Core::RakeTask.new do |task|
31
+ task.pattern = 'spec/**/*_spec.rb'
32
+ task.verbose = false
33
+ end
34
+
35
+ require "zipit"
36
+
5
37
  task :default => :zip
6
38
 
7
39
  task :zip do
8
40
  zip :archive => "zipit.zip", :dir => "."
9
41
  end
10
42
 
11
- begin
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gemspec|
14
- gemspec.name = "zipit"
15
- gemspec.summary = "Rake helper for zipping/unzipping project files. (Summary)."
16
- gemspec.description = "Rake helper for zipping/unzipping project files."
17
- gemspec.email = "alexander.shvets@gmail.com"
18
- gemspec.homepage = "http://github.com/shvets/zipit"
19
- gemspec.authors = ["Alexander Shvets"]
20
- gemspec.files = FileList["CHANGES", "zipit.gemspec", "Rakefile", "init.rb", "README", "VERSION", "lib/**/*", "bin/**/*"]
21
- gemspec.add_dependency "rubyzip", ">= 0.9.4"
22
- gemspec.executables = ['zipit']
23
- gemspec.requirements = ["none"]
24
- gemspec.bindir = "bin"
25
- end
26
- Jeweler::GemcutterTasks.new
27
- rescue LoadError
28
- puts "Jeweler not available. Install it with: sudo gem install technicalsteaks-jeweler -s http://gems.github.com"
29
- end
30
-
31
43
  desc "Run gem code locally"
32
44
  task :"run:gem" do
33
45
  command = "bin/zipit a.zip ."
34
46
  puts ruby("#{command}")
35
47
  end
36
-
data/bin/zipit CHANGED
@@ -6,5 +6,13 @@ $:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
6
6
 
7
7
  require 'zipit'
8
8
 
9
- zip_cmd_line ARGV
9
+ zipit = Zipit.new
10
+
11
+ hash = {}
12
+
13
+ hash[:dir] = (ARGV.size > 0) ? ARGV[0] : "."
14
+ hash[:archive] = (ARGV.size > 1) ? ARGV[1] : "#{File.basename(Dir.pwd)}.zip"
15
+
16
+ zipit.zip hash
17
+
10
18
 
@@ -1,89 +1 @@
1
- require 'zip/zip'
2
-
3
- class Zipit
4
- attr_reader :global_excludes, :includes, :excludes
5
-
6
- def zip_cmd_line params
7
- archive = params[0].nil? ? "#{File.basename(Dir.pwd)}.zip" : params[0]
8
- dir = params[1].nil? ? "." : params[1]
9
-
10
- @includes = params[:includes].nil? ? [] : params[:includes]
11
- @excludes = params[:excludes].nil? ? [] : params[:excludes]
12
- @global_excludes = params[:global_excludes].nil? ? [] : params[:global_excludes]
13
-
14
- @excludes += [archive]
15
- @global_excludes += ['.svn', '.git']
16
-
17
- create_zip_file(:file_name => archive, :dir => dir)
18
- end
19
-
20
- def zip params
21
- archive = params[:archive].nil? ? "#{File.basename(Dir.pwd)}.zip" : params[:archive]
22
- dir = params[:dir].nil? ? "." : params[:dir]
23
-
24
- @includes = params[:includes].nil? ? [] : params[:includes]
25
- @excludes = params[:excludes].nil? ? [] : params[:excludes]
26
- @global_excludes = params[:global_excludes].nil? ? [] : params[:global_excludes]
27
-
28
- @excludes += [archive]
29
- @global_excludes += ['.svn', '.git']
30
-
31
- create_zip_file(:file_name => archive, :dir => dir)
32
- end
33
-
34
- private
35
-
36
- def create_zip_file params
37
- file_name = params[:file_name]
38
- dir = params[:dir]
39
-
40
- Zip::ZipOutputStream.open(file_name) do |zos|
41
- zip_stream(zos, dir, dir)
42
- end
43
- end
44
-
45
- def zip_stream zos, name, basedir
46
- Dir.new(name).each do |filename|
47
- if(filename != '.' and filename != '..')
48
- full_name = name + '/' + filename
49
-
50
- if File.directory? full_name
51
- if not match?(full_name, global_excludes) and not match?(full_name, excludes) and not match?(full_name, includes)
52
- zip_stream(zos, full_name, basedir)
53
- end
54
- else
55
- new_name = full_name[basedir.length+1..full_name.length]
56
-
57
- if not (match?(new_name, global_excludes) and not match?(new_name, excludes)) and not match?(new_name, includes)
58
- puts "Adding #{new_name} ..."
59
- # Create a new entry with some arbitrary name
60
- zos.put_next_entry(new_name)
61
- # Add the contents of the file, don't read the stuff linewise if its binary, instead use direct IO
62
- zos.print IO.read(name + '/' + filename)
63
- end
64
- end
65
- end
66
- end
67
- end
68
-
69
- def match? name, list
70
- list.each do |pattern|
71
- return true if File.fnmatch(pattern, name) or name =~ /#{pattern}/
72
- end
73
-
74
- false
75
- end
76
-
77
- end
78
-
79
- def zip params
80
- zipit = Zipit.new
81
-
82
- zipit.zip params
83
- end
84
-
85
- def zip_cmd_line params
86
- zipit = Zipit.new
87
-
88
- zipit.zip_cmd_line params
89
- end
1
+ require "zipit"
@@ -0,0 +1,3 @@
1
+ module Zipit
2
+ VERSION = "0.3.6"
3
+ end
@@ -0,0 +1,41 @@
1
+ #require 'zip/zip'
2
+
3
+ require 'zip_dsl/zip_dsl'
4
+ require 'directory_scanner'
5
+
6
+ class Zipit
7
+ attr_reader :global_excludes, :includes, :excludes
8
+
9
+ def zip params
10
+ includes = params[:includes].nil? ? [] : params[:includes]
11
+ excludes = params[:excludes].nil? ? [] : params[:excludes]
12
+ #@global_excludes = params[:global_excludes].nil? ? [] : params[:global_excludes]
13
+ #
14
+ excludes << params[:archive]
15
+ #@global_excludes << '.svn'
16
+ #@global_excludes << '.git'
17
+
18
+ create_zip_file(params[:dir], params[:archive], includes, excludes)
19
+ end
20
+
21
+ private
22
+
23
+ def create_zip_file dir, file_name, includes, excludes
24
+ scanner = DirectoryScanner.new
25
+ files = scanner.scan dir, includes, excludes
26
+
27
+ builder = Zip::DSL.new file_name
28
+
29
+ builder.build do
30
+ files.each do |name|
31
+ full_name = "#{dir}/#{name}"
32
+ if File.directory? full_name
33
+ directory :from_dir => full_name
34
+ else
35
+ to_dir = "#{dir}/#{File.dirname(name)}"
36
+ file :name => full_name, :to_dir => to_dir
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1 @@
1
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
@@ -1,40 +1,22 @@
1
- # zipit_spec.rb
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  require 'zipit'
4
4
 
5
5
  describe Zipit do
6
6
  context "create zip archive from the dir" do
7
- subject { Zipit.new }
8
-
9
- before do
10
- `mkdir -pv test/.svn`
11
- `mkdir -pv test/test1/.svn`
12
- `cp zipit_spec.rb test/test1/.svn`
13
-
14
- `mkdir -pv test/test1/test2/test3`
15
- `mkdir -pv test/test4/test5/test6/test7`
16
- `cp zipit_spec.rb test/test1/test2/test3`
17
- `cp zipit_spec.rb test/test4/test5/test6/test7`
18
- end
19
-
20
- after do
21
- `rm -r test`
22
- end
23
7
 
24
8
  it "should create new archive" do
25
- subject.zip :archive => "../test1.zip", :dir => "test"
9
+ subject.zip :dir => "config", :archive => "config.zip"
26
10
 
27
- Zip::ZipFile.open("../test1.zip") do |zipfile|
28
- zipfile.find_entry('test1/test2/test3/zipit_spec.rb').should_not be_nil
29
- end
11
+ reader = Zip::Reader.new "config.zip"
12
+ reader.list.should include("config/application.rb")
30
13
  end
31
14
 
32
15
  it "should not include test2" do
33
- subject.zip :archive => "../test2.zip", :dir => "test", :excludes => ["test2"]
16
+ subject.zip :dir => "config", :archive => "config.zip", :excludes => ["config/environments"]
34
17
 
35
- Zip::ZipFile.open("../test2.zip") do |zipfile|
36
- zipfile.find_entry('test1/test2/test3/zipit_spec.rb').should be_nil
37
- end
18
+ reader = Zip::Reader.new "config.zip"
19
+ reader.list.should_not include("config/environments/test.rb")
38
20
  end
39
21
  end
40
22
  end
@@ -1,54 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{zipit}
8
- s.version = "0.3.5"
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/zipit/version')
9
4
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Alexander Shvets"]
12
- s.date = %q{2011-08-26}
13
- s.default_executable = %q{zipit}
14
- s.description = %q{Rake helper for zipping/unzipping project files.}
15
- s.email = %q{alexander.shvets@gmail.com}
16
- s.executables = ["zipit"]
17
- s.extra_rdoc_files = [
18
- "README"
19
- ]
20
- s.files = [
21
- "CHANGES",
22
- "README",
23
- "Rakefile",
24
- "VERSION",
25
- "bin/zipit",
26
- "bin/zipit.bat",
27
- "lib/zipit.rb",
28
- "zipit.gemspec"
29
- ]
30
- s.homepage = %q{http://github.com/shvets/zipit}
31
- s.require_paths = ["lib"]
32
- s.requirements = ["none"]
33
- s.rubygems_version = %q{1.6.2}
34
- s.summary = %q{Rake helper for zipping/unzipping project files. (Summary).}
35
- s.test_files = [
36
- "spec/zipit_spec.rb"
37
- ]
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "zipit"
7
+ spec.summary = %q{Rake helper for zipping/unzipping project files. (Summary).}
8
+ spec.description = %q{Rake helper for zipping/unzipping project files.}
9
+ spec.email = "alexander.shvets@gmail.com"
10
+ spec.authors = ["Alexander Shvets"]
11
+ spec.homepage = "http://github.com/shvets/zipit"
38
12
 
39
- if s.respond_to? :specification_version then
40
- s.specification_version = 3
13
+ spec.files = `git ls-files`.split($\)
14
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ spec.bindir = "bin"
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+ spec.version = Zipit::VERSION
41
19
 
42
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
- s.add_runtime_dependency(%q<zip>, [">= 0"])
44
- s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.4"])
45
- else
46
- s.add_dependency(%q<zip>, [">= 0"])
47
- s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
48
- end
49
- else
50
- s.add_dependency(%q<zip>, [">= 0"])
51
- s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
52
- end
20
+ spec.add_runtime_dependency "zip_dsl", [">= 0"]
21
+ spec.add_development_dependency "gemspec_deps_gen", [">= 0"]
22
+ spec.add_development_dependency "gemcutter", [">= 0"]
23
+
53
24
  end
54
-
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/zipit/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "zipit"
7
+ spec.summary = %q{Rake helper for zipping/unzipping project files. (Summary).}
8
+ spec.description = %q{Rake helper for zipping/unzipping project files.}
9
+ spec.email = "alexander.shvets@gmail.com"
10
+ spec.authors = ["Alexander Shvets"]
11
+ spec.homepage = "http://github.com/shvets/zipit"
12
+
13
+ spec.files = `git ls-files`.split($\)
14
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ spec.bindir = "bin"
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+ spec.version = Zipit::VERSION
19
+
20
+ <%= include_dependencies %>
21
+ end
metadata CHANGED
@@ -1,104 +1,122 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: zipit
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.6
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 5
10
- version: 0.3.5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Alexander Shvets
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-26 00:00:00 -04:00
19
- default_executable: zipit
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
12
+ date: 2012-06-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: zip_dsl
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :runtime
24
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- name: zip
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: gemspec_deps_gen
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
36
39
  prerelease: false
37
- type: :runtime
38
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: gemcutter
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 51
44
- segments:
45
- - 0
46
- - 9
47
- - 4
48
- version: 0.9.4
49
- name: rubyzip
50
- version_requirements: *id002
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
51
62
  description: Rake helper for zipping/unzipping project files.
52
63
  email: alexander.shvets@gmail.com
53
- executables:
64
+ executables:
54
65
  - zipit
66
+ - zipit.bat
55
67
  extensions: []
56
-
57
- extra_rdoc_files:
58
- - README
59
- files:
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - .idea/.name
72
+ - .idea/.rakeTasks
73
+ - .idea/cssxfire.xml
74
+ - .idea/encodings.xml
75
+ - .idea/misc.xml
76
+ - .idea/modules.xml
77
+ - .idea/scopes/scope_settings.xml
78
+ - .idea/vcs.xml
79
+ - .idea/workspace.xml
80
+ - .idea/zipit.iml
81
+ - .rvmrc
60
82
  - CHANGES
83
+ - Gemfile
84
+ - Gemfile.lock
61
85
  - README
62
86
  - Rakefile
63
- - VERSION
64
87
  - bin/zipit
65
88
  - bin/zipit.bat
66
89
  - lib/zipit.rb
67
- - zipit.gemspec
90
+ - lib/zipit/version.rb
91
+ - lib/zipit/zipit.rb
92
+ - spec/spec_helper.rb
68
93
  - spec/zipit_spec.rb
69
- has_rdoc: true
94
+ - zipit.gemspec
95
+ - zipit.gemspec.erb
70
96
  homepage: http://github.com/shvets/zipit
71
97
  licenses: []
72
-
73
98
  post_install_message:
74
99
  rdoc_options: []
75
-
76
- require_paths:
100
+ require_paths:
77
101
  - lib
78
- required_ruby_version: !ruby/object:Gem::Requirement
102
+ required_ruby_version: !ruby/object:Gem::Requirement
79
103
  none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- hash: 3
84
- segments:
85
- - 0
86
- version: "0"
87
- required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
109
  none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
96
- requirements:
97
- - none
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
98
115
  rubyforge_project:
99
- rubygems_version: 1.6.2
116
+ rubygems_version: 1.8.23
100
117
  signing_key:
101
118
  specification_version: 3
102
119
  summary: Rake helper for zipping/unzipping project files. (Summary).
103
- test_files:
120
+ test_files:
121
+ - spec/spec_helper.rb
104
122
  - spec/zipit_spec.rb