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
@@ -1,235 +0,0 @@
1
- ######################################################################
2
- # APACHE TASKS #
3
- ######################################################################
4
- Capistrano::Configuration.instance(:must_exist).load do
5
- on :start, 'apache:environment_detection'
6
-
7
- run_task 'web_server:stop', :as => 'manager'
8
- run_task 'web_server:start', :as => 'manager'
9
- run_task 'web_server:restart', :as => 'manager'
10
-
11
- run_task 'website:install', :as => 'manager'
12
- run_task 'website:remove', :as => 'manager'
13
- run_task 'website:enable', :as => 'manager'
14
- run_task 'website:disable', :as => 'manager'
15
-
16
- namespace :deploy do
17
- namespace :web do
18
- desc <<-DESC
19
- Enables the website's application by removing the maintenance page.
20
- DESC
21
- task :enable do
22
- website.maintenance_mode.disable
23
- end
24
-
25
- desc <<-DESC
26
- Disables the website's application by installing the maintenance page.
27
- DESC
28
- task :disable do
29
- website.maintenance_mode.enable
30
- end
31
- end
32
- end
33
-
34
- namespace :web_server do
35
- desc "Stop Apache"
36
- task :stop do
37
- apache.stop
38
- end
39
-
40
- desc "Start Apache"
41
- task :start do
42
- apache.start
43
- end
44
-
45
- desc "Restart Apache"
46
- task :restart do
47
- apache.restart
48
- end
49
- end
50
-
51
- namespace :website do
52
- desc "Creates the site configuration for the files."
53
- task :create do
54
- apache.virtual_host.install
55
- end
56
-
57
- desc "Completely removes the site configuration from the server (but leaves the files.)"
58
- task :remove do
59
- apache.virtual_host.remove
60
- end
61
-
62
- desc "Enable Site"
63
- task :enable do
64
- apache.website.enable
65
- end
66
-
67
- desc "Disable Site"
68
- task :disable do
69
- apache.website.disable
70
- end
71
-
72
- namespace :maintenance_mode do
73
- desc <<-DESC
74
- Makes the application web-accessible again. Removes the \
75
- "maintenance.html" page generated by deploy:web:disable, which (if your \
76
- web servers are configured correctly) will make your application \
77
- web-accessible again.
78
- DESC
79
- task :disable, :except => { :no_release => true } do
80
- run "rm #{shared_path}/system/maintenance.html"
81
- end
82
-
83
- desc <<-DESC
84
- Present a maintenance page to visitors. Disables your application's web \
85
- interface by writing a "maintenance.html" file to each web server. The \
86
- servers must be configured to detect the presence of this file, and if \
87
- it is present, always display it instead of performing the request.
88
-
89
- By default, the maintenance page will just say the site is down for \
90
- "maintenance", and will be back "shortly", but you can customize the \
91
- page by specifying the REASON and UNTIL environment variables:
92
-
93
- $ cap deploy:web:disable \\
94
- REASON="hardware upgrade" \\
95
- UNTIL="12pm Central Time"
96
-
97
- Further customization will require that you write your own task.
98
- DESC
99
- task :enable, :except => { :no_release => true } do
100
- on_rollback { rm "#{shared_path}/system/maintenance.html" }
101
-
102
- require 'erb'
103
- deadline, reason = ENV['UNTIL'], ENV['REASON']
104
-
105
- template = File.read("./app/views/layouts/maintenance.html.erb")
106
- maintenance_page = ERB.new(template).result(binding)
107
-
108
- put maintenance_page, "#{shared_path}/system/maintenance.html", :mode => 0644
109
- end
110
- end
111
- end
112
-
113
- namespace :apache do
114
- desc "[internal] Checks to see what type of Apache installation is running on the remote."
115
- task :environment_detection do
116
- find_apache_control_script
117
-
118
- if apache_control_script =~ /apache2/
119
- set :apache_enable_script, "a2ensite"
120
- set :apache_disable_script, "a2dissite"
121
- end
122
- end
123
-
124
- desc "[internal] Starts the Apache webserver"
125
- task :start do
126
- run "#{sudo} #{apache_control_script} start"
127
- end
128
-
129
- desc "[internal] Stops the Apache webserver"
130
- task :stop do
131
- run "#{sudo} #{apache_control_script} stop"
132
- end
133
-
134
- desc "[internal] Stops the Apache webserver"
135
- task :restart do
136
- run "#{sudo} #{apache_control_script} restart"
137
- end
138
-
139
- desc "[internal] Reloads the Apache configurations."
140
- task :reload do
141
- run "#{sudo} #{apache_control_script} reload"
142
- end
143
-
144
- namespace :website do
145
- desc "[internal] Enables the Apache site on the server level."
146
- task :enable do
147
- abort "Sorry, auto-enabling sites is not supported on your version of Apache." unless exists?(:apache_enable_script)
148
-
149
- run "#{sudo} #{apache_enable_script} #{deploy_name}"
150
- apache.reload
151
- end
152
-
153
- desc "[internal] Disables the Apache site on the server level."
154
- task :disable do
155
- abort "Sorry, auto-disabling sites is not supported on your version of Apache." unless exists?(:apache_disable_script)
156
-
157
- run "#{sudo} #{apache_disable_script} #{deploy_name}"
158
- apache.reload
159
- end
160
- end
161
-
162
- namespace :virtual_host do
163
- desc "[internal] Install Virtual Host"
164
- task :install do
165
- abort "Sorry, auto-installing sites is not supported on your version of Apache." unless exists?(:apache_disable_script)
166
-
167
- virtual_host_config = <<-VHOST
168
- <VirtualHost #{web_server_ip}:443>
169
- ServerName #{deploy_name}
170
- DocumentRoot #{deploy_to}/current/public
171
-
172
- SSLEngine on
173
- SSLCertificateFile /etc/ssl/certs/#{domain}.crt
174
- SSLCertificateKeyFile /etc/ssl/certs/#{domain}.key
175
-
176
- RailsEnv #{rails_env}
177
- RackEnv #{rails_env}
178
-
179
- <Directory "#{deploy_to}/current/public">
180
- Options FollowSymLinks -MultiViews
181
- AllowOverride all
182
- Order allow,deny
183
- Allow from all
184
- </Directory>
185
-
186
- RewriteEngine On
187
-
188
- ErrorDocument 503 /system/maintenance.html
189
- RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
190
- RewriteCond %{SCRIPT_FILENAME} !maintenance.html
191
- RewriteCond %{REQUEST_URI} !^/images/
192
- RewriteCond %{REQUEST_URI} !^/robots.txt
193
- RewriteCond %{REQUEST_URI} !^/sitemap
194
- RewriteRule ^.*$ - [redirect=503,last]
195
-
196
- ErrorLog /var/log/apache2/#{application}-errors.log
197
-
198
- LogLevel warn
199
-
200
- CustomLog /var/log/apache2/#{application}-access.log combined
201
- ServerSignature On
202
- </VirtualHost>
203
-
204
- <VirtualHost #{web_server_ip}:80>
205
- ServerName #{deploy_name}
206
-
207
- Redirect permanent / https://#{deploy_name}
208
- </VirtualHost>
209
- VHOST
210
-
211
- put virtual_host_config, "#{user_home}/#{deploy_name}"
212
- run "#{sudo} mv #{user_home}/#{deploy_name} /etc/apache2/sites-available"
213
- run "#{sudo} /etc/init.d/apache2 reload"
214
- end
215
-
216
- desc "[internal] Remove Virtual Host"
217
- task :remove do
218
- abort "Sorry, auto-removing sites is not supported on your version of Apache." unless exists?(:apache_disable_script)
219
-
220
- run "#{sudo} rm /etc/apache2/sites-available/#{deploy_name}"
221
- run "#{sudo} /etc/init.d/apache2 reload"
222
- end
223
- end
224
- end
225
- end
226
-
227
- def find_apache_control_script
228
- if remote_file_exists?("/usr/sbin/apachectl")
229
- set :apache_control_script, "/usr/sbin/apachectl"
230
- elsif remote_file_exists?("/usr/sbin/apache2")
231
- set :apache_control_script, "/usr/sbin/apache2"
232
- end
233
-
234
- abort "Couldn't figure out your version of Apache" unless exists?(:apache_control_script)
235
- end
@@ -1,68 +0,0 @@
1
- ######################################################################
2
- # BUNDLER TASKS #
3
- ######################################################################
4
- Capistrano::Configuration.instance(:must_exist).load do
5
- before 'gems:install', 'bundler:install'
6
-
7
- namespace :gems do
8
- desc "Install Bundled Gems"
9
- task :install do
10
- run "cd #{current_release} && bundle install --gemfile #{current_release}/Gemfile --path #{shared_path}/bundle --deployment --quiet --without development test"
11
- end
12
-
13
- desc "Update Bundled Gems"
14
- task :update do
15
- raise "I'm sorry Dave, but I can't let you do that. I have full control over production." if rails_env == 'production'
16
-
17
- run "cd #{current_release} && bundle update"
18
- end
19
- end
20
-
21
- namespace :bundler do
22
- desc "Install Bundler"
23
- task :install do
24
- bundler_install_command = "gem install bundler --version #{gem_packager_version} --no-ri --no-rdoc && gem cleanup bundler"
25
-
26
- if fetch(:capabilities).include? :rvm
27
- run_with_rvm "#{ruby_version}@global", bundler_install_command
28
- else
29
- run bundler_install_command
30
- end
31
- end
32
- end
33
- end
34
-
35
- ######################################################################
36
- # BUNDLER CHECKS #
37
- ######################################################################
38
- Capistrano::Configuration.instance(:must_exist).load do
39
- namespace :capabilities do
40
- namespace :check do
41
- desc <<-DESC
42
- [internal] Checks to see if all necessary Bundler capabilities variables have been set up.
43
- DESC
44
- task :bundler do
45
- required_variables = [
46
- :gem_packager_version
47
- ]
48
-
49
- verify_variables(required_variables)
50
- end
51
- end
52
- end
53
- end
54
-
55
- ######################################################################
56
- # BUNDLER DEFAULTS #
57
- ######################################################################
58
- Capistrano::Configuration.instance(:must_exist).load do
59
- namespace :capabilities do
60
- namespace :defaults do
61
- desc "[internal] Sets intelligent defaults for Bundler deployments."
62
- task :bundler do
63
- _cset :gem_packager_version, `gem list bundler`.match(/\((.*)\)/)[1]
64
- set :rake, 'bundle exec rake'
65
- end
66
- end
67
- end
68
- end
@@ -1,42 +0,0 @@
1
- ######################################################################
2
- # RVM TASKS #
3
- ######################################################################
4
- def run_with_rvm(ruby_env_string, command)
5
- run("rvm use #{ruby_env_string} && #{command}")
6
- end
7
-
8
- ######################################################################
9
- # RVM CHECKS #
10
- ######################################################################
11
- Capistrano::Configuration.instance(:must_exist).load do
12
- namespace :capabilities do
13
- namespace :check do
14
- desc <<-DESC
15
- [internal] Checks to see if all necessary RVM variables have been set up.
16
- DESC
17
- task :rvm do
18
- required_variables = [
19
- :ruby_version,
20
- :ruby_gemset,
21
- :rvm_ruby_string,
22
- ]
23
-
24
- verify_variables(required_variables)
25
- end
26
- end
27
- end
28
- end
29
-
30
- ######################################################################
31
- # RVM DEFAULTS #
32
- ######################################################################
33
- Capistrano::Configuration.instance(:must_exist).load do
34
- namespace :capabilities do
35
- namespace :defaults do
36
- _cset :ruby_version, ENV["rvm_ruby_string"]
37
- _cset :ruby_gemset, ENV["GEM_HOME"].split('@')[1]
38
-
39
- _cset(:rvm_ruby_string) {ruby_gemset ? "#{ruby_version}@#{ruby_gemset}" : ruby_version}
40
- end
41
- end
42
- end
@@ -1,109 +0,0 @@
1
- ######################################################################
2
- # EMAIL NOTIFIER TASKS #
3
- ######################################################################
4
- require 'mail'
5
- require 'erb'
6
- require 'chicken_soup/notifiers/email_notifier'
7
-
8
- Capistrano::Configuration.instance(:must_exist).load do |cap|
9
- before 'notifiers:defaults:email', 'vc:log'
10
- after 'deploy:cleanup', 'notify:by_email'
11
-
12
- namespace :notify do
13
- desc <<-DESC
14
- [internal] Sends a notification via email once a deployment is complete.
15
- DESC
16
- task :by_email do
17
- if !cap[:email_notifier_client_recipients].empty?
18
- Mail.deliver do
19
- to cap[:email_notifier_client_recipients]
20
- from cap[:email_notifier_sender]
21
- subject cap[:email_notifier_subject]
22
- body cap[:email_notifier_client_body]
23
- end
24
- end
25
-
26
- if !cap[:email_notifier_internal_recipients].empty?
27
- Mail.deliver do
28
- to cap[:email_notifier_internal_recipients]
29
- from cap[:email_notifier_sender]
30
- subject cap[:email_notifier_subject]
31
- body cap[:email_notifier_internal_body]
32
- end
33
- end
34
- end
35
- end
36
- end
37
-
38
- ######################################################################
39
- # EMAIL NOTIFIER CHECKS #
40
- ######################################################################
41
- Capistrano::Configuration.instance(:must_exist).load do
42
- namespace :notifiers do
43
- namespace :check do
44
- desc <<-DESC
45
- [internal] Checks to see if all necessary email notification environment variables have been set up.
46
- DESC
47
- task :email do
48
- required_variables = [
49
- :email_notifier_client_recipients,
50
- :email_notifier_internal_recipients,
51
- :email_notifier_domain,
52
- :email_notifier_username,
53
- :email_notifier_password
54
- ]
55
-
56
- verify_variables(required_variables)
57
- end
58
- end
59
- end
60
- end
61
-
62
- ######################################################################
63
- # EMAIL NOTIFIER DEFAULTS #
64
- ######################################################################
65
- Capistrano::Configuration.instance(:must_exist).load do |cap|
66
- namespace :notifiers do
67
- namespace :defaults do
68
- task :email do
69
- _cset :email_notifier_format, 'html'
70
-
71
- _cset :email_notifier_mail_method, :smtp
72
- _cset :email_notifier_server, "smtp.gmail.com"
73
- _cset :email_notifier_port, 587
74
- _cset :email_notifier_authentication, 'plain'
75
-
76
- _cset :email_notifier_mail_options, { :address => email_notifier_server,
77
- :port => email_notifier_port,
78
- :domain => email_notifier_domain,
79
- :user_name => email_notifier_username,
80
- :password => email_notifier_password,
81
- :authentication => email_notifier_authentication,
82
- :enable_starttls_auto => true }
83
-
84
- _cset :email_notifier_client_recipients, []
85
- _cset :email_notifier_internal_recipients, []
86
- _cset :email_notifier_sender, 'theshadow@theshadowknows.com'
87
- _cset :email_notifier_subject, "#{application.titleize} has been deployed to #{rails_env.capitalize}"
88
- _cset :email_notifier_client_template, read_template("client_email.#{email_notifier_format}.erb")
89
- _cset :email_notifier_internal_template, read_template("internal_email.#{email_notifier_format}.erb")
90
-
91
- email_notifier = ChickenSoup::EmailNotifier.new(cap)
92
- _cset :email_notifier_client_body, render_erb(email_notifier_client_template, email_notifier)
93
- _cset :email_notifier_internal_body, render_erb(email_notifier_internal_template, email_notifier)
94
-
95
- Mail.defaults do
96
- delivery_method cap[:email_notifier_mail_method], cap[:email_notifier_mail_options]
97
- end
98
- end
99
- end
100
- end
101
- end
102
-
103
- def render_erb(template, email_info)
104
- ERB.new(template, 0, "%<>").result(binding)
105
- end
106
-
107
- def read_template(template)
108
- File.read(File.join(File.dirname(__FILE__), template))
109
- end