gploy 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +11 -6
- data/Rakefile +9 -1
- data/bin/gploy +5 -6
- data/lib/gploy/configure.rb +18 -14
- data/lib/gploy/helpers.rb +10 -20
- metadata +3 -3
data/README.markdown
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
Version 0.1.5 brings some improvements in the way it will deploy.
|
2
|
+
|
3
|
+
Notes Version 0.1.5
|
4
|
+
A new command called gploy -d
|
5
|
+
The log file was also changed to indicate that the command was run locally or remotely.
|
2
6
|
|
3
7
|
## Introduction
|
4
8
|
|
@@ -7,8 +11,8 @@ This is a simple RubyGems to configure your Rails Project for deployment using g
|
|
7
11
|
## What directory structure is used
|
8
12
|
This gem use a structure in webserver like this:
|
9
13
|
|
10
|
-
1. ~/repos
|
11
|
-
2. ~/rails_app
|
14
|
+
1. ~/repos -> For host a git repository
|
15
|
+
2. ~/rails_app -> For host your production project
|
12
16
|
3. ~/public_html -> For create a symlink to the project in rails_app directory
|
13
17
|
|
14
18
|
## Files generated
|
@@ -24,7 +28,7 @@ The contents of this file must be like this:
|
|
24
28
|
password: password
|
25
29
|
app_name: project_name
|
26
30
|
origin: git origin
|
27
|
-
|
31
|
+
|
28
32
|
If your git is already configured for origin use another, for example: production
|
29
33
|
|
30
34
|
### The post-receive file:
|
@@ -72,8 +76,9 @@ Finally now you can run the command that will upload your project to the server
|
|
72
76
|
|
73
77
|
If no error occurs, your project must be available now.
|
74
78
|
|
75
|
-
From now when you want update your project simply do a commit of changes and run git push production master to update project in server
|
76
|
-
|
79
|
+
From now when you want update your project simply do a commit of changes and run git push production master to update project in server or run:
|
80
|
+
|
81
|
+
> gploy -d
|
77
82
|
#OBS: This is a initial version then careful when using it. If you find bugs please let me know, fell free for make a fork in project at [github](http://github.com/edipofederle/gploy) and fix the bugs :D.
|
78
83
|
|
79
84
|
|
data/Rakefile
CHANGED
@@ -5,12 +5,20 @@ require 'rake/gempackagetask'
|
|
5
5
|
require 'spec/rake/spectask'
|
6
6
|
|
7
7
|
GEM = "gploy"
|
8
|
-
GEM_VERSION = "0.1.
|
8
|
+
GEM_VERSION = "0.1.5"
|
9
9
|
SUMMARY = "Simple gem to configure rails project deploy using git(locaweb server only)"
|
10
10
|
AUTHOR = "Edipo Luis Federle"
|
11
11
|
EMAIL = "edipofederle@gmail.com"
|
12
12
|
HOMEPAGE = "http://edipolf.com"
|
13
13
|
|
14
|
+
|
15
|
+
desc "Run all examples with RCov"
|
16
|
+
Spec::Rake::SpecTask.new('examples_with_rcov') do |t|
|
17
|
+
t.spec_files = FileList['spec/*.rb']
|
18
|
+
t.rcov = true
|
19
|
+
t.rcov_opts = ['--exclude', 'spec']
|
20
|
+
|
21
|
+
end
|
14
22
|
|
15
23
|
spec = Gem::Specification.new do |s|
|
16
24
|
s.name = GEM
|
data/bin/gploy
CHANGED
@@ -1,31 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "rubygems"
|
3
3
|
require "rubigen"
|
4
|
+
require "gploy"
|
4
5
|
|
5
6
|
if %w(-v --version).include? ARGV.first
|
6
|
-
require "gploy"
|
7
7
|
puts "#{File.basename($0)} - #{Gploy::Configure::VERSION}"
|
8
8
|
exit(0)
|
9
9
|
end
|
10
10
|
|
11
11
|
if %(-configure -c).include? ARGV.first
|
12
|
-
require "gploy"
|
13
12
|
c = Gploy::Configure.new
|
14
13
|
c.configure_server
|
15
14
|
end
|
16
15
|
if %(-pr).include? ARGV.first
|
17
|
-
require "gploy"
|
18
16
|
c = Gploy::Configure.new
|
19
17
|
c.configure_hook
|
20
18
|
end
|
21
19
|
if %(-setup -s).include? ARGV.first
|
22
|
-
require "gploy"
|
23
20
|
c = Gploy::Configure.new
|
24
21
|
c.setup
|
25
22
|
end
|
26
23
|
if %(-update-hook -uh).include? ARGV.first
|
27
|
-
require "gploy"
|
28
24
|
c = Gploy::Configure.new
|
29
25
|
c.upload_hook
|
30
26
|
end
|
31
|
-
|
27
|
+
if %(-deploy -d).include? ARGV.first
|
28
|
+
c = Gploy::Configure.new
|
29
|
+
c.new_deploy
|
30
|
+
end
|
data/lib/gploy/configure.rb
CHANGED
@@ -8,14 +8,12 @@ module Gploy
|
|
8
8
|
class Configure
|
9
9
|
|
10
10
|
include Helpers
|
11
|
-
VERSION = '0.1.
|
12
|
-
|
13
|
-
|
11
|
+
VERSION = '0.1.5'
|
12
|
+
|
14
13
|
def configure_server
|
15
14
|
create_file_and_direcotry_unless_exists("config", "config.yaml")
|
16
15
|
puts "Files created into the config directory. Now need edit config.yaml"
|
17
16
|
puts ""
|
18
|
-
puts "A suggestion for you"
|
19
17
|
puts "---------------------------------------------------------"
|
20
18
|
puts "You can put this content into your config.yaml file and edit it"
|
21
19
|
post_commands_server
|
@@ -52,6 +50,15 @@ module Gploy
|
|
52
50
|
update_hook(@user, @url, @app_name)
|
53
51
|
puts "File successfully Updated"
|
54
52
|
end
|
53
|
+
|
54
|
+
def read_config_file
|
55
|
+
config = YAML.load_file("config/config.yaml")
|
56
|
+
config["config"].each { |key, value| instance_variable_set("@#{key}", value) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def remote
|
60
|
+
@shell = start(@url, @user, @password)
|
61
|
+
end
|
55
62
|
|
56
63
|
def path
|
57
64
|
"config/post-receive"
|
@@ -62,15 +69,6 @@ module Gploy
|
|
62
69
|
restart_server(@app_name)
|
63
70
|
end
|
64
71
|
|
65
|
-
def read_config_file
|
66
|
-
config = YAML.load_file("config/config.yaml")
|
67
|
-
config["config"].each { |key, value| instance_variable_set("@#{key}", value) }
|
68
|
-
end
|
69
|
-
|
70
|
-
def remote
|
71
|
-
@shell = start(@url, @user, @password)
|
72
|
-
end
|
73
|
-
|
74
72
|
def start(server, user, pass)
|
75
73
|
Net::SSH.start(server, user, :password => pass)
|
76
74
|
end
|
@@ -115,6 +113,11 @@ module Gploy
|
|
115
113
|
def add_remote_origin(server, user, name, origin)
|
116
114
|
run_remote("cd rails_app/#{name}/ && git remote add #{origin} ~/repos/#{name}.git/")
|
117
115
|
end
|
116
|
+
|
117
|
+
def new_deploy
|
118
|
+
read_config_file
|
119
|
+
run_local("git checkout #{@branch} - && git push #{@origin} master")
|
120
|
+
end
|
118
121
|
|
119
122
|
def clone(name)
|
120
123
|
@shell.exec!("git clone ~/repos/#{name}.git ~/rails_app/#{name}")
|
@@ -125,11 +128,12 @@ module Gploy
|
|
125
128
|
end
|
126
129
|
|
127
130
|
def push_local(origin)
|
128
|
-
run_local "git push #{origin} master"
|
131
|
+
run_local "git checkout master && git push #{origin} master"
|
129
132
|
end
|
130
133
|
|
131
134
|
def tmp_create(name)
|
132
135
|
run_remote "cd rails_app/#{name}/ && mkdir tmp"
|
133
136
|
end
|
137
|
+
|
134
138
|
end
|
135
139
|
end
|
data/lib/gploy/helpers.rb
CHANGED
@@ -4,22 +4,22 @@ module Gploy
|
|
4
4
|
|
5
5
|
def check_if_dir_log_exists
|
6
6
|
unless dirExists?("log")
|
7
|
-
Dir.mkdir("log")
|
7
|
+
Dir.mkdir("log")
|
8
8
|
false
|
9
9
|
else
|
10
10
|
true
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def logger(msg)
|
14
|
+
def logger(msg, type)
|
15
15
|
puts "--> #{msg}"
|
16
16
|
File.open(LOG_PATH, 'a+') do |f|
|
17
|
-
f.puts "#{Time.now} => #{msg}"
|
17
|
+
f.puts "#{Time.now} => |#{type}| #{msg}"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def run_remote(command)
|
22
|
-
logger(command)
|
22
|
+
logger(command, "remote")
|
23
23
|
@shell.exec!(command)
|
24
24
|
end
|
25
25
|
|
@@ -28,24 +28,14 @@ module Gploy
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def run_local(command)
|
31
|
-
logger(command)
|
31
|
+
logger(command, "local")
|
32
32
|
Kernel.system command
|
33
33
|
end
|
34
34
|
|
35
35
|
def sys_link(name)
|
36
36
|
run_remote "ln -s ~/rails_app/#{name}/public ~/public_html/#{name}"
|
37
37
|
end
|
38
|
-
|
39
|
-
def read_hook_sample(name)
|
40
|
-
puts "Escrevendo Hook File"
|
41
|
-
path = "~/repos/#{name}.git/hooks/post-receive"
|
42
|
-
File.open("config/post-receive", "r") do |fline|
|
43
|
-
while(line = fline.gets)
|
44
|
-
@shell.exec!("echo '#{line}' >> #{path}")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
38
|
+
|
49
39
|
def update_hook_into_server(username, url, name)
|
50
40
|
run_local "chmod +x config/post-receive && scp config/post-receive #{username}@#{url}:repos/#{name}.git/hooks/"
|
51
41
|
end
|
@@ -64,15 +54,15 @@ module Gploy
|
|
64
54
|
|
65
55
|
def migrate(name)
|
66
56
|
if useMigrations?
|
67
|
-
logger("Run db:migrate")
|
57
|
+
logger("Run db:migrate", "remote")
|
68
58
|
run_remote "cd rails_app/#{name}/ && rake db:migrate RAILS_ENV=production"
|
69
59
|
end
|
70
|
-
logger("
|
60
|
+
logger("rake db:migrae => FALSE", nil)
|
71
61
|
end
|
72
62
|
|
73
63
|
def restart_server(name)
|
64
|
+
logger("restart server", "remote")
|
74
65
|
run_remote "cd rails_app/#{name}/tmp && touch restart.txt"
|
75
|
-
puts "Server Restarted"
|
76
66
|
end
|
77
67
|
|
78
68
|
def post_commands
|
@@ -84,7 +74,7 @@ module Gploy
|
|
84
74
|
env -i rake db:migrate RAILS_ENV=production
|
85
75
|
env -i touch ~/rails_app/#{@app_name}/tmp/restart.txt
|
86
76
|
CMD
|
87
|
-
|
77
|
+
puts commands
|
88
78
|
end
|
89
79
|
|
90
80
|
def post_commands_server
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 5
|
9
|
+
version: 0.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Edipo Luis Federle
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-30 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|