geordi 0.18.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.ruby-version +1 -0
- data/README.md +199 -110
- data/Rakefile +40 -0
- data/bin/apache-site +1 -19
- data/bin/cap-all +1 -27
- data/bin/cleanup-directory +1 -11
- data/bin/console-for +1 -12
- data/bin/cuc +1 -2
- data/bin/cuc-show +1 -2
- data/bin/cuc-vnc-setup +1 -114
- data/bin/deploy-to-production +1 -91
- data/bin/dump-for +4 -32
- data/bin/dumple +2 -4
- data/bin/geordi +10 -0
- data/bin/gitpt +1 -2
- data/bin/launchy_browser +9 -3
- data/bin/load-dump +1 -4
- data/bin/migrate-all +1 -13
- data/bin/optimize-png +1 -118
- data/bin/power-rake +1 -7
- data/bin/remove-executable-flags +1 -6
- data/bin/rs +1 -26
- data/bin/run_tests +1 -2
- data/bin/setup-firefox-for-selenium +1 -3
- data/bin/shell-for +1 -8
- data/bin/tests +1 -5
- data/geordi.gemspec +19 -0
- data/lib/geordi/COMMAND_TEMPLATE +29 -0
- data/lib/geordi/capistrano.rb +9 -7
- data/lib/geordi/capistrano_config.rb +66 -0
- data/lib/geordi/cli.rb +28 -0
- data/lib/geordi/commands/all_targets.rb +26 -0
- data/lib/geordi/commands/apache_site.rb +22 -0
- data/lib/geordi/commands/bundle_install.rb +7 -0
- data/lib/geordi/commands/cleanup_directory.rb +16 -0
- data/lib/geordi/commands/commit.rb +171 -0
- data/lib/geordi/commands/console.rb +24 -0
- data/lib/geordi/commands/create_database_yml.rb +18 -0
- data/lib/geordi/commands/create_databases.rb +16 -0
- data/lib/geordi/commands/cucumber.rb +20 -0
- data/lib/geordi/commands/deploy.rb +65 -0
- data/lib/geordi/commands/devserver.rb +14 -0
- data/lib/geordi/commands/dump.rb +63 -0
- data/lib/geordi/commands/migrate.rb +26 -0
- data/lib/geordi/commands/png_optimize.rb +92 -0
- data/lib/geordi/commands/rake.rb +21 -0
- data/lib/geordi/commands/remove_executable_flags.rb +14 -0
- data/lib/geordi/commands/rspec.rb +40 -0
- data/lib/geordi/commands/security_update.rb +56 -0
- data/lib/geordi/commands/setup.rb +33 -0
- data/lib/geordi/commands/setup_firefox_for_selenium.rb +6 -0
- data/lib/geordi/commands/setup_vnc.rb +84 -0
- data/lib/geordi/commands/shell.rb +20 -0
- data/lib/geordi/commands/test.rb +9 -0
- data/lib/geordi/commands/unit.rb +11 -0
- data/lib/geordi/commands/update.rb +33 -0
- data/lib/geordi/commands/version.rb +7 -0
- data/lib/geordi/commands/vnc_show.rb +6 -0
- data/lib/geordi/commands/with_firefox_for_selenium.rb +18 -0
- data/lib/geordi/commands/with_rake.rb +11 -0
- data/lib/geordi/{cuc.rb → cucumber.rb} +28 -39
- data/lib/geordi/dump_loader.rb +44 -70
- data/lib/geordi/firefox_for_selenium.rb +93 -74
- data/lib/geordi/interaction.rb +47 -0
- data/lib/geordi/remote.rb +66 -0
- data/lib/geordi/util.rb +60 -0
- data/lib/geordi/version.rb +1 -1
- data/lib/geordi.rb +1 -0
- metadata +50 -16
- data/bin/install-gems-remotely +0 -18
- data/bin/install-gems-remotely.sh +0 -16
- data/bin/power-deploy +0 -18
- data/bin/remotify-local-branch +0 -12
- data/lib/geordi/gitpt.rb +0 -175
@@ -0,0 +1,21 @@
|
|
1
|
+
desc 'rake TASK', 'Run a rake task in several Rails environments'
|
2
|
+
long_desc <<-LONGDESC
|
3
|
+
Example: `geordi rake db:migrate`
|
4
|
+
|
5
|
+
TASK is run in the following Rails environments (if present):
|
6
|
+
|
7
|
+
- development
|
8
|
+
- test
|
9
|
+
- cucumber
|
10
|
+
LONGDESC
|
11
|
+
|
12
|
+
def rake(*args)
|
13
|
+
for env in %w(development test cucumber) # update long_desc when changing this
|
14
|
+
if File.exists? "config/environments/#{env}.rb"
|
15
|
+
call = %w[bundle exec rake] + args + ["RAILS_ENV=#{env}"]
|
16
|
+
note_cmd call.join(' ')
|
17
|
+
|
18
|
+
Util.system! *call
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
desc 'remove-executable-flags', 'Remove executable-flags from files that should not be executable'
|
2
|
+
def remove_executable_flags
|
3
|
+
announce 'Removing executable-flags'
|
4
|
+
|
5
|
+
patterns = %w[
|
6
|
+
*.rb *.html *.erb *.haml *.yml *.css *.sass *.rake *.png *.jpg
|
7
|
+
*.gif *.pdf *.txt *.rdoc *.feature Rakefile VERSION README Capfile
|
8
|
+
]
|
9
|
+
for pattern in patterns
|
10
|
+
note pattern
|
11
|
+
`find . -name "#{pattern}" -exec chmod -x {} ';'`
|
12
|
+
end
|
13
|
+
puts 'Done.'
|
14
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
desc 'rspec [FILES]', 'Run RSpec'
|
2
|
+
long_desc <<-LONGDESC
|
3
|
+
Example: `geordi rspec spec/models/user_spec.rb:13`
|
4
|
+
|
5
|
+
Runs RSpec as you want: with RSpec 1/2 detection, `bundle exec`, rspec_spinner
|
6
|
+
detection, etc.
|
7
|
+
LONGDESC
|
8
|
+
|
9
|
+
def rspec(*files)
|
10
|
+
if File.exists?('spec/spec_helper.rb')
|
11
|
+
invoke_cmd 'bundle_install'
|
12
|
+
|
13
|
+
announce 'Running specs'
|
14
|
+
|
15
|
+
if file_containing?('Gemfile', /parallel_tests/) and files.empty?
|
16
|
+
note 'All specs at once (using parallel_tests)'
|
17
|
+
Util.system! 'bundle exec rake parallel:spec', :fail_message => 'Specs failed.'
|
18
|
+
|
19
|
+
else
|
20
|
+
# tell which specs will be run
|
21
|
+
if files.empty?
|
22
|
+
files << 'spec/'
|
23
|
+
note 'All specs in spec/'
|
24
|
+
else
|
25
|
+
note 'Only: ' + files.join(', ')
|
26
|
+
end
|
27
|
+
|
28
|
+
command = ['bundle exec']
|
29
|
+
# differentiate RSpec 1/2
|
30
|
+
command << (File.exists?('script/spec') ? 'spec -c' : 'rspec')
|
31
|
+
command << '-r rspec_spinner -f RspecSpinner::Bar' if file_containing?('Gemfile', /rspec_spinner/)
|
32
|
+
command << files.join(' ')
|
33
|
+
|
34
|
+
puts
|
35
|
+
Util.system! command.join(' '), :fail_message => 'Specs failed.'
|
36
|
+
end
|
37
|
+
else
|
38
|
+
note 'RSpec not employed.'
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
desc 'security-update [step]', 'Support for performing security updates'
|
2
|
+
long_desc <<-LONGDESC
|
3
|
+
Preparation for security update: `geordi security-update`
|
4
|
+
|
5
|
+
After performing the update: `geordi security-update finish`
|
6
|
+
|
7
|
+
Switches branches, pulls, pushes and deploys as required by our workflow. Tells
|
8
|
+
what it will do before it does it.
|
9
|
+
LONGDESC
|
10
|
+
|
11
|
+
def security_update(step='prepare')
|
12
|
+
case step
|
13
|
+
when 'prepare'
|
14
|
+
announce 'Preparing for security update'
|
15
|
+
warn 'Please read https://makandracards.com/makandra/1587 before applying security updates!'
|
16
|
+
note 'About to: pull master and production branches, checkout production'
|
17
|
+
wait 'Continue?'
|
18
|
+
|
19
|
+
Util.system! 'git checkout master', :show_cmd => true
|
20
|
+
Util.system! 'git pull', :show_cmd => true
|
21
|
+
Util.system! 'git checkout production', :show_cmd => true
|
22
|
+
Util.system! 'git pull', :show_cmd => true
|
23
|
+
|
24
|
+
success 'Successfully prepared for security update'
|
25
|
+
puts
|
26
|
+
note 'Please apply the security update now.'
|
27
|
+
note 'When you are done, run `geordi security-update finish`.'
|
28
|
+
|
29
|
+
|
30
|
+
when 'finish'
|
31
|
+
announce 'Finishing security update'
|
32
|
+
|
33
|
+
# ensure everything is committed
|
34
|
+
`git status --porcelain`.empty? or fail('There are uncommitted changes.')
|
35
|
+
note 'Working directory clean.'
|
36
|
+
|
37
|
+
print 'Have you successfully run all tests? [yN] '
|
38
|
+
exit unless $stdin.gets =~ /[yes]+/
|
39
|
+
|
40
|
+
note 'About to: push production, checkout & pull master, merge production, push master, deploy all stages'
|
41
|
+
wait 'Continue?'
|
42
|
+
|
43
|
+
Util.system! 'git push', :show_cmd => true
|
44
|
+
Util.system! 'git checkout master', :show_cmd => true
|
45
|
+
Util.system! 'git pull', :show_cmd => true
|
46
|
+
Util.system! 'git merge production', :show_cmd => true
|
47
|
+
Util.system! 'git push', :show_cmd => true
|
48
|
+
|
49
|
+
invoke_cmd 'all_targets', 'deploy:migrations'
|
50
|
+
|
51
|
+
success 'Successfully pushed and deployed security update'
|
52
|
+
puts
|
53
|
+
note 'Now send an email to customer and project lead, informing them about the update.'
|
54
|
+
note 'Do not forget to make a joblog on a security budget, if available.'
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
desc 'setup', 'Setup a project for the first time'
|
2
|
+
long_desc <<-LONGDESC
|
3
|
+
Example: `geordi setup`
|
4
|
+
|
5
|
+
Check out a repository, cd into its directory. Now let `setup` do the tiring
|
6
|
+
work: run `bundle install`, create `database.yml`, create databases, migrate
|
7
|
+
(all if applicable).
|
8
|
+
|
9
|
+
After setting up, loads a dump into the development db when called with the
|
10
|
+
`--dump` option:
|
11
|
+
|
12
|
+
geordi setup -d staging
|
13
|
+
|
14
|
+
After setting up, runs all tests when called with the `--test` option:
|
15
|
+
|
16
|
+
geordi setup -t
|
17
|
+
|
18
|
+
See `geordi help setup` for details.
|
19
|
+
LONGDESC
|
20
|
+
|
21
|
+
option :dump, :type => :string, :aliases => '-d', :banner => 'TARGET',
|
22
|
+
:desc => 'After setup, dump the TARGET db and source it into the development db'
|
23
|
+
option :test, :type => :boolean, :aliases => '-t', :desc => 'After setup, run tests'
|
24
|
+
|
25
|
+
def setup
|
26
|
+
invoke_cmd 'create_databases'
|
27
|
+
invoke_cmd 'migrate'
|
28
|
+
|
29
|
+
success 'Successfully set up the project.'
|
30
|
+
|
31
|
+
invoke_cmd 'dump', options.dump, :load => true if options.dump
|
32
|
+
invoke_cmd 'tests' if options.test
|
33
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class ::String
|
2
|
+
def colorize(color_code)
|
3
|
+
"\e[#{color_code}m#{self}\e[0m"
|
4
|
+
end
|
5
|
+
|
6
|
+
def red() colorize(31) end
|
7
|
+
def pink() colorize(35) end
|
8
|
+
def green() colorize(32) end
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'setup-vnc', 'Setup VNC for running Selenium tests there'
|
12
|
+
def setup_vnc
|
13
|
+
`clear`
|
14
|
+
|
15
|
+
instruct <<-TEXT
|
16
|
+
This script will help you install a VNC server and a VNC viewer.
|
17
|
+
|
18
|
+
With those you will be able to use our cucumber script without being
|
19
|
+
disturbed by focus-stealing selenium windows. Instead, they will open
|
20
|
+
inside a VNC session. You can still inspect everything with #{"geordi
|
21
|
+
vnc_show".pink}.
|
22
|
+
|
23
|
+
Please open a second shell to execute instructions.
|
24
|
+
TEXT
|
25
|
+
|
26
|
+
announce 'Setup VNC server'
|
27
|
+
|
28
|
+
if installed?('vncserver')
|
29
|
+
success 'It appears you already have a VNC server installed. Good job!'
|
30
|
+
else
|
31
|
+
instruct <<-TEXT
|
32
|
+
Please run #{'sudo apt-get install vnc4server'.pink}.
|
33
|
+
TEXT
|
34
|
+
|
35
|
+
instruct <<-TEXT
|
36
|
+
We will now set a password for your VNC server.
|
37
|
+
|
38
|
+
When running our cucumber script, you will not actually need this
|
39
|
+
password, and there is no security risk. However, if you start a vncserver
|
40
|
+
without our cucumber script, a user with your password can connect to
|
41
|
+
your machine.
|
42
|
+
|
43
|
+
Please run #{'vncserver :20'.pink} and #{'enter a secure password'.red}.
|
44
|
+
TEXT
|
45
|
+
|
46
|
+
instruct <<-TEXT
|
47
|
+
Now stop the server again.
|
48
|
+
Please run #{'vncserver -kill :20'.pink}.
|
49
|
+
TEXT
|
50
|
+
end
|
51
|
+
|
52
|
+
announce 'Setup VNC viewer'
|
53
|
+
|
54
|
+
if installed?('vncviewer')
|
55
|
+
success 'It appears you already have a VNC viewer installed. Good job!'
|
56
|
+
else
|
57
|
+
instruct <<-TEXT
|
58
|
+
Please run #{'sudo apt-get install xtightvncviewer'.pink}.
|
59
|
+
TEXT
|
60
|
+
end
|
61
|
+
|
62
|
+
instruct <<-TEXT, false
|
63
|
+
All done. Our cucumber script will now automatically run Selenium features
|
64
|
+
in VNC.
|
65
|
+
#{"Happy cuking!".green}
|
66
|
+
TEXT
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def instruct(text, wait = true)
|
73
|
+
text =~ /^( *)./
|
74
|
+
level = $1 ? $1.size : 0
|
75
|
+
text.gsub!(/^ {#{level}}/, '')
|
76
|
+
puts text
|
77
|
+
|
78
|
+
wait('[ENTER]') if wait
|
79
|
+
end
|
80
|
+
|
81
|
+
def installed?(app)
|
82
|
+
`which #{app}`
|
83
|
+
$?.success?
|
84
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This method has a triple 'l' because :shell is a Thor reserved word. However,
|
2
|
+
# it can still be called with `geordi shell` :)
|
3
|
+
|
4
|
+
desc 'shell TARGET', 'Open a shell on a Capistrano deploy target'
|
5
|
+
long_desc <<-LONGDESC
|
6
|
+
Example: `geordi shell production`
|
7
|
+
|
8
|
+
Lets you select the server to connect to when called with `--select-server`:
|
9
|
+
|
10
|
+
geordi shell production -s
|
11
|
+
LONGDESC
|
12
|
+
|
13
|
+
option :select_server, :default => false, :type => :boolean, :aliases => '-s'
|
14
|
+
|
15
|
+
def shelll(target, *args)
|
16
|
+
require 'geordi/remote'
|
17
|
+
|
18
|
+
announce 'Opening a shell on ' + target
|
19
|
+
Geordi::Remote.new(target).shell(options)
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
desc 'update', 'Bring a project up to date'
|
2
|
+
long_desc <<-LONGDESC
|
3
|
+
Example: `geordi update`
|
4
|
+
|
5
|
+
Performs: `git pull`, `bundle install` (if necessary) and migrates (if applicable).
|
6
|
+
|
7
|
+
After updating, loads a dump into the development db when called with the
|
8
|
+
`--dump` option:
|
9
|
+
|
10
|
+
geordi update -d staging
|
11
|
+
|
12
|
+
After updating, runs all tests when called with the `--test` option:
|
13
|
+
|
14
|
+
geordi update -t
|
15
|
+
|
16
|
+
See `geordi help update` for details.
|
17
|
+
LONGDESC
|
18
|
+
|
19
|
+
option :dump, :type => :string, :aliases => '-d', :banner => 'TARGET',
|
20
|
+
:desc => 'After updating, dump the TARGET db and source it into the development db'
|
21
|
+
option :test, :type => :boolean, :aliases => '-t', :desc => 'After updating, run tests'
|
22
|
+
|
23
|
+
def update
|
24
|
+
announce 'Updating repository'
|
25
|
+
Util.system! 'git pull', :show_cmd => true
|
26
|
+
|
27
|
+
invoke_cmd 'migrate'
|
28
|
+
|
29
|
+
success 'Successfully updated the project.'
|
30
|
+
|
31
|
+
invoke_cmd 'dump', options.dump, :load => true if options.dump
|
32
|
+
invoke_cmd 'tests' if options.test
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
desc 'with-firefox-for-selenium COMMAND', 'Run a command with firefox for selenium set up'
|
2
|
+
long_desc <<-LONGDESC
|
3
|
+
Example: `geordi with-firefox-for-selenium b cucumber`
|
4
|
+
|
5
|
+
Useful when you need Firefox for Selenium, but can't use the `geordi cucumber`
|
6
|
+
command.
|
7
|
+
LONGDESC
|
8
|
+
|
9
|
+
def with_firefox_for_selenium(*command)
|
10
|
+
note 'Setting up Firefox for Selenium ...'
|
11
|
+
require 'geordi/cucumber'
|
12
|
+
Cucumber.new.setup_vnc
|
13
|
+
FirefoxForSelenium.setup_firefox
|
14
|
+
puts
|
15
|
+
|
16
|
+
note_cmd command.join
|
17
|
+
Util.system! *command
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
desc 'with-rake', 'Run tests with `rake`'
|
2
|
+
def with_rake
|
3
|
+
if file_containing?('Rakefile', /^task.+default.+(spec|test)/)
|
4
|
+
invoke_cmd 'bundle_install'
|
5
|
+
|
6
|
+
announce 'Running tests with `rake`'
|
7
|
+
Util.system! 'rake'
|
8
|
+
else
|
9
|
+
note '`rake` does not run tests.'
|
10
|
+
end
|
11
|
+
end
|
@@ -1,34 +1,32 @@
|
|
1
|
-
require
|
2
|
-
require File.join(File.dirname(__FILE__), 'firefox_for_selenium')
|
1
|
+
require 'rubygems'
|
3
2
|
require 'tempfile'
|
4
3
|
|
4
|
+
# This require-style is to prevent Ruby from loading files of a different
|
5
|
+
# version of Geordi.
|
6
|
+
require File.expand_path('../interaction', __FILE__)
|
7
|
+
require File.expand_path('../firefox_for_selenium', __FILE__)
|
8
|
+
|
5
9
|
module Geordi
|
6
10
|
class Cucumber
|
11
|
+
include Geordi::Interaction
|
7
12
|
|
8
13
|
VNC_DISPLAY = ':17'
|
9
14
|
VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} -localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024"
|
10
15
|
VNC_VIEWER_COMMAND = "vncviewer #{VNC_DISPLAY}"
|
11
16
|
VNC_ENV_VARIABLES = %w[DISPLAY BROWSER LAUNCHY_BROWSER]
|
12
17
|
|
13
|
-
def run
|
14
|
-
|
15
|
-
puts "Running Cucumber tests..."
|
16
|
-
puts "========================="
|
18
|
+
def run(argv)
|
19
|
+
self.argv = argv
|
17
20
|
|
18
21
|
consolidate_rerun_txt_files
|
19
22
|
show_features_to_run
|
20
|
-
|
21
23
|
setup_vnc
|
22
24
|
|
23
25
|
command = use_parallel_tests? ? parallel_execution_command : serial_execution_command
|
26
|
+
note 'Command: ' + command if argv.include? '-v'
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
2.times { puts }
|
28
|
-
end
|
29
|
-
|
30
|
-
2.times { puts }
|
31
|
-
exec command
|
28
|
+
puts
|
29
|
+
system command
|
32
30
|
end
|
33
31
|
|
34
32
|
def launch_vnc_viewer
|
@@ -38,10 +36,11 @@ module Geordi
|
|
38
36
|
end
|
39
37
|
unless $?.success?
|
40
38
|
if $?.exitstatus == 127
|
41
|
-
|
39
|
+
fail 'VNC viewer not found. Install it with `geordi setup-vnc`.'
|
42
40
|
else
|
43
|
-
|
41
|
+
note 'VNC viewer could not be opened:'
|
44
42
|
puts error
|
43
|
+
puts
|
45
44
|
end
|
46
45
|
end
|
47
46
|
}
|
@@ -58,21 +57,16 @@ module Geordi
|
|
58
57
|
VNC_ENV_VARIABLES.each do |variable|
|
59
58
|
ENV["OUTER_#{variable}"] = ENV[variable] if ENV[variable]
|
60
59
|
end
|
61
|
-
ENV["BROWSER"] = ENV["LAUNCHY_BROWSER"] = File.expand_path(
|
60
|
+
ENV["BROWSER"] = ENV["LAUNCHY_BROWSER"] = File.expand_path('../../../bin/launchy_browser', __FILE__)
|
62
61
|
ENV["DISPLAY"] = VNC_DISPLAY
|
63
62
|
|
64
|
-
|
65
|
-
puts "Selenium is running in a VNC window. Use cuc-show to view it."
|
63
|
+
note 'Selenium is running in a VNC window. Use `geordi vnc-show` to view it.'
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
69
|
-
|
70
67
|
private
|
71
68
|
|
72
|
-
|
73
|
-
def argv
|
74
|
-
@argv ||= ARGV
|
75
|
-
end
|
69
|
+
attr_accessor :argv
|
76
70
|
|
77
71
|
def serial_execution_command
|
78
72
|
format_args = []
|
@@ -83,7 +77,7 @@ module Geordi
|
|
83
77
|
end
|
84
78
|
|
85
79
|
def parallel_execution_command
|
86
|
-
|
80
|
+
note 'Using parallel_tests'
|
87
81
|
self.argv = argv - command_line_features
|
88
82
|
gem 'parallel_tests', parallel_tests_version
|
89
83
|
require 'parallel_tests'
|
@@ -112,13 +106,12 @@ module Geordi
|
|
112
106
|
end
|
113
107
|
|
114
108
|
def show_features_to_run
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
puts "-----------------------------------------"
|
109
|
+
if features_to_run.empty?
|
110
|
+
note 'All features in features/'
|
111
|
+
else
|
112
|
+
notification = 'Only: ' + features_to_run.join(', ')
|
113
|
+
notification << + ' (from rerun.txt)' if (features_to_run == rerun_txt_features) && (features_to_run != command_line_features)
|
114
|
+
note notification
|
122
115
|
end
|
123
116
|
end
|
124
117
|
|
@@ -170,8 +163,7 @@ module Geordi
|
|
170
163
|
def consolidate_rerun_txt_files
|
171
164
|
parallel_rerun_files = Dir.glob("parallel_rerun*.txt")
|
172
165
|
unless parallel_rerun_files.empty?
|
173
|
-
|
174
|
-
puts "consolidating parallel_rerun.txt files ..."
|
166
|
+
note 'Consolidating parallel_rerun.txt files ...'
|
175
167
|
|
176
168
|
rerun_content = []
|
177
169
|
parallel_rerun_files.each do |filename|
|
@@ -235,15 +227,12 @@ module Geordi
|
|
235
227
|
98 # was already running after all
|
236
228
|
true
|
237
229
|
when 127 # not installed
|
238
|
-
|
239
|
-
puts
|
240
|
-
puts
|
230
|
+
warn 'Could not launch VNC server. Install it with `geordi setup-vnc`.'
|
241
231
|
false
|
242
232
|
else
|
243
|
-
|
233
|
+
warn 'Starting VNC failed:'
|
244
234
|
puts error
|
245
235
|
puts
|
246
|
-
puts
|
247
236
|
false
|
248
237
|
end
|
249
238
|
end
|
data/lib/geordi/dump_loader.rb
CHANGED
@@ -1,86 +1,60 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'highline'
|
3
|
+
require 'geordi/interaction'
|
4
|
+
require 'geordi/util'
|
3
5
|
|
6
|
+
module Geordi
|
7
|
+
class DumpLoader
|
8
|
+
include Geordi::Interaction
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@argv = argv
|
9
|
-
@verbose = !!@argv.delete('-v')
|
10
|
-
end
|
11
|
-
|
12
|
-
def dumps_dir
|
13
|
-
require 'etc'
|
14
|
-
user_dir = Etc.getpwuid.dir
|
15
|
-
File.join(user_dir, 'dumps')
|
16
|
-
end
|
10
|
+
def initialize(file)
|
11
|
+
@dump_file = file
|
12
|
+
end
|
17
13
|
|
18
|
-
|
19
|
-
|
14
|
+
def development_database_config
|
15
|
+
require 'yaml'
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def mysql_command
|
27
|
-
ENV['MYSQL_PWD'] = config['password']
|
28
|
-
command = 'mysql --silent'
|
29
|
-
command << ' -u' << config['username']
|
30
|
-
command << ' --default-character-set=utf8'
|
31
|
-
command << ' ' << config['database']
|
32
|
-
command << ' < ' << dump_file
|
33
|
-
end
|
34
|
-
alias_method :mysql2_command, :mysql_command
|
17
|
+
@config ||= YAML::load(ERB.new(File.read('config/database.yml')).result)
|
18
|
+
@config['development']
|
19
|
+
end
|
20
|
+
alias_method :config, :development_database_config
|
35
21
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
def source_dump!
|
46
|
-
source_command = send("#{config['adapter']}_command")
|
47
|
-
`#{source_command}`
|
48
|
-
end
|
49
|
-
|
50
|
-
def choose_dump_file
|
51
|
-
highline = HighLine.new
|
52
|
-
|
53
|
-
available_dumps = Dir.glob("#{dumps_dir}/*.dump").sort
|
54
|
-
selected_dump = highline.choose(*available_dumps) do |menu|
|
55
|
-
menu.hidden('') { exit }
|
22
|
+
def mysql_command
|
23
|
+
command = 'mysql --silent'
|
24
|
+
command << ' -p' << config['password']
|
25
|
+
command << ' -u' << config['username']
|
26
|
+
command << ' --default-character-set=utf8'
|
27
|
+
command << ' ' << config['database']
|
28
|
+
command << ' < ' << dump_file
|
56
29
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
30
|
+
alias_method :mysql2_command, :mysql_command
|
31
|
+
|
32
|
+
def postgresql_command
|
33
|
+
ENV['PGPASSWORD'] = config['password']
|
34
|
+
command = 'pg_restore --no-owner --clean'
|
35
|
+
command << ' --username=' << config['username']
|
36
|
+
command << ' --host=' << config['host']
|
37
|
+
command << ' --dbname=' << config['database']
|
38
|
+
command << ' ' << dump_file
|
64
39
|
end
|
65
|
-
end
|
66
40
|
|
67
|
-
|
68
|
-
|
41
|
+
def dump_file
|
42
|
+
@dump_file ||= begin
|
43
|
+
dumps_glob = File.join(File.expand_path('~'), 'dumps', '*.dump')
|
44
|
+
available_dumps = Dir.glob(dumps_glob).sort
|
69
45
|
|
70
|
-
|
46
|
+
HighLine.new.choose(*available_dumps) do |menu|
|
47
|
+
menu.hidden('') { fail 'Abort.' }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def load
|
53
|
+
note 'Source file: ' + dump_file
|
71
54
|
|
72
|
-
|
73
|
-
|
74
|
-
else
|
75
|
-
$stderr.puts "An error occured while loading the dump #{File.basename(dump_file)}."
|
55
|
+
source_command = send("#{config['adapter']}_command")
|
56
|
+
Util.system! source_command, :fail_message => "An error occured loading #{File.basename(dump_file)}"
|
76
57
|
end
|
77
|
-
|
78
|
-
$?.success?
|
79
|
-
end
|
80
58
|
|
81
|
-
def execute!
|
82
|
-
execute or exit(1)
|
83
59
|
end
|
84
|
-
|
85
60
|
end
|
86
|
-
|