zipeador 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +33 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +24 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/zipeador.rb +44 -0
- data/lib/zipeador/version.rb +3 -0
- data/zipeador.gemspec +43 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0162d37b0daaac4d30e902e74eeaf44d0a71ba5ea66f9addd920d83ae8251f56
|
4
|
+
data.tar.gz: 8d7690c903c8074c7c4d9c369c79a3238bf123cd0a955d9ec184182c2796a44d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a910300e57feae2c6beebd9f7e7a44b9d75a60fa63c1d928323bb2fde73d230caa8b0c00dd697355d418a9336ee3edab4796ac3b13cdaa5ba56847d6d4de1e0
|
7
|
+
data.tar.gz: eecbc37d6ad5cf1768122a422170c27aad32a815bfbbb68364f1e405e955ed63c1515f512dc968c2b2319eea7fb80f87a55b6e6f4bc1c9aa683f0330192ee450
|
data/.gitignore
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
|
10
|
+
*.gem
|
11
|
+
|
12
|
+
# Ignore bundler config.
|
13
|
+
/.bundle
|
14
|
+
|
15
|
+
# Ignore all logfiles and tempfiles.
|
16
|
+
/log/*
|
17
|
+
/tmp/*
|
18
|
+
!/log/.keep
|
19
|
+
!/tmp/.keep
|
20
|
+
|
21
|
+
/node_modules
|
22
|
+
/yarn-error.log
|
23
|
+
|
24
|
+
.byebug_history
|
25
|
+
# CUSTOM
|
26
|
+
.project
|
27
|
+
.DS_Store
|
28
|
+
.idea
|
29
|
+
.secret
|
30
|
+
*.test
|
31
|
+
/dump.rdb
|
32
|
+
/.env
|
33
|
+
.ruby-version
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
zipeador (0.1.1)
|
5
|
+
rubyzip (>= 1.2.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
minitest (5.11.3)
|
11
|
+
rake (10.5.0)
|
12
|
+
rubyzip (1.2.2)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
bundler (~> 1.17)
|
19
|
+
minitest (~> 5.0)
|
20
|
+
rake (~> 10.0)
|
21
|
+
zipeador!
|
22
|
+
|
23
|
+
BUNDLED WITH
|
24
|
+
1.17.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Ronald Macedo
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Zipeador
|
2
|
+
|
3
|
+
Welcome to your new gem!
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'zipeador'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install zipeador
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
```ruby
|
24
|
+
Zipeador.zip(file)
|
25
|
+
Zipeador.unzip(zipfile)
|
26
|
+
```
|
27
|
+
## Bugs
|
28
|
+
|
29
|
+
Bug reports at alf@nubefact.com
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "zipeador"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/zipeador.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "zipeador/version"
|
2
|
+
require 'securerandom'
|
3
|
+
require 'zip'
|
4
|
+
|
5
|
+
module Zipeador
|
6
|
+
class Error < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.zip(name, file)
|
10
|
+
begin
|
11
|
+
stringio = Zip::OutputStream.write_buffer do |zio|
|
12
|
+
zio.put_next_entry(name)
|
13
|
+
zio.write(file)
|
14
|
+
end
|
15
|
+
stringio.rewind
|
16
|
+
stringio.sysread
|
17
|
+
rescue => e
|
18
|
+
raise Error.new = e
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.unzip(file)
|
23
|
+
begin
|
24
|
+
filename = "#{SecureRandom.uuid}.zip"
|
25
|
+
temp_file = Tempfile.new(filename)
|
26
|
+
temp_file.binmode
|
27
|
+
temp_file.write(file)
|
28
|
+
temp_file.flush
|
29
|
+
begin
|
30
|
+
Zip::File.open(temp_file.path) do |zip_file|
|
31
|
+
#Find specific entry, PDF or XML
|
32
|
+
entry = zip_file.glob('*.xml').first || zip_file.glob('*.pdf').first
|
33
|
+
entry.get_input_stream.read
|
34
|
+
end
|
35
|
+
ensure
|
36
|
+
#Close and delete the temp file
|
37
|
+
temp_file.close
|
38
|
+
temp_file.unlink
|
39
|
+
end
|
40
|
+
rescue => e
|
41
|
+
raise Error.new = e
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/zipeador.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "zipeador/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "zipeador"
|
8
|
+
spec.version = Zipeador::VERSION
|
9
|
+
spec.authors = ["Alf Macedo Lopez"]
|
10
|
+
spec.email = ["alf@nubefact.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Tools for Zip, Unzip in memory}
|
13
|
+
spec.description = %q{Enjoy!}
|
14
|
+
spec.homepage = "https://www.nubefact.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/gems/zipeador"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/alfml/zipeador"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/alfml/zipeador"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
42
|
+
spec.add_runtime_dependency 'rubyzip', ">= 1.2.2"
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zipeador
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alf Macedo Lopez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubyzip
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.2
|
69
|
+
description: Enjoy!
|
70
|
+
email:
|
71
|
+
- alf@nubefact.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/zipeador.rb
|
86
|
+
- lib/zipeador/version.rb
|
87
|
+
- zipeador.gemspec
|
88
|
+
homepage: https://www.nubefact.com
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata:
|
92
|
+
allowed_push_host: https://rubygems.org/gems/zipeador
|
93
|
+
homepage_uri: https://www.nubefact.com
|
94
|
+
source_code_uri: https://github.com/alfml/zipeador
|
95
|
+
changelog_uri: https://github.com/alfml/zipeador
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.7.7
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Tools for Zip, Unzip in memory
|
116
|
+
test_files: []
|