zip_generator 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTVkMWQ3ODMzNDdmYjQ3NWRiNzI5YmIzNTI4ZjkxZmQ5NGRlYjRkZA==
5
+ data.tar.gz: !binary |-
6
+ NDAyYzIzYjE3N2Y2YjY3NzRiZjI5MTNlOTE3MGZkYzJkN2I2MjFlOA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTIyMzRhOTU1MGNkOTBkNTUyN2JjMmVlNjZmNDYwOTAyZjU1YWFkNzAxYjM5
10
+ NDI2NTNlZTRjYzk0MzUzNGZiODk2YTViNTc0Y2M4N2E3NTE2YjBhNzU3YmEz
11
+ ZDYzNmQxNGY4NzZlMmEzNzM2YTZmNjJjODQzYmM1MDEwNWVmYmM=
12
+ data.tar.gz: !binary |-
13
+ YTcyMDQ3NDRlODQxNTY0ZTkwMDllZWU5MzQ0MTE5MWVmOGFiNGM2NjFkMmVi
14
+ NjJmNTkwYTljYTk3Njc4NTIxNDZjM2U4NzM3OGVhMDIzY2JkOWRjZGQ3NWU4
15
+ OGQ3MWQ3NTAyOWNkMDA3ZTY0MzJmYzM0MWMyNzYzOTY2OWI2MWY=
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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zip_generator.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ankita Kanitkar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ankita Kanitkar
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.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # ZipGenerator
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'zip_generator'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install zip_generator
18
+
19
+ ## Usage
20
+ Zip generatoris a small customization added on top of ruby zip.
21
+ Helps to create a zip file from array of files. Files should be in specific format : {name: "File Name" , data: "File Content"}
22
+
23
+ TODO: Extend funtinality for various formats.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( http://github.com/[my-github-username]/zip_generator/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ require "zip_generator/version"
2
+ require "zip"
3
+ require "zip/zipfilesystem"
4
+
5
+ module ZipGenerator
6
+ # Your code goes here...
7
+ def self.generate_zip_files files
8
+ #files should be an array of Hash {data: file_content ,name: file_name}
9
+ begin
10
+ stringio = Zip::ZipOutputStream::write_buffer do |zio|
11
+ files.each do |key|
12
+ if key.has_key?('name'.to_sym)
13
+ zio.put_next_entry(key['name'])
14
+ zio.write key['data']
15
+ else
16
+ raise "Format Error"
17
+ end
18
+ end
19
+ end
20
+ stringio.rewind
21
+ stringio.sysread
22
+ rescue => msg
23
+ msg
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module ZipGenerator
2
+ VERSION = "0.0.1"
3
+ end
File without changes
@@ -0,0 +1,18 @@
1
+ require 'zip_generator'
2
+ require 'spec_helper'
3
+
4
+ describe ZipGenerator do
5
+
6
+ it "should return a zipped file containing all the files supplied as array" do
7
+ file1 = {data: File.open("file1.txt", "w+") {|f| f.write("File Content for file 1") } , name: "file1.txt"}
8
+ file2 = {data: File.open("file2.txt", "w+") {|f| f.write("File content for file 2") } , name: "file2.txt"}
9
+ file_arr = [file1,file2]
10
+ zipped = ZipGenerator.generate_zip_files(file_arr)
11
+ zipped.should be_a_kind_of(String)
12
+ end
13
+ it "should raise error" do
14
+ file1 = {content: File.open("file1.txt", "w+") {|f| f.write("File Content for file 1")} }
15
+ zipped = ZipGenerator.generate_zip_files([file1])
16
+ zipped.should be_a_kind_of(RuntimeError)
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zip_generator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "zip_generator"
8
+ spec.version = ZipGenerator::VERSION
9
+ spec.authors = ["Ankita Kanitkar","Hemali Jain"]
10
+ spec.email = ["ankitakanitkar@gmail.com"]
11
+ spec.summary = %q{Generate a zip file from array of files}
12
+ spec.description = %q{Generate a zip file from array of files}
13
+ spec.homepage = "https://github.com/ankitakanitkar/zip_generator"
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_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_runtime_dependency "rubyzip", "~>1.0.0"
24
+ spec.add_runtime_dependency "zip-zip"
25
+ spec.add_development_dependency "rspec-rails"
26
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zip_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ankita Kanitkar
8
+ - Hemali Jain
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-07-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.6'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.6'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rubyzip
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: 1.0.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 1.0.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: zip-zip
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec-rails
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: Generate a zip file from array of files
85
+ email:
86
+ - ankitakanitkar@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/zip_generator.rb
98
+ - lib/zip_generator/version.rb
99
+ - spec/spec_helper.rb
100
+ - spec/zip_generator_spec.rb
101
+ - zip_generator.gemspec
102
+ homepage: https://github.com/ankitakanitkar/zip_generator
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.2.2
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Generate a zip file from array of files
126
+ test_files:
127
+ - spec/spec_helper.rb
128
+ - spec/zip_generator_spec.rb