heroku_tool 0.7.1 → 0.8.0

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
  SHA256:
3
- metadata.gz: 896b566139715224a901f3119080b64e5e127f325bee2e040e210e4734a774f0
4
- data.tar.gz: 18bf3e7d65ea20c497107af42d4b6a5b6eaa98e6ad6fac4654005b86689e9ce5
3
+ metadata.gz: 366d3213e1b652d45f89a3cdc8cd76ccfdf48c5727c13cbdcf215cef666c1a2e
4
+ data.tar.gz: 315e1c68673b6f3af2d944633b19d3f75d3856a9e8d81d028ada208834cd9759
5
5
  SHA512:
6
- metadata.gz: bda281415b8e1859bf0b127665650f5faa6079285a96d1ed8e96edf29b8b4c51d73102fa77f9558869563e4bb53baa81bbcbd4936cc2402c88c335396e1c5a17
7
- data.tar.gz: 35754cfb7317c05f6d6b3e720870bd2f781e1f19c1f5f76bdd4bb385b98cca6a3dbd1bfaa28b471ba25f5ff56ebb0b035b7df1662022a8641372e8e9db84a300
6
+ metadata.gz: ee39dd422b621fe18873394e5ae60e68f6294137de76dc0bfa67e084e4763791edc4d2bb74f1e7f0ccd2e4e05e0113b0ad9b38f92c0e825445d4095064cceb80
7
+ data.tar.gz: b9b3254bb923175c97f69ead7cb9658063a94ed499bb41b0da30075e406cd1c0b31a41127e924593a0f9f27df542e81940529d0bb0514c385c22888cc6fa21cb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.8.0
4
+
5
+ - allow for multiple databases in configuration
6
+
3
7
  ## v0.7.1
4
8
 
5
9
  - update for changes to heroku cli in heroku 9.0 (#12)
@@ -1,9 +1,19 @@
1
1
  # NB need to specify a username in the database.yml if you want to use any of these commands
2
2
  module HerokuTool
3
3
  class DbConfiguration
4
- def config
5
- db_config_from_file = ERB.new(File.read("config/database.yml")).result
6
- @config ||= YAML.safe_load(db_config_from_file, permitted_classes: [], permitted_symbols: [], aliases: true)
4
+ attr_reader :config_all, :config_env
5
+
6
+ def initialize(filepath: "config/database.yml", rails_env: ENV["RAILS_ENV"] || "development")
7
+ db_config_from_file = ERB.new(File.read(filepath)).result
8
+ @config_all = YAML.safe_load(db_config_from_file, permitted_classes: [], permitted_symbols: [], aliases: true)
9
+ config_env = @config_all[rails_env]
10
+ @config_env = if config_env["database"].is_a?(String)
11
+ config_env
12
+ elsif config_env.key?("primary")
13
+ config_env["primary"]
14
+ else
15
+ config_env.values.first
16
+ end
7
17
  end
8
18
 
9
19
  def generate_drop_tables_sql
@@ -12,22 +22,13 @@ module HerokuTool
12
22
  end
13
23
 
14
24
  def user_arg
15
- username = db_config["username"]
25
+ username = config_env["username"]
16
26
  username.present? && "-U #{username}" || ""
17
27
  end
18
28
 
19
29
  def database
20
- db_config["database"]
30
+ config_env["database"]
21
31
  end
22
32
 
23
- private
24
-
25
- def db_config
26
- config[env]
27
- end
28
-
29
- def env
30
- ENV["RAILS_ENV"] || "development"
31
- end
32
33
  end
33
34
  end
@@ -391,12 +391,8 @@ class Heroku < Thor
391
391
  def from_dump
392
392
  invoke "warn", [], from: options[:from]
393
393
  source = lookup_heroku(options[:from])
394
- rails_env = ENV["RAILS_ENV"] || "development"
395
- db_config = HerokuTool::DbConfiguration.new.config[rails_env]
396
- db_username = db_config["username"]
397
- db = db_config["database"]
398
- db_username_params = db_username.blank? && "" || "-U #{db_username}"
399
- puts_and_system "pg_restore --verbose --clean --no-acl --no-owner -h localhost #{db_username_params} -d #{db} #{source.dump_filename}"
394
+ db_config = HerokuTool::DbConfiguration.new
395
+ puts_and_system "pg_restore --verbose --clean --no-acl --no-owner -h localhost #{db_config.user_arg} -d #{db_config.database} #{source.dump_filename}"
400
396
  Configuration.after_sync_down(self) unless options[:just_restore]
401
397
  end
402
398
 
@@ -1,3 +1,3 @@
1
1
  module HerokuTool
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Diggins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-30 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor