chicken_soup 0.1.0 → 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.
Files changed (64) hide show
  1. data/.gitignore +2 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/chicken_soup.gemspec +3 -1
  5. data/lib/chicken_soup/capabilities.rb +21 -6
  6. data/lib/chicken_soup/capabilities/apache/apache-checks.rb +19 -0
  7. data/lib/chicken_soup/capabilities/apache/apache-defaults.rb +30 -0
  8. data/lib/chicken_soup/capabilities/apache/apache-tasks.rb +85 -0
  9. data/lib/chicken_soup/capabilities/bundler/bundler-checks.rb +19 -0
  10. data/lib/chicken_soup/capabilities/bundler/bundler-defaults.rb +14 -0
  11. data/lib/chicken_soup/capabilities/bundler/bundler-tasks.rb +35 -0
  12. data/lib/chicken_soup/capabilities/checks.rb +1 -1
  13. data/lib/chicken_soup/capabilities/defaults.rb +22 -5
  14. data/lib/chicken_soup/capabilities/{git.rb → git/git-defaults.rb} +2 -13
  15. data/lib/chicken_soup/capabilities/heroku/heroku-checks.rb +22 -0
  16. data/lib/chicken_soup/capabilities/heroku/heroku-defaults.rb +16 -0
  17. data/lib/chicken_soup/capabilities/{heroku.rb → heroku/heroku-tasks.rb} +5 -45
  18. data/lib/chicken_soup/capabilities/{mysql.rb → mysql/mysql-tasks.rb} +0 -0
  19. data/lib/chicken_soup/capabilities/nginx/nginx-checks.rb +19 -0
  20. data/lib/chicken_soup/capabilities/nginx/nginx-defaults.rb +21 -0
  21. data/lib/chicken_soup/capabilities/nginx/nginx-tasks.rb +85 -0
  22. data/lib/chicken_soup/capabilities/{passenger.rb → passenger/passenger-tasks.rb} +1 -1
  23. data/lib/chicken_soup/capabilities/postgres/postgres-checks.rb +17 -0
  24. data/lib/chicken_soup/capabilities/postgres/postgres-defaults.rb +15 -0
  25. data/lib/chicken_soup/capabilities/{postgres.rb → postgres/postgres-tasks.rb} +1 -1
  26. data/lib/chicken_soup/capabilities/rvm/rvm-checks.rb +21 -0
  27. data/lib/chicken_soup/capabilities/rvm/rvm-defaults.rb +13 -0
  28. data/lib/chicken_soup/capabilities/rvm/rvm-tasks.rb +6 -0
  29. data/lib/chicken_soup/capabilities/shared/db-checks.rb +19 -0
  30. data/lib/chicken_soup/capabilities/shared/db-defaults.rb +13 -0
  31. data/lib/chicken_soup/capabilities/shared/{db.rb → db-tasks.rb} +24 -11
  32. data/lib/chicken_soup/capabilities/shared/web_server-tasks.rb +99 -0
  33. data/lib/chicken_soup/capabilities/{svn.rb → svn/svn-defaults.rb} +0 -13
  34. data/lib/chicken_soup/capabilities/svn/svn-tasks.rb +12 -0
  35. data/lib/chicken_soup/capabilities/tasks.rb +12 -0
  36. data/lib/chicken_soup/capabilities/unix/unix-checks.rb +33 -0
  37. data/lib/chicken_soup/capabilities/unix/unix-defaults.rb +42 -0
  38. data/lib/chicken_soup/capabilities/{unix.rb → unix/unix-tasks.rb} +4 -83
  39. data/lib/chicken_soup/deploy.rb +0 -5
  40. data/lib/chicken_soup/environment.rb +10 -0
  41. data/lib/chicken_soup/environment/checks.rb +17 -2
  42. data/lib/chicken_soup/environment/defaults.rb +25 -3
  43. data/lib/chicken_soup/environment/tasks.rb +12 -0
  44. data/lib/chicken_soup/global.rb +77 -2
  45. data/lib/chicken_soup/notifiers.rb +7 -4
  46. data/lib/chicken_soup/notifiers/checks.rb +1 -1
  47. data/lib/chicken_soup/notifiers/defaults.rb +1 -2
  48. data/lib/chicken_soup/notifiers/email/email-checks.rb +26 -0
  49. data/lib/chicken_soup/notifiers/email/email-defaults.rb +50 -0
  50. data/lib/chicken_soup/notifiers/email/email-tasks.rb +37 -0
  51. data/lib/chicken_soup/notifiers/email/presenter.rb +56 -0
  52. data/lib/chicken_soup/notifiers/{git.rb → git/git-tasks.rb} +0 -0
  53. data/lib/chicken_soup/notifiers/{hoptoad.rb → hoptoad/hoptoad-tasks.rb} +0 -0
  54. data/lib/chicken_soup/notifiers/tasks.rb +12 -0
  55. data/lib/chicken_soup/templates/client_email.html.erb +21 -0
  56. data/lib/chicken_soup/templates/internal_email.html.erb +19 -0
  57. data/lib/chicken_soup/version.rb +1 -1
  58. data/lib/chicken_stock.rb +3 -3
  59. data/spec/support/focused.rb +10 -0
  60. metadata +91 -35
  61. data/lib/chicken_soup/capabilities/apache.rb +0 -235
  62. data/lib/chicken_soup/capabilities/bundler.rb +0 -68
  63. data/lib/chicken_soup/capabilities/rvm.rb +0 -42
  64. data/lib/chicken_soup/notifiers/email.rb +0 -109
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  *.gem
2
2
  .bundle
