berkshelf 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/.gitignore +20 -0
  2. data/.rbenv-version +1 -0
  3. data/Gemfile +3 -0
  4. data/Guardfile +23 -0
  5. data/LICENSE +22 -0
  6. data/README.rdoc +102 -0
  7. data/Thorfile +47 -0
  8. data/berkshelf.gemspec +39 -0
  9. data/features/config.sample.yml +3 -0
  10. data/features/init_command.feature +40 -0
  11. data/features/install.feature +55 -0
  12. data/features/lockfile.feature +22 -0
  13. data/features/step_definitions/chef_server_steps.rb +13 -0
  14. data/features/step_definitions/cli_steps.rb +56 -0
  15. data/features/step_definitions/filesystem_steps.rb +79 -0
  16. data/features/support/env.rb +55 -0
  17. data/features/update.feature +23 -0
  18. data/features/upload_command.feature +43 -0
  19. data/features/without.feature +25 -0
  20. data/lib/berkshelf.rb +90 -0
  21. data/lib/berkshelf/berksfile.rb +170 -0
  22. data/lib/berkshelf/cached_cookbook.rb +253 -0
  23. data/lib/berkshelf/cookbook_source.rb +139 -0
  24. data/lib/berkshelf/cookbook_source/git_location.rb +54 -0
  25. data/lib/berkshelf/cookbook_source/path_location.rb +27 -0
  26. data/lib/berkshelf/cookbook_source/site_location.rb +206 -0
  27. data/lib/berkshelf/cookbook_store.rb +77 -0
  28. data/lib/berkshelf/core_ext.rb +3 -0
  29. data/lib/berkshelf/core_ext/file.rb +14 -0
  30. data/lib/berkshelf/core_ext/kernel.rb +33 -0
  31. data/lib/berkshelf/core_ext/pathname.rb +24 -0
  32. data/lib/berkshelf/downloader.rb +92 -0
  33. data/lib/berkshelf/dsl.rb +39 -0
  34. data/lib/berkshelf/errors.rb +20 -0
  35. data/lib/berkshelf/generator_files/Berksfile.erb +3 -0
  36. data/lib/berkshelf/generator_files/chefignore +44 -0
  37. data/lib/berkshelf/git.rb +70 -0
  38. data/lib/berkshelf/init_generator.rb +38 -0
  39. data/lib/berkshelf/lockfile.rb +42 -0
  40. data/lib/berkshelf/resolver.rb +176 -0
  41. data/lib/berkshelf/tx_result.rb +12 -0
  42. data/lib/berkshelf/tx_result_set.rb +37 -0
  43. data/lib/berkshelf/uploader.rb +153 -0
  44. data/lib/berkshelf/version.rb +3 -0
  45. data/lib/chef/knife/berks_init.rb +29 -0
  46. data/lib/chef/knife/berks_install.rb +27 -0
  47. data/lib/chef/knife/berks_update.rb +23 -0
  48. data/lib/chef/knife/berks_upload.rb +39 -0
  49. data/spec/fixtures/Berksfile +3 -0
  50. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/README.md +12 -0
  51. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +6 -0
  52. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/recipes/default.rb +8 -0
  53. data/spec/fixtures/cookbooks/example_cookbook/README.md +12 -0
  54. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +6 -0
  55. data/spec/fixtures/cookbooks/example_cookbook/recipes/default.rb +8 -0
  56. data/spec/fixtures/cookbooks/invalid_ruby_files-1.0.0/recipes/default.rb +1 -0
  57. data/spec/fixtures/cookbooks/invalid_template_files-1.0.0/templates/default/broken.erb +1 -0
  58. data/spec/fixtures/cookbooks/nginx-0.100.5/README.md +77 -0
  59. data/spec/fixtures/cookbooks/nginx-0.100.5/attributes/default.rb +65 -0
  60. data/spec/fixtures/cookbooks/nginx-0.100.5/definitions/nginx_site.rb +35 -0
  61. data/spec/fixtures/cookbooks/nginx-0.100.5/files/default/mime.types +73 -0
  62. data/spec/fixtures/cookbooks/nginx-0.100.5/files/ubuntu/mime.types +73 -0
  63. data/spec/fixtures/cookbooks/nginx-0.100.5/libraries/nginxlib.rb +1 -0
  64. data/spec/fixtures/cookbooks/nginx-0.100.5/metadata.rb +91 -0
  65. data/spec/fixtures/cookbooks/nginx-0.100.5/providers/defprovider.rb +1 -0
  66. data/spec/fixtures/cookbooks/nginx-0.100.5/recipes/default.rb +59 -0
  67. data/spec/fixtures/cookbooks/nginx-0.100.5/resources/defresource.rb +1 -0
  68. data/spec/fixtures/cookbooks/nginx-0.100.5/templates/default/nginx.pill.erb +15 -0
  69. data/spec/fixtures/cookbooks/nginx-0.100.5/templates/default/plugins/nginx.rb.erb +66 -0
  70. data/spec/fixtures/lockfile_spec/with_lock/Berksfile +1 -0
  71. data/spec/fixtures/lockfile_spec/without_lock/Berksfile.lock +5 -0
  72. data/spec/spec_helper.rb +92 -0
  73. data/spec/support/chef_api.rb +27 -0
  74. data/spec/support/matchers/file_system_matchers.rb +115 -0
  75. data/spec/support/matchers/filepath_matchers.rb +19 -0
  76. data/spec/unit/berkshelf/cached_cookbook_spec.rb +420 -0
  77. data/spec/unit/berkshelf/cookbook_source/git_location_spec.rb +59 -0
  78. data/spec/unit/berkshelf/cookbook_source/path_location_spec.rb +34 -0
  79. data/spec/unit/berkshelf/cookbook_source/site_location_spec.rb +166 -0
  80. data/spec/unit/berkshelf/cookbook_source_spec.rb +194 -0
  81. data/spec/unit/berkshelf/cookbook_store_spec.rb +71 -0
  82. data/spec/unit/berkshelf/cookbookfile_spec.rb +160 -0
  83. data/spec/unit/berkshelf/downloader_spec.rb +82 -0
  84. data/spec/unit/berkshelf/dsl_spec.rb +42 -0
  85. data/spec/unit/berkshelf/git_spec.rb +63 -0
  86. data/spec/unit/berkshelf/init_generator_spec.rb +52 -0
  87. data/spec/unit/berkshelf/lockfile_spec.rb +25 -0
  88. data/spec/unit/berkshelf/resolver_spec.rb +126 -0
  89. data/spec/unit/berkshelf/tx_result_set_spec.rb +77 -0
  90. data/spec/unit/berkshelf/tx_result_spec.rb +21 -0
  91. data/spec/unit/berkshelf/uploader_spec.rb +71 -0
  92. data/spec/unit/berkshelf_spec.rb +29 -0
  93. metadata +411 -0
