easy_zip 0.1.0 → 0.1.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 +4 -4
- data/README.md +2 -0
- data/lib/easy_zip/file.rb +44 -0
- data/lib/easy_zip/version.rb +1 -1
- data/lib/easy_zip.rb +5 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c06256836d2201077f6e3b09a0928ea8bd2a854
|
4
|
+
data.tar.gz: ba40b0466a51bea72869e793143e8486369d3a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a12043480bbc974d30f32e7bc11c1b12033c4fa1f7a69a5ee88370da572459e9ce13b6e3ef34f34f0cfbbdc040d13fa051ea6d2bfa9df49980efe40d28f56501
|
7
|
+
data.tar.gz: fbb098d5d549cf13ee9318f116d7df4a65f93336b848efd6f36324bcefe633fbb92dd1bcc569ba9f588a29bdea0e107592bf38ceaabe1ee65224828e1ccab3bb
|
data/README.md
CHANGED
@@ -26,6 +26,8 @@ Or install it yourself as:
|
|
26
26
|
```ruby
|
27
27
|
# read lines from gzip.
|
28
28
|
EasyZip::Gzip.read_lines('read gzip filepath')
|
29
|
+
# write value to gzip.
|
30
|
+
EasyZip::Gzip.write_lines('write gzip filepath', 'write value')
|
29
31
|
# write lines to gzip.
|
30
32
|
EasyZip::Gzip.write_lines('write gzip filepath', ['first', 'second', 'third'])
|
31
33
|
```
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
|
3
|
+
# easy zip module.
|
4
|
+
module EasyZip
|
5
|
+
|
6
|
+
# file class.
|
7
|
+
class File
|
8
|
+
|
9
|
+
# read all lines in gzip file.
|
10
|
+
# @param [String] filepath read filepath.
|
11
|
+
# @return [Array] file lines.
|
12
|
+
def self.read_lines(filepath)
|
13
|
+
|
14
|
+
lines = nil
|
15
|
+
# read gzip file, and read all lines.
|
16
|
+
Zlib::GzipReader.open(filepath) { |gz|
|
17
|
+
lines = gz.readlines
|
18
|
+
}
|
19
|
+
|
20
|
+
lines
|
21
|
+
end
|
22
|
+
|
23
|
+
# write all lines to gzip file.
|
24
|
+
# @param [String] filepath write filepath.
|
25
|
+
# @param [String / Array] values write value or lines(Array).
|
26
|
+
def self.write_lines(filepath, values)
|
27
|
+
|
28
|
+
lines = nil
|
29
|
+
# if values is String, create new Array instance.
|
30
|
+
if values.is_a?(String)
|
31
|
+
lines = [values]
|
32
|
+
elsif values.is_a?(Array)
|
33
|
+
lines = values
|
34
|
+
end
|
35
|
+
|
36
|
+
Zlib::GzipWriter.open(filepath) { |gz|
|
37
|
+
# write to gzip file.
|
38
|
+
lines.each { |line|
|
39
|
+
gz.puts(line)
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/easy_zip/version.rb
CHANGED
data/lib/easy_zip.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "easy_zip/version"
|
2
|
-
require
|
2
|
+
require "easy_zip/file"
|
3
3
|
|
4
4
|
# easy zip module.
|
5
5
|
module EasyZip
|
@@ -12,26 +12,15 @@ module EasyZip
|
|
12
12
|
# @return [Array] file lines.
|
13
13
|
def self.read_lines(filepath)
|
14
14
|
|
15
|
-
|
16
|
-
# read gzip file, and read all lines.
|
17
|
-
Zlib::GzipReader.open(filepath) { |gz|
|
18
|
-
lines = gz.readlines
|
19
|
-
}
|
20
|
-
|
21
|
-
lines
|
15
|
+
EasyZip::File.read_lines(filepath)
|
22
16
|
end
|
23
17
|
|
24
18
|
# write all lines to gzip file.
|
25
19
|
# @param [String] filepath write filepath.
|
26
|
-
# @param [Array]
|
27
|
-
def self.write_lines(filepath,
|
20
|
+
# @param [String / Array] values write value or lines(Array).
|
21
|
+
def self.write_lines(filepath, values)
|
28
22
|
|
29
|
-
|
30
|
-
# write to gzip file.
|
31
|
-
lines.each { |line|
|
32
|
-
gz.puts(line)
|
33
|
-
}
|
34
|
-
}
|
23
|
+
EasyZip::File.write_lines(filepath, values)
|
35
24
|
end
|
36
25
|
end
|
37
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_zip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- h.shigemoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- bin/setup
|
73
73
|
- easy_zip.gemspec
|
74
74
|
- lib/easy_zip.rb
|
75
|
+
- lib/easy_zip/file.rb
|
75
76
|
- lib/easy_zip/version.rb
|
76
77
|
homepage: https://github.com/koyupi/easy_zip
|
77
78
|
licenses:
|