3
+ .yardoc
3
4
  Gemfile.lock
4
5
  pkg/*
6
+ todo.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.2@chicken_soup
data/chicken_soup.gemspec CHANGED
@@ -28,8 +28,10 @@ Gem::Specification.new do |s|
28
28
  s.require_paths = ["lib"]
29
29
  #= Manifest =#
30
30
 
31
- s.add_dependency('capistrano', '~> 2.5.19')
31
+ s.add_dependency('capistrano', '~> 2.6.0')
32
32
  s.add_dependency('mail', '~> 2.2.15')
33
33
 
34
34
  s.add_development_dependency('bundler', '~> 1.0.10')
35
+ s.add_development_dependency('rspec', '~> 2.6.0')
36
+ s.add_development_dependency('yard', '~> 0.7.1')
35
37
  end
@@ -1,16 +1,31 @@
1
1
  ######################################################################
2
- # CAPABILITIES SETUP #
2
+ # CAPABILITIES SETUP
3
+ #
4
+ # Beginning here, the deployment will utilize the :capabilities array
5
+ # which should have been set in the deploy.rb file. If :capabilites
6
+ # was not set, then nothing else is loaded.
7
+ #
8
+ # If it was set, we first load all of the default values for each
9
+ # capability's environment variables.
10
+ #
11
+ # Next, we verify that each capability has what it needs to proceed
12
+ # through the rest of the deployment. If not, the deployment will
13
+ # abort.
14
+ #
3
15
  ######################################################################
4
16
  Capistrano::Configuration.instance(:must_exist).load do
5
17
  require 'chicken_soup/capabilities/defaults'
6
18
  require "chicken_soup/capabilities/checks"
19
+ require "chicken_soup/capabilities/tasks"
7
20
 
8
- desc "[internal] This task is only here because `require` cannot be used within a `namespace`"
9
- task :load_capabilities do
10
- require "chicken_soup/capabilities/#{deployment_type}"
21
+ ['defaults', 'checks', 'tasks'].each do |method|
22
+ desc "[internal] This task is only here because `require` cannot be used within a `namespace`"
23
+ task "load_capability_#{method}".to_sym do
24
+ require_if_exists "chicken_soup/capabilities/#{deployment_type}/#{deployment_type}-#{method}"
11
25
 
12
- fetch(:capabilities).each do |capability|
13
- require "chicken_soup/capabilities/#{capability}"
26
+ fetch(:capabilities).each do |capability|
27
+ require_if_exists "chicken_soup/capabilities/#{capability}/#{capability}-#{method}"
28
+ end
14
29
  end
15
30
  end
16
31
  end
@@ -0,0 +1,19 @@
1
+ ######################################################################
2
+ # APACHE CHECKS #
3
+ ######################################################################
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ namespace :capabilities do
6
+ namespace :check do
7
+ desc <<-DESC
8
+ [internal] Checks to see if all necessary Apache capabilities variables have been set up.
9
+ DESC
10
+ task :apache do
11
+ required_variables = [
12
+ :web_server_control_script
13
+ ]
14
+
15
+ verify_variables(required_variables)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ ######################################################################
2
+ # APACHE DEFAULTS #
3
+ ######################################################################
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ namespace :capabilities do
6
+ namespace :defaults do
7
+ desc "[internal] Sets intelligent defaults for Apache deployments."
8
+ task :apache do
9
+ find_web_server_control_script
10
+
11
+ if web_server_control_script =~ /apache2/
12
+ set :apache_enable_script, "a2ensite"
13
+ set :apache_disable_script, "a2dissite"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ def find_web_server_control_script
21
+ if remote_file_exists?("/usr/sbin/apachectl")
22
+ set :web_server_control_script, "/usr/sbin/apachectl"
23
+ elsif remote_file_exists?("/usr/sbin/apache2")
24
+ set :web_server_control_script, "/usr/sbin/apache2"
25
+ elsif remote_file_exists?("/usr/sbin/httpd")
26
+ set :web_server_control_script, "/usr/sbin/httpd"
27
+ end
28
+
29
+ abort "Couldn't figure out how to control your installation of Apache" unless exists?(:web_server_control_script)
30
+ end
@@ -0,0 +1,85 @@
1
+ ######################################################################
2
+ # APACHE TASKS #
3
+ ######################################################################
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ require 'chicken_soup/capabilities/shared/web_server-tasks'
6
+
7
+ namespace :website do
8
+ desc "Creates the site configuration for the files."
9
+ task :create do
10
+ abort "Sorry, auto-installing sites is not supported on your version of Apache." unless exists?(:apache_disable_script)
11
+
12
+ virtual_host_config = <<-VHOST
13
+ <VirtualHost #{web_server_ip}:443>
14
+ ServerName #{deploy_site_name}
15
+ DocumentRoot #{deploy_to}/current/public
16
+
17
+ SSLEngine on
18
+ SSLCertificateFile /etc/ssl/certs/#{domain}.crt
19
+ SSLCertificateKeyFile /etc/ssl/certs/#{domain}.key
20
+
21
+ RailsEnv #{rails_env}
22
+ RackEnv #{rails_env}
23
+
24
+ <Directory "#{deploy_to}/current/public">
25
+ Options FollowSymLinks -MultiViews
26
+ AllowOverride all
27
+ Order allow,deny
28
+ Allow from all
29
+ </Directory>
30
+
31
+ RewriteEngine On
32
+
33
+ ErrorDocument 503 /system/maintenance.html
34
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
35
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
36
+ RewriteCond %{REQUEST_URI} !^/images/
37
+ RewriteCond %{REQUEST_URI} !^/robots.txt
38
+ RewriteCond %{REQUEST_URI} !^/sitemap
39
+ RewriteRule ^.*$ - [redirect=503,last]
40
+
41
+ ErrorLog /var/log/apache2/#{application}-errors.log
42
+
43
+ LogLevel warn
44
+
45
+ CustomLog /var/log/apache2/#{application}-access.log combined
46
+ ServerSignature On
47
+ </VirtualHost>
48
+
49
+ <VirtualHost #{web_server_ip}:80>
50
+ ServerName #{deploy_site_name}
51
+
52
+ Redirect permanent / https://#{deploy_site_name}
53
+ </VirtualHost>
54
+ VHOST
55
+
56
+ put virtual_host_config, "#{user_home}/#{deploy_site_name}"
57
+ run "#{sudo} mv #{user_home}/#{deploy_site_name} /etc/apache2/sites-available"
58
+ web_server.reload
59
+ end
60
+
61
+ desc "Completely removes the site configuration from the server (but leaves the files.)"
62
+ task :remove do
63
+ abort "Sorry, auto-removing sites is not supported on your version of Apache." unless exists?(:apache_disable_script)
64
+
65
+ run "#{sudo} rm /etc/apache2/sites-available/#{deploy_site_name}"
66
+ web_server.reload
67
+ end
68
+
69
+ desc "Enable Site"
70
+ task :enable do
71
+ abort "Sorry, auto-enabling sites is not supported on your version of Apache." unless exists?(:apache_enable_script)
72
+
73
+ run "#{sudo} #{apache_enable_script} #{deploy_site_name}"
74
+ web_server.reload
75
+ end
76
+
77
+ desc "Disable Site"
78
+ task :disable do
79
+ abort "Sorry, auto-disabling sites is not supported on your version of Apache." unless exists?(:apache_disable_script)
80
+
81
+ run "#{sudo} #{apache_disable_script} #{deploy_site_name}"
82
+ web_server.reload
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,19 @@
1
+ ######################################################################
2
+ # BUNDLER CHECKS #
3
+ ######################################################################
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ namespace :capabilities do
6
+ namespace :check do
7
+ desc <<-DESC
8
+ [internal] Checks to see if all necessary Bundler capabilities variables have been set up.
9
+ DESC
10
+ task :bundler do
11
+ required_variables = [
12
+ :gem_packager_version
13
+ ]
14
+
15
+ verify_variables(required_variables)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ ######################################################################
2
+ # BUNDLER DEFAULTS #
3
+ ######################################################################
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ namespace :capabilities do
6
+ namespace :defaults do
7
+ desc "[internal] Sets intelligent defaults for Bundler deployments."
8
+ task :bundler do
9
+ _cset :gem_packager_version, `gem list bundler`.match(/\((.*)\)/)[1]
10
+ set :rake, "RAILS_ENV=#{rails_env} bundle exec rake"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ ######################################################################
2
+ # BUNDLER TASKS #
3
+ ######################################################################
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ before 'gems:install', 'bundler:install'
6
+
7
+ run_task 'bundler:install', :as => manager_username
8
+
9
+ namespace :gems do
10
+ desc "Install Bundled Gems"
11
+ task :install do
12
+ run "cd #{latest_release} && bundle install --gemfile #{latest_release}/Gemfile --path #{shared_path}/bundle --deployment --quiet --without development test"
13
+ end
14
+
15
+ desc "Update Bundled Gems"
16
+ task :update do
17
+ abort "I'm sorry Dave, but I can't let you do that. I have full control over production." if rails_env == 'production'
18
+
19
+ run "cd #{latest_release} && bundle update"
20
+ end
21
+ end
22
+
23
+ namespace :bundler do
24
+ desc "Install Bundler"
25
+ task :install do
26
+ bundler_install_command = "gem install bundler --version #{gem_packager_version} --no-ri --no-rdoc && gem cleanup bundler"
27
+
28
+ if fetch(:capabilities).include? :rvm
29
+ run_with_rvm "#{ruby_version}@global", bundler_install_command
30
+ else
31
+ run bundler_install_command
32
+ end
33
+ end
34
+ end
35
+ end
@@ -2,7 +2,7 @@
2
2
  # CAPABILITIES CHECK #
3
3
  ######################################################################
4
4
  Capistrano::Configuration.instance(:must_exist).load do
5
- after 'environment:check', 'capabilities:check'
5
+ before 'capabilities:check', 'load_capability_checks'
6
6
 
7
7
  namespace :capabilities do
8
8
  namespace :check do
@@ -1,19 +1,36 @@
1
1
  ######################################################################
2
- # DEFAULT CAPABILITIES SETUP #
2
+ # DEFAULT CAPABILITIES SETUP
3
+ #
4
+ # The 'capabilities:defaults' task hooks itself into the deployment
5
+ # stream by attaching an after hook to 'environment:defaults'.
6
+ #
7
+ # Prior to execution, all of the capabilities which were specified in
8
+ # the deploy.rb file are loaded and then each capability has its
9
+ # 'defaults' task called.
10
+ #
11
+ # All capability's defaults tasks are in the format:
12
+ # capabilities:defaults:<capability_name>
13
+ #
14
+ # Defaults tasks are there simply to set standard conventional
15
+ # standards on each capability. In almost all cases, they can
16
+ # be overridden.
17
+ #
18
+ # Defaults are also optional. If a capability doesn't require any
19
+ # environment variables to be set, it can simply omit a defaults task.
20
+ #
3
21
  ######################################################################
4
22
  Capistrano::Configuration.instance(:must_exist).load do
5
- after 'environment:defaults', 'capabilities:defaults'
6
- before 'capabilities:defaults', 'load_capabilities'
23
+ before 'capabilities:defaults', 'load_capability_defaults'
7
24
 
8
25
  namespace :capabilities do
9
26
  namespace :defaults do
10
27
  desc <<-DESC
11
- [internal] Installs the entire capabilities for the given deployment type.
28
+ [internal] Installs all capabilities for the given deployment type.
12
29
 
13
30
  Most of these values can be overridden in each application's deploy.rb file.
14
31
  DESC
15
32
  task :default do
16
- defaults.send(deployment_type.to_s)
33
+ capabilities.defaults.send(deployment_type.to_s)
17
34
 
18
35
  if exists?(:capabilities)
19
36
  fetch(:capabilities).each do |capability|
@@ -1,16 +1,3 @@
1
- ######################################################################
2
- # GIT TASKS #
3
- ######################################################################
4
- Capistrano::Configuration.instance(:must_exist).load do
5
- namespace :vc do
6
- desc <<-DESC
7
- DESC
8
- task :log do
9
- set :vc_log, `git log #{previous_revision}..#{current_revision} --pretty=format:%ai:::%an:::%s`
10
- end
11
- end
12
- end
13
-
14
1
  ######################################################################
15
2
  # GIT DEFAULTS #
16
3
  ######################################################################
@@ -27,6 +14,8 @@ Capistrano::Configuration.instance(:must_exist).load do
27
14
  set(:branch) { `git branch`.match(/\* (\S+)\s/m)[1] || raise("Couldn't determine current branch") }
28
15
  set(:remote) { `git remote`.match(/(\S+)\s/m)[1] || raise("Couldn't determine default remote repository") }
29
16
  ssh_options[:forward_agent] = true
17
+
18
+ set :vc_log, `git log #{previous_revision}..#{current_revision} --pretty=format:%ai:::%an:::%s`
30
19
  end
31
20
  end
32
21
  end
@@ -0,0 +1,22 @@
1
+ ######################################################################
2
+ # HEROKU CHECKS #
3
+ ######################################################################
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ namespace :capabilities do
6
+ namespace :check do
7
+ desc <<-DESC
8
+ [internal] Checks to see if all necessary Heroku environment variables have been set up.
9
+ DESC
10
+ task :heroku do
11
+ required_variables = [
12
+ :deploy_site_name,
13
+ :user,
14
+ :heroku_credentials_path,
15
+ :heroku_credentials_file
16
+ ]
17
+
18
+ verify_variables(required_variables)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ ######################################################################
2
+ # HEROKU DEFAULTS #
3
+ ######################################################################
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ namespace :capabilities do
6
+ namespace :defaults do
7
+ desc "[internal] Sets intelligent defaults for Heroku deployments"
8
+ task :heroku do
9
+ _cset :heroku_credentials_path, "#{ENV["HOME"]}/.heroku"
10
+ _cset :heroku_credentials_file, "#{heroku_credentials_path}/credentials"
11
+
12
+ _cset(:password) {Capistrano::CLI.password_prompt("Encrypted Heroku Password: ")}
13
+ end
14
+ end
15
+ end
16
+ end
@@ -33,14 +33,14 @@ Capistrano::Configuration.instance(:must_exist).load do
33
33
  Installs a new domain for the application on the Heroku server.
34
34
  DESC
35
35
  task :install do
36
- `heroku domains:add #{deploy_name}`
36
+ `heroku domains:add #{deploy_site_name}`
37
37
  end
38
38
 
39
39
  desc <<-DESC
40
40
  Removes the domain for the application from the Heroku server.
41
41
  DESC
42
42
  task :remove do
43
- `heroku domains:remove #{deploy_name}`
43
+ `heroku domains:remove #{deploy_site_name}`
44
44
  end
45
45
 
46
46
  namespace :addon do
@@ -110,7 +110,7 @@ Capistrano::Configuration.instance(:must_exist).load do
110
110
  that are valid for a Heroku deployment.
111
111
  DESC
112
112
  task :raise_error do
113
- raise "Deploying the #{rails_env} environment to Heroku. This command is invalid."
113
+ abort "Deploying the #{rails_env} environment to Heroku. This command is invalid."
114
114
  end
115
115
  end
116
116
 
@@ -220,7 +220,7 @@ Capistrano::Configuration.instance(:must_exist).load do
220
220
 
221
221
  desc "Reset database and seed fresh"
222
222
  task :reset_and_seed do
223
- raise "I'm sorry Dave, but I can't let you do that. I have full control over production." if rails_env == 'production'
223
+ abort "I'm sorry Dave, but I can't let you do that. I have full control over production." if rails_env == 'production'
224
224
  db.backup
225
225
  `heroku pg:reset`
226
226
  `heroku rake db:seed`
@@ -228,7 +228,7 @@ Capistrano::Configuration.instance(:must_exist).load do
228
228
 
229
229
  desc "Seed database"
230
230
  task :seed do
231
- raise "I'm sorry Dave, but I can't let you do that. I have full control over production." if rails_env == 'production'
231
+ abort "I'm sorry Dave, but I can't let you do that. I have full control over production." if rails_env == 'production'
232
232
  db.backup
233
233
  `heroku rake db:seed`
234
234
  end
@@ -244,43 +244,3 @@ Capistrano::Configuration.instance(:must_exist).load do
244
244
  `heroku invoke #{ENV['COMMAND']}`
245
245
  end
246
246
  end
247
-
248
- ######################################################################
249
- # HEROKU CHECKS #
250
- ######################################################################
251
- Capistrano::Configuration.instance(:must_exist).load do
252
- namespace :capabilities do
253
- namespace :check do
254
- desc <<-DESC
255
- [internal] Checks to see if all necessary Heroku environment variables have been set up.
256
- DESC
257
- task :heroku do
258
- required_variables = [
259
- :deploy_name,
260
- :user,
261
- :heroku_credentials_path,
262
- :heroku_credentials_file
263
- ]
264
-
265
- verify_variables(required_variables)
266
- end
267
- end
268
- end
269
- end
270
-
271
- ######################################################################
272
- # HEROKU DEFAULTS #
273
- ######################################################################
274
- Capistrano::Configuration.instance(:must_exist).load do
275
- namespace :capabilities do
276
- namespace :defaults do
277
- desc "[internal] Sets intelligent defaults for Heroku deployments"
278
- task :heroku do
279
- _cset :heroku_credentials_path, "#{ENV["HOME"]}/.heroku"
280
- _cset :heroku_credentials_file, "#{heroku_credentials_path}/credentials"
281
-
282
- _cset(:password) {Capistrano::CLI.password_prompt("Encrypted Heroku Password: ")}
283
- end
284
- end
285
- end
286
- end