pg_export 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 201f8536eee374325ff46fed2abb128fb84e74f8
4
- data.tar.gz: 6ca8e88f017d709370c865255bbaad5ca5831ad8
3
+ metadata.gz: 1c28369f4ecffa9479ea9f20505f09b7354ae5c6
4
+ data.tar.gz: d833bbf0099e4b6640fdc8adca851aeb559a453f
5
5
  SHA512:
6
- metadata.gz: 6f40ec721d54b90c848c80a196170ed99a4c6369750dc7f2537dbbe38e477e28fa73aff6b7062c989760df569846fe14aa052e92ae03fc7f73ce86b821e03b5e
7
- data.tar.gz: 68a3f91e02b7562d88874c531cee8ccf121d864d42b66bebb259c4f127d009afbd9f7cc69817887d60bbc64303eec6d06529b74ffc407ada44adbf89bc727162
6
+ metadata.gz: 24db2448717fa02e6a35273ae53b356f1906441cad18e38fbf1c52eedd141dfc680e7d0be3c232c8fcc9dd282f24483199c29f8f81f7643230c1ec2497731c1e
7
+ data.tar.gz: 7fe5392339e1acea375ac7e235ee09652c9f0f72a8ced4aa80061f0c3dac90b532a9b04a88e9955faf220a8e291d005ca0f1f3d12d5914f994aeac04add52b26
@@ -16,7 +16,7 @@ class PgExport
16
16
  raise 'Overwrite it'
17
17
  end
18
18
 
19
- def read_chunk
19
+ def open
20
20
  raise 'Overwrite it'
21
21
  end
22
22
 
@@ -8,8 +8,12 @@ class PgExport
8
8
  ''
9
9
  end
10
10
 
11
- def read_chunk
12
- read(CHUNK_SIZE)
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
- dump_gz.open(:write) do |gz|
16
- gz.write(dump.read_chunk) until dump.eof?
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(gz.readpartial(Dump::Base::CHUNK_SIZE)) until gz.eof?
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
@@ -1,3 +1,3 @@
1
1
  class PgExport
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '0.3.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Maicher