Class: Inspec::Resources::Nginx
- Inherits:
-
Object
- Object
- Inspec::Resources::Nginx
- Defined in:
- lib/inspec/resources/nginx.rb
Instance Attribute Summary collapse
-
#bin_dir ⇒ Object
readonly
Returns the value of attribute bin_dir.
-
#nginx_path ⇒ Object
readonly
Returns the value of attribute nginx_path.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #compiler_info ⇒ Object
-
#initialize(nginx_path = "/usr/sbin/nginx") ⇒ Nginx
constructor
A new instance of Nginx.
- #modules ⇒ Object
- #openssl_version ⇒ Object
- #resource_id ⇒ Object
- #support_info ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(nginx_path = "/usr/sbin/nginx") ⇒ Nginx
Returns a new instance of Nginx.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/inspec/resources/nginx.rb', line 23 def initialize(nginx_path = "/usr/sbin/nginx") return skip_resource "The `nginx` resource is not yet available on your OS." if inspec.os.windows? return skip_resource "The `nginx` binary not found in the path provided." unless inspec.command(nginx_path).exist? @nginx_path = nginx_path cmd = inspec.command("#{nginx_path} -V 2>&1") if cmd.exit_status != 0 return skip_resource "Error using the command nginx -V" end @data = cmd.stdout @params = {} read_content end |
Instance Attribute Details
#bin_dir ⇒ Object (readonly)
Returns the value of attribute bin_dir.
21 22 23 |
# File 'lib/inspec/resources/nginx.rb', line 21 def bin_dir @bin_dir end |
#nginx_path ⇒ Object (readonly)
Returns the value of attribute nginx_path.
21 22 23 |
# File 'lib/inspec/resources/nginx.rb', line 21 def nginx_path @nginx_path end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
21 22 23 |
# File 'lib/inspec/resources/nginx.rb', line 21 def params @params end |
Instance Method Details
#compiler_info ⇒ Object
49 50 51 52 |
# File 'lib/inspec/resources/nginx.rb', line 49 def compiler_info result = @data.scan(/built by (\S+)\s(\S+)\s(\S+)/).flatten Hashie::Mash.new({ "compiler" => result[0], "version" => result[1], "date" => result[2] }) end |
#modules ⇒ Object
59 60 61 |
# File 'lib/inspec/resources/nginx.rb', line 59 def modules @data.scan(/--with-(\S+)_module/).flatten end |
#openssl_version ⇒ Object
44 45 46 47 |
# File 'lib/inspec/resources/nginx.rb', line 44 def openssl_version result = @data.scan(/built with OpenSSL\s(\S+)\s(\d+\s\S+\s\d{4})/).flatten Hashie::Mash.new({ "version" => result[0], "date" => result[1] }) end |
#resource_id ⇒ Object
63 64 65 |
# File 'lib/inspec/resources/nginx.rb', line 63 def resource_id nginx_path || "nginx" end |
#support_info ⇒ Object
54 55 56 57 |
# File 'lib/inspec/resources/nginx.rb', line 54 def support_info support_info = @data.scan(/(.*\S+) support enabled/).flatten support_info.empty? ? nil : support_info.join(" ") end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/inspec/resources/nginx.rb', line 67 def to_s "Nginx Environment" end |