wpcap 0.2.1 → 0.2.2
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.
- data/lib/wpcap/recipes/mysql.rb +16 -18
- data/lib/wpcap/recipes/templates/mysql.yml.erb +2 -3
- data/lib/wpcap/utility.rb +7 -2
- data/lib/wpcap/version.rb +1 -1
- metadata +1 -1
data/lib/wpcap/recipes/mysql.rb
CHANGED
@@ -53,7 +53,7 @@ configuration.load do
|
|
53
53
|
|
54
54
|
prepare_env
|
55
55
|
run "mkdir -p #{backups_path}"
|
56
|
-
filename = "
|
56
|
+
filename = "db_backup.#{Time.now.to_f}.sql.bz2"
|
57
57
|
filepath = "#{backups_path}/#{filename}"
|
58
58
|
on_rollback { run "rm #{filepath}" }
|
59
59
|
run "mysqldump --user=#{db_username} -p --host=#{db_host} #{db_database} | bzip2 -z9 > #{filepath}" do |ch, stream, out|
|
@@ -65,10 +65,7 @@ configuration.load do
|
|
65
65
|
desc "Restores the database from the latest compressed dump"
|
66
66
|
task :restore_most_recent, :roles => :db, :only => { :primary => true } do
|
67
67
|
prepare_env
|
68
|
-
|
69
|
-
ch.send_data "#{db_password}\n" if out =~ /^Enter password:/
|
70
|
-
puts out
|
71
|
-
end
|
68
|
+
restore_dump(most_recent_backup)
|
72
69
|
end
|
73
70
|
|
74
71
|
desc "Restores the database from the latest compressed dump"
|
@@ -107,7 +104,7 @@ configuration.load do
|
|
107
104
|
prepare_env(:development)
|
108
105
|
run_locally "#{local_mysql_path}mysqldump --user #{db_username} --password=#{db_password} #{db_database} | bzip2 -z9 > #{local_dump}"
|
109
106
|
run "mkdir -p #{backups_path}"
|
110
|
-
filename = "
|
107
|
+
filename = "local_upload.#{Time.now.to_f}.sql.bz2"
|
111
108
|
filepath = "#{backups_path}/#{filename}"
|
112
109
|
upload "#{local_dump}" , "#{filepath}"
|
113
110
|
end
|
@@ -156,18 +153,19 @@ configuration.load do
|
|
156
153
|
desc "Create database.yml in shared path with settings for current stage and test env"
|
157
154
|
task :create_yaml do
|
158
155
|
#Create a new database enviroment unless it already exists in config.
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
156
|
+
return if db_config[stage]
|
157
|
+
|
158
|
+
template_path = "#{shared_path}/config/database.yml"
|
159
|
+
set :db_username, "#{application.split(".").first}_#{stage}"
|
160
|
+
set :db_database, "#{application.split(".").first}_#{stage}"
|
161
|
+
set :db_password, random_password(16)
|
162
|
+
set :db_prefix, db_config["development"]["prefix"]
|
163
|
+
run "mkdir -p #{shared_path}/config"
|
164
|
+
template "mysql.yml.erb", template_path
|
165
|
+
server_yaml = capture "cat #{template_path}"
|
166
|
+
server_mysql_config_yaml = YAML.load(server_yaml)
|
167
|
+
update_db_config(server_mysql_config_yaml)
|
168
|
+
|
171
169
|
end
|
172
170
|
|
173
171
|
def db_config
|
data/lib/wpcap/utility.rb
CHANGED
@@ -4,11 +4,16 @@ class Wpcap::Utility
|
|
4
4
|
puts red("****#{text}****")
|
5
5
|
end
|
6
6
|
|
7
|
+
def self.question(text)
|
8
|
+
puts blue("****#{text}****")
|
9
|
+
end
|
10
|
+
|
7
11
|
def self.colorize(text, color_code)
|
8
12
|
"\e[#{color_code}m#{text}\e[0m"
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.red(text); self.colorize(text, 31); end
|
12
16
|
def self.green(text); self.colorize(text, 32); end
|
13
|
-
|
14
|
-
|
17
|
+
def self.blue(text); self.colorize(text, 34); end
|
18
|
+
|
19
|
+
end
|
data/lib/wpcap/version.rb
CHANGED