inploy 1.2.0 → 1.3.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/Rakefile +1 -1
- data/lib/inploy/deploy.rb +20 -8
- data/lib/inploy/helper.rb +15 -8
- data/lib/inploy/servers/passenger.rb +9 -0
- data/lib/inploy/servers/unicorn.rb +9 -0
- data/lib/inploy/templates/locaweb.rb +33 -0
- data/lib/tasks/inploy.rake +3 -0
- metadata +7 -5
- data/lib/inploy/locaweb.rb +0 -31
data/Rakefile
CHANGED
data/lib/inploy/deploy.rb
CHANGED
@@ -2,19 +2,29 @@ module Inploy
|
|
2
2
|
class Deploy
|
3
3
|
include Helper
|
4
4
|
|
5
|
-
attr_accessor :repository, :user, :application, :hosts, :path, :ssh_opts, :branch
|
5
|
+
attr_accessor :repository, :user, :application, :hosts, :path, :ssh_opts, :branch, :environment
|
6
6
|
|
7
7
|
def initialize
|
8
|
+
self.server = :passenger
|
8
9
|
@branch = 'master'
|
10
|
+
@environment = 'production'
|
9
11
|
end
|
10
12
|
|
11
13
|
def template=(template)
|
12
|
-
|
13
|
-
|
14
|
+
load_module("templates/#{template}")
|
15
|
+
end
|
16
|
+
|
17
|
+
def server=(server)
|
18
|
+
load_module("servers/#{server}")
|
14
19
|
end
|
15
20
|
|
16
21
|
def remote_setup
|
17
|
-
|
22
|
+
if branch.eql? "master"
|
23
|
+
checkout = ""
|
24
|
+
else
|
25
|
+
checkout = "&& $($(git branch | grep -vq #{branch}) && git checkout -f -b #{branch} origin/#{branch})"
|
26
|
+
end
|
27
|
+
remote_run "cd #{path} && git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout} && rake inploy:local:setup environment=#{environment}"
|
18
28
|
end
|
19
29
|
|
20
30
|
def local_setup
|
@@ -24,24 +34,26 @@ module Inploy
|
|
24
34
|
end
|
25
35
|
|
26
36
|
def remote_update
|
27
|
-
remote_run "cd #{application_path} && rake inploy:local:update"
|
37
|
+
remote_run "cd #{application_path} && rake inploy:local:update environment=#{environment}"
|
28
38
|
end
|
29
39
|
|
30
40
|
def local_update
|
31
41
|
run "git pull origin #{branch}"
|
32
42
|
after_update_code
|
33
43
|
end
|
34
|
-
|
44
|
+
|
35
45
|
private
|
36
46
|
|
37
47
|
def after_update_code
|
48
|
+
run "git submodule update --init"
|
38
49
|
copy_sample_files
|
39
50
|
install_gems
|
40
51
|
migrate_database
|
41
52
|
run "rm -R -f public/cache"
|
42
53
|
rake_if_included "more:parse"
|
43
54
|
rake_if_included "asset:packager:build_all"
|
44
|
-
|
45
|
-
|
55
|
+
rake_if_included "hoptoad:deploy TO=#{environment} REPO=#{repository} REVISION=#{`git log | head -1 | cut -d ' ' -f 2`}"
|
56
|
+
restart_server
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
data/lib/inploy/helper.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
module Inploy
|
2
2
|
module Helper
|
3
|
+
def load_module(filename)
|
4
|
+
require "inploy/#{filename}"
|
5
|
+
extend eval(filename.split("/").map { |word| camelize(word) }.join("::"))
|
6
|
+
end
|
7
|
+
|
3
8
|
def create_folders(*folders)
|
4
9
|
folders.each { |folder| create_folder folder }
|
5
10
|
end
|
6
|
-
|
11
|
+
|
7
12
|
def create_folder(path)
|
8
13
|
run "mkdir -p #{path}"
|
9
14
|
end
|
10
|
-
|
15
|
+
|
11
16
|
def host
|
12
17
|
hosts.first
|
13
18
|
end
|
14
|
-
|
19
|
+
|
15
20
|
def camelize(string)
|
16
21
|
string.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
17
22
|
end
|
@@ -27,12 +32,14 @@ module Inploy
|
|
27
32
|
end
|
28
33
|
|
29
34
|
def secure_copy(src, dest)
|
30
|
-
|
31
|
-
|
35
|
+
unless File.exists?(dest)
|
36
|
+
log "mv #{src} #{dest}"
|
37
|
+
FileUtils.cp src, dest
|
38
|
+
end
|
32
39
|
end
|
33
40
|
|
34
41
|
def migrate_database
|
35
|
-
rake "db:migrate RAILS_ENV
|
42
|
+
rake "db:migrate RAILS_ENV=#{environment}"
|
36
43
|
end
|
37
44
|
|
38
45
|
def tasks
|
@@ -40,7 +47,7 @@ module Inploy
|
|
40
47
|
end
|
41
48
|
|
42
49
|
def rake_if_included(command)
|
43
|
-
rake command if tasks.include?("rake #{command}")
|
50
|
+
rake command if tasks.include?("rake #{command.split[0]}")
|
44
51
|
end
|
45
52
|
|
46
53
|
def rake(command)
|
@@ -63,7 +70,7 @@ module Inploy
|
|
63
70
|
end
|
64
71
|
|
65
72
|
def install_gems
|
66
|
-
rake "gems:install"
|
73
|
+
rake "gems:install RAILS_ENV=#{environment}"
|
67
74
|
end
|
68
75
|
end
|
69
76
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Inploy
|
2
|
+
module Templates
|
3
|
+
module Locaweb
|
4
|
+
def remote_setup
|
5
|
+
run "rm -Rf #{tmp_path} && git clone . #{tmp_path} && tar czf - #{tmp_path} | ssh #{user}@#{host} 'tar xzfv - -C ~/ && mv ~#{tmp_path} #{path}/ && cd #{application_path} && rake inploy:local:setup'"
|
6
|
+
end
|
7
|
+
|
8
|
+
def remote_update
|
9
|
+
run "git push ssh://[#{user}@#{host}]#{application_path} master"
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def local_setup
|
14
|
+
super
|
15
|
+
run "ln -s #{application_path}/public /home/#{user}/public_html/#{application}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def local_update
|
19
|
+
after_update_code
|
20
|
+
end
|
21
|
+
|
22
|
+
def path
|
23
|
+
@path ||= "/home/#{user}/rails_app"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def tmp_path
|
29
|
+
"/tmp/#{application}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/tasks/inploy.rake
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Carrion
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-23 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,13 +22,15 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
+
- lib/tasks/inploy.rake
|
25
26
|
- lib/inploy/deploy.rb
|
27
|
+
- lib/inploy/servers/unicorn.rb
|
28
|
+
- lib/inploy/servers/passenger.rb
|
29
|
+
- lib/inploy/templates/locaweb.rb
|
26
30
|
- lib/inploy/helper.rb
|
27
|
-
- lib/inploy/locaweb.rb
|
28
31
|
- lib/inploy.rb
|
29
|
-
- lib/tasks/inploy.rake
|
30
|
-
- Rakefile
|
31
32
|
- README.textile
|
33
|
+
- Rakefile
|
32
34
|
has_rdoc: true
|
33
35
|
homepage: http://www.diegocarrion.com
|
34
36
|
licenses: []
|
data/lib/inploy/locaweb.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Inploy
|
2
|
-
module Locaweb
|
3
|
-
def remote_setup
|
4
|
-
run "rm -Rf #{tmp_path} && git clone . #{tmp_path} && tar czf - #{tmp_path} | ssh #{user}@#{host} 'tar xzfv - -C ~/ && mv ~#{tmp_path} #{path}/ && cd #{application_path} && rake inploy:local:setup'"
|
5
|
-
end
|
6
|
-
|
7
|
-
def remote_update
|
8
|
-
run "git push ssh://[#{user}@#{host}]#{application_path} master"
|
9
|
-
super
|
10
|
-
end
|
11
|
-
|
12
|
-
def local_setup
|
13
|
-
super
|
14
|
-
run "ln -s #{application_path}/public /home/#{user}/public_html/#{application}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def local_update
|
18
|
-
after_update_code
|
19
|
-
end
|
20
|
-
|
21
|
-
def path
|
22
|
-
@path ||= "/home/#{user}/rails_app"
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def tmp_path
|
28
|
-
"/tmp/#{application}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|