geordi 0.3.2 → 0.4.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/bin/console-for +25 -0
- data/bin/dump-for +6 -6
- data/bin/shell-for +9 -5
- data/lib/geordi/version.rb +1 -1
- metadata +7 -5
data/bin/console-for
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def find_project_root
|
4
|
+
current = Dir.pwd
|
5
|
+
until (File.exists? 'Capfile')
|
6
|
+
Dir.chdir '..'
|
7
|
+
return nil if current == Dir.pwd
|
8
|
+
current = Dir.pwd
|
9
|
+
end
|
10
|
+
current
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
stage = ARGV.shift
|
15
|
+
root = find_project_root or raise 'Call me from inside a Rails project!'
|
16
|
+
|
17
|
+
if File.exists? "#{root}/script/console"
|
18
|
+
exec "shell-for #{stage} script/console #{stage}"
|
19
|
+
else
|
20
|
+
exec "shell-for #{stage} bundle exec rails console #{stage}"
|
21
|
+
end
|
22
|
+
rescue Exception => e
|
23
|
+
$stderr.puts e.message
|
24
|
+
exit 1
|
25
|
+
end
|
data/bin/dump-for
CHANGED
@@ -18,18 +18,16 @@ def find_project_root
|
|
18
18
|
end
|
19
19
|
|
20
20
|
begin
|
21
|
-
require 'rubygems'
|
22
|
-
require 'net/ssh'
|
23
|
-
|
24
21
|
stage = ARGV.shift
|
22
|
+
dump_name = "dump_for_download.dump"
|
25
23
|
|
26
|
-
find_project_root or raise 'Call me from inside a Rails project'
|
24
|
+
find_project_root or raise 'Call me from inside a Rails project!'
|
27
25
|
|
28
26
|
data = if stage
|
29
27
|
deploy_file = Dir['config/deploy/*.rb'].find do |file|
|
30
28
|
file.match(/\/#{stage}.rb$/)
|
31
29
|
end
|
32
|
-
deploy_file or raise "
|
30
|
+
deploy_file or raise "Stage does not exist: #{stage}"
|
33
31
|
|
34
32
|
File.open(deploy_file).readlines
|
35
33
|
else
|
@@ -53,7 +51,9 @@ begin
|
|
53
51
|
system command
|
54
52
|
|
55
53
|
puts "Downloading dump_for_download..."
|
56
|
-
|
54
|
+
system "scp #{user}@#{server}:~/dumps/#{dump_name} #{@project_root}/tmp/#{environment}.dump"
|
55
|
+
puts
|
56
|
+
puts "Dumped the #{environment.upcase} database to PROJECT_ROOT/tmp/#{environment}.dump"
|
57
57
|
|
58
58
|
rescue Exception => e
|
59
59
|
$stderr.puts e.message
|
data/bin/shell-for
CHANGED
@@ -19,8 +19,9 @@ end
|
|
19
19
|
|
20
20
|
begin
|
21
21
|
stage = ARGV.shift
|
22
|
+
remote_command = ARGV.join(' ').strip
|
22
23
|
|
23
|
-
find_project_root or raise 'Call me from inside a Rails project'
|
24
|
+
find_project_root or raise 'Call me from inside a Rails project!'
|
24
25
|
|
25
26
|
data = if stage
|
26
27
|
deploy_file = Dir['config/deploy/*.rb'].find do |file|
|
@@ -40,17 +41,20 @@ begin
|
|
40
41
|
(user and server and deploy_to) or raise "Could not find required data (user, server and deploy-target).\nUsage: shell-for DEPLOYMENT_STAGE"
|
41
42
|
|
42
43
|
path = deploy_to + "/current"
|
43
|
-
|
44
|
+
ssh = %(ssh #{user}@#{server})
|
44
45
|
|
45
46
|
if path.match /#\{.*\}/
|
46
47
|
puts %(NOTE: "#{path}" is not a valid path.)
|
47
48
|
puts %(NOTE: Connecting to deploy user home.)
|
49
|
+
puts
|
48
50
|
sleep 2
|
51
|
+
|
52
|
+
exec ssh
|
49
53
|
else
|
50
|
-
command
|
54
|
+
command = remote_command.empty? ? "bash --login" : remote_command
|
55
|
+
|
56
|
+
exec ssh + %( -t "cd #{path} && #{command}")
|
51
57
|
end
|
52
|
-
|
53
|
-
exec command
|
54
58
|
|
55
59
|
rescue Exception => e
|
56
60
|
$stderr.puts e.message
|
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: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.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: 2011-
|
18
|
+
date: 2011-07-08 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -26,6 +26,7 @@ executables:
|
|
26
26
|
- apache-site
|
27
27
|
- b
|
28
28
|
- cleanup-directory
|
29
|
+
- console-for
|
29
30
|
- cuc
|
30
31
|
- dump-for
|
31
32
|
- dumple
|
@@ -50,6 +51,7 @@ files:
|
|
50
51
|
- bin/apache-site
|
51
52
|
- bin/b
|
52
53
|
- bin/cleanup-directory
|
54
|
+
- bin/console-for
|
53
55
|
- bin/cuc
|
54
56
|
- bin/dump-for
|
55
57
|
- bin/dumple
|