nxt_heroku_database_backup 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: 0c309bebb4e21b0b88474e2466ba4044ce80373e75443a8a48e34367ebdc4e31
4
- data.tar.gz: 844589c882460f11c8b09b1de1a5822a88604d5517d60ebe9d52423239966169
3
+ metadata.gz: 51f97418f01f18ca7de20dcc6f67d8598d6d8e21725c58d6f8c689918089d449
4
+ data.tar.gz: 6adfded58467cdcb883c805c3e95d584acc4d6433d55fd4df86bb82fe44253d2
5
5
  SHA512:
6
- metadata.gz: 87bae3995bcbf58bfd8f4e12d37ea4f2546c97b03c5e0a7e3c01f7704c74d53afffee49b61680c395466934c584b671eafdbfec2bb86e2ba9e26e43d4762ff21
7
- data.tar.gz: 14b8a28b34c74d2faa8366ed876c4e433cc7745ce317b525321bd2f6623d5db827aad7f4e1e2d11cd3ab30a9cc34416a50c261b910353abcbac14c07727c5b29
6
+ metadata.gz: fa2557b59d6ca4ec1aa5a8c3d2c722037f4c816ce678ac2b3809cfd3a80e1786664eb9434fe97bf30897544816a50957ddf10c9b30cb867eddfc71d62e626bd8
7
+ data.tar.gz: 83b30af454d3f11a1b6ce2ff39513d0a71c1b26b02b1b813108fe8f2e41f705e9213d1d32b1b7a963ce6425cadd60a4fad253a315352696a0150be1973b2edee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nxt_heroku_database_backup (0.1.2)
4
+ nxt_heroku_database_backup (0.1.3)
5
5
  aws-sdk-s3
6
6
  nxt_init
7
7
 
@@ -12,7 +12,7 @@ module NxtHerokuDatabaseBackup
12
12
  environment: -> { default_environment },
13
13
  backup_name: -> { default_backup_name },
14
14
  backup_tmp_path: -> { default_backup_tmp_path },
15
- uploader: -> { Uploader::S3.new(bucket_name: upload_destination, file_path: encrypted_backup_tmp_path) }
15
+ uploader: -> { Uploader::S3.build(bucket_name: upload_destination, file_path: encrypted_backup_tmp_path) }
16
16
 
17
17
 
18
18
  def backup_latest_dump
@@ -3,7 +3,17 @@ module NxtHerokuDatabaseBackup
3
3
  class S3
4
4
  include NxtInit
5
5
 
6
- attr_init :bucket_name, :file_path
6
+ attr_init :bucket_name, :file_path, :credentials
7
+
8
+ def self.build(bucket_name:, file_path:, credentials: nil)
9
+ credentials ||= {
10
+ access_key_id: ENV.fetch('DATABASE_BACKUP_AWS_ACCESS_KEY_ID'),
11
+ secret_access_key: ENV.fetch('DATABASE_BACKUP_AWS_SECRET_ACCESS_KEY'),
12
+ region: ENV.fetch('DATABASE_BACKUP_AWS_REGION')
13
+ }
14
+
15
+ new(bucket_name: bucket_name, file_path: file_path, credentials: credentials)
16
+ end
7
17
 
8
18
  def call
9
19
  aws_object.upload_file(file_path)
@@ -22,20 +32,8 @@ module NxtHerokuDatabaseBackup
22
32
  client.create_bucket(bucket: bucket_name)
23
33
  end
24
34
 
25
- def bucket_name
26
- @bucket_name ||= "#{heroku_app_name}-db-backups"
27
- end
28
-
29
35
  def client
30
- @client ||= Aws::S3::Client.new(**aws_credentials)
31
- end
32
-
33
- def aws_credentials
34
- {
35
- access_key_id: ENV.fetch('DATABASE_BACKUP_AWS_ACCESS_KEY_ID'),
36
- secret_access_key: ENV.fetch('DATABASE_BACKUP_AWS_SECRET_ACCESS_KEY'),
37
- region: ENV.fetch('DATABASE_BACKUP_AWS_REGION')
38
- }
36
+ @client ||= Aws::S3::Client.new(**credentials)
39
37
  end
40
38
  end
41
39
  end
@@ -1,3 +1,3 @@
1
1
  module NxtHerokuDatabaseBackup
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nxt_heroku_database_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Robecke