zipit 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -4,3 +4,7 @@
4
4
  == Version 0.1.0
5
5
 
6
6
  * Initial release.
7
+
8
+ == Version 0.2.0
9
+
10
+ * Adding binary zipit.
data/Rakefile CHANGED
@@ -1,9 +1,6 @@
1
1
  # Rakefile for zipit
2
2
 
3
- require "lib/zip_it"
4
-
5
- # require 'rake'
6
- # require 'rake/gempackagetask'
3
+ require "lib/zipit_helper"
7
4
 
8
5
  task :default => :zip
9
6
 
@@ -11,3 +8,9 @@ task :zip do
11
8
  zip :archive => "zipit.zip", :dir => "."
12
9
  end
13
10
 
11
+ desc "Run gem code locally"
12
+ task :"run:gem" do
13
+ command = "bin/zipit $1 $2"
14
+ puts ruby("#{command}")
15
+ end
16
+
data/bin/zipit ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems' unless RUBY_VERSION =~ /1.9.*/
4
+
5
+ #!/usr/bin/env ruby
6
+
7
+ $:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
8
+
9
+ require 'zipit_helper'
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
81
+
data/bin/zipit.bat ADDED
@@ -0,0 +1,6 @@
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" %*
data/zipit.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{zipit}
5
- s.version = "0.1.0"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.description = %q{Rake helper for zipping/unzipping project files.}
12
12
  s.email = %q{alexander.shvets@gmail.com}
13
13
 
14
- s.files = ["CHANGES", "zipit.gemspec", "Rakefile", "README", "lib/zip_it.rb"]
14
+ s.files = ["CHANGES", "zipit.gemspec", "Rakefile", "README", "bin/zipit", 'bin/zipit.bat']
15
15
 
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://github.com/shvets/zipit}
@@ -26,4 +26,6 @@ Gem::Specification.new do |s|
26
26
 
27
27
  s.platform = Gem::Platform::RUBY
28
28
  s.requirements = ["none"]
29
+ s.executables = ['zipit']
30
+ s.bindir = "bin"
29
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
@@ -15,8 +15,8 @@ dependencies: []
15
15
 
16
16
  description: Rake helper for zipping/unzipping project files.
17
17
  email: alexander.shvets@gmail.com
18
- executables: []
19
-
18
+ executables:
19
+ - zipit
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files: []
@@ -26,7 +26,8 @@ files:
26
26
  - zipit.gemspec
27
27
  - Rakefile
28
28
  - README
29
- - lib/zip_it.rb
29
+ - bin/zipit
30
+ - bin/zipit.bat
30
31
  has_rdoc: true
31
32
  homepage: http://github.com/shvets/zipit
32
33
  licenses: []
data/lib/zip_it.rb DELETED
@@ -1,69 +0,0 @@
1
- require 'zip/zip'
2
-
3
- class ZipIt
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
- #puts new_name
26
-
27
- #unless contains?(@excludes, full_name) and not contains?(@includes, full_name)
28
- if (match?(new_name, @global_excludes) or match?(new_name, @excludes)) and
29
- not match?(new_name, @includes)
30
- ;
31
- else
32
- puts "Adding #{new_name} ..."
33
- # Create a new entry with some arbitrary name
34
- zos.put_next_entry(new_name)
35
- # Add the contents of the file, don't read the stuff linewise if its binary, instead use direct IO
36
- zos.print IO.read(name + '/' + filename)
37
- end
38
- end
39
- end
40
- end
41
- end
42
-
43
- # def contains? name, list
44
- # list.each do |element|
45
- # pos = name =~ /#{element}/
46
- # pos = pos.nil? ? -1 : pos
47
- #
48
- # return true if pos >=0
49
- # end
50
- #
51
- # false
52
- # end
53
-
54
- def match? name, list
55
- list.each do |pattern|
56
- return true if File.fnmatch(pattern, name)
57
- end
58
-
59
- false
60
- end
61
- end
62
-
63
- def zip params
64
- zipit = ZipIt.new
65
-
66
- zipit.create_zip_file(
67
- :file_name => params[:archive], :dir => params[:dir],
68
- :global_excludes => ['.svn'], :excludes => ["*.zip"])
69
- end