meskyanichi-generators 0.0.1 → 0.1.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/CHANGELOG ADDED
@@ -0,0 +1,16 @@
1
+
2
+ Meskyanichi - Generators |0.0.2|
3
+ -----------------------------------------------------------
4
+
5
+ - Finished "capistrano_template"
6
+
7
+ -----------------------------------------------------------
8
+
9
+
10
+ Meskyanichi - Generators |0.0.1|
11
+ -----------------------------------------------------------
12
+
13
+ - Made an initial commit
14
+ - Pushed the unfinished core of "capistrano_template"
15
+
16
+ -----------------------------------------------------------
data/README.rdoc CHANGED
@@ -1,7 +1,92 @@
1
- = generators
1
+ = Generators
2
+
3
+ a few simple generators that might help you get your application up and running just a little bit faster!
4
+
5
+ For now the gem only provides a generator for a simple capistrano template.
6
+
7
+
8
+ == The Capistrano Template
9
+
10
+ Essentially what this does, is generate a basic Capistrano deployment recipe. The recipe does a couple of things initially when you set it up.
11
+
12
+ - Create the necessary folders and files, namely the releases, current(symlink) and the shared folder
13
+ - Creates a log folder and generates a new production.log
14
+ - Creates a config folder and then syncs the database.yml from your Rails application to the remote server
15
+
16
+ During every deployment, the recipe will:
17
+
18
+ - Update your remote repository before deployment to ensure all files are up to date
19
+ - After deployment, will restart the application for Passenger
20
+ - After deployment, will place the symlinks for the database and production.log files correctly
21
+ - Make the javascripts and stylesheets directory, located in the RAILS_ROOT/public directory, writable to avoid script caching errors
22
+
23
+ If you wish to generate the simple Capistrano Template, open the terminal, go to the root of your rails application and type the following:
24
+
25
+ script/generate capistrano_template
26
+
27
+ This will generate the capistrano template which you help you get up and running.
28
+
29
+ You can also pass in additional arguments to let the generator help you fill in Capistrano recipe.
30
+
31
+ script/generate capistrano_template MyDomain.com git ssh://MyDomain.com/MyRepository.git master root /var/www/vhosts/MyDomain.com/httpdocs
32
+
33
+ If you fill in the above correctly, (this also depends on your server setup / OS / etc), then it should work right out of the box.
34
+
35
+ Below are the arguments which you can provide, in order:
36
+
37
+ domain_name (e.g. MyDomain.com)
38
+ scm (e.g. git)
39
+ repository (e.g. ssh://MyDomain.com/MyRepository.git)
40
+ branch (e.g. master)
41
+ user (e.g. root)
42
+ deploy_to (e.g. /var/www/vhosts/MyDomain.com/httpdocs)
43
+
44
+ This generates the deploy.rb file with the specified settings in the RAILS_ROOT/config directory.
45
+
46
+ Now the whole process in steps:
47
+
48
+ 1: sudo gem install meskyanichi-generators
49
+ 2: go to root of rails app and type "capify ."
50
+ 3: then type "script/generate capistrano_template [arg1..arg6]"
51
+ 4: when it prompts if you wish to overwrite, type "y" and hit return
52
+ 5: now type "cap deploy:setup" to set up the whole directory structure and files
53
+ 6: after the setup is finished, and assuming you have your local git repository set up correctly,
54
+ type "cap deploy" and your application will go live in a matter of seconds!
55
+
56
+ If you did not fill in all the arguments, or wish double check if it was all set up correctly, open the
57
+ deploy.rb file located in the config directory and have a look. You can easily modify everything to your liking as well!
58
+
59
+
60
+ == The Capistrano Template - Commands
61
+
62
+ The recipe provides a few commands which are pretty useful. Including syncing your local database.yml file
63
+ with the one on the server so that you are not forced to go SSH or FTP to the server to manually change it.
64
+
65
+ cap deploy:sync_database
66
+
67
+ If you wish to restart your application for Passenger without re-deploying your application, for example, after syncing the new database.yml,
68
+ and you once again don't want to SHH manually, then you can do a:
69
+
70
+ cap deploy:restart
71
+
72
+ This will restart the application for Passenger.
73
+
74
+ cap deploy:setup
75
+
76
+ This will run the setup task, which will do everything Capistrano does out of the box,
77
+ but also executes the tasks I mentioned at the top of this README.
78
+
79
+ cap deploy
80
+
81
+ After you've setup Capistrano correctly using the cap deploy:setup, you may now use the above command to deploy your rails application!
82
+
83
+
84
+
85
+ == Git (Coming Soon!)
2
86
 
3
- Description goes here.
4
87
 
5
88
  == Copyright
6
89
 
7
90
  Copyright (c) 2009 Michael. See LICENSE for details.
91
+
92
+
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 0
4
- :patch: 1
3
+ :minor: 1
4
+ :patch: 0
@@ -1,7 +1,45 @@
1
1
  class CapistranoTemplateGenerator < Rails::Generator::Base
2
+
3
+ def initialize(runtime_args, runtime_options = {})
4
+ super
5
+
6
+ @domain_name = @args[0] || "MyDomain.com"
7
+ @scm = @args[1] || "git"
8
+ @repository = @args[2] || "ssh://MyDomain.com/MyRepository.git"
9
+ @branch = @args[3] || "master"
10
+ @user = @args[4] || "root"
11
+ @deploy_to = @args[5] || "/var/www/vhosts/#{domain_name}/httpdocs"
12
+
13
+ end
14
+
2
15
  def manifest
3
16
  record do |m|
4
- m.file 'deploy.rb', 'config/deploy.rb'
17
+ m.template 'deploy.rb', 'config/deploy.rb'
5
18
  end
6
19
  end
20
+
21
+ def domain_name
22
+ @domain_name
23
+ end
24
+
25
+ def scm
26
+ @scm
27
+ end
28
+
29
+ def repository
30
+ @repository
31
+ end
32
+
33
+ def branch
34
+ @branch
35
+ end
36
+
37
+ def user
38
+ @user
39
+ end
40
+
41
+ def deploy_to
42
+ @deploy_to
43
+ end
44
+
7
45
  end
@@ -1 +1,79 @@
1
- This is a test!
1
+ # Application Domain (MyDomain.com)
2
+ # Convention: Make sure the correct domain name (same as the folder on the server in /var/www/vhosts/)
3
+ set :application, "<%= domain_name %>"
4
+
5
+ # Set server where the application is going to be uploaded to.
6
+ role :web, application
7
+ role :app, application
8
+ role :db, application
9
+
10
+ # Set the user
11
+ # :user => Set the user that will attempt to access the remote repository
12
+ # :deploy_to => Set the deployment location (destination) on the remote server
13
+ # :use_sudo => Set to false
14
+ set :user, "<%= user %>"
15
+ set :deploy_to, "<%= deploy_to %>"
16
+ set :use_sudo, false
17
+
18
+ # Git Repository Location
19
+ # :scm => Specify the source code management tool you want to use (default is git)
20
+ # :repository => Assign the repository location where the application resides
21
+ # :branch => Select the branch that capistrano should fetch from (default is master)
22
+ set :scm, "<%= scm %>"
23
+ set :repository, "<%= repository %>"
24
+ set :branch, "<%= branch %>"
25
+
26
+ # Required: default_run_options[:pty] - This will allow the user to connect to protected repository after
27
+ # logging in when the system prompts for the server's root password
28
+ # default_run_options => (default is true)
29
+ default_run_options[:pty] = true
30
+
31
+ # You can add additional deployment tasks, or alter the ones below.
32
+ namespace :deploy do
33
+
34
+ desc "Sets up the shared folder on the remote server"
35
+ task :setup_shared_folder do
36
+ run "touch #{shared_path}/log/production.log"
37
+ run "chmod 0666 #{shared_path}/log/production.log"
38
+ end
39
+
40
+ desc "Syncs the database.yml to the server"
41
+ task :sync_database do
42
+ system "rsync -vr --exclude='.DS_Store' config/database.yml #{user}@#{application}:#{shared_path}/config/"
43
+ end
44
+
45
+ desc "Restart Application with Passenger."
46
+ task :restart do
47
+ run "touch #{current_path}/tmp/restart.txt"
48
+ end
49
+
50
+ desc "Symlink database."
51
+ task :symlink_database do
52
+ run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
53
+ end
54
+
55
+ desc "Make javascripts and stylesheets directories writable."
56
+ task :make_js_and_css_writable do
57
+ run "chmod 777 #{release_path}/public/javascripts"
58
+ run "chmod 777 #{release_path}/public/stylesheets"
59
+ end
60
+
61
+ desc "Updates repository before deployment."
62
+ task :update_repository do
63
+ system "git add ."
64
+ system "git commit -a -m 'Comitted for repository.'"
65
+ system "git push origin master"
66
+ end
67
+
68
+ end
69
+
70
+ # Tasks that run before the deployment process
71
+ before 'deploy', 'deploy:update_repository'
72
+
73
+ # Tasks that run directly after the initial setup
74
+ after 'deploy:setup', 'deploy:setup_shared_folder'
75
+ after 'deploy:setup', 'deploy:sync_database'
76
+
77
+ # Tasks that run directly after deployment
78
+ after 'deploy:update_code', 'deploy:symlink_database'
79
+ after 'deploy:update_code', 'deploy:make_js_and_css_writable'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meskyanichi-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael
@@ -30,6 +30,7 @@ files:
30
30
  - lib/generators.rb
31
31
  - test/generators_test.rb
32
32
  - test/test_helper.rb
33
+ - CHANGELOG
33
34
  - rails_generators
34
35
  - rails_generators/capistrano_template
35
36
  - rails_generators/capistrano_template/capistrano_template_generator.rb