pg_export 0.5.0 → 0.5.1

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: 69c56bdaa52fa25112c93ffd284cd806ce6fa707
4
- data.tar.gz: 285340dfcf4c20067d57e8d805868b453f7cbf5f
3
+ metadata.gz: 763552e9063089d2137c2eff38b159caee96f457
4
+ data.tar.gz: 445e0c662a841abf1c9ee1f3ba4fa05dc845e6e3
5
5
  SHA512:
6
- metadata.gz: 8d51c8854e8d2b4d17dd43c96e43d4e1a97af5c8653472e51898fa3018278b5126629d279e29c407ddf0233bb898da77e3f06456495604a63e2ac07f743b3ca2
7
- data.tar.gz: be9ad50fb36708db2e6232168677fc9eb8f24f4491862d37feb73230e0bd3aa550ebd19b1f4def5c6475620be2b507b54b1abce891b327cada84a1d1afbe4a86
6
+ metadata.gz: 9f8e27408b4aa14d29783f3672c456d09521cce85195fee112fbd32b8fd3b987f039a82dc28e652553fc40f63be0d80509cf05eb1299494c9beaac57ff8d7f2f
7
+ data.tar.gz: ab1c4938fbbb933735c35f806d6eca4745d240a7d749641180724ccebaba06e976b49a73762bc36eb4a7a577fdb6f2fe8e20ca41f4028cba29f8c235125c9204
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.5.1 - 2017.03.31
2
+
3
+ - Simplify Dump entity design
4
+ - Fix docs
5
+
1
6
  ### 0.5.0 - 2017.03.11
2
7
 
3
8
  - Add restriction on DUMP_ENCRYPTION_KEY, to be exactly 16 characters length
data/README.md CHANGED
@@ -71,7 +71,7 @@ __Step 1.__ Prepare FTP account and put configuration into env variables. Dumps
71
71
  BACKUP_FTP_USER="user"
72
72
  BACKUP_FTP_PASSWORD="password"
73
73
 
74
- __Step 2.__ Put dump encryption key into env variable (at least 16 characters). Dumps will be SSL(AES-128-CBC) encrypted using that key.
74
+ __Step 2.__ Put dump encryption key into env variable (exactly 16 characters). Dumps will be SSL(AES-128-CBC) encrypted using that key.
75
75
 
76
76
  # /etc/environment
77
77
  DUMP_ENCRYPTION_KEY="1234567890abcdef"
@@ -0,0 +1,48 @@
1
+ class PgExport
2
+ class Dump
3
+ extend Forwardable
4
+ include SizeHuman
5
+
6
+ CHUNK_SIZE = (2**16).freeze
7
+
8
+ def_delegators :file, :path, :read, :write, :<<, :rewind, :close, :size, :eof?
9
+
10
+ attr_reader :name
11
+
12
+ def initialize(name)
13
+ @name = name
14
+ end
15
+
16
+ def ext
17
+ ''
18
+ end
19
+
20
+ def open(operation_type, &block)
21
+ case operation_type.to_sym
22
+ when :read then File.open(path, 'r', &block)
23
+ when :write then File.open(path, 'w', &block)
24
+ else raise ArgumentError, 'Operation type can be only :read or :write'
25
+ end
26
+ end
27
+
28
+ def each_chunk
29
+ open(:read) do |file|
30
+ yield file.read(CHUNK_SIZE) until file.eof?
31
+ end
32
+ end
33
+
34
+ def to_s
35
+ "#{name} (#{size_human})"
36
+ end
37
+
38
+ private
39
+
40
+ def file
41
+ @file ||= Tempfile.new(file_name)
42
+ end
43
+
44
+ def file_name
45
+ name.downcase.gsub(/[^0-9a-z]/, '_')
46
+ end
47
+ end
48
+ end
@@ -1,5 +1,5 @@
1
1
  class PgExport
2
- module Dump
2
+ class Dump
3
3
  module SizeHuman
4
4
  def size_human
