zipit 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/Rakefile +21 -1
  2. data/VERSION +1 -0
  3. data/bin/zipit +1 -70
  4. data/lib/zipit_helper.rb +64 -0
  5. data/zipit.gemspec +33 -16
  6. metadata +39 -19
  7. data/bin/zipit.bat +0 -6
data/Rakefile CHANGED
@@ -8,9 +8,29 @@ task :zip do
8
8
  zip :archive => "zipit.zip", :dir => "."
9
9
  end
10
10
 
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", "README", "VERSION", "lib/**/*"]
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
+
11
31
  desc "Run gem code locally"
12
32
  task :"run:gem" do
13
- command = "bin/zipit $1 $2"
33
+ command = "bin/zipit a.zip ."
14
34
  puts ruby("#{command}")
15
35
  end
16
36
 
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.1
data/bin/zipit CHANGED
@@ -8,74 +8,5 @@ $:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
8
8
 
9
9
  require 'zipit_helper'
10
10
 
11
- #$KCODE='u'
12
-
13
- # class ZipIt
14
- #
15
- # # USAGE= <<-TEXT
16
- # # Usage:
17
- # # translate list - displays the list of supported languages
18
- # # translate detect "hello world" - detects language of text
19
- # # translate en:ru "hello world" - translates from en to ru
20
- # # translate ru "hello world" - translated from auto-detected language to ru
21
- # # TEXT
22
- #
23
- # def initialize
24
- # @zipit = ZipItHelper.new
25
- # end
26
- #
27
- # def print_languages list, title
28
- # puts title
29
- # puts list.join(', ')
30
- # end
31
- #
32
- # def display text
33
- # if RUBY_PLATFORM =~ /mswin32/
34
- # File.open("temp.txt", "w") {|f| f.write text }
35
- # %x[notepad temp.txt]
36
- # else
37
- # puts text
38
- # end
39
- # end
40
- #
41
- # def run
42
- # if(ARGV.size == 0)
43
- # puts USAGE and return
44
- # end
45
- #
46
- # case ARGV.shift
47
- #
48
- # when 'list' then
49
- # hash = @translator.supported_languages
50
- #
51
- # print_languages hash[:from_languages], "From Languages:"
52
- # print_languages hash[:to_languages], "To Languages:"
53
- # when 'detect' then
54
- # language = @translator.detect_language(ARGV.shift)
55
- #
56
- # puts "Language: #{language.inspect}"
57
- # when /(..):(..)/ then
58
- # from_text = ARGV.join(' ')
59
- # from = $1
60
- # to = $2
61
- #
62
- # display(@translator.translate(from.to_sym, to.to_sym, from_text))
63
- # when /(..)/ then
64
- # from_text = ARGV.join(' ')
65
- #
66
- # from = @translator.detect_language(from_text)['language']
67
- # to = $1
68
- #
69
- # begin
70
- # display(@translator.translate(from.to_sym, to.to_sym, from_text))
71
- # rescue Exception => e
72
- # puts "Error: " + e.message
73
- # end
74
- # end
75
- # end
76
- # end
77
- #
78
- # Translate.new.run
79
-
80
- zip ARGV
11
+ zip_cmd_line ARGV
81
12
 
@@ -0,0 +1,64 @@
1
+ require 'zip/zip'
2
+
3
+ class ZipitHelper
4
+ def create_zip_file params
5
+ file_name = params[:file_name]
6
+ dir = params[:dir]
7
+ @global_excludes = params[:global_excludes].nil? ? [] : params[:global_excludes]
8
+ @includes = params[:includes].nil? ? [] : params[:includes]
9
+ @excludes = params[:excludes].nil? ? [] : params[:excludes]
10
+
11
+ Zip::ZipOutputStream.open(file_name) do |zos|
12
+ zip(zos, dir, dir)
13
+ end
14
+ end
15
+
16
+ def zip zos, name, basedir
17
+ Dir.new(name).each do |filename|
18
+ if(filename != '.' and filename != '..')
19
+ full_name = name + '/' + filename
20
+
21
+ if File.directory? full_name
22
+ zip(zos, full_name, basedir)
23
+ else
24
+ new_name = full_name[basedir.length+1..full_name.length]
25
+
26
+ if (match?(new_name, @global_excludes) or match?(new_name, @excludes)) and
27
+ not match?(new_name, @includes)
28
+ ;
29
+ else
30
+ puts "Adding #{new_name} ..."
31
+ # Create a new entry with some arbitrary name
32
+ zos.put_next_entry(new_name)
33
+ # Add the contents of the file, don't read the stuff linewise if its binary, instead use direct IO
34
+ zos.print IO.read(name + '/' + filename)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ def match? name, list
42
+ list.each do |pattern|
43
+ return true if File.fnmatch(pattern, name)
44
+ end
45
+
46
+ false
47
+ end
48
+ end
49
+
50
+ def zip_cmd_line params
51
+ zipit = ZipitHelper.new
52
+
53
+ zipit.create_zip_file(
54
+ :file_name => params[0], :dir => params[1],
55
+ :global_excludes => ['.svn'], :excludes => ["*.zip"])
56
+ end
57
+
58
+ def zip params
59
+ zipit = ZipitHelper.new
60
+
61
+ zipit.create_zip_file(
62
+ :file_name => params[:archive], :dir => params[:dir],
63
+ :global_excludes => ['.svn'], :excludes => ["*.zip"])
64
+ end
@@ -1,31 +1,48 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{zipit}
5
- s.version = "0.2.0"
8
+ s.version = "0.3.1"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
-
9
11
  s.authors = ["Alexander Shvets"]
