gploy 0.0.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,101 @@
1
+ ## Introduction
2
+
3
+ This is a sample RubyGems to configure your Rails Project for deployment using git push, this gem only make a series of configurations in your local project and to in your web server. This gem consider what you are using locaweb to host your project and using git obviously.
4
+
5
+ ## What directory structure is used
6
+ This gem use a structure in webserver like this:
7
+
8
+ 1. ~/repos -> For host a git repository
9
+ 2. ~/rails_app -> For host your production project
10
+ 3. ~/public_html -> For create a symlink to the project in rails_app directory
11
+
12
+ ## Files generated
13
+ This gem generate only two simple file into the config directory, one file is called config.yaml and other is post-receive.
14
+
15
+ ### The config.yaml file:
16
+
17
+ The contents of this file should be like this:
18
+
19
+ config:
20
+ url: host
21
+ user: username
22
+ password: password
23
+ app_name: project_name
24
+ origin: git origin
25
+
26
+ If your git is already configured for origin use another, for example: production
27
+
28
+ ### The post-receive file:
29
+
30
+ The contents of this file should be like this:
31
+
32
+ #!/bin/sh
33
+ cd ~/rails_app/project_name
34
+ env -i git reset --hard
35
+ env -i git pull project_name master
36
+ env -i rake db:migrate RAILS_ENV=production
37
+ env -i touch ~/rails_app/project_name/tmp/restart.txt
38
+
39
+ The post-receive file is a git hook, read more about hooks at: [www.ru.kernel.org](http://www.ru.kernel.org/pub/software/scm/git/docs/v1.5.2.5/hooks.html)
40
+
41
+ ## Usage
42
+ First thing you should do is install the gploy gem in your computer:
43
+
44
+ sudo gem install gploy
45
+
46
+ after it inside your rails project your should execute the following commands:
47
+
48
+ > gploy -c // For generate config.yaml file
49
+
50
+ Now you can edit this file with your data, make sure you not have a origin set in git if you will use it.
51
+
52
+ Now lets generate a post-receive file, this file is a git hook, and should have commands that you want that are executed when your run git push in your project, for this execute:
53
+
54
+ > gploy -pr // For generate post-receive file
55
+
56
+ This command will generate a snippet like this:
57
+
58
+ #!/bin/sh
59
+ cd ~/rails_app/project_name
60
+ env -i git reset --hard
61
+ env -i git pull project_name master
62
+ env -i rake db:migrate RAILS_ENV=production
63
+ env -i touch ~/rails_app/project_name/tmp/restart.txt
64
+
65
+ Put it inside the config/post-receive file. You can add more commands in the post-receive file if you want.
66
+
67
+ Finally now you can run the command that will upload your project to the server and do what needs to be done:
68
+
69
+ > gploy -s
70
+
71
+ If no error occurs, your project should be available now.
72
+
73
+ 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.
74
+
75
+ #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.
76
+
77
+
78
+ ## LICENSE:
79
+
80
+ (The MIT License)
81
+
82
+ Copyright (c) 2008 Edipo Luis Federle
83
+
84
+ Permission is hereby granted, free of charge, to any person obtaining
85
+ a copy of this software and associated documentation files (the
86
+ 'Software'), to deal in the Software without restriction, including
87
+ without limitation the rights to use, copy, modify, merge, publish,
88
+ distribute, sublicense, and/or sell copies of the Software, and to
89
+ permit persons to whom the Software is furnished to do so, subject to
90
+ the following conditions:
91
+
92
+ The above copyright notice and this permission notice shall be
93
+ included in all copies or substantial portions of the Software.
94
+
95
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
96
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
97
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
98
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
99
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
100
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
101
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -5,8 +5,8 @@ require 'rake/gempackagetask'
5
5
  require 'spec/rake/spectask'
6
6
 
7
7
  GEM = "gploy"
8
- GEM_VERSION = "0.0.1"
9
- SUMMARY = "Sample gem to configure rails project deploy using git(locaweb server only)"
8
+ GEM_VERSION = "0.1.2"
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"
data/bin/gploy CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require "rubygems"
4
3
  require "rubigen"
5
4
 
@@ -8,7 +8,7 @@ module Gploy
8
8
  class Configure
9
9
 
10
10
  include Helpers
11
- VERSION = '0.0.1'
11
+ VERSION = '0.1.2'
12
12
 
13
13
  def configure_server
14
14
  create_file_and_direcotry_unless_exists("config", "config.yaml")
@@ -18,7 +18,6 @@ module Gploy
18
18
  puts "---------------------------------------------------------"
19
19
  puts "You can put this content into your config.yaml file and edit it"
20
20
  post_commands_server
21
- puts ""
22
21
  end
23
22
 
24
23
  def configure_hook
@@ -37,11 +36,12 @@ module Gploy
37
36
  add_remote(@url, @user, @app_name, @origin)
38
37
  push_local(@origin)
39
38
  clone_into_server(@app_name)
39
+ add_remote_origin(@url, @user, @app_name, @origin)
40
40
  sys_link(@app_name)
41
41
  tmp_create(@app_name)
42
42
  update_hook_into_server(@user, @url, @app_name)
43
43
  run_tasks
44
- puts "OK. No error Found. You now can run git push #{@origin} master for update your project"
44
+ puts "OK. No error Found. You now can run <git push #{@origin} master> for update your project"
45
45
  end
46
46
 
47
47
  def upload_hook
@@ -50,7 +50,7 @@ module Gploy
50
50
  update_hook(@user, @url, @app_name)
51
51
  puts "File successfully Updated"
52
52
  end
53
-
53
+
54
54
  def path
55
55
  "config/post-receive"
56
56
  end
@@ -100,17 +100,19 @@ module Gploy
100
100
 
101
101
  def create_file_and_direcotry_unless_exists(dir, file)
102
102
  unless dirExists?("#{dir}")
103
- puts "directory #{dir} created successfully"
104
103
  Dir.mkdir(dir)
105
104
  end
106
105
  unless File.exists?("config/#{file}")
107
- puts "File #{file} created successfully"
108
106
  FileUtils.touch "#{dir}/#{file}"
109
107
  end
110
108
  end
111
109
 
112
110
  def add_remote(server, user, name, origin)
113
- execute("git remote add #{origin} #{user}@#{server}:~/repos/#{name}.git")
111
+ run_local("git remote add #{origin} #{user}@#{server}:~/repos/#{name}.git")
112
+ end
113
+
114
+ def add_remote_origin(server, user, name, origin)
115
+ run_remote("cd rails_app/#{name}/ && git remote add #{origin} ~/repos/#{name}.git/")
114
116
  end
115
117
 
116
118
  def clone(name)
@@ -122,7 +124,7 @@ module Gploy
122
124
  end
123
125
 
124
126
  def push_local(origin)
125
- run "git push #{origin} master"
127
+ run_local "git push #{origin} master"
126
128
  end
127
129
 
128
130
  def tmp_create(name)
data/lib/gploy/helpers.rb CHANGED
@@ -1,86 +1,79 @@
1
1
  require 'logger'
2
+
2
3
  module Gploy
3
- module Helpers
4
+ module Helpers
4
5
 
5
- def log_messager(msg)
6
- @log.info(msg)
7
- end
6
+ def log(msg)
7
+ puts "--> #{msg}"
8
+ end
8
9
 
9
- def run_remote(command)
10
- @shell.exec!(command)
11
- end
10
+ def run_remote(command)
11
+ log(command)
12
+ @shell.exec!(command)
13
+ end
14
+
15
+ def dirExists?(dir)
16
+ File.directory? dir
17
+ end
18
+
19
+ def run_local(command)
20
+ log(command)
21
+ Kernel.system command
22
+ end
23
+
24
+ def sys_link(name)
25
+ run_remote "ln -s ~/rails_app/#{name}/public ~/public_html/#{name}"
26
+ end
12
27
 
13
- def dirExists?(dir)
14
- File.directory? dir
15
- end
28
+ def read_hook_sample(name)
29
+ puts "Escrevendo Hook File"
30
+ path = "~/repos/#{name}.git/hooks/post-receive"
31
+ File.open("config/post-receive", "r") do |fline|
32
+ while(line = fline.gets)
33
+ @shell.exec!("echo '#{line}' >> #{path}")
34
+ end
35
+ end
36
+ end
16
37
 
17
- def execute(command)
18
- Kernel.system command
19
- end
38
+ def update_hook_into_server(username, url, name)
39
+ run_local "chmod +x config/post-receive && scp config/post-receive #{username}@#{url}:repos/#{name}.git/hooks/"
40
+ end
20
41
 
21
- def run(command, disable_sudo = false)
22
- if disable_sudo
23
- Kernel.system command
24
- else
25
- Kernel.system "#{@sudo}#{command}"
26
- end
27
- end
28
-
29
- def sys_link(name)
30
- puts "Symbolic link created successfully"
31
- run_remote "ln -s ~/rails_app/#{name}/public ~/public_html/#{name}"
32
- end
33
-
34
- def read_hook_sample(name)
35
- puts "Escrevendo Hook File"
36
- path = "~/repos/#{name}.git/hooks/post-receive"
37
- File.open("config/post-receive", "r") do |fline|
38
- while(line = fline.gets)
39
- @shell.exec!("echo '#{line}' >> #{path}")
40
- end
41
- end
42
- end
43
-
44
- def update_hook_into_server(username, url, name)
45
- run "chmod +x config/post-receive && scp config/post-receive #{username}@#{url}:repos/#{name}.git/hooks/"
46
- end
42
+ def update_hook(username, url, name)
43
+ run_local "scp config/post-receive #{username}@#{url}:repos/#{name}.git/hooks/"
44
+ end
47
45
 
48
- def update_hook(username, url, name)
49
- run "scp config/post-receive #{username}@#{url}:repos/#{name}.git/hooks/"
50
- end
51
-
52
- def migrate(name)
53
- run_remote "cd rails_app/#{name}/ && rake db:migrate RAILS_ENV=production"
54
- end
55
-
56
- def restart_server(name)
57
- run_remote "cd rails_app/#{name}/tmp && touch restart.txt"
58
- puts "Server Restarted"
59
- end
60
-
61
- def post_commands
62
- commands = <<CMD
63
- #!/bin/sh
64
- cd ~/rails_app/#{@app_name}
65
- env -i git reset --hard
66
- env -i git pull #{@origin} master
67
- env -i rake db:migrate RAILS_ENV=production
68
- env -i touch ~/rails_app/#{@app_name}/tmp/restart.txt
69
-
46
+ def migrate(name)
47
+ run_remote "cd rails_app/#{name}/ && rake db:migrate RAILS_ENV=production"
48
+ end
49
+
50
+ def restart_server(name)
51
+ run_remote "cd rails_app/#{name}/tmp && touch restart.txt"
52
+ puts "Server Restarted"
53
+ end
54
+
55
+ def post_commands
56
+ commands = <<CMD
57
+ #!/bin/sh
58
+ cd ~/rails_app/#{@app_name}
59
+ env -i git reset --hard
60
+ env -i git pull #{@origin} master
61
+ env -i rake db:migrate RAILS_ENV=production
62
+ env -i touch ~/rails_app/#{@app_name}/tmp/restart.txt
70
63
  CMD
71
64
  puts commands
72
- end
73
-
74
- def post_commands_server
75
- commands = <<CMD
76
- config:
77
- url: <user_server>
78
- user: <userbae>
79
- password: <password>
80
- app_name: <app_name>
81
- origin: <git origin>
65
+ end
66
+
67
+ def post_commands_server
68
+ commands = <<CMD
69
+ config:
70
+ url: <user_server>
71
+ user: <userbae>
72
+ password: <password>
73
+ app_name: <app_name>
74
+ origin: <git origin>
82
75
  CMD
83
76
  puts commands
84
- end
77
+ end
85
78
  end
86
79
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 0
8
7
  - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.1.2
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-03-23 00:00:00 -03:00
17
+ date: 2010-03-25 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -45,7 +45,7 @@ files:
45
45
  - lib/gploy/helpers.rb
46
46
  - lib/gploy.rb
47
47
  - Rakefile
48
- - README.textile
48
+ - README.markdown
49
49
  has_rdoc: true
50
50
  homepage: http://edipolf.com
51
51
  licenses: []
@@ -76,6 +76,6 @@ rubyforge_project: gploy
76
76
  rubygems_version: 1.3.6
77
77
  signing_key:
78
78
  specification_version: 3
79
- summary: Sample gem to configure rails project deploy using git(locaweb server only)
79
+ summary: Simple gem to configure rails project deploy using git(locaweb server only)
80
80
  test_files: []
81
81
 
data/README.textile DELETED
@@ -1,24 +0,0 @@
1
- h2. LICENSE:
2
-
3
- (The MIT License)
4
-
5
- Copyright (c) 2008 Edipo Luis Federle
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining
8
- a copy of this software and associated documentation files (the
9
- 'Software'), to deal in the Software without restriction, including
10
- without limitation the rights to use, copy, modify, merge, publish,
11
- distribute, sublicense, and/or sell copies of the Software, and to
12
- permit persons to whom the Software is furnished to do so, subject to
13
- the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.