heroku_pg_loader 0.0.2 → 0.0.3
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 +4 -4
- data/lib/heroku_pg_loader.rb +37 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 961c9a4ed8bede88badf672c00e51be244062f32
|
4
|
+
data.tar.gz: a95cd05c5c99e7a3aedc2e6d7d5bd4cfae163238
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b9e01632cc906a557cbc55501c99dbfbf14243e604097a989f243a197920325aae4db1ab6a63be5410d2ffea10b1ca666062bc99503c1da76d274700974b66
|
7
|
+
data.tar.gz: 6174db8f3a3f64cba08f30b7e6ed8c79894e70116c5751155b7cb0630ccb63eb57c460b318d2d1b24ac0e198a5d500b4660d26d3549a0a678923aff8bef66490
|
data/lib/heroku_pg_loader.rb
CHANGED
@@ -43,7 +43,6 @@ class HerokuPgLoader
|
|
43
43
|
def dump_file
|
44
44
|
if @dump_file.nil?
|
45
45
|
path = "#{working_dir}/latest.dump"
|
46
|
-
puts "Creating dump file #{path}"
|
47
46
|
@dump_file = File.open(path, 'w')
|
48
47
|
end
|
49
48
|
@dump_file
|
@@ -59,31 +58,40 @@ class HerokuPgLoader
|
|
59
58
|
|
60
59
|
def get_database_details
|
61
60
|
|
62
|
-
|
63
|
-
db_config = YAML.load_file("#{working_dir}/config/database.yml")
|
64
|
-
|
65
|
-
dev_config = db_config["development"]
|
66
|
-
if dev_config["adapter"] == "postgresql"
|
67
|
-
@db_name = dev_config["database"]
|
68
|
-
@db_username = dev_config["username"]
|
69
|
-
@db_password = dev_config["password"]
|
70
|
-
end
|
61
|
+
guess_database_from_rails_config
|
71
62
|
|
72
63
|
@db_name = prompt "Local Database Name:\n (WARNING: THIS DATABASE WILL BE ERASED)",
|
73
|
-
|
74
|
-
|
64
|
+
@db_name,
|
65
|
+
"Database name not entered"
|
75
66
|
|
76
67
|
@db_username = prompt "Database Username:",
|
77
|
-
|
78
|
-
|
68
|
+
@db_username,
|
69
|
+
"Database username not entered"
|
79
70
|
|
80
71
|
@db_password = prompt "Database Password:",
|
81
|
-
|
82
|
-
|
72
|
+
@db_password,
|
73
|
+
"Database Password not entered"
|
74
|
+
end
|
75
|
+
|
76
|
+
def guess_database_from_rails_config
|
77
|
+
rails_db_config_file = "#{working_dir}/config/database.yml"
|
78
|
+
|
79
|
+
if File.exist? rails_db_config_file
|
80
|
+
|
81
|
+
# Read database.yml
|
82
|
+
db_config = YAML.load_file(rails_db_config_file)
|
83
|
+
|
84
|
+
dev_config = db_config["development"]
|
85
|
+
if dev_config["adapter"] == "postgresql"
|
86
|
+
@db_name = dev_config["database"]
|
87
|
+
@db_username = dev_config["username"]
|
88
|
+
@db_password = dev_config["password"]
|
89
|
+
end
|
90
|
+
end
|
83
91
|
end
|
84
92
|
|
85
93
|
def working_dir
|
86
|
-
|
94
|
+
Dir.getwd
|
87
95
|
end
|
88
96
|
|
89
97
|
def prompt(message, current_value, error_message)
|
@@ -97,21 +105,24 @@ class HerokuPgLoader
|
|
97
105
|
end
|
98
106
|
|
99
107
|
def get_app_name
|
100
|
-
|
108
|
+
guess_app_name
|
101
109
|
|
102
110
|
@heroku_app_name = prompt "Heroku App Name:",
|
103
|
-
|
104
|
-
|
111
|
+
@heroku_app_name,
|
112
|
+
"No Heroku App Name entered"
|
105
113
|
end
|
106
114
|
|
107
|
-
def
|
108
|
-
|
115
|
+
def guess_app_name
|
116
|
+
|
117
|
+
if File.exist?("#{working_dir}/.git")
|
118
|
+
git_remote = `git remote -v | grep heroku`
|
109
119
|
|
110
|
-
|
111
|
-
|
120
|
+
/git@heroku.com:(\w*).git/.match(git_remote)
|
121
|
+
@heroku_app_name = $1
|
112
122
|
|
113
|
-
|
114
|
-
|
123
|
+
if @heroku_app_name
|
124
|
+
puts "Heroku App Detected: #{@heroku_app_name}"
|
125
|
+
end
|
115
126
|
end
|
116
127
|
end
|
117
128
|
|