capistrano-exts 1.0.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 (48) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Guardfile +13 -0
  4. data/Rakefile +9 -0
  5. data/capistrano-exts.gemspec +35 -0
  6. data/examples/php_fpm/deploy/development.rb +121 -0
  7. data/examples/php_fpm/deploy/production.rb +121 -0
  8. data/examples/php_fpm/deploy/staging.rb +121 -0
  9. data/examples/php_fpm/deploy.rb +38 -0
  10. data/examples/rails_passenger/deploy/development.rb +121 -0
  11. data/examples/rails_passenger/deploy/production.rb +121 -0
  12. data/examples/rails_passenger/deploy/staging.rb +121 -0
  13. data/examples/rails_passenger/deploy.rb +38 -0
  14. data/examples/rails_reverse_proxy/deploy/development.rb +121 -0
  15. data/examples/rails_reverse_proxy/deploy/production.rb +121 -0
  16. data/examples/rails_reverse_proxy/deploy/staging.rb +121 -0
  17. data/examples/rails_reverse_proxy/deploy.rb +38 -0
  18. data/lib/capistrano-exts/core_ext/string/filters.rb +12 -0
  19. data/lib/capistrano-exts/core_ext.rb +10 -0
  20. data/lib/capistrano-exts/receipts/base.rb +22 -0
  21. data/lib/capistrano-exts/receipts/contao.rb +81 -0
  22. data/lib/capistrano-exts/receipts/functions.rb +55 -0
  23. data/lib/capistrano-exts/receipts/git.rb +37 -0
  24. data/lib/capistrano-exts/receipts/god.rb +30 -0
  25. data/lib/capistrano-exts/receipts/multistage.rb +90 -0
  26. data/lib/capistrano-exts/receipts/mysql.rb +214 -0
  27. data/lib/capistrano-exts/receipts/rails.rb +45 -0
  28. data/lib/capistrano-exts/receipts/servers/db_server.rb +19 -0
  29. data/lib/capistrano-exts/receipts/servers/web_server/apache.rb +55 -0
  30. data/lib/capistrano-exts/receipts/servers/web_server/nginx.rb +81 -0
  31. data/lib/capistrano-exts/receipts/servers/web_server.rb +112 -0
  32. data/lib/capistrano-exts/receipts/servers.rb +51 -0
  33. data/lib/capistrano-exts/receipts/unicorn.rb +27 -0
  34. data/lib/capistrano-exts/receipts.rb +17 -0
  35. data/lib/capistrano-exts/servers/utils/erb.rb +16 -0
  36. data/lib/capistrano-exts/servers/utils/variables.rb +25 -0
  37. data/lib/capistrano-exts/servers/web_server/nginx.rb +20 -0
  38. data/lib/capistrano-exts/servers/web_server.rb +69 -0
  39. data/lib/capistrano-exts/templates/multistage.rb +118 -0
  40. data/lib/capistrano-exts/templates/web_servers/nginx.conf.erb +95 -0
  41. data/lib/capistrano-exts/version.rb +12 -0
  42. data/lib/capistrano-exts.rb +14 -0
  43. data/spec/rendered_templates/nginx_php_fpm.conf +58 -0
  44. data/spec/requests/nginx_spec.rb +38 -0
  45. data/spec/servers/web_server/nginx_spec.rb +179 -0
  46. data/spec/spec_helper.rb +27 -0
  47. data/spec/support/factories.rb +1 -0
  48. metadata +220 -0
