pg_export 0.3.1 → 0.3.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c28369f4ecffa9479ea9f20505f09b7354ae5c6
|
4
|
+
data.tar.gz: d833bbf0099e4b6640fdc8adca851aeb559a453f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24db2448717fa02e6a35273ae53b356f1906441cad18e38fbf1c52eedd141dfc680e7d0be3c232c8fcc9dd282f24483199c29f8f81f7643230c1ec2497731c1e
|
7
|
+
data.tar.gz: 7fe5392339e1acea375ac7e235ee09652c9f0f72a8ced4aa80061f0c3dac90b532a9b04a88e9955faf220a8e291d005ca0f1f3d12d5914f994aeac04add52b26
|
@@ -8,8 +8,12 @@ class PgExport
|
|
8
8
|
''
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def open(operation_type, &block)
|
12
|
+
case operation_type.to_sym
|
13
|
+
when :read then File.open(path, 'r', &block)
|
14
|
+
when :write then File.open(path, 'w', &block)
|
15
|
+
else raise ArgumentError, 'Operation type can be only :read or :write'
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -12,8 +12,10 @@ class PgExport
|
|
12
12
|
|
13
13
|
def self.compress(dump)
|
14
14
|
dump_gz = CompressedDump.new
|
15
|
-
|
16
|
-
|
15
|
+
dump.open(:read) do |f|
|
16
|
+
dump_gz.open(:write) do |gz|
|
17
|
+
gz.write(f.read(Dump::Base::CHUNK_SIZE)) until f.eof?
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
logger.info "Create #{dump_gz}"
|
@@ -23,9 +25,10 @@ class PgExport
|
|
23
25
|
def self.decompress(dump_gz)
|
24
26
|
dump = SqlDump.new
|
25
27
|
dump_gz.open(:read) do |gz|
|
26
|
-
dump.write
|
28
|
+
dump.open(:write) do |f|
|
29
|
+
f.write(gz.readpartial(Dump::Base::CHUNK_SIZE)) until gz.eof?
|
30
|
+
end
|
27
31
|
end
|
28
|
-
dump.rewind
|
29
32
|
|
30
33
|
logger.info "Create #{dump}"
|
31
34
|
dump
|
data/lib/pg_export/version.rb
CHANGED