Class: Nginxbrew::Configuration
- Inherits:
-
Object
- Object
- Nginxbrew::Configuration
- Defined in:
- lib/nginxbrew/config/base.rb
Constant Summary collapse
- NGX_URL =
"http://nginx.org/download"
- OPENRESTY_URL =
"http://openresty.org/download"
Instance Attribute Summary collapse
-
#builtfile ⇒ Object
readonly
Returns the value of attribute builtfile.
-
#dist_dir ⇒ Object
readonly
Returns the value of attribute dist_dir.
-
#dist_to ⇒ Object
readonly
Returns the value of attribute dist_to.
-
#home_dir ⇒ Object
readonly
Returns the value of attribute home_dir.
-
#is_openresty ⇒ Object
readonly
Returns the value of attribute is_openresty.
-
#nginx_log_dir ⇒ Object
readonly
Returns the value of attribute nginx_log_dir.
-
#ngx_conf_path ⇒ Object
Returns the value of attribute ngx_conf_path.
-
#ngx_configure ⇒ Object
Returns the value of attribute ngx_configure.
-
#ngx_group ⇒ Object
Returns the value of attribute ngx_group.
-
#ngx_prefix ⇒ Object
Returns the value of attribute ngx_prefix.
-
#ngx_sbin_path ⇒ Object
readonly
Returns the value of attribute ngx_sbin_path.
-
#ngx_user ⇒ Object
Returns the value of attribute ngx_user.
-
#ngx_version ⇒ Object
readonly
Returns the value of attribute ngx_version.
-
#package_name ⇒ Object
readonly
Returns the value of attribute package_name.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
-
#tarball ⇒ Object
readonly
Returns the value of attribute tarball.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #configure_command ⇒ Object
- #configure_options ⇒ Object
-
#initialize(opts = {}) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(opts = {}) ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nginxbrew/config/base.rb', line 22 def initialize(opts={}) @home_dir = opts[:home_dir] @dist_dir = opts[:dist_dir] @ngx_version = opts[:ngx_version] @is_openresty = opts[:is_openresty] @package_name = opts[:package_name] @dist_to = File.join(@dist_dir, @package_name) @nginx_log_dir = File.join(@home_dir, "logs", @package_name) @src = src_name(@ngx_version, @is_openresty) @tarball = "#{@src}.tar.gz" @url = "#{@is_openresty ? OPENRESTY_URL : NGX_URL}/#{@tarball}" @ngx_sbin_path = File.join(@dist_to, "bin/nginx") @builtfile = File.join(@dist_to, "built") @ngx_conf_path = File.join(@dist_to, "nginx.conf") @ngx_configure = {} @ngx_prefix = @dist_to @ngx_user = "nginx" @ngx_group = "nginx" end |
Instance Attribute Details
#builtfile ⇒ Object (readonly)
Returns the value of attribute builtfile.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def builtfile @builtfile end |
#dist_dir ⇒ Object (readonly)
Returns the value of attribute dist_dir.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def dist_dir @dist_dir end |
#dist_to ⇒ Object (readonly)
Returns the value of attribute dist_to.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def dist_to @dist_to end |
#home_dir ⇒ Object (readonly)
Returns the value of attribute home_dir.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def home_dir @home_dir end |
#is_openresty ⇒ Object (readonly)
Returns the value of attribute is_openresty.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def is_openresty @is_openresty end |
#nginx_log_dir ⇒ Object (readonly)
Returns the value of attribute nginx_log_dir.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def nginx_log_dir @nginx_log_dir end |
#ngx_conf_path ⇒ Object
Returns the value of attribute ngx_conf_path.
17 18 19 |
# File 'lib/nginxbrew/config/base.rb', line 17 def ngx_conf_path @ngx_conf_path end |
#ngx_configure ⇒ Object
Returns the value of attribute ngx_configure.
17 18 19 |
# File 'lib/nginxbrew/config/base.rb', line 17 def ngx_configure @ngx_configure end |
#ngx_group ⇒ Object
Returns the value of attribute ngx_group.
17 18 19 |
# File 'lib/nginxbrew/config/base.rb', line 17 def ngx_group @ngx_group end |
#ngx_prefix ⇒ Object
Returns the value of attribute ngx_prefix.
17 18 19 |
# File 'lib/nginxbrew/config/base.rb', line 17 def ngx_prefix @ngx_prefix end |
#ngx_sbin_path ⇒ Object (readonly)
Returns the value of attribute ngx_sbin_path.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def ngx_sbin_path @ngx_sbin_path end |
#ngx_user ⇒ Object
Returns the value of attribute ngx_user.
17 18 19 |
# File 'lib/nginxbrew/config/base.rb', line 17 def ngx_user @ngx_user end |
#ngx_version ⇒ Object (readonly)
Returns the value of attribute ngx_version.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def ngx_version @ngx_version end |
#package_name ⇒ Object (readonly)
Returns the value of attribute package_name.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def package_name @package_name end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def src @src end |
#tarball ⇒ Object (readonly)
Returns the value of attribute tarball.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def tarball @tarball end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
19 20 21 |
# File 'lib/nginxbrew/config/base.rb', line 19 def url @url end |
Instance Method Details
#configure_command ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/nginxbrew/config/base.rb', line 42 def configure_command dest = ["./configure"] .inject(dest) do |memo, opt| memo << "#{opt[0]}" + (opt[1].nil? ? "" : "=#{opt[1]}") memo end.join(" ") end |
#configure_options ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/nginxbrew/config/base.rb', line 50 def cmd =<<-EOF --user=#{@ngx_user} \ --group=#{@ngx_group} \ --prefix=#{@ngx_prefix} \ --sbin-path=#{@ngx_sbin_path} \ --conf-path=#{@ngx_conf_path} \ --error-log-path=#{@nginx_log_dir}/error.log \ --http-log-path=#{@nginx_log_dir}/access.log \ --http-client-body-temp-path=#{@home_dir}/tmp/client_body \ --http-proxy-temp-path=#{@home_dir}/tmp/proxy \ --pid-path=#{@home_dir}/run/nginx.pid EOF dest = cmd.split(" ").inject({}) do |memo, opt| kv = opt.split("=") memo[kv[0]] = (kv.size == 2) ? kv[1] : nil memo end dest.merge!(@ngx_configure) if @ngx_configure dest end |