total_compressor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in total_compressor.gemspec
4
+ gemspec
5
+
6
+ gem 'awesome_print'
7
+ gem 'rubyzip', "~> 0.9.9"
8
+ gem 'rspec' , '>= 2.14'
data/LICENSE.txt ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2013 PhlowerTeam
2
+
3
+ https://github.com/phlowerteam
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # TotalCompressor
2
+
3
+ Tool (wrapper) for compression and handling multiple type of archives.
4
+
5
+ Supports next archive types:
6
+ - Zip;
7
+ - GZip;
8
+ - RAR;
9
+ - 7z.
10
+
11
+ ## Installation
12
+
13
+ Install appropriate tools before using:
14
+
15
+ apt-get install zlib1g zlib1g-dev zip rar p7zip
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ gem 'total_compressor'
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install total_compressor
28
+
29
+ ## Usage
30
+
31
+ Command line: tcomp [<key>] path
32
+ <key> - determine supported type of compression:
33
+ z - use Zip
34
+ g - use GZip
35
+ r - use RAR
36
+ 7 - use 7z
37
+
38
+ Examples:
39
+ tcomp z '/home/alex/The Lord of the Rings.txt' # creates '/home/alex/The Lord of the Rings.txt.zip'
40
+ tcomp /home/alex/Hobbit.txt.7z # creates /home/alex/Hobbit.txt
41
+
42
+ API:
43
+
44
+ require 'total_compressor'
45
+
46
+ TotalCompressor.compress('/home/alex/Hobbit.txt', 'zip') # => '/home/alex/Hobbit.txt.zip'
47
+ TotalCompressor.compress('/home/alex/Hobbit.txt', 'gzip') # => '/home/alex/Hobbit.txt.gzip'
48
+ TotalCompressor.compress('/home/alex/Hobbit.txt', 'rar') # => '/home/alex/Hobbit.txt.rar'
49
+ TotalCompressor.compress('/home/alex/Hobbit.txt', '7z') # => '/home/alex/Hobbit.txt.7z'
50
+
51
+ TotalCompressor.decompress('/home/alex/Hobbit.txt.7z') # => '/home/alex/Hobbit.txt'
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create new Pull Request
60
+
61
+ ## Contacts
62
+
63
+ https://github.com/phlowerteam
64
+
65
+ phlowerteam@gmail.com
66
+
67
+ ## License
68
+
69
+ Copyright (c) 2013 PhlowerTeam
70
+
71
+ MIT License
72
+
73
+ Permission is hereby granted, free of charge, to any person obtaining
74
+ a copy of this software and associated documentation files (the
75
+ "Software"), to deal in the Software without restriction, including
76
+ without limitation the rights to use, copy, modify, merge, publish,
77
+ distribute, sublicense, and/or sell copies of the Software, and to
78
+ permit persons to whom the Software is furnished to do so, subject to
79
+ the following conditions:
80
+
81
+ The above copyright notice and this permission notice shall be
82
+ included in all copies or substantial portions of the Software.
83
+
84
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
87
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
88
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
89
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
90
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/tcomp ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'total_compressor'
4
+
5
+ TotalCompressor.cmdline
@@ -0,0 +1,77 @@
1
+ require 'total_compressor/version'
2
+ require 'zip/zip'
3
+ require 'awesome_print'
4
+
5
+ module TotalCompressor
6
+ class BaseCompressor; end
7
+ class TZip < BaseCompressor; end
8
+ class TGzip < BaseCompressor; end
9
+ class TRar < BaseCompressor; end
10
+ class T7z < BaseCompressor; end
11
+
12
+ class << self
13
+ def cmdline
14
+ case ARGV.size
15
+ when 1
16
+ decompress(ARGV[0])
17
+ when 2
18
+ compress(ARGV[1], BaseCompressor::HASH_TYPE[ARGV[0]]) if BaseCompressor::HASH_TYPE[ARGV[0]]
19
+ else
20
+ raise
21
+ end
22
+ rescue
23
+ show_help
24
+ end
25
+
26
+ def compress(path, format)
27
+ if BaseCompressor::TYPE[format]
28
+ eval("TotalCompressor::T#{format.capitalize}.new.compress(\'#{path}\')")
29
+ else
30
+ ap BaseCompressor::MSG[:unsupported]
31
+ end
32
+ end
33
+
34
+ def decompress(path)
35
+ format = path.split('.')[-1]
36
+ if BaseCompressor::TYPE[format]
37
+ eval("TotalCompressor::T#{format.capitalize}.new.decompress(\'#{path}\')")
38
+ else
39
+ ap BaseCompressor::MSG[:unsupported]
40
+ end
41
+ end
42
+
43
+ def test
44
+ result = []
45
+ compressors = constants
46
+ compressors -= [:BaseCompressor, :VERSION]
47
+ compressors.each do |compressor|
48
+ result << eval("TotalCompressor::#{compressor.to_s}.new.test")
49
+ end
50
+ result
51
+ end
52
+
53
+ def show_help
54
+ puts %Q{
55
+ Total Compressor, v0.1, 2013, MIT License, https://github.com/phlowerteam
56
+ Tool (wrapper) for compression and handling multiple type of archives.
57
+
58
+ Usage: tcomp [<key>] path
59
+ <key> - determine supported type of compression:
60
+ z - use Zip
61
+ g - use GZip (can't compress folder, only file)
62
+ r - use RAR
63
+ 7 - use 7z
64
+
65
+ Examples:
66
+ tcomp z '/home/alex/The Lord of the Rings.txt' # creates '/home/alex/The Lord of the Rings.txt.zip'
67
+ tcomp /home/alex/Hobbit.txt.7z # creates /home/alex/Hobbit.txt
68
+ }
69
+ end
70
+ end
71
+ end
72
+
73
+ load 'lib/total_compressor/compressors/base_compressor.rb'
74
+ load 'lib/total_compressor/compressors/t_zip.rb'
75
+ load 'lib/total_compressor/compressors/t_gzip.rb'
76
+ load 'lib/total_compressor/compressors/t_rar.rb'
77
+ load 'lib/total_compressor/compressors/t_7z.rb'
@@ -0,0 +1,3 @@
1
+ module TotalCompressor
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ RSpec.configure do |config|
2
+ config.treat_symbols_as_metadata_keys_with_true_values = true
3
+ config.run_all_when_everything_filtered = true
4
+ config.filter_run :focus
5
+
6
+ config.order = 'random'
7
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'total_compressor'
3
+
4
+ describe TotalCompressor do
5
+ it 'Test all compressors' do
6
+ TotalCompressor.test.join.should_not match(/Failure/)
7
+ end
8
+ 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 'total_compressor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "total_compressor"
8
+ spec.version = TotalCompressor::VERSION
9
+ spec.authors = ["PhlowerTeam"]
10
+ spec.email = ["phlowerteam@gmail.com"]
11
+ spec.description = %q{Wrapper for handling multiple type of archives}
12
+ spec.summary = %q{Supports zip, gzip, rar, 7z archive types}
13
+ spec.homepage = "https://github.com/phlowerteam"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = ["tcomp"]
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+
25
+ spec.add_runtime_dependency "awesome_print"
26
+ spec.add_runtime_dependency "rubyzip", "~> 0.9.9"
27
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: total_compressor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - PhlowerTeam
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
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: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
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'
62
+ - !ruby/object:Gem::Dependency
63
+ name: awesome_print
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rubyzip
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.9.9
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.9.9
94
+ description: Wrapper for handling multiple type of archives
95
+ email:
96
+ - phlowerteam@gmail.com
97
+ executables:
98
+ - tcomp
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - Gemfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - lib/total_compressor.rb
108
+ - lib/total_compressor/version.rb
109
+ - spec/spec_helper.rb
110
+ - spec/total_compressor_spec.rb
111
+ - total_compressor.gemspec
112
+ - bin/tcomp
113
+ homepage: https://github.com/phlowerteam
114
+ licenses:
115
+ - MIT
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ segments:
127
+ - 0
128
+ hash: -2772250057242909755
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ segments:
136
+ - 0
137
+ hash: -2772250057242909755
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 1.8.25
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: Supports zip, gzip, rar, 7z archive types
144
+ test_files:
145
+ - spec/spec_helper.rb
146
+ - spec/total_compressor_spec.rb