@@ -0,0 +1,65 @@
1
+ #
2
+ # Cookbook Name:: nginx
3
+ # Attributes:: default
4
+ #
5
+ # Author:: Adam Jacob (<adam@opscode.com>)
6
+ # Author:: Joshua Timberman (<joshua@opscode.com>)
7
+ #
8
+ # Copyright 2009-2011, Opscode, Inc.
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+ #
22
+
23
+ default[:nginx][:version] = "1.0.14"
24
+
25
+ case platform
26
+ when "debian","ubuntu"
27
+ default[:nginx][:dir] = "/etc/nginx"
28
+ default[:nginx][:log_dir] = "/var/log/nginx"
29
+ default[:nginx][:user] = "www-data"
30
+ default[:nginx][:binary] = "/usr/sbin/nginx"
31
+ default[:nginx][:init_style] = "runit"
32
+ else
33
+ default[:nginx][:dir] = "/etc/nginx"
34
+ default[:nginx][:log_dir] = "/var/log/nginx"
35
+ default[:nginx][:user] = "www-data"
36
+ default[:nginx][:binary] = "/usr/sbin/nginx"
37
+ default[:nginx][:init_style] = "init"
38
+ end
39
+
40
+ default[:nginx][:pid] = "/var/run/nginx.pid"
41
+
42
+ default[:nginx][:gzip] = "on"
43
+ default[:nginx][:gzip_http_version] = "1.0"
44
+ default[:nginx][:gzip_comp_level] = "2"
45
+ default[:nginx][:gzip_proxied] = "any"
46
+ default[:nginx][:gzip_types] = [
47
+ "text/plain",
48
+ "text/html",
49
+ "text/css",
50
+ "application/x-javascript",
51
+ "text/xml",
52
+ "application/xml",
53
+ "application/xml+rss",
54
+ "text/javascript",
55
+ "application/javascript",
56
+ "application/json"
57
+ ]
58
+
59
+ default[:nginx][:keepalive] = "on"
60
+ default[:nginx][:keepalive_timeout] = 65
61
+ default[:nginx][:worker_processes] = cpu[:total]
62
+ default[:nginx][:worker_connections] = 1024
63
+ default[:nginx][:server_names_hash_bucket_size] = 64
64
+
65
+ default[:nginx][:disable_access_log] = false
@@ -0,0 +1,35 @@
1
+ #
2
+ # Cookbook Name:: nginx
3
+ # Definition:: nginx_site
4
+ # Author:: AJ Christensen <aj@junglist.gen.nz>
5
+ #
6
+ # Copyright 2008-2009, Opscode, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ define :nginx_site, :enable => true do
22
+ if params[:enable]
23
+ execute "nxensite #{params[:name]}" do
24
+ command "/usr/sbin/nxensite #{params[:name]}"
25
+ notifies :reload, resources(:service => "nginx")
26
+ not_if do ::File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
27
+ end
28
+ else
29
+ execute "nxdissite #{params[:name]}" do
30
+ command "/usr/sbin/nxdissite #{params[:name]}"
31
+ notifies :reload, resources(:service => "nginx")
32
+ only_if do ::File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,73 @@
1
+ types {
2
+ text/html html htm shtml;
3
+ text/css css;
4
+ text/xml xml;
5
+ image/gif gif;
6
+ image/jpeg jpeg jpg;
7
+ application/x-javascript js;
8
+ application/json json;
9
+ application/atom+xml atom;
10
+ application/rss+xml rss;
11
+
12
+ text/mathml mml;
13
+ text/plain txt;
14
+ text/vnd.sun.j2me.app-descriptor jad;
15
+ text/vnd.wap.wml wml;
16
+ text/x-component htc;
17
+
18
+ image/png png;
19
+ image/tiff tif tiff;
20
+ image/vnd.wap.wbmp wbmp;
21
+ image/x-icon ico;
22
+ image/x-jng jng;
23
+ image/x-ms-bmp bmp;
24
+ image/svg+xml svg;
25
+
26
+ application/java-archive jar war ear;
27
+ application/mac-binhex40 hqx;
28
+ application/msword doc;
29
+ application/pdf pdf;
30
+ application/postscript ps eps ai;
31
+ application/rtf rtf;
32
+ application/vnd.ms-excel xls;
33
+ application/vnd.ms-powerpoint ppt;
34
+ application/vnd.wap.wmlc wmlc;
35
+ application/vnd.wap.xhtml+xml xhtml;
36
+ application/vnd.google-earth.kml+xml kml;
37
+ application/vnd.google-earth.kmz kmz;
38
+ application/x-cocoa cco;
39
+ application/x-java-archive-diff jardiff;
40
+ application/x-java-jnlp-file jnlp;
41
+ application/x-makeself run;
42
+ application/x-perl pl pm;
43
+ application/x-pilot prc pdb;
44
+ application/x-rar-compressed rar;
45
+ application/x-redhat-package-manager rpm;
46
+ application/x-sea sea;
47
+ application/x-shockwave-flash swf;
48
+ application/x-stuffit sit;
49
+ application/x-tcl tcl tk;
50
+ application/x-x509-ca-cert der pem crt;
51
+ application/x-xpinstall xpi;
52
+ application/zip zip;
53
+
54
+ application/octet-stream bin exe dll;
55
+ application/octet-stream deb;
56
+ application/octet-stream dmg;
57
+ application/octet-stream eot;
58
+ application/octet-stream iso img;
59
+ application/octet-stream msi msp msm;
60
+
61
+ audio/midi mid midi kar;
62
+ audio/mpeg mp3;
63
+ audio/x-realaudio ra;
64
+
65
+ video/3gpp 3gpp 3gp;
66
+ video/mpeg mpeg mpg;
67
+ video/quicktime mov;
68
+ video/x-flv flv;
69
+ video/x-mng mng;
70
+ video/x-ms-asf asx asf;
71
+ video/x-ms-wmv wmv;
72
+ video/x-msvideo avi;
73
+ }
@@ -0,0 +1,73 @@
1
+ types {
2
+ text/html html htm shtml;
3
+ text/css css;
4
+ text/xml xml;
5
+ image/gif gif;
6
+ image/jpeg jpeg jpg;
7
+ application/x-javascript js;
8
+ application/json json;
9
+ application/atom+xml atom;
10
+ application/rss+xml rss;
11
+
12
+ text/mathml mml;
13
+ text/plain txt;
14
+ text/vnd.sun.j2me.app-descriptor jad;
15
+ text/vnd.wap.wml wml;
16
+ text/x-component htc;
17
+
18
+ image/png png;
19
+ image/tiff tif tiff;
20
+ image/vnd.wap.wbmp wbmp;
21
+ image/x-icon ico;
22
+ image/x-jng jng;
23
+ image/x-ms-bmp bmp;
24
+ image/svg+xml svg;
25
+
26
+ application/java-archive jar war ear;
27
+ application/mac-binhex40 hqx;
28
+ application/msword doc;
29
+ application/pdf pdf;
30
+ application/postscript ps eps ai;
31
+ application/rtf rtf;
32
+ application/vnd.ms-excel xls;
33
+ application/vnd.ms-powerpoint ppt;
34
+ application/vnd.wap.wmlc wmlc;
35
+ application/vnd.wap.xhtml+xml xhtml;
36
+ application/vnd.google-earth.kml+xml kml;
37
+ application/vnd.google-earth.kmz kmz;
38
+ application/x-cocoa cco;
39
+ application/x-java-archive-diff jardiff;
40
+ application/x-java-jnlp-file jnlp;
41
+ application/x-makeself run;
42
+ application/x-perl pl pm;
43
+ application/x-pilot prc pdb;
44
+ application/x-rar-compressed rar;
45
+ application/x-redhat-package-manager rpm;
46
+ application/x-sea sea;
47
+ application/x-shockwave-flash swf;
48
+ application/x-stuffit sit;
49
+ application/x-tcl tcl tk;
50
+ application/x-x509-ca-cert der pem crt;
51
+ application/x-xpinstall xpi;
52
+ application/zip zip;
53
+
54
+ application/octet-stream bin exe dll;
55
+ application/octet-stream deb;
56
+ application/octet-stream dmg;
57
+ application/octet-stream eot;
58
+ application/octet-stream iso img;
59
+ application/octet-stream msi msp msm;
60
+
61
+ audio/midi mid midi kar;
62
+ audio/mpeg mp3;
63
+ audio/x-realaudio ra;
64
+
65
+ video/3gpp 3gpp 3gp;
66
+ video/mpeg mpeg mpg;
67
+ video/quicktime mov;
68
+ video/x-flv flv;
69
+ video/x-mng mng;
70
+ video/x-ms-asf asx asf;
71
+ video/x-ms-wmv wmv;
72
+ video/x-msvideo avi;
73
+ }
@@ -0,0 +1,91 @@
1
+ maintainer "Opscode, Inc."
2
+ maintainer_email "cookbooks@opscode.com"
3
+ license "Apache 2.0"
4
+ description "Installs and configures nginx"
5
+ version "0.100.5"
6
+
7
+ recipe "nginx", "Installs nginx package and sets up configuration with Debian apache style with sites-enabled/sites-available"
8
+ recipe "nginx::source", "Installs nginx from source and sets up configuration with Debian apache style with sites-enabled/sites-available"
9
+
10
+ %w{ ubuntu debian centos redhat fedora }.each do |os|
11
+ supports os
12
+ end
13
+
14
+ %w{ build-essential runit bluepill }.each do |cb|
15
+ depends cb
16
+ end
17
+
18
+ depends 'ohai', '~> 1.0.2'
19
+
20
+ attribute "nginx/dir",
21
+ :display_name => "Nginx Directory",
22
+ :description => "Location of nginx configuration files",
23
+ :default => "/etc/nginx"
24
+
25
+ attribute "nginx/log_dir",
26
+ :display_name => "Nginx Log Directory",
27
+ :description => "Location for nginx logs",
28
+ :default => "/var/log/nginx"
29
+
30
+ attribute "nginx/user",
31
+ :display_name => "Nginx User",
32
+ :description => "User nginx will run as",
33
+ :default => "www-data"
34
+
35
+ attribute "nginx/binary",
36
+ :display_name => "Nginx Binary",
37
+ :description => "Location of the nginx server binary",
38
+ :default => "/usr/sbin/nginx"
39
+
40
+ attribute "nginx/gzip",
41
+ :display_name => "Nginx Gzip",
42
+ :description => "Whether gzip is enabled",
43
+ :default => "on"
44
+
45
+ attribute "nginx/gzip_http_version",
46
+ :display_name => "Nginx Gzip HTTP Version",
47
+ :description => "Version of HTTP Gzip",
48
+ :default => "1.0"
49
+
50
+ attribute "nginx/gzip_comp_level",
51
+ :display_name => "Nginx Gzip Compression Level",
52
+ :description => "Amount of compression to use",
53
+ :default => "2"
54
+
55
+ attribute "nginx/gzip_proxied",
56
+ :display_name => "Nginx Gzip Proxied",
57
+ :description => "Whether gzip is proxied",
58
+ :default => "any"
59
+
60
+ attribute "nginx/gzip_types",
61
+ :display_name => "Nginx Gzip Types",
62
+ :description => "Supported MIME-types for gzip",
63
+ :type => "array",
64
+ :default => [ "text/plain", "text/html", "text/css", "application/x-javascript", "text/xml", "application/xml", "application/xml+rss", "text/javascript" ]
65
+
66
+ attribute "nginx/keepalive",
67
+ :display_name => "Nginx Keepalive",
68
+ :description => "Whether to enable keepalive",
69
+ :default => "on"
70
+
71
+ attribute "nginx/keepalive_timeout",
72
+ :display_name => "Nginx Keepalive Timeout",
73
+ :default => "65"
74
+
75
+ attribute "nginx/worker_processes",
76
+ :display_name => "Nginx Worker Processes",
77
+ :description => "Number of worker processes",
78
+ :default => "1"
79
+
80
+ attribute "nginx/worker_connections",
81
+ :display_name => "Nginx Worker Connections",
82
+ :description => "Number of connections per worker",
83
+ :default => "1024"
84
+
85
+ attribute "nginx/server_names_hash_bucket_size",
86
+ :display_name => "Nginx Server Names Hash Bucket Size",
87
+ :default => "64"
88
+
89
+ attribute "nginx/disable_access_log",
90
+ :display_name => "Disable Access Log",
91
+ :default => "false"
@@ -0,0 +1 @@
1
+ puts "default provider"
@@ -0,0 +1,59 @@
1
+ #
2
+ # Cookbook Name:: nginx
3
+ # Recipe:: default
4
+ # Author:: AJ Christensen <aj@junglist.gen.nz>
5
+ #
6
+ # Copyright 2008-2009, Opscode, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ include_recipe "nginx::ohai_plugin"
22
+
23
+ package "nginx"
24
+
25
+ directory node[:nginx][:log_dir] do
26
+ mode 0755
27
+ owner node[:nginx][:user]
28
+ action :create
29
+ end
30
+
31
+ %w{nxensite nxdissite}.each do |nxscript|
32
+ template "/usr/sbin/#{nxscript}" do
33
+ source "#{nxscript}.erb"
34
+ mode 0755
35
+ owner "root"
36
+ group "root"
37
+ end
38
+ end
39
+
40
+ template "nginx.conf" do
41
+ path "#{node[:nginx][:dir]}/nginx.conf"
42
+ source "nginx.conf.erb"
43
+ owner "root"
44
+ group "root"
45
+ mode 0644
46
+ notifies :reload, "service[nginx]"
47
+ end
48
+
49
+ template "#{node[:nginx][:dir]}/sites-available/default" do
50
+ source "default-site.erb"
51
+ owner "root"
52
+ group "root"
53
+ mode 0644
54
+ end
55
+
56
+ service "nginx" do
57
+ supports :status => true, :restart => true, :reload => true
58
+ action [ :enable, :start ]
59
+ end
@@ -0,0 +1 @@
1
+ puts "default resource"
@@ -0,0 +1,15 @@
1
+ Bluepill.application("nginx", :log_file => "<%= @log_dir %>/bluepill-nginx.log") do |app|
2
+ app.process("nginx") do |process|
3
+ process.pid_file = "<%= @pid %>"
4
+ process.working_dir = "<%= @working_dir %>"
5
+ process.start_command = "<%= @src_binary %> -c <%= @nginx_dir %>/nginx.conf"
6
+ process.stop_command = "kill -QUIT {{PID}}"
7
+ process.restart_command = "kill -HUP {{PID}}"
8
+ process.daemonize = true
9
+ process.stdout = process.stderr = "<%= @log_dir %>/nginx.log"
10
+
11
+ process.monitor_children do |child_process|
12
+ child_process.stop_command = "kill -QUIT {{PID}}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,66 @@
1
+ #
2
+ # Author:: Jamie Winsor (<jamie@vialstudios.com>)
3
+ #
4
+ # Copyright 2012, Riot Games
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "nginx"
20
+ provides "nginx/version"
21
+ provides "nginx/configure_arguments"
22
+ provides "nginx/prefix"
23
+ provides "nginx/conf_path"
24
+
25
+ def parse_flags(flags)
26
+ prefix = nil
27
+ conf_path = nil
28
+
29
+ flags.each do |flag|
30
+ case flag
31
+ when /^--prefix=(.+)$/
32
+ prefix = $1
33
+ when /^--conf-path=(.+)$/
34
+ conf_path = $1
35
+ end
36
+ end
37
+
38
+ [ prefix, conf_path ]
39
+ end
40
+
41
+ nginx Mash.new unless nginx
42
+ nginx[:version] = nil unless nginx[:version]
43
+ nginx[:configure_arguments] = Array.new unless nginx[:configure_arguments]
44
+ nginx[:prefix] = nil unless nginx[:prefix]
45
+ nginx[:conf_path] = nil unless nginx[:conf_path]
46
+
47
+ status, stdout, stderr = run_command(:no_status_check => true, :command => "<%= @nginx_bin %> -V")
48
+
49
+ if status == 0
50
+ stderr.split("\n").each do |line|
51
+ case line
52
+ when /^configure arguments:(.+)/
53
+ # This could be better: I'm splitting on configure arguments which removes them and also
54
+ # adds a blank string at index 0 of the array. This is why we drop index 0 and map to
55
+ # add the '--' prefix back to the configure argument.
56
+ nginx[:configure_arguments] = $1.split(/\s--/).drop(1).map { |ca| "--#{ca}" }
57
+
58
+ prefix, conf_path = parse_flags(nginx[:configure_arguments])
59
+
60
+ nginx[:prefix] = prefix
61
+ nginx[:conf_path] = conf_path
62
+ when /^nginx version: nginx\/(.+)/
63
+ nginx[:version] = $1
64
+ end
65
+ end
66
+ end