10
- s.date = %q{2010-02-02}
12
+ s.date = %q{2010-05-11}
13
+ s.default_executable = %q{zipit}
11
14
  s.description = %q{Rake helper for zipping/unzipping project files.}
12
15
  s.email = %q{alexander.shvets@gmail.com}
13
-
14
- s.files = ["CHANGES", "zipit.gemspec", "Rakefile", "README", "bin/zipit", 'bin/zipit.bat']
15
-
16
- s.has_rdoc = true
16
+ s.executables = ["zipit"]
17
+ s.extra_rdoc_files = [
18
+ "README"
19
+ ]
20
+ s.files = [
21
+ "CHANGES",
22
+ "README",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/zipit_helper.rb",
26
+ "zipit.gemspec"
27
+ ]
17
28
  s.homepage = %q{http://github.com/shvets/zipit}
29
+ s.rdoc_options = ["--charset=UTF-8"]
18
30
  s.require_paths = ["lib"]
19
- s.rubyforge_project = %q{zipit}
20
- s.rubygems_version = %q{1.3.2}
21
- s.summary = %q{Rake helper for zipping/unzipping project files.}
31
+ s.requirements = ["none"]
32
+ s.rubygems_version = %q{1.3.6}
33
+ s.summary = %q{Rake helper for zipping/unzipping project files. (Summary).}
22
34
 
23
35
  if s.respond_to? :specification_version then
24
- s.specification_version = 2
25
- end
36
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
37
+ s.specification_version = 3
26
38
 
27
- s.platform = Gem::Platform::RUBY
28
- s.requirements = ["none"]
29
- s.executables = ['zipit']
30
- s.bindir = "bin"
39
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
+ s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.4"])
41
+ else
42
+ s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
43
+ end
44
+ else
45
+ s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
46
+ end
31
47
  end
48
+
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 1
9
+ version: 0.3.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Alexander Shvets
@@ -9,52 +14,67 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-02 00:00:00 -05:00
13
- default_executable:
14
- dependencies: []
15
-
17
+ date: 2010-05-11 00:00:00 -04:00
18
+ default_executable: zipit
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rubyzip
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 9
30
+ - 4
31
+ version: 0.9.4
32
+ type: :runtime
33
+ version_requirements: *id001
16
34
  description: Rake helper for zipping/unzipping project files.
17
35
  email: alexander.shvets@gmail.com
18
36
  executables:
19
37
  - zipit
20
38
  extensions: []
21
39
 
22
- extra_rdoc_files: []
23
-
40
+ extra_rdoc_files:
41
+ - README
24
42
  files:
25
43
  - CHANGES
26
- - zipit.gemspec
27
- - Rakefile
28
44
  - README
29
- - bin/zipit
30
- - bin/zipit.bat
45
+ - Rakefile
46
+ - VERSION
47
+ - lib/zipit_helper.rb
48
+ - zipit.gemspec
31
49
  has_rdoc: true
32
50
  homepage: http://github.com/shvets/zipit
33
51
  licenses: []
34
52
 
35
53
  post_install_message:
36
- rdoc_options: []
37
-
54
+ rdoc_options:
55
+ - --charset=UTF-8
38
56
  require_paths:
39
57
  - lib
40
58
  required_ruby_version: !ruby/object:Gem::Requirement
41
59
  requirements:
42
60
  - - ">="
43
61
  - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
44
64
  version: "0"
45
- version:
46
65
  required_rubygems_version: !ruby/object:Gem::Requirement
47
66
  requirements:
48
67
  - - ">="
49
68
  - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
50
71
  version: "0"
51
- version:
52
72
  requirements:
53
73
  - none
54
- rubyforge_project: zipit
55
- rubygems_version: 1.3.5
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.6
56
76
  signing_key:
57
- specification_version: 2
58
- summary: Rake helper for zipping/unzipping project files.
77
+ specification_version: 3
78
+ summary: Rake helper for zipping/unzipping project files. (Summary).
59
79
  test_files: []
60
80
 
@@ -1,6 +0,0 @@
1
- @ECHO OFF
2
- IF NOT "%~f0" == "~f0" GOTO :WinNT
3
- @"ruby.exe" "C:/Ruby/ruby-1.9.1/bin/zipit" %1 %2 %3 %4 %5 %6 %7 %8 %9
4
- GOTO :EOF
5
- :WinNT
6
- @"ruby.exe" "%~dpn0" %*