deployer 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  Deployer is gem that enhances Capistrano to simplify the deployment of Ruby on Rails applications.
4
4
 
5
- It assumes you are using Passenger to serve your Ruby on Rails applications.
5
+ It assumes you are using Passenger to serve your Ruby on Rails applications, and Bundler to manage gem dependencies.
6
+
7
+ It works with **Ruby on Rails 3** and **Ruby on Rails 2** applications as long as you are using **Bundler**.
8
+
9
+ *If you are currently using the old config.gem method in a Ruby on Rails 2 application, you can easily change this to make it use Bundler instead. [Check out my gist on how to achieve Rails 2 Bundler compatibility.](http://gist.github.com/400609)*
6
10
 
7
11
 
8
12
  ## Getting Started
@@ -146,7 +150,7 @@ Here you can specify that you want to pull/push from/to a git repository that's
146
150
 
147
151
  And then here is the last bit of server configuration you can specify.
148
152
 
149
- ### *Adding Application Specific Deployment Tasks*
153
+ ### Adding Application Specific Deployment Tasks
150
154
 
151
155
  Inside the *namespace :deploy do* block you can define your own deployment tasks that are specific to your application.
152
156
 
data/bin/enhancify CHANGED
@@ -1,5 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'optparse'
7
+ rescue LoadError
8
+ puts '[Deployer] => Tried load load OptionParser but could not find it.'
9
+ puts '[Deployer] => Install Option Parser ( gem install OptionParser ) and try again.'
10
+ exit
11
+ end
12
+
3
13
  options = {}
4
14
 
5
15
  optparse = OptionParser.new do |opts|
@@ -59,12 +69,13 @@ File.open(File.join(File.dirname(__FILE__), '..', 'setup', 'deploy.rb'), "r") do
59
69
  end
60
70
  end
61
71
 
62
- unless File.open(File.join('Capfile'), 'r').read.include?('require "deployer/initializer"')
72
+ # checks for both require "deployer" and require "deployer/initializer"
73
+ unless File.open(File.join('Capfile'), 'r').read.include?('require "deployer"')
63
74
  puts "[Deployer] => Adding Deployer Loader inside #{PATH}/Capfile."
64
75
  File.open(File.join(PATH, 'Capfile'), "a") do |capfile|
65
76
  capfile << <<-CAPFILE
66
77
  \n
67
- require "deployer/initializer"
78
+ require "deployer"
68
79
  load deployer
69
80
  CAPFILE
70
81
  end
data/lib/deployer.rb CHANGED
@@ -1,34 +1,5 @@
1
1
  ##
2
- # Load Deployer Helpers
3
- require File.join(File.dirname(__FILE__), 'deployer', 'helpers')
4
-
5
- ##
6
- # This Configuration Is *Conventional*
7
- set :application, ip
8
- set :deploy_to, "/var/apps/#{appname}" unless respond_to?(:deploy_to)
9
- set :repository_path, "/var/git/#{appname}.git" unless respond_to?(:repository_path)
10
- set :repository, "#{user}@#{application}:#{repository_path}"
11
- set :repository, repository_url if respond_to?(:repository_url)
12
-
13
- set :scm, 'git'
14
- set :use_sudo, false
15
- role :web, application
16
- role :app, application
17
- role :db, application
18
- default_run_options[:pty] = true
19
-
20
- ##
21
- # Default Configuration
22
- set :remote, 'origin' unless respond_to?(:remote)
23
- set :branch, 'master' unless respond_to?(:branch)
24
-
25
- ##
26
- # Load Deployment Tasks
27
- load_tasks('global')
28
- load_tasks('passenger')
29
- load_tasks('plugin')
30
- load_tasks('db')
31
- load_tasks('gems')
32
- load_tasks('repository')
33
- load_tasks('environment')
34
- load_tasks('commands')
2
+ # Returns a path that can be loaded by the "load" method inside the Capfile
3
+ def deployer
4
+ File.join(File.dirname(__FILE__), 'deployer', 'deploy.rb')
5
+ end
@@ -0,0 +1,35 @@
1
+ ##
2
+ # Load Deployer Helpers
3
+ require File.join(File.dirname(__FILE__), 'helpers')
4
+
5
+ ##
6
+ # This Configuration Is *Conventional*
7
+ set :application, ip
8
+ set :deploy_to, respond_to?(:deploy_path) ? deploy_path : "/var/apps/#{appname}"
9
+ set :repository_path, "/var/git/#{appname}.git" unless respond_to?(:repository_path)
10
+ set :repository, "#{user}@#{application}:#{repository_path}"
11
+ set :repository, repository_url if respond_to?(:repository_url)
12
+
13
+ set :scm, 'git'
14
+ set :use_sudo, false
15
+ role :web, application
16
+ role :app, application
17
+ role :db, application
18
+ default_run_options[:pty] = true
19
+
20
+ ##
21
+ # Default Configuration
22
+ set :remote, 'origin' unless respond_to?(:remote)
23
+ set :branch, 'master' unless respond_to?(:branch)
24
+
25
+ ##
26
+ # Load Deployment Tasks
27
+ load_tasks('global')
28
+ load_tasks('sync')
29
+ load_tasks('passenger')
30
+ load_tasks('plugin')
31
+ load_tasks('db')
32
+ load_tasks('gems')
33
+ load_tasks('repository')
34
+ load_tasks('environment')
35
+ load_tasks('commands')
@@ -7,7 +7,7 @@ end
7
7
  ##
8
8
  # Helper Method that assists in loading in tasks from the tasks folder
9
9
  def load_tasks(tasks)
10
- load File.join(File.dirname(__FILE__), '..', 'tasks', "#{tasks}.rb")
10
+ load File.join(File.dirname(__FILE__), 'tasks', "#{tasks}.rb")
11
11
  end
12
12
 
13
13
  ##
@@ -37,7 +37,7 @@ end
37
37
  def bundle_path
38
38
  return @bundle_path if @bundle_path
39
39
  Net::SSH.start(ip, user) do |ssh|
40
- @bundle_path = ssh.exec!("which bundle").chomp || "bundle"
40
+ @bundle_path = ssh.exec!("which bundle") || "bundle"
41
41
  end
42
42
  @bundle_path
43
43
  end
@@ -1,5 +1,3 @@
1
1
  ##
2
- # Returns a path that can be loaded by the "load" method inside the Capfile
3
- def deployer
4
- File.join(File.dirname(__FILE__), '..', 'deployer.rb')
5
- end
2
+ # For backwards compatibility from previous deployer versions
3
+ require File.join(File.dirname(__FILE__), '..', 'deployer')
File without changes
@@ -1,15 +1,5 @@
1
1
  namespace :deploy do
2
2
  namespace :db do
3
-
4
- desc "Syncs the database.yml file from the local machine to the remote machine"
5
- task :sync_yaml do
6
- log "Syncing local database.yml (config/database.yml) to the shared folder (#{appname}/shared/config/database.yml)"
7
- unless File.exist?("config/database.yml")
8
- puts "There is no config/database.yml.\n "
9
- exit
10
- end
11
- system "rsync -vr --exclude='.DS_Store' config/database.yml #{user}@#{application}:#{shared_path}/config/"
12
- end
13
3
 
14
4
  desc "Create the database"
15
5
  task :create do
File without changes
File without changes
@@ -5,8 +5,10 @@ namespace :deploy do
5
5
  system "cap deploy:setup_shared_path"
6
6
  system "cap deploy:setup_symlinks"
7
7
  system "cap deploy:gems:install"
8
- system "cap deploy:db:create"
9
- system "cap deploy:db:migrate"
8
+ unless respond_to?(:skip_database) and skip_database
9
+ system "cap deploy:db:create"
10
+ system "cap deploy:db:migrate"
11
+ end
10
12
  after_deploy if respond_to?(:after_deploy)
11
13
  system "cap deploy:passenger:restart"
12
14
  end
@@ -15,7 +17,7 @@ namespace :deploy do
15
17
  task :initial do
16
18
  system "cap deploy:setup"
17
19
  system "cap deploy:setup_shared_path"
18
- system "cap deploy:db:sync_yaml"
20
+ system "cap deploy:sync:files"
19
21
  end
20
22
 
21
23
  desc "Sets up the shared path"
@@ -31,7 +33,10 @@ namespace :deploy do
31
33
  desc "Creates symbolic links from the application to the shared folders"
32
34
  task :setup_symlinks do
33
35
  log "Creating symbolic links from the application to the shared folders"
34
- shared_symlinks = %w(config/database.yml)
36
+ shared_symlinks = %w()
37
+ unless respond_to?(:skip_database) and skip_database
38
+ shared_symlinks << "config/database.yml"
39
+ end
35
40
  shared_symlinks += additional_shared_symlinks if respond_to?(:additional_shared_symlinks)
36
41
  shared_symlinks.each do |symlink|
37
42
  run "ln -nfs #{File.join(shared_path, symlink)} #{File.join(current_path, symlink)}"
File without changes
File without changes
File without changes
@@ -0,0 +1,31 @@
1
+ namespace :deploy do
2
+ namespace :sync do
3
+ desc "Syncs the configured files from the local machine to the remote machine"
4
+ task :files do
5
+ files = []
6
+
7
+ unless respond_to?(:skip_database) and skip_database
8
+ files << "config/database.yml"
9
+ end
10
+
11
+ if respond_to?(:sync_files)
12
+ files += sync_files
13
+ end
14
+
15
+ files.each do |file|
16
+ if File.exist?(file)
17
+ path_parts = file.split('/')
18
+ file = path_parts.pop
19
+ if path_parts.empty?
20
+ path = ''
21
+ else
22
+ path = path_parts.join('/') + '/'
23
+ end
24
+
25
+ log "Syncing local file \"#{path + file}\" to the shared folder (#{appname}/shared/#{path + file})"
26
+ system "rsync -vr --exclude='.DS_Store' #{path + file} #{user}@#{application}:#{shared_path}/#{path}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
data/setup/deploy.rb CHANGED
@@ -36,29 +36,62 @@ set :remote, "origin" # the remote that should be deployed
36
36
  set :branch, "production" # the branch that should be deployed
37
37
 
38
38
 
39
+ ##
40
+ # Optional
41
+ # Specify custom deployment path
42
+
43
+ # set :deploy_path, "/var/apps/#{appname}"
44
+
45
+
39
46
  ##
40
47
  # Optional
41
48
  # If you want to use a repository from a different location (github.com, trunksapp.com, etc)
42
49
  # Then you can specify the URL here. When using this, the "cap deploy:repository" tasks won't work.
50
+
43
51
  # set :repository_url, "deployer@example.com:/path/to/repository.git"
44
52
 
45
53
 
46
54
  ##
47
- # Set up additional shared folders
48
- set :additional_shared_folders,
49
- %w(public/system db)
55
+ # Optional
56
+ # Use this to define a list of files you want to upload for the deploy:initial task
57
+
58
+ # set :sync_files,
59
+ # %w(config/mongoid.yml)
50
60
 
51
61
 
52
62
  ##
63
+ # Optional
64
+ # Use this to skip database deployment tasks (db:create, db:migrate)
65
+ # Useful when, for example, not using ActiveRecord, but MongoDB with Mongoid instead
66
+
67
+ # set :skip_database, true
68
+
69
+
70
+ ##
71
+ # Optional
72
+ # Set up additional shared folders. The example below will create:
73
+ # SHARED_PATH/public/system
74
+ # SHARED_PATH/public/assets
75
+ # SHARED_PATH/db
76
+
77
+ # set :additional_shared_folders,
78
+ # %w(public/system public/assets db)
79
+
80
+
81
+ ##
82
+ # Optional
53
83
  # Set up additional shared symlinks
54
84
  # These are mirrored to the Rails Applications' structure
55
85
  # public/system = RAILS_ROOT/public/system => SHARED_PATH/public/system
86
+ # public/assets = RAILS_ROOT/public/assets => SHARED_PATH/public/assets
56
87
  # db/production.sqlite3 = RAILS_ROOT/db/production.sqlite3 => SHARED_PATH/db/production.sqlite3
57
- set :additional_shared_symlinks,
58
- %w(public/system db/production.sqlite3)
88
+
89
+ # set :additional_shared_symlinks,
90
+ # %w(public/system public/assets db/production.sqlite3)
59
91
 
60
92
 
61
93
  ##
94
+ # Optional
62
95
  # Additional Application Specific Tasks and Callbacks
63
96
  # In here you can specify which Application Specific tasks you would like to run right before
64
97
  # Passenger restarts the application. You invoke the by simply calling "run_custom_task"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deployer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael van Rooijen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-14 00:00:00 +02:00
18
+ date: 2010-07-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -60,17 +60,19 @@ extra_rdoc_files: []
60
60
 
61
61
  files:
62
62
  - bin/enhancify
63
+ - lib/deployer/deploy.rb
63
64
  - lib/deployer/helpers.rb
64
65
  - lib/deployer/initializer.rb
66
+ - lib/deployer/tasks/commands.rb
67
+ - lib/deployer/tasks/db.rb
68
+ - lib/deployer/tasks/environment.rb
69
+ - lib/deployer/tasks/gems.rb
70
+ - lib/deployer/tasks/global.rb
71
+ - lib/deployer/tasks/passenger.rb
72
+ - lib/deployer/tasks/plugin.rb
73
+ - lib/deployer/tasks/repository.rb
74
+ - lib/deployer/tasks/sync.rb
65
75
  - lib/deployer.rb
66
- - lib/tasks/commands.rb
67
- - lib/tasks/db.rb
68
- - lib/tasks/environment.rb
69
- - lib/tasks/gems.rb
70
- - lib/tasks/global.rb
71
- - lib/tasks/passenger.rb
72
- - lib/tasks/plugin.rb
73
- - lib/tasks/repository.rb
74
76
  - setup/deploy.rb
75
77
  - README.md
76
78
  - LICENSE