Class: Nginxtra::Actions::Compile
- Inherits:
-
Object
- Object
- Nginxtra::Actions::Compile
- Includes:
- Nginxtra::Action
- Defined in:
- lib/nginxtra/actions/compile.rb
Overview
The Nginxtra::Actions::Compile class encapsulates compiling nginx so it is ready with the specified compile options. An optional option of :force can be passed with true to make compilation happen no matter what.
Instance Method Summary collapse
-
#compile ⇒ Object
Run the full compilation of nginx.
-
#configure ⇒ Object
Configure nginx with the specified compile options.
-
#copy_to_base ⇒ Object
Copy the nginx source directory to the base directory.
-
#different_compile_options? ⇒ Boolean
Determine if the compile options differ from those last compiled with.
-
#different_nginx_version? ⇒ Boolean
Determine if the last nginx compiled version is different from the current nginx version.
-
#make(*args) ⇒ Object
Run make against the configured nginx.
-
#should_compile? ⇒ Boolean
Determine if compiling should happen.
-
#up_to_date ⇒ Object
Notify the user that the compilation is up to date.
-
#update_last_compile ⇒ Object
Update Nginxtra::Status with the last compile time and options.
Methods included from Nginxtra::Action
Instance Method Details
#compile ⇒ Object
Run the full compilation of nginx.
11 12 13 14 15 16 17 18 |
# File 'lib/nginxtra/actions/compile.rb', line 11 def compile return up_to_date unless should_compile? copy_to_base configure make make "install" update_last_compile end |
#configure ⇒ Object
Configure nginx with the specified compile options.
26 27 28 29 30 |
# File 'lib/nginxtra/actions/compile.rb', line 26 def configure @thor.inside Nginxtra::Config.src_dir do run! "sh configure --prefix=#{Nginxtra::Config.build_dir} --conf-path=#{Nginxtra::Config.nginx_config} --pid-path=#{Nginxtra::Config.nginx_pidfile} #{@config.}" end end |
#copy_to_base ⇒ Object
Copy the nginx source directory to the base directory.
21 22 23 |
# File 'lib/nginxtra/actions/compile.rb', line 21 def copy_to_base @thor.directory "vendor/nginx", Nginxtra::Config.src_dir end |
#different_compile_options? ⇒ Boolean
Determine if the compile options differ from those last compiled with.
50 51 52 |
# File 'lib/nginxtra/actions/compile.rb', line 50 def Nginxtra::Status[:last_compile_options] != @config. end |
#different_nginx_version? ⇒ Boolean
Determine if the last nginx compiled version is different from the current nginx version.
56 57 58 |
# File 'lib/nginxtra/actions/compile.rb', line 56 def different_nginx_version? Nginxtra::Status[:last_compile_version] != Nginxtra::Config.nginx_version end |
#make(*args) ⇒ Object
Run make against the configured nginx.
33 34 35 36 37 |
# File 'lib/nginxtra/actions/compile.rb', line 33 def make(*args) @thor.inside Nginxtra::Config.src_dir do run! ["make", *args].join(" ") end end |
#should_compile? ⇒ Boolean
Determine if compiling should happen. This will return false if the last compile options equal the current options and the last compile version is the same as the current nginx version, or if the force option was passed in at construction time.
43 44 45 46 |
# File 'lib/nginxtra/actions/compile.rb', line 43 def should_compile? return true if force? || different_nginx_version? end |
#up_to_date ⇒ Object
Notify the user that the compilation is up to date
69 70 71 |
# File 'lib/nginxtra/actions/compile.rb', line 69 def up_to_date @thor.say "nginx compilation is up to date" end |
#update_last_compile ⇒ Object
Update Nginxtra::Status with the last compile time and options.
62 63 64 65 66 |
# File 'lib/nginxtra/actions/compile.rb', line 62 def update_last_compile Nginxtra::Status[:last_compile_options] = @config. Nginxtra::Status[:last_compile_time] = Time.now Nginxtra::Status[:last_compile_version] = Nginxtra::Config.nginx_version end |