multiple_files_gzip_reader 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/multiple_files_gzip_reader.rb +55 -0
- data/lib/multiple_files_gzip_reader/version.rb +3 -0
- data/multiple_files_gzip_reader.gemspec +26 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: e2c7e52132d1df16b32598b0e5b1e02f71a7804f
|
4
|
+
data.tar.gz: c1b7af5609c9c786d351649925631060dc9206a7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9e7fd1f678abd6d50e0b99133352826c4f2055fc72d734b0ec09210fa15db02cc0a6824c08a378cc7b64cecd758a2358ff2a6339b0c85639e58260b9ed1261c
|
7
|
+
data.tar.gz: 1784dbcfdb713b3179127d8baae2f1a99abfe504d1015216b462e218f844bf5a34a4221fce094b0483b36dda4bf03adc29a30dda5c08d9cfd20c9ed559b0b155
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 exAspArk
|
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,67 @@
|
|
1
|
+
# MultipleFilesGzipReader
|
2
|
+
|
3
|
+
It is a library which allows to read a gzip archive with multiple files in it.
|
4
|
+
|
5
|
+
Currently Ruby standard library called `Zlib::GzipReader` cannot do this: [issue](https://bugs.ruby-lang.org/issues/9790), [issue](https://bugs.ruby-lang.org/issues/11180).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'multiple_files_gzip_reader'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install multiple_files_gzip_reader
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
`Zlib::GzipReader`:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
> file = File.open("test/fixtures/test.json.gz")
|
29
|
+
|
30
|
+
> Zlib::GzipReader.new(file).each_line { |line| puts line }
|
31
|
+
# foo
|
32
|
+
# => nil
|
33
|
+
```
|
34
|
+
|
35
|
+
`MultipleFilesGzipReader`:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
> file = File.open("test/fixtures/test.json.gz")
|
39
|
+
|
40
|
+
> MultipleFilesGzipReader.new(file).each_line { |line| puts line }
|
41
|
+
# foo
|
42
|
+
# bar
|
43
|
+
# => nil
|
44
|
+
|
45
|
+
> puts `gunzip -c test/fixtures/test.json.gz`
|
46
|
+
# foo
|
47
|
+
# bar
|
48
|
+
# => nil
|
49
|
+
```
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Running tests
|
58
|
+
|
59
|
+
$ ruby -Ilib:test test/multiple_files_gzip_reader_test.rb
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it ( https://github.com/[my-github-username]/multiple_files_gzip_reader/fork )
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "multiple_files_gzip_reader"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "multiple_files_gzip_reader/version"
|
2
|
+
require "zlib"
|
3
|
+
|
4
|
+
class MultipleFilesGzipReader
|
5
|
+
def initialize(io, options = {})
|
6
|
+
@io = io
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def rewind
|
11
|
+
io.pos = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def each_line(*args, &block)
|
15
|
+
loop do
|
16
|
+
gzip_reader = Zlib::GzipReader.new(io, options)
|
17
|
+
|
18
|
+
gzip_reader.each_line(*args, &block)
|
19
|
+
|
20
|
+
unused = gzip_reader.unused
|
21
|
+
gzip_reader.finish
|
22
|
+
|
23
|
+
io.pos -= unused ? unused.length : 0
|
24
|
+
break if io.pos == io.size
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def readlines(*args)
|
29
|
+
result = []
|
30
|
+
|
31
|
+
loop do
|
32
|
+
gzip_reader = Zlib::GzipReader.new(io, options)
|
33
|
+
|
34
|
+
result.concat gzip_reader.readlines(*args)
|
35
|
+
|
36
|
+
unused = gzip_reader.unused
|
37
|
+
gzip_reader.finish
|
38
|
+
|
39
|
+
io.pos -= unused ? unused.length : 0
|
40
|
+
break if io.pos == io.size
|
41
|
+
end
|
42
|
+
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def io
|
49
|
+
@io
|
50
|
+
end
|
51
|
+
|
52
|
+
def options
|
53
|
+
@options
|
54
|
+
end
|
55
|
+
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 'multiple_files_gzip_reader/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "multiple_files_gzip_reader"
|
8
|
+
spec.version = MultipleFilesGzipReader::VERSION
|
9
|
+
spec.authors = ["Evgeny Li"]
|
10
|
+
spec.email = ["exaspark@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{GzipReader for reading multiple files}
|
13
|
+
spec.description = %q{GzipReader for reading multiple files}
|
14
|
+
spec.homepage = "https://github.com/exAspArk/multiple_files_gzip_reader"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.6"
|
25
|
+
spec.add_development_dependency "pry-byebug", "~> 2.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: multiple_files_gzip_reader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Evgeny Li
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-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.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
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.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
description: GzipReader for reading multiple files
|
70
|
+
email:
|
71
|
+
- exaspark@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- bin/console
|
81
|
+
- bin/setup
|
82
|
+
- lib/multiple_files_gzip_reader.rb
|
83
|
+
- lib/multiple_files_gzip_reader/version.rb
|
84
|
+
- multiple_files_gzip_reader.gemspec
|
85
|
+
homepage: https://github.com/exAspArk/multiple_files_gzip_reader
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: GzipReader for reading multiple files
|
109
|
+
test_files: []
|
110
|
+
has_rdoc:
|