safety_net 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/safety_net.rb +7 -5
  3. data/safety_net.gemspec +2 -2
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -1,7 +1,7 @@
1
1
  module SafetyNet
2
2
  def dump_table(table_name)
3
3
  table_name = table_name.to_s
4
- db_name, db_user, db_pass = get_db_config
4
+ db_host, db_name, db_user, db_pass = get_db_config
5
5
 
6
6
  mysqldump = get_command_path('mysqldump')
7
7
  if mysqldump == 'SKIP!'
@@ -12,7 +12,7 @@ module SafetyNet
12
12
 
13
13
  host = `hostname`.chomp
14
14
  puts "** Backing up #{table_name} to #{backup_file} on #{host} **"
15
- system "#{mysqldump} -u#{db_user} -p#{db_pass} #{db_name}" \
15
+ system "#{mysqldump} -h#{db_host} -u#{db_user} -p#{db_pass} #{db_name}" \
16
16
  " #{table_name} > #{backup_file}"
17
17
  if $?.exitstatus != 0
18
18
  raise "UNABLE TO BACKUP #{table_name}. Bugging out."
@@ -24,7 +24,7 @@ module SafetyNet
24
24
 
25
25
  def restore_table(table_name)
26
26
  table_name = table_name.to_s
27
- db_name, db_user, db_pass = get_db_config
27
+ db_host, db_name, db_user, db_pass = get_db_config
28
28
 
29
29
  mysql= get_command_path('mysql')
30
30
  if mysql== 'SKIP!'
@@ -41,7 +41,8 @@ module SafetyNet
41
41
 
42
42
  restore_file = File.join(tmp_dir, file_name)
43
43
  puts "** Restoring #{table_name} from #{restore_file} **"
44
- system "#{mysql} -u#{db_user} -p#{db_pass} #{db_name} < #{restore_file}"
44
+ system "#{mysql} -h#{db_host} -u#{db_user} -p#{db_pass} #{db_name}" \
45
+ " < #{restore_file}"
45
46
  if $?.exitstatus != 0
46
47
  raise "UNABLE TO RESTORE #{table_name}. Bugging out."
47
48
  end
@@ -51,7 +52,8 @@ module SafetyNet
51
52
 
52
53
  def get_db_config
53
54
  db_config = ActiveRecord::Base.connection.instance_values["config"]
54
- return [db_config[:database], db_config[:user], db_config[:password]]
55
+ return [db_config[:host], db_config[:database], db_config[:user],
56
+ db_config[:password]]
55
57
  end
56
58
 
57
59
  def get_command_path(command)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{safety_net}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rusty Burchfield"]
12
- s.date = %q{2009-12-04}
12
+ s.date = %q{2009-12-07}
13
13
  s.description = %q{Backup/restore a mysql table in rails. Great for crazy data migrations where you want to keep a copy of the table.}
14
14
  s.email = %q{GICodeWarrior@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safety_net
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rusty Burchfield
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-04 00:00:00 -08:00
12
+ date: 2009-12-07 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency