gploy 0.1.7 → 0.2.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/Manifest DELETED
@@ -1,23 +0,0 @@
1
- Manifest
2
- README.markdown
3
- Rakefile
4
- bin/gploy
5
- config/config.yaml
6
- config/post-receive
7
- install.rb
8
- lib/TODO.txt
9
- lib/gploy.rb
10
- lib/gploy/configure.rb
11
- lib/gploy/helpers.rb
12
- lib/gploy/logger.rb
13
- lib/gploy/teste.rb
14
- test/TimeChange.rb
15
- test/config/config.yaml
16
- test/config/post-receive
17
- test/db/schema.rb
18
- test/helper.rb
19
- test/suite.rb
20
- test/test_configuration.rb
21
- test/test_configure.rb
22
- test/test_logger.rb
23
- test/unMocker.rb
data/README.markdown DELETED
@@ -1,120 +0,0 @@
1
- Notes Version 0.1.6
2
-
3
- - Rake -T show all features of gem
4
-
5
- - This version dont have more features that previous, i just try improve the code, but it still is very ugly :D
6
-
7
- Notes Version 0.1.5
8
- -A new command called gploy -d
9
-
10
- -The log file was also changed to indicate that the command is running locally or remotely.
11
-
12
- -Now gploy only make deploy of content in a master branch, for this reason the line "branch" in the config.yaml file was deleted, so make sure that master branch it ok.
13
-
14
-
15
-
16
- ## Introduction
17
-
18
-
19
- This is a simple 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.
20
-
21
- ## What directory structure is used
22
- This gem use a structure in webserver like this:
23
-
24
- 1. ~/repos -> For host a git repository
25
- 2. ~/rails_app -> For host your production project
26
- 3. ~/public_html -> For create a symlink to the project in rails_app directory
27
-
28
- ## Files generated
29
- This gem generate only two simple file into the config directory, one file is called config.yaml and other is post-receive.
30
-
31
- ### The config.yaml file:
32
-
33
- The contents of this file must be like this:
34
-
35
- config:
36
- url: host
37
- user: username
38
- password: password
39
- app_name: project_name
40
- origin: git origin
41
-
42
- If your git is already configured for origin use another, for example: production
43
-
44
- ### The post-receive file:
45
-
46
- The contents of this file must be like this:
47
-
48
- #!/bin/sh
49
- cd ~/rails_app/project_name
50
- env -i git reset --hard
51
- env -i git pull project_name master
52
- env -i rake db:migrate RAILS_ENV=production
53
- env -i touch ~/rails_app/project_name/tmp/restart.txt
54
-
55
- 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)
56
-
57
- ## Usage
58
- First thing you must do is install the gploy gem in your computer:
59
-
60
- sudo gem install gploy
61
-
62
- after it inside your rails project your must execute the following commands:
63
-
64
- > gploy -c // For generate config.yaml file
65
-
66
- Now you can edit this file with your data, make sure you not have a origin set in git if you will use it.
67
-
68
- Now lets generate a post-receive file, this file is a git hook, and must have commands that you want that are executed when your run git push in your project, for this execute:
69
-
70
- > gploy -pr // For generate post-receive file
71
-
72
- This command will generate a snippet like this:
73
-
74
- #!/bin/sh
75
- cd ~/rails_app/project_name
76
- env -i git reset --hard
77
- env -i git pull project_name master
78
- env -i rake db:migrate RAILS_ENV=production
79
- env -i touch ~/rails_app/project_name/tmp/restart.txt
80
-
81
- Put it inside the config/post-receive file. You can add more commands in the post-receive file if you want.
82
-
83
- Finally now you can run the command that will upload your project to the server and do what needs to be done:
84
-
85
- > gploy -s
86
-
87
- If no error occurs, your project must be available now.
88
-
89
- 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:
90
-
91
- > gploy -d
92
- ###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.
93
-
94
- ## Thanks
95
- - Marcelo Luiz Onhate ( http://about.me/onhate ) for correcting some things that README: D
96
-
97
- ### LICENSE:
98
-
99
- (The MIT License)
100
-
101
- Copyright (c) 2008 Edipo Luis Federle
102
-
103
- Permission is hereby granted, free of charge, to any person obtaining
104
- a copy of this software and associated documentation files (the
105
- 'Software'), to deal in the Software without restriction, including
106
- without limitation the rights to use, copy, modify, merge, publish,
107
- distribute, sublicense, and/or sell copies of the Software, and to
108
- permit persons to whom the Software is furnished to do so, subject to
109
- the following conditions:
110
-
111
- The above copyright notice and this permission notice shall be
112
- included in all copies or substantial portions of the Software.
113
-
114
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
115
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
116
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
117
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
118
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
119
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
120
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/config/config.yaml DELETED
File without changes
data/config/post-receive DELETED
File without changes
data/install.rb DELETED
File without changes
data/lib/TODO.txt DELETED
@@ -1 +0,0 @@
1
- - Arrumar testes que fazem uso de diretorios, criar e deletar(setup/teardown)
data/lib/gploy/logger.rb DELETED
@@ -1,8 +0,0 @@
1
- module Gploy
2
- module Logger
3
- def log(msg)
4
- a = Time.now.strftime('%Y-%m-%d %H:%M:%S')
5
- $stderr.puts(a + " " + msg)
6
- end
7
- end
8
- end
data/lib/gploy/teste.rb DELETED
@@ -1,5 +0,0 @@
1
- module Gploy
2
- class Tese
3
- include Helpers
4
- end
5
- end
data/test/TimeChange.rb DELETED
@@ -1,14 +0,0 @@
1
- class TimeChange
2
- # author: Gary S. Weaver
3
- # from: http://stufftohelpyouout.blogspot.com/2009/09/how-to-unmock-in-mocha-and-temporarily.html
4
- # see also: http://stackoverflow.com/questions/1215245/ruby-unit-testing-how-to-fake-time-now
5
-
6
- def self.to(time)
7
- Time.stubs(:now).returns(time)
8
- end
9
-
10
- def self.back_to_now
11
- UnMocker.unmock(Time, 'now')
12
- end
13
- end
14
-
File without changes
File without changes
data/test/db/schema.rb DELETED
File without changes
data/test/helper.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'mocha'
4
- require 'shoulda'
5
- require 'rr'
6
- require File.join(File.dirname(__FILE__), *%w[.. lib gploy])
7
-
8
- include Gploy
9
- class Test::Unit::TestCase
10
- include RR::Adapters::TestUnit
11
- def dest_dir(*subdirs)
12
- File.join(File.dirname(__FILE__), 'dest', *subdirs)
13
- end
14
-
15
- def source_dir(*subdirs)
16
- File.join(File.dirname(__FILE__), 'source', *subdirs)
17
- end
18
-
19
- def clear_dest
20
- FileUtils.rm_rf(dest_dir)
21
- end
22
-
23
-
24
- end
data/test/suite.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'test/unit'
2
-
3
- #Run all tests.
4
- tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"]
5
- tests.each do |file|
6
- require file
7
- end
@@ -1,23 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
- class ConfigureTest < Test::Unit::TestCase
3
-
4
- def setup
5
- @path = File.join(Dir.pwd, '_config.yml')
6
- end
7
-
8
- def testLoadFileConfire
9
- connection = Gploy::Configure.new
10
- mock(YAML).load_file(@path){ Hash.new}
11
- mock($stderr).puts("Configuration ok from #{@path}")
12
- connection.read_config_file(@path)
13
- end
14
-
15
- def testBadConfi
16
- connection = Gploy::Configure.new
17
- mock(YAML).load_file(@path) { raise "No such file or directory - #{@path}" }
18
- mock($stderr).puts("WARNING: I Could not read configuration file.")
19
- mock($stderr).puts("\tNo such file or directory - #{@path}")
20
- connection.read_config_file(@path)
21
- end
22
-
23
- end
@@ -1,143 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
- class ConfigureTest < Test::Unit::TestCase
3
-
4
- def testeOne
5
- assert(true)
6
- end
7
-
8
- def setup
9
-
10
- mockRespinse = mock("Net::SSH")
11
- ssh = mock("Net::SSH")
12
-
13
- @connection = Gploy::Configure.new
14
-
15
- @connection.expects(:start).once.returns(@ssh)
16
- @c = @connection.remote
17
-
18
- @path = File.join(Dir.pwd, '_config.yml')
19
-
20
- @url = "server_name"
21
- @user = "user_name"
22
- @password = "user_senha"
23
- @app_name = "fake_project"
24
- @origin = "production"
25
- end
26
-
27
-
28
- def testShouldReturnGemVersion
29
- assert_not_nil(!nil,Gploy::Configure::VERSION)
30
- assert_equal("0.1.7", Gploy::VERSION)
31
- end
32
- def testShouldHaveALogPath
33
- assert_equal("./log/gploylog.log", Gploy::Configure::LOG_PATH);
34
- end
35
-
36
- def testCreateDirLogIfDontExist
37
- dir_log = @connection.check_if_dir_log_exists
38
- assert(dir_log, "Directory Log not found")
39
- end
40
-
41
- def testIfSomeDirectoryExist
42
- no_dir = "fakedir"
43
- assert_equal(false, @connection.dirExists?(no_dir))
44
- assert_equal(true, @connection.dirExists?("log"))
45
- end
46
-
47
- def testOne
48
- expect_command_local "chmod +x config/post-receive && scp config/post-receive #{@user}@#{@url}:repos/#{@app_name}.git/hooks/"
49
- @connection.update_hook_into_server(@user, @url, @app_name)
50
- end
51
-
52
- def testUploadPostReceiveFile
53
- expect_command_local "scp config/post-receive #{@user}@#{@url}:repos/#{@app_name}.git/hooks/"
54
- @connection.update_hook(@user, @url, @app_name)
55
- end
56
-
57
- def testIfExistPostReceiveFileIntoConfigFolder
58
- @connection.create_hook_file
59
- assert File.exists?(File.join("config",'post-receive'))
60
- end
61
-
62
- def testReturnPathPostReceive
63
- assert_equal("config/post-receive", @connection.path)
64
- end
65
-
66
- def testIfExistCofigFile
67
- @connection.create_file_and_direcotry_unless_exists("config", "config.yaml")
68
- assert File.exists?(File.join("config",'config.yaml'))
69
- end
70
-
71
- def testShouldReturnPathForHookFileIntoServer
72
- assert_equal("~/repos/#{@name}.git/hooks/post-receive", @connection.path_hook(@name))
73
- end
74
-
75
- def testShouldCreateSysLinkIntoServer
76
- expect_command_remote "ln -s ~/rails_app/#{@app_name}/public ~/public_html/#{@app_name}"
77
- @connection.sys_link(@app_name)
78
- end
79
-
80
- def testShouldDreateTmpDirIntoProjectServer
81
- expect_command_remote "cd rails_app/#{@app_name}/ && mkdir tmp"
82
- @connection.tmp_create(@app_name)
83
- end
84
-
85
- def testShouldCreateAndInitializeRepoIntoServer
86
- expect_command_remote "cd repos/ && mkdir nome.git && cd nome.git && git init --bare"
87
- @connection.create_repo("nome")
88
- end
89
-
90
- def testShouldAddGitRemoteInLocalProject
91
- expect_command_local "git remote add #{@origin} #{@user}@#{@url}:~/repos/#{@app_name}.git"
92
- @connection.add_remote(@url, @user, @app_name, @origin)
93
- end
94
-
95
- def testShoulRunCloneIntoServer
96
- # @logger.expects(:log).once.with(instance_of(String))
97
- expect_command_remote "git clone ~/repos/#{@app_name}.git ~/rails_app/#{@app_name}"
98
- @connection.clone(@app_name)
99
- end
100
-
101
- def testShouldRunCloneIntoServer2
102
- expect_command_remote "git clone repos/#{@app_name}.git ~/rails_app/#{@app_name}"
103
- @connection.clone_into_server(@app_name)
104
- end
105
-
106
- def testShouldRunPushMaster
107
- # @logger.expects(:log).once.with(instance_of(String))
108
- expect_command_local "git checkout master && git push #{@origin} master"
109
- @connection.push_local(@origin)
110
- end
111
-
112
- def tesShouldNotRunMigrateTask
113
- @connection.migrate(@app_name)
114
- end
115
-
116
- def testShouldRestartServer
117
- expect_command_remote("cd rails_app/#{@app_name}/tmp && touch restart.txt")
118
- @connection.restart_server(@app_name)
119
- end
120
-
121
- #FIX THIS TEST
122
- def RtestShouldRunMigrateTask
123
- FileUtils.remove_dir("db")
124
- #Dir.mkdir("db")
125
- FileUtils.touch("db/schema.rb")
126
- expect_command_remote "cd rails_app/#{@app_name}/ && rake db:migrate RAILS_ENV=production"
127
- @connection.migrate(@app_name)
128
- end
129
-
130
- def testLogMessage
131
- a = Time.stubs(:now).returns(Time.mktime(1970,1,1))
132
- mock($stderr).puts(Time.now.strftime('%Y-%m-%d %H:%M:%S') + " Hello")
133
- @connection.log("Hello")
134
- end
135
-
136
- def expect_command_local(command)
137
- Kernel.expects(:system).with(command)
138
- end
139
-
140
- def expect_command_remote(command)
141
- @c.expects(:exec!).with(command)
142
- end
143
- end
data/test/test_logger.rb DELETED
File without changes
data/test/unMocker.rb DELETED
@@ -1,13 +0,0 @@
1
- class UnMocker
2
- # author: Gary S. Weaver
3
- # from: http://stufftohelpyouout.blogspot.com/2009/09/how-to-unmock-in-mocha-and-temporarily.html
4
- # based on solution from Jacob in http://szeryf.wordpress.com/2007/11/09/unstubbing-methods-in-mocha/
5
-
6
- def self.unmock(class_or_instance, method_name)
7
- Mocha::Mockery.instance.stubba.stubba_methods.each do |meth|
8
- if meth.stubbee == class_or_instance && meth.method == method_name
9
- meth.unstub
10
- end
11
- end
12
- end
13
- end