geordi 0.12.8 → 0.13.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.
- data/README.md +10 -0
- data/bin/load-dump +83 -0
- data/lib/geordi/version.rb +1 -1
- metadata +9 -6
data/README.md
CHANGED
@@ -93,6 +93,16 @@ Stores a timestamped database dump for the given Rails environment in `~/dumps`:
|
|
93
93
|
More information at http://makandracards.com/makandra/1008-dump-your-database-with-dumple
|
94
94
|
|
95
95
|
|
96
|
+
load-dump
|
97
|
+
---------
|
98
|
+
|
99
|
+
Loads a database dump (e.g. created with dump-for or dumple) into you database.
|
100
|
+
|
101
|
+
load-dump [path/to/dump]
|
102
|
+
|
103
|
+
More information at https://makandracards.com/makandra/8975-geordi-use-load-dump-script-to-source-a-database-dump-into-your-database
|
104
|
+
|
105
|
+
|
96
106
|
|
97
107
|
gitpt
|
98
108
|
-----
|
data/bin/load-dump
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'highline'
|
5
|
+
|
6
|
+
|
7
|
+
class DumpLoader
|
8
|
+
|
9
|
+
def initialize(argv)
|
10
|
+
@argv = argv
|
11
|
+
@verbose = !!@argv.delete('-v')
|
12
|
+
end
|
13
|
+
|
14
|
+
def dumps_dir
|
15
|
+
require 'etc'
|
16
|
+
user_dir = Etc.getpwuid.dir
|
17
|
+
File.join(user_dir, 'dumps')
|
18
|
+
end
|
19
|
+
|
20
|
+
def source_dump(dump)
|
21
|
+
require 'pty'
|
22
|
+
output_buffer = StringIO.new
|
23
|
+
PTY.spawn("script/dbconsole -p") do |output, input, pid|
|
24
|
+
input.write("source #{dump};\nexit;\n")
|
25
|
+
output_buffer.write output.read
|
26
|
+
end
|
27
|
+
|
28
|
+
output_and_errors = output_buffer.string.split("\n")
|
29
|
+
output = output_and_errors.reject{ |line| line =~ /^ERROR / }
|
30
|
+
errors = output_and_errors.select{ |line| line =~ /^ERROR / }
|
31
|
+
|
32
|
+
[output, errors]
|
33
|
+
end
|
34
|
+
|
35
|
+
def choose_dump_file
|
36
|
+
highline = HighLine.new
|
37
|
+
|
38
|
+
available_dumps = Dir.glob("#{dumps_dir}/*.dump").sort
|
39
|
+
selected_dump = highline.choose(*available_dumps) do |menu|
|
40
|
+
menu.hidden('') { exit }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_dump_file
|
45
|
+
if ARGV[0] && File.exists?(ARGV[0])
|
46
|
+
ARGV[0]
|
47
|
+
else
|
48
|
+
choose_dump_file
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def puts_info(msg = "")
|
54
|
+
puts msg if @verbose
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute!
|
58
|
+
dump_to_load = get_dump_file
|
59
|
+
|
60
|
+
puts_info
|
61
|
+
puts_info "sourcing #{dump_to_load} into db ..."
|
62
|
+
|
63
|
+
output, errors = source_dump(dump_to_load)
|
64
|
+
|
65
|
+
puts_info
|
66
|
+
puts_info output.join("\n")
|
67
|
+
|
68
|
+
if errors.empty?
|
69
|
+
puts_info "sourcing completed successfully."
|
70
|
+
exit(0)
|
71
|
+
else
|
72
|
+
$stderr.puts "some errors occured while loading the dump #{File.basename(dump_to_load)}:"
|
73
|
+
$stderr.puts errors.join("\n");
|
74
|
+
exit(1)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
DumpLoader.new(ARGV).execute!
|
82
|
+
|
83
|
+
|
data/lib/geordi/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geordi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 13
|
9
|
+
- 0
|
10
|
+
version: 0.13.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Henning Koch
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-06-
|
18
|
+
date: 2012-06-11 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Collection of command line tools we use in our daily work with Ruby, Rails and Linux at makandra.
|
@@ -33,6 +33,7 @@ executables:
|
|
33
33
|
- gitpt
|
34
34
|
- install-gems-remotely
|
35
35
|
- install-gems-remotely.sh
|
36
|
+
- load-dump
|
36
37
|
- migrate-all
|
37
38
|
- power-deploy
|
38
39
|
- power-rake
|
@@ -62,6 +63,7 @@ files:
|
|
62
63
|
- bin/gitpt
|
63
64
|
- bin/install-gems-remotely
|
64
65
|
- bin/install-gems-remotely.sh
|
66
|
+
- bin/load-dump
|
65
67
|
- bin/migrate-all
|
66
68
|
- bin/power-deploy
|
67
69
|
- bin/power-rake
|
@@ -106,9 +108,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
108
|
requirements: []
|
107
109
|
|
108
110
|
rubyforge_project: geordi
|
109
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.21
|
110
112
|
signing_key:
|
111
113
|
specification_version: 3
|
112
114
|
summary: Collection of command line tools we use in our daily work with Ruby, Rails and Linux at makandra.
|
113
115
|
test_files: []
|
114
116
|
|
117
|
+
has_rdoc:
|