@@ -0,0 +1,58 @@
1
+ server {
2
+ listen 80;
3
+ server_name technogate.fr www.technogate.fr;
4
+
5
+ root /home/vhosts/technogate/public;
6
+
7
+ index index.php index.html;
8
+
9
+ location / {
10
+
11
+ # this serves static files that exist without running other rewrite tests
12
+ if (-f $request_filename) {
13
+ expires 30d;
14
+ break;
15
+ }
16
+
17
+ # this sends all non-existing file or directory requests to index.php
18
+ if (!-e $request_filename) {
19
+ rewrite ^(.+)$ /index.php?q=$1 last;
20
+ }
21
+
22
+
23
+
24
+ }
25
+
26
+ location ~ /\.ht {
27
+ deny all;
28
+ }
29
+
30
+ location ~ .php$ {
31
+ fastcgi_pass localhost:30313;
32
+ fastcgi_index index.php;
33
+ fastcgi_param SCRIPT_FILENAME /home/vhosts/technogate/public$fastcgi_script_name;
34
+
35
+ fastcgi_param QUERY_STRING $query_string;
36
+ fastcgi_param REQUEST_METHOD $request_method;
37
+ fastcgi_param CONTENT_TYPE $content_type;
38
+ fastcgi_param CONTENT_LENGTH $content_length;
39
+
40
+ fastcgi_param SCRIPT_NAME $fastcgi_script_name;
41
+ fastcgi_param REQUEST_URI $request_uri;
42
+ fastcgi_param DOCUMENT_URI $document_uri;
43
+ fastcgi_param DOCUMENT_ROOT $document_root;
44
+ fastcgi_param SERVER_PROTOCOL $server_protocol;
45
+
46
+ fastcgi_param GATEWAY_INTERFACE CGI/1.1;
47
+ fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
48
+
49
+ fastcgi_param REMOTE_ADDR $remote_addr;
50
+ fastcgi_param REMOTE_PORT $remote_port;
51
+ fastcgi_param SERVER_ADDR $server_addr;
52
+ fastcgi_param SERVER_PORT $server_port;
53
+ fastcgi_param SERVER_NAME $server_name;
54
+
55
+
56
+ }
57
+
58
+ }
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nginx do
4
+
5
+ describe ":php_fpm" do
6
+ subject { Nginx.new :php_fpm}
7
+
8
+ before(:each) do
9
+ @application_url = %w(technogate.fr www.technogate.fr)
10
+ @application = 'technogate'
11
+ @php_fpm_host = 'localhost'
12
+ @php_fpm_port = 30313
13
+ @public_path = '/home/vhosts/technogate/public'
14
+ @indexes = %w(index.php index.html)
15
+
16
+ subject.application_url = @application_url
17
+ subject.application = @application
18
+ subject.php_fpm_host = @php_fpm_host
19
+ subject.php_fpm_port = @php_fpm_port
20
+ subject.public_path = @public_path
21
+ subject.indexes = @indexes
22
+ end
23
+
24
+ it "should render the correct file" do
25
+ expected_result = File.read File.join(RENDERED_TEMPLATES_PATH, 'nginx_php_fpm.conf')
26
+ subject.render.should == expected_result
27
+ end
28
+ end
29
+
30
+ describe ":rails_passenger" do
31
+
32
+ end
33
+
34
+ describe ":rails_reverse_proxy" do
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,179 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nginx do
4
+
5
+ describe "instance" do
6
+ it "should require a mode" do
7
+ lambda {
8
+ Nginx.new
9
+ }.should raise_error(ArgumentError)
10
+ end
11
+
12
+ it "should require a valid mode" do
13
+ lambda {
14
+ Nginx.new(:invalid_mode)
15
+ }.should raise_error(ArgumentError)
16
+ end
17
+ end
18
+
19
+ describe "requirement" do
20
+ describe ":php_fpm" do
21
+ subject { Nginx.new :php_fpm }
22
+
23
+ before(:each) do
24
+ subject.application_url = %w(example.com www.example.com)
25
+ subject.application = 'example'
26
+ subject.php_fpm_host = 'localhost'
27
+ subject.php_fpm_port = 60313
28
+ subject.public_path = '/path/to/application'
29
+ subject.indexes = %w(index.php)
30
+ end
31
+
32
+ it "should require an 'application_url'" do
33
+ subject.application_url = nil
34
+ lambda {
35
+ subject.render
36
+ }.should raise_error(ArgumentError, "application_url is required, please define it.")
37
+ end
38
+
39
+ it "should require an 'public_path'" do
40
+ subject.public_path = nil
41
+ lambda {
42
+ subject.render
43
+ }.should raise_error(ArgumentError, "public_path is required, please define it.")
44
+ end
45
+
46
+ it "should require both 'php_fpm_host'" do
47
+ subject.php_fpm_host = nil
48
+ lambda {
49
+ subject.render
50
+ }.should raise_error(ArgumentError, "php_fpm_host is required, please define it.")
51
+ end
52
+
53
+ it "should require both 'php_fpm_port'" do
54
+ subject.php_fpm_port = nil
55
+ lambda {
56
+ subject.render
57
+ }.should raise_error(ArgumentError, "php_fpm_port is required, please define it.")
58
+ end
59
+ end
60
+
61
+ describe ":rails_passenger" do
62
+ subject { Nginx.new :rails_passenger }
63
+
64
+ it "should require 'public_path'"
65
+
66
+ it "should have passenger enabled"
67
+ end
68
+
69
+ describe ":rails_reverse_proxy" do
70
+ subject { Nginx.new :rails_reverse_proxy }
71
+
72
+ it "should require 'reverse_proxy_server_address'"
73
+
74
+ it "should require 'reverse_proxy_server_port'"
75
+
76
+ it "should require 'reverse_proxy_socket'"
77
+
78
+ it "should have reverse_proxy enabled"
79
+ end
80
+ end
81
+
82
+ describe "rendering" do
83
+ describe ":php_fpm" do
84
+ subject { Nginx.new :php_fpm }
85
+
86
+ before(:each) do
87
+ subject.application_url = %w(example.com www.example.com)
88
+ subject.application = 'example'
89
+ subject.php_fpm_host = 'localhost'
90
+ subject.php_fpm_port = 60313
91
+ subject.public_path = '/path/to/application'
92
+ subject.indexes = %w(index.php)
93
+ end
94
+
95
+ it "should render 'public_path'" do |variable|
96
+ subject.public_path = '/path/to/application'
97
+ subject.render.should =~ %r{root\s+/path/to/application;}
98
+ end
99
+
100
+ it "should render 'authentification_file'" do
101
+ subject.authentification_file = '/path/to/authentification_file'
102
+ subject.render.should =~%r{auth_basic_user_file\s+/path/to/authentification_file;}
103
+ end
104
+
105
+ it "should render 'logs_path'" do
106
+ subject.logs_path = '/path/to/logs'
107
+ subject.render.should =~ %r{access_log\s+/path/to/logs/access.log;}
108
+ subject.render.should =~ %r{error_log\s+/path/to/logs/error.log;}
109
+ end
110
+
111
+ it "should have 'logs_path' optional" do
112
+ subject.render.should_not =~ %r{access_log.+/access.log;}
113
+ subject.render.should_not =~ %r{error_log.+/error.log;}
114
+ end
115
+
116
+ it "should render 'listen_port'" do
117
+ subject.listen_port = 8080
118
+ subject.render.should =~ /listen 8080;/
119
+ end
120
+
121
+ it "should default the 'listen_port' to 80" do
122
+ subject.render.should =~ /listen 80;/
123
+ end
124
+
125
+ it "should render 'application_url'" do
126
+ subject.application_url = %w(technogate.fr www.technogate.fr)
127
+ subject.render.should =~ %r{server_name\s+technogate.fr www.technogate.fr;}
128
+ end
129
+
130
+ it "should render 'indexes'" do
131
+ subject.indexes = %w(index.php index.html)
132
+ subject.render.should =~ %r{index\s+index.php index.html;}
133
+ end
134
+
135
+ it "should have 'indexes' optional" do
136
+ subject.indexes = nil
137
+ subject.render.should_not =~ %r{\s+index .+;}
138
+ end
139
+
140
+ it "should render 'mod_rewrite_simulation'" do
141
+ subject.mod_rewrite_simulation = true
142
+ subject.render.should =~ %r{rewrite.+index.php.+last;}
143
+ end
144
+
145
+ it "should have 'mod_rewrite_simulation' on by default" do
146
+ subject.render.should =~ %r{rewrite.+index.php.+last;}
147
+ end
148
+
149
+ it "should render 'php_fpm_host'" do
150
+ subject.php_fpm_host = 'localhost'
151
+ subject.render.should =~ %r{\s+fastcgi_pass\s+localhost:.+$}
152
+ end
153
+
154
+ it "should render 'php_fpm_port'" do
155
+ subject.php_fpm_host = 'localhost'
156
+ subject.php_fpm_port = 5454
157
+ subject.render.should =~ %r{\s+fastcgi_pass\s+localhost:5454.+$}
158
+ end
159
+ end
160
+
161
+ describe ":rails_passenger" do
162
+ subject { Nginx.new :rails_passenger }
163
+
164
+ it "should render 'application'"
165
+
166
+ it "should have passenger enabled"
167
+ end
168
+
169
+ describe ":rails_reverse_proxy" do
170
+ subject { Nginx.new :rails_reverse_proxy }
171
+
172
+ it "should render 'reverse_proxy_server_address'"
173
+
174
+ it "should render 'reverse_proxy_server_port'"
175
+
176
+ it "should render 'reverse_proxy_socket'"
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'faker'
3
+ require 'rspec'
4
+
5
+ # Require the library (without receipts)
6
+ require File.expand_path("../../lib/capistrano-exts.rb", __FILE__)
7
+
8
+ # Define the path to the rendered templates
9
+ RENDERED_TEMPLATES_PATH = File.expand_path(File.join File.dirname(__FILE__), 'rendered_templates')
10
+
11
+ # Include all modules for easier tests
12
+ include Capistrano::Extensions
13
+ include Server
14
+
15
+ # Require factories
16
+ Dir[ROOT_PATH + "/spec/support/**/*.rb"].each {|f| require f}
17
+
18
+ RSpec.configure do |config|
19
+ # == Mock Framework
20
+ #
21
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
22
+ #
23
+ config.mock_with :mocha
24
+ # config.mock_with :flexmock
25
+ # config.mock_with :rr
26
+ # config.mock_with :rspec
27
+ end
@@ -0,0 +1 @@
1
+ require 'factory_girl'
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-exts
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Wael Nasreddine
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-02 00:00:00.000000000 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ requirement: &2153828600 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 2.8.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2153828600
26
+ - !ruby/object:Gem::Dependency
27
+ name: i18n
28
+ requirement: &2153827300 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *2153827300
37
+ - !ruby/object:Gem::Dependency
38
+ name: activesupport
39
+ requirement: &2153825980 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: 3.1.0
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: *2153825980
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: &2153824960 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: 2.6.0
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *2153824960
59
+ - !ruby/object:Gem::Dependency
60
+ name: mocha
61
+ requirement: &2153823840 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: 0.2.12
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *2153823840
70
+ - !ruby/object:Gem::Dependency
71
+ name: factory_girl
72
+ requirement: &2153822780 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 2.0.5
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *2153822780
81
+ - !ruby/object:Gem::Dependency
82
+ name: faker19
83
+ requirement: &2153821860 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: 1.0.5
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *2153821860
92
+ - !ruby/object:Gem::Dependency
93
+ name: guard
94
+ requirement: &2153820720 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: 0.6.2
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *2153820720
103
+ - !ruby/object:Gem::Dependency
104
+ name: guard-bundler
105
+ requirement: &2153819920 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.1.3
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: *2153819920
114
+ - !ruby/object:Gem::Dependency
115
+ name: guard-rspec
116
+ requirement: &2153819160 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: 0.4.3
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: *2153819160
125
+ - !ruby/object:Gem::Dependency
126
+ name: growl_notify
127
+ requirement: &2153818460 !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - =
131
+ - !ruby/object:Gem::Version
132
+ version: 0.0.1
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: *2153818460
136
+ description: Handy extensions for Capistrano
137
+ email:
138
+ - wael.nasreddine@gmail.com
139
+ executables: []
140
+ extensions: []
141
+ extra_rdoc_files: []
142
+ files:
143
+ - .gitignore
144
+ - Gemfile
145
+ - Guardfile
146
+ - Rakefile
147
+ - capistrano-exts.gemspec
148
+ - examples/php_fpm/deploy.rb
149
+ - examples/php_fpm/deploy/development.rb
150
+ - examples/php_fpm/deploy/production.rb
151
+ - examples/php_fpm/deploy/staging.rb
152
+ - examples/rails_passenger/deploy.rb
153
+ - examples/rails_passenger/deploy/development.rb
154
+ - examples/rails_passenger/deploy/production.rb
155
+ - examples/rails_passenger/deploy/staging.rb
156
+ - examples/rails_reverse_proxy/deploy.rb
157
+ - examples/rails_reverse_proxy/deploy/development.rb
158
+ - examples/rails_reverse_proxy/deploy/production.rb
159
+ - examples/rails_reverse_proxy/deploy/staging.rb
160
+ - lib/capistrano-exts.rb
161
+ - lib/capistrano-exts/core_ext.rb
162
+ - lib/capistrano-exts/core_ext/string/filters.rb
163
+ - lib/capistrano-exts/receipts.rb
164
+ - lib/capistrano-exts/receipts/base.rb
165
+ - lib/capistrano-exts/receipts/contao.rb
166
+ - lib/capistrano-exts/receipts/functions.rb
167
+ - lib/capistrano-exts/receipts/git.rb
168
+ - lib/capistrano-exts/receipts/god.rb
169
+ - lib/capistrano-exts/receipts/multistage.rb
170
+ - lib/capistrano-exts/receipts/mysql.rb
171
+ - lib/capistrano-exts/receipts/rails.rb
172
+ - lib/capistrano-exts/receipts/servers.rb
173
+ - lib/capistrano-exts/receipts/servers/db_server.rb
174
+ - lib/capistrano-exts/receipts/servers/web_server.rb
175
+ - lib/capistrano-exts/receipts/servers/web_server/apache.rb
176
+ - lib/capistrano-exts/receipts/servers/web_server/nginx.rb
177
+ - lib/capistrano-exts/receipts/unicorn.rb
178
+ - lib/capistrano-exts/servers/utils/erb.rb
179
+ - lib/capistrano-exts/servers/utils/variables.rb
180
+ - lib/capistrano-exts/servers/web_server.rb
181
+ - lib/capistrano-exts/servers/web_server/nginx.rb
182
+ - lib/capistrano-exts/templates/multistage.rb
183
+ - lib/capistrano-exts/templates/web_servers/nginx.conf.erb
184
+ - lib/capistrano-exts/version.rb
185
+ - spec/rendered_templates/nginx_php_fpm.conf
186
+ - spec/requests/nginx_spec.rb
187
+ - spec/servers/web_server/nginx_spec.rb
188
+ - spec/spec_helper.rb
189
+ - spec/support/factories.rb
190
+ has_rdoc: true
191
+ homepage: https://github.com/Extensions/capistrano-exts
192
+ licenses: []
193
+ post_install_message:
194
+ rdoc_options: []
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ none: false
205
+ requirements:
206
+ - - ! '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ requirements: []
210
+ rubyforge_project: capistrano-exts
211
+ rubygems_version: 1.6.2
212
+ signing_key:
213
+ specification_version: 3
214
+ summary: Handy extensions for Capistrano
215
+ test_files:
216
+ - spec/rendered_templates/nginx_php_fpm.conf
217
+ - spec/requests/nginx_spec.rb
218
+ - spec/servers/web_server/nginx_spec.rb
219
+ - spec/spec_helper.rb
220
+ - spec/support/factories.rb