geordi 0.18.0 → 1.0.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.
- 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
data/bin/cuc-vnc-setup
CHANGED
@@ -1,116 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
# colorization
|
5
|
-
def colorize(color_code)
|
6
|
-
"\e[#{color_code}m#{self}\e[0m"
|
7
|
-
end
|
8
|
-
|
9
|
-
def red
|
10
|
-
colorize(31)
|
11
|
-
end
|
12
|
-
|
13
|
-
def green
|
14
|
-
colorize(32)
|
15
|
-
end
|
16
|
-
|
17
|
-
def yellow
|
18
|
-
colorize(33)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def pause
|
23
|
-
puts
|
24
|
-
puts "[ENTER] to continue".yellow
|
25
|
-
gets
|
26
|
-
puts
|
27
|
-
end
|
28
|
-
|
29
|
-
def say(text)
|
30
|
-
text =~ /^( *)./
|
31
|
-
level = $1 ? $1.size : 0
|
32
|
-
text.gsub!(/^ {#{level}}/, '')
|
33
|
-
puts text
|
34
|
-
end
|
35
|
-
|
36
|
-
def installed?(app)
|
37
|
-
`which #{app}`
|
38
|
-
$?.success?
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
`clear`
|
43
|
-
|
44
|
-
say <<-TEXT
|
45
|
-
|
46
|
-
This script will help you install a VNC server and a VNC viewer.
|
47
|
-
|
48
|
-
With those you will be able to use #{"cuc".green} without being disturbed by
|
49
|
-
focus-stealing selenium windows.
|
50
|
-
|
51
|
-
All windows will insteads open inside a VNC session. You can still inspect
|
52
|
-
everything by using the #{"cuc-show".green} command.
|
53
|
-
TEXT
|
54
|
-
pause
|
55
|
-
|
56
|
-
say <<-TEXT
|
57
|
-
#{"Please open a second shell to execute any commands.".red}
|
58
|
-
TEXT
|
59
|
-
pause
|
60
|
-
|
61
|
-
if installed?("vncserver")
|
62
|
-
say <<-TEXT
|
63
|
-
It appears #{"you already have a VNC server installed".green}. Good job.
|
64
|
-
TEXT
|
65
|
-
pause
|
66
|
-
else
|
67
|
-
say <<-TEXT
|
68
|
-
We are going to install and configure a VNC server.
|
69
|
-
|
70
|
-
Please run:
|
71
|
-
#{"sudo apt-get install vnc4server".red}
|
72
|
-
TEXT
|
73
|
-
pause
|
74
|
-
|
75
|
-
say <<-TEXT
|
76
|
-
We will now set a password for your VNC server. #{"Please choose a secure password.".red}
|
77
|
-
|
78
|
-
When running the #{"cuc".green} script, you will not actually need this password,
|
79
|
-
and there is no security risk. However if you start a vncserver without
|
80
|
-
#{"cuc".green}, a user with this password can connect to your machine.
|
81
|
-
|
82
|
-
Please run:
|
83
|
-
#{"vncserver :20".red}
|
84
|
-
#{"and enter a password".red}
|
85
|
-
TEXT
|
86
|
-
pause
|
87
|
-
|
88
|
-
say <<-TEXT
|
89
|
-
We will now stop the server again.
|
90
|
-
|
91
|
-
Please run:
|
92
|
-
#{"vncserver -kill :20".red}
|
93
|
-
TEXT
|
94
|
-
pause
|
95
|
-
end
|
96
|
-
|
97
|
-
if installed?("vncviewer")
|
98
|
-
say <<-TEXT
|
99
|
-
It appears #{"you already have a VNC viewer installed".green}. Good job.
|
100
|
-
TEXT
|
101
|
-
pause
|
102
|
-
else
|
103
|
-
say <<-TEXT
|
104
|
-
We are going to install and configure a VNC viewer.
|
105
|
-
|
106
|
-
Please run:
|
107
|
-
#{"sudo apt-get install xtightvncviewer".red}
|
108
|
-
TEXT
|
109
|
-
pause
|
110
|
-
end
|
111
|
-
|
112
|
-
say <<-TEXT
|
113
|
-
All done. #{"cuc".green} will automatically use this from now on.
|
114
|
-
|
115
|
-
#{"Happy cuking!".green}
|
116
|
-
TEXT
|
3
|
+
exec 'geordi', 'setup-vnc'
|
data/bin/deploy-to-production
CHANGED
@@ -1,93 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
colors = %w[ black red green yellow blue pink cyan white ].map(&:to_sym)
|
5
|
-
color = 30 + colors.index(color_name)
|
6
|
-
if background_code = colors.index(background_color_name)
|
7
|
-
background = 40 + background_code
|
8
|
-
bold = 1
|
9
|
-
end
|
10
|
-
[ bold, color, background ].compact.join ';'
|
11
|
-
end
|
12
|
-
|
13
|
-
def colorize(text, color_name, background_color_name = nil)
|
14
|
-
color_code = color_code(color_name, background_color_name)
|
15
|
-
"\e[#{color_code}m#{text}\e[0m"
|
16
|
-
end
|
17
|
-
|
18
|
-
def header(text)
|
19
|
-
puts colorize(text, :yellow, :blue), ''
|
20
|
-
end
|
21
|
-
|
22
|
-
def call_or_fail(command, return_output = false)
|
23
|
-
puts colorize(command, :pink), ''
|
24
|
-
if return_output
|
25
|
-
result = `#{command}`.to_s.strip
|
26
|
-
$?.success? or raise "Error while calling #{command}: #{$?}"
|
27
|
-
else
|
28
|
-
result = system(command) or raise "Error while calling #{command}: #{$?}"
|
29
|
-
puts
|
30
|
-
end
|
31
|
-
result
|
32
|
-
end
|
33
|
-
|
34
|
-
def prompt(message, default)
|
35
|
-
print "#{message}"
|
36
|
-
print " [#{default}]" if default
|
37
|
-
print ": "
|
38
|
-
input = gets.strip
|
39
|
-
if input.empty? && default
|
40
|
-
input = default
|
41
|
-
end
|
42
|
-
puts
|
43
|
-
input
|
44
|
-
end
|
45
|
-
|
46
|
-
def success(message)
|
47
|
-
puts colorize(message, :green), ''
|
48
|
-
exit 0
|
49
|
-
end
|
50
|
-
|
51
|
-
def error(message)
|
52
|
-
puts colorize(message, :red), ''
|
53
|
-
exit 1
|
54
|
-
end
|
55
|
-
|
56
|
-
puts
|
57
|
-
|
58
|
-
ENV['PAGER'] = 'cat'
|
59
|
-
|
60
|
-
master_branch = prompt('master branch', 'master')
|
61
|
-
production_branch = prompt('production branch', 'production')
|
62
|
-
production_stage = prompt('production capistrano stage', 'production')
|
63
|
-
|
64
|
-
header("Checking if your #{master_branch} is up to date")
|
65
|
-
|
66
|
-
diff_size = call_or_fail("git fetch && git diff #{master_branch} origin/#{master_branch} | wc -l", true)
|
67
|
-
changes_size = call_or_fail("git status -s | wc -l", true)
|
68
|
-
|
69
|
-
if diff_size == '0' and changes_size == '0'
|
70
|
-
puts "All good.", ''
|
71
|
-
else
|
72
|
-
error "Your #{master_branch} is not the same as on origin or holds uncommitted changes. Fix that first."
|
73
|
-
end
|
74
|
-
|
75
|
-
header("Checking what's on #{production_stage} right now...")
|
76
|
-
|
77
|
-
call_or_fail("git checkout #{production_branch} && git pull")
|
78
|
-
|
79
|
-
header("You are about to deploy the following commits from #{master_branch} to #{production_branch}:")
|
80
|
-
|
81
|
-
call_or_fail("git log #{production_branch}..#{master_branch} --oneline")
|
82
|
-
|
83
|
-
if prompt("Go ahead with the deployment? (y/n)", "n").downcase == 'y'
|
84
|
-
capistrano_call = "cap #{production_stage} deploy:migrations"
|
85
|
-
if File.exists?('Gemfile') && File.open('Gemfile').read.scan(/capistrano/).any?
|
86
|
-
capistrano_call = "bundle exec #{capistrano_call}"
|
87
|
-
end
|
88
|
-
call_or_fail("git merge #{master_branch} && git push && #{capistrano_call}")
|
89
|
-
success 'Deployment complete.'
|
90
|
-
else
|
91
|
-
error 'Deployment cancelled.'
|
92
|
-
end
|
93
|
-
|
3
|
+
exec 'geordi', 'deploy'
|
data/bin/dump-for
CHANGED
@@ -1,35 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + "/../lib/geordi/capistrano"
|
3
|
-
require File.dirname(__FILE__) + "/../lib/geordi/dump_loader"
|
4
|
-
include Geordi::Capistrano
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
success = shell_for("dumple #{config.env} --for_download", :exec => false)
|
10
|
-
|
11
|
-
if success
|
12
|
-
source_path = "~/dumps/dump_for_download.dump"
|
13
|
-
destination_directory = "#{config.root}/tmp"
|
14
|
-
system "mkdir -p #{destination_directory}" # Ensure the destination directory exists
|
15
|
-
destination_path = "#{destination_directory}/#{stage}.dump"
|
16
|
-
|
17
|
-
puts "Downloading dump_for_download ..."
|
18
|
-
system "scp #{config.user}@#{config.primary_server}:#{source_path} #{destination_path}"
|
19
|
-
puts "Dumped the #{stage.upcase} database to RAILS_ROOT/tmp/#{stage}.dump"
|
20
|
-
|
21
|
-
# source dump if option was given
|
22
|
-
if ARGV.include?("-s")
|
23
|
-
puts
|
24
|
-
puts "Sourcing dump into development database..."
|
25
|
-
success = DumpLoader.new([destination_path]).execute
|
26
|
-
if success
|
27
|
-
puts "Your database is now sourced with a fresh #{stage} dump."
|
28
|
-
else
|
29
|
-
$stderr.puts "Could not source the downloaded #{stage} dump."
|
30
|
-
end
|
31
|
-
end
|
32
|
-
else
|
33
|
-
raise "An error occurred. Aborting..."
|
34
|
-
end
|
3
|
+
if (i = ARGV.index '-s')
|
4
|
+
ARGV[i] = '-l'
|
35
5
|
end
|
6
|
+
|
7
|
+
exec 'geordi', 'dump', *ARGV
|
data/bin/dumple
CHANGED
@@ -60,8 +60,7 @@ begin
|
|
60
60
|
dump_path = "#{dump_dir}/#{config['database']}_#{Time.now.strftime("%Y%m%d_%H%M%S")}.dump"
|
61
61
|
end
|
62
62
|
|
63
|
-
puts
|
64
|
-
puts "Dumping database for \"#{environment}\" environment ..."
|
63
|
+
puts "> Dumping database for \"#{environment}\" environment ..."
|
65
64
|
|
66
65
|
host = config['host'] || 'localhost'
|
67
66
|
|
@@ -78,8 +77,7 @@ begin
|
|
78
77
|
|
79
78
|
dump_size_kb = (File.size(dump_path) / 1024).round
|
80
79
|
|
81
|
-
puts "Dumped to #{dump_path} (#{dump_size_kb} KB)"
|
82
|
-
puts
|
80
|
+
puts "> Dumped to #{dump_path} (#{dump_size_kb} KB)"
|
83
81
|
rescue Exception => e
|
84
82
|
$stderr.puts e.message
|
85
83
|
exit 1
|
data/bin/geordi
ADDED
data/bin/gitpt
CHANGED
data/bin/launchy_browser
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.join(File.dirname(__FILE__), '../lib/geordi/cuc')
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
# This script is a part of Geordi. It is used by the cucumber command to have
|
4
|
+
# launchy open error pages from tests in the users browser, as apposed to
|
5
|
+
# opening it within VNC.
|
6
6
|
|
7
|
+
# For unknown reasons, #require cannot find 'geordi/cucumber', so we need to
|
8
|
+
# require it this way. Hours have been spent trying to require 'geordi/cucumber'.
|
9
|
+
require File.expand_path('../../lib/geordi/cucumber', __FILE__)
|
7
10
|
Geordi::Cucumber.new.restore_env
|
8
11
|
|
12
|
+
require 'rubygems'
|
13
|
+
require 'launchy'
|
14
|
+
|
9
15
|
Launchy.open(ARGV.first)
|
data/bin/load-dump
CHANGED
data/bin/migrate-all
CHANGED
@@ -1,15 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
parallel_tests_available = ['rake', 'parallel:spec'] if File.exists?('Gemfile') && File.open('Gemfile').read.scan(/parallel_tests/).any?
|
5
|
-
|
6
|
-
command = if parallel_tests_available
|
7
|
-
'b rake db:migrate parallel:prepare'
|
8
|
-
else
|
9
|
-
'power-rake db:migrate'
|
10
|
-
end
|
11
|
-
|
12
|
-
4.times { puts }
|
13
|
-
puts "Running command:\n#{command}"
|
14
|
-
puts "============================================"
|
15
|
-
exec command
|
3
|
+
exec 'geordi', 'migrate'
|
data/bin/optimize-png
CHANGED
@@ -1,120 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
# pngcrush -rem allb -reduce -brute original.png optimized.png
|
5
|
-
# pngcrush -d target-dir/ *.png
|
6
|
-
#
|
7
|
-
# -rem allb — remove all extraneous data (Except transparency and gamma; to remove everything except transparency, try -rem alla)
|
8
|
-
# -reduce — eliminate unused colors and reduce bit-depth (If possible)
|
9
|
-
#
|
10
|
-
# -brute — attempt all optimization methods (Requires MUCH MORE processing time and may not improve optimization by much)
|
11
|
-
#
|
12
|
-
# original.png — the name of the original (unoptimized) PNG file
|
13
|
-
# optimized.png — the name of the new, optimized PNG file
|
14
|
-
# -d target-dir/ — bulk convert into this directory "target-dir"
|
15
|
-
#
|
16
|
-
# -rem cHRM -rem sRGB -rem gAMA -rem ICC — remove color profiles by name (shortcut -rem alla)
|
17
|
-
#
|
18
|
-
# An article explaining why removing gamma correction
|
19
|
-
# http://hsivonen.iki.fi/png-gamma/
|
20
|
-
|
21
|
-
# Rails: file activesupport/lib/active_support/core_ext/string/starts_ends_with.rb, line 27
|
22
|
-
def ends_with?(string, suffix)
|
23
|
-
string[-suffix.length, suffix.length] == suffix
|
24
|
-
end
|
25
|
-
|
26
|
-
def indented_puts(str="")
|
27
|
-
puts " #{str}"
|
28
|
-
end
|
29
|
-
|
30
|
-
def print_manual
|
31
|
-
script_name = "optimize-png"
|
32
|
-
|
33
|
-
indented_puts
|
34
|
-
indented_puts script_name
|
35
|
-
indented_puts "=" *script_name.size
|
36
|
-
indented_puts "- Removes color profiles: cHRM, sRGB, gAMA, ICC, etc."
|
37
|
-
indented_puts "- Eliminates unused colors and reduce bit-depth (If possible)"
|
38
|
-
indented_puts "- May reduce PNG file size lossless"
|
39
|
-
indented_puts
|
40
|
-
indented_puts "Batch-optimize all *.png in a directory:"
|
41
|
-
indented_puts " #{script_name} directory"
|
42
|
-
indented_puts
|
43
|
-
indented_puts "Batch-optimize the current directory:"
|
44
|
-
indented_puts " #{script_name} ."
|
45
|
-
indented_puts
|
46
|
-
indented_puts "Optimize single file:"
|
47
|
-
indented_puts " #{script_name} input.png"
|
48
|
-
indented_puts
|
49
|
-
end
|
50
|
-
|
51
|
-
def optimization_default_args
|
52
|
-
args = ""
|
53
|
-
args << "-rem alla " # remove everything except transparency
|
54
|
-
args << "-rem text " # remove text chunks
|
55
|
-
args << "-reduce " # eliminate unused colors and reduce bit-depth (If possible)
|
56
|
-
args
|
57
|
-
end
|
58
|
-
|
59
|
-
def optimize_file(input_file, output_file)
|
60
|
-
system "pngcrush #{optimization_default_args} '#{input_file}' '#{output_file}'"
|
61
|
-
end
|
62
|
-
|
63
|
-
def unused_tempfile_path(original)
|
64
|
-
dirname = File.dirname(original)
|
65
|
-
basename = File.basename(original)
|
66
|
-
count = 0
|
67
|
-
begin
|
68
|
-
tmp_name = "#{dirname}/#{basename}_temp_#{count += 1}.png"
|
69
|
-
end while File.exists?(tmp_name)
|
70
|
-
tmp_name
|
71
|
-
end
|
72
|
-
|
73
|
-
def optimize_inplace(input_file)
|
74
|
-
temp_file = unused_tempfile_path(input_file)
|
75
|
-
result = optimize_file(input_file, temp_file)
|
76
|
-
if result.nil?
|
77
|
-
puts "Error was #{$?}"
|
78
|
-
else
|
79
|
-
FileUtils.rm(input_file)
|
80
|
-
FileUtils.mv("#{temp_file}", "#{input_file}")
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def batch_optimize_inplace(path)
|
85
|
-
# Dir[".png"] works case sensitive, so to catch all funky .png extensions we have to go the following way:
|
86
|
-
png_relative_paths = []
|
87
|
-
Dir["#{path}/*.*"].each do |file_name|
|
88
|
-
png_relative_paths << file_name if ends_with?(File.basename(file_name.downcase), ".png")
|
89
|
-
end
|
90
|
-
png_relative_paths.each do |png_relative_path|
|
91
|
-
optimize_inplace(png_relative_path)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def main
|
96
|
-
if `which pngcrush`.strip == ""
|
97
|
-
indented_puts
|
98
|
-
indented_puts "You have to install pngcrush first: sudo apt-get install pngcrush"
|
99
|
-
indented_puts
|
100
|
-
elsif ARGV.size == 1
|
101
|
-
path = ARGV[0]
|
102
|
-
if File.directory?(path)
|
103
|
-
batch_optimize_inplace(path)
|
104
|
-
elsif File.file?(path)
|
105
|
-
optimize_inplace(path)
|
106
|
-
else
|
107
|
-
print_manual
|
108
|
-
indented_puts "*** Error: '#{path}' is neither a directory nor a file ***"
|
109
|
-
indented_puts
|
110
|
-
end
|
111
|
-
else
|
112
|
-
print_manual
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
main()
|
117
|
-
|
118
|
-
|
119
|
-
|
120
2
|
|
3
|
+
exec 'geordi', 'png-optimize', *ARGV
|
data/bin/power-rake
CHANGED
data/bin/remove-executable-flags
CHANGED
@@ -1,8 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
for pattern in %w[ *.rb *.html *.erb *.haml *.yml *.css *.sass *.rake *.png *.jpg *.gif *.pdf *.txt *.rdoc Rakefile VERSION README Capfile ]
|
5
|
-
puts "- #{pattern}"
|
6
|
-
`find . -name "#{pattern}" -exec chmod -x {} ';'`
|
7
|
-
end
|
8
|
-
puts "Done."
|
3
|
+
exec 'geordi', 'remove-executable-flags'
|
data/bin/rs
CHANGED
@@ -1,28 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
4.times { puts }
|
5
|
-
puts "Running RSpec tests..."
|
6
|
-
puts "======================"
|
7
|
-
|
8
|
-
# Check if we're looking at a Rails 2 / rspec 1 project
|
9
|
-
rspec1 = File.exists?('script/spec')
|
10
|
-
rspec_args = rspec1 ? ["spec", "-c"] : ["rspec"]
|
11
|
-
|
12
|
-
# Check if rspec_spinner is available
|
13
|
-
spinner_available = File.exists?('Gemfile') && File.open('Gemfile').read.scan(/rspec_spinner/).any?
|
14
|
-
spinner_args = spinner_available ? ['-r', 'rspec_spinner', '-f', 'RspecSpinner::Bar'] : []
|
15
|
-
|
16
|
-
# Check if parallel_tests is available
|
17
|
-
parallel_tests_available = ['rake', 'parallel:spec'] if File.exists?('Gemfile') && File.open('Gemfile').read.scan(/parallel_tests/).any?
|
18
|
-
|
19
|
-
use_parallel_tests = parallel_tests_available && (ARGV[0] == nil)
|
20
|
-
|
21
|
-
if use_parallel_tests
|
22
|
-
puts "Using parallel_tests ...\n\n"
|
23
|
-
exec 'b rake parallel:spec'
|
24
|
-
else
|
25
|
-
# Run rspec behind bundler
|
26
|
-
ARGV[0] ||= 'spec'
|
27
|
-
exec *["b", rspec_args, spinner_args, ARGV].flatten
|
28
|
-
end
|
3
|
+
exec 'geordi', 'rspec', *ARGV
|
data/bin/run_tests
CHANGED
data/bin/shell-for
CHANGED
@@ -1,10 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + "/../lib/geordi/capistrano"
|
3
|
-
include Geordi::Capistrano
|
4
2
|
|
5
|
-
|
6
|
-
self.stage = ARGV.shift
|
7
|
-
command = ARGV.any? ? ARGV.join(' ') : nil
|
8
|
-
|
9
|
-
shell_for(command, :select_server => true)
|
10
|
-
end
|
3
|
+
exec 'geordi', 'shell', *ARGV
|
data/bin/tests
CHANGED
data/geordi.gemspec
CHANGED
@@ -19,4 +19,23 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# s.add_development_dependency 'debugger'
|
24
|
+
|
25
|
+
s.post_install_message = <<-ATTENTION
|
26
|
+
|
27
|
+
********************************************
|
28
|
+
|
29
|
+
geordi 1.0.0 moves most of the scripts to
|
30
|
+
the `geordi` binary. Run `geordi` and
|
31
|
+
`geordi help <cmd>` for further information.
|
32
|
+
|
33
|
+
Tip: Create an alias for geordi for quick
|
34
|
+
access. Add this to your ~/.bashrc:
|
35
|
+
|
36
|
+
alias g="geordi"
|
37
|
+
|
38
|
+
********************************************
|
39
|
+
|
40
|
+
ATTENTION
|
22
41
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# This file serves as a template for adding new commands.
|
2
|
+
# For more inspiration, see already implemented commands.
|
3
|
+
|
4
|
+
# Since commands can be invoked by only typing their first letters, please try
|
5
|
+
# to find a command name that has a unique prefix.
|
6
|
+
|
7
|
+
desc 'command ARG [OPTIONAL]', 'one-line description'
|
8
|
+
long_desc <<-LONGDESC # optional
|
9
|
+
Start with an example: `command bla bla`
|
10
|
+
|
11
|
+
Detailed description with anything the user needs to know.
|
12
|
+
|
13
|
+
Short and long description are printed on the console AND included in the README
|
14
|
+
by `rake update_readme`. Thus, please format descriptions in a way that's reader
|
15
|
+
friendly both in Markdown and the console.
|
16
|
+
LONGDESC
|
17
|
+
|
18
|
+
option :opt, :type => :boolean, :aliases => '-o', :banner => 'VALUE_NAME',
|
19
|
+
:desc => 'If set, VALUE_NAME will be used for something'
|
20
|
+
|
21
|
+
def setup
|
22
|
+
# Invoke other commands like this:
|
23
|
+
invoke_cmd 'other_command', 'argument', :an => 'option'
|
24
|
+
|
25
|
+
fail 'Option missing' unless options.opt?
|
26
|
+
|
27
|
+
# For formatted output, see geordi/interaction.rb
|
28
|
+
success 'Done.'
|
29
|
+
end
|
data/lib/geordi/capistrano.rb
CHANGED
@@ -16,7 +16,7 @@ module Geordi
|
|
16
16
|
@root = find_project_root!
|
17
17
|
load_capistrano_config
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def user
|
21
21
|
@capistrano_config.fetch(:user)
|
22
22
|
end
|
@@ -24,7 +24,7 @@ module Geordi
|
|
24
24
|
def servers
|
25
25
|
@capistrano_config.find_servers(:roles => [:app])
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def primary_server
|
29
29
|
@capistrano_config.find_servers(:roles => [:app], :only => { :primary => true }).first
|
30
30
|
end
|
@@ -40,7 +40,7 @@ module Geordi
|
|
40
40
|
def shell
|
41
41
|
@capistrano_config.fetch(:default_shell, 'bash --login')
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
|
45
45
|
private
|
46
46
|
|
@@ -49,7 +49,9 @@ module Geordi
|
|
49
49
|
config.load('deploy')
|
50
50
|
config.load('config/deploy')
|
51
51
|
if @stage and @stage != ''
|
52
|
+
puts ::Capistrano::Version.to_s
|
52
53
|
config.stage = @stage
|
54
|
+
|
53
55
|
config.find_and_execute_task(stage)
|
54
56
|
end
|
55
57
|
|
@@ -83,7 +85,7 @@ module Geordi
|
|
83
85
|
exit 1
|
84
86
|
end
|
85
87
|
end
|
86
|
-
|
88
|
+
|
87
89
|
def select_server
|
88
90
|
choose do |menu|
|
89
91
|
config.servers.each do |server|
|
@@ -99,11 +101,11 @@ module Geordi
|
|
99
101
|
|
100
102
|
def shell_for(command, options = {})
|
101
103
|
server = options[:select_server] ? select_server : config.primary_server
|
102
|
-
|
104
|
+
|
103
105
|
remote_commands = [ 'cd', config.path ]
|
104
106
|
remote_commands << '&&' << config.shell
|
105
107
|
remote_commands << "-c '#{command}'" if command
|
106
|
-
|
108
|
+
|
107
109
|
args = [ 'ssh', %(#{config.user}@#{server}), '-t', remote_commands.join(' ') ]
|
108
110
|
if options.fetch(:exec, true)
|
109
111
|
exec(*args)
|
@@ -111,6 +113,6 @@ module Geordi
|
|
111
113
|
system(*args)
|
112
114
|
end
|
113
115
|
end
|
114
|
-
|
116
|
+
|
115
117
|
end
|
116
118
|
end
|