5
5
  {
@@ -2,7 +2,7 @@ class PgExport
2
2
  class Aes
3
3
  class Decryptor < Base
4
4
  def call(enc_dump)
5
- dump = PlainDump.new
5
+ dump = Dump.new('Dump')
6
6
  copy_using(cipher, from: enc_dump, to: dump)
7
7
  logger.info "Create #{dump}"
8
8
  dump
@@ -2,7 +2,7 @@ class PgExport
2
2
  class Aes
3
3
  class Encryptor < Base
4
4
  def call(dump)
5
- enc_dump = EncryptedDump.new
5
+ enc_dump = Dump.new('Encrypted Dump')
6
6
  copy_using(cipher, from: dump, to: enc_dump)
7
7
  logger.info "Create #{enc_dump}"
8
8
  enc_dump
@@ -7,7 +7,7 @@ class PgExport
7
7
  end
8
8
 
9
9
  def create_dump
10
- dump = PlainDump.new
10
+ dump = Dump.new('Dump')
11
11
  Open3.popen3("pg_dump -Fc --file #{dump.path} #{database_name}") do |_, _, err|
12
12
  error = err.read
13
13
  raise PgDumpError, error unless error.empty?
@@ -16,7 +16,7 @@ class PgExport
16
16
  end
17
17
 
18
18
  def download(name)
19
- dump = EncryptedDump.new
19
+ dump = Dump.new('Encrypted Dump')
20
20
  ftp_adapter.download_file(dump.path, name)
21
21
  logger.info "Download #{dump} #{name} from #{ftp_adapter}"
22
22
  dump
@@ -1,3 +1,3 @@
1
1
  class PgExport
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
data/lib/pg_export.rb CHANGED
@@ -12,9 +12,7 @@ require 'pg_export/includable_modules/dump/size_human'
12
12
  require 'pg_export/includable_modules/services_container'
13
13
  require 'pg_export/errors'
14
14
  require 'pg_export/configuration'
15
- require 'pg_export/entities/dump/base'
16
- require 'pg_export/entities/plain_dump'
17
- require 'pg_export/entities/encrypted_dump'
15
+ require 'pg_export/entities/dump'
18
16
  require 'pg_export/services/ftp_adapter'
19
17
  require 'pg_export/services/ftp_connection'
20
18
  require 'pg_export/services/bash_utils'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Maicher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-11 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cli_spinnable
@@ -148,9 +148,7 @@ files:
148
148
  - bin/setup
149
149
  - lib/pg_export.rb
150
150
  - lib/pg_export/configuration.rb
151
- - lib/pg_export/entities/dump/base.rb
152
- - lib/pg_export/entities/encrypted_dump.rb
153
- - lib/pg_export/entities/plain_dump.rb
151
+ - lib/pg_export/entities/dump.rb
154
152
  - lib/pg_export/errors.rb
155
153
  - lib/pg_export/includable_modules/colourable_string.rb
156
154
  - lib/pg_export/includable_modules/dump/size_human.rb
@@ -1,42 +0,0 @@
1
- class PgExport
2
- module Dump
3
- class Base
4
- extend Forwardable
5
- include SizeHuman
6
-
7
- CHUNK_SIZE = (2**16).freeze
8
-
9
- def_delegators :file, :path, :read, :write, :<<, :rewind, :close, :size, :eof?
10
-
11
- def initialize
12
- @file = Tempfile.new('dump')
13
- end
14
-
15
- def ext
16
- ''
17
- end
18
-
19
- def open(operation_type, &block)
20
- case operation_type.to_sym
21
- when :read then File.open(path, 'r', &block)
22
- when :write then File.open(path, 'w', &block)
23
- else raise ArgumentError, 'Operation type can be only :read or :write'
24
- end
25
- end
26
-
27
- def each_chunk
28
- open(:read) do |file|
29
- yield file.read(CHUNK_SIZE) until file.eof?
30
- end
31
- end
32
-
33
- def to_s
34
- "#{name || self.class} #{file.class} (#{size_human})"
35
- end
36
-
37
- private
38
-
39
- attr_reader :file
40
- end
41
- end
42
- end
@@ -1,7 +0,0 @@
1
- class PgExport
2
- class EncryptedDump < Dump::Base
3
- def name
4
- 'Encrypted Dump'
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- class PgExport
2
- class PlainDump < Dump::Base
3
- def name
4
- 'Dump'
5
- end
6
- end